Add support JIS X 0201.

Fork of GT20L16J1Y_font by Toyomasa Watarai

Committer:
MACRUM
Date:
Tue Jan 14 07:36:32 2014 +0000
Revision:
0:61b32e34bcbf
Child:
2:aed20a7685b9
Initial release of GT20L16J1Y_font library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 0:61b32e34bcbf 1 #include "mbed.h"
MACRUM 0:61b32e34bcbf 2 #include "GT20L16J1Y_font.h"
MACRUM 0:61b32e34bcbf 3
MACRUM 0:61b32e34bcbf 4 GT20L16J1Y_FONT::GT20L16J1Y_FONT() : _spi(p11, p12, p13), _CS(p10) {
MACRUM 0:61b32e34bcbf 5 }
MACRUM 0:61b32e34bcbf 6
MACRUM 0:61b32e34bcbf 7 void GT20L16J1Y_FONT::read(unsigned short code) {
MACRUM 0:61b32e34bcbf 8 unsigned char c1, c2, MSB,LSB;
MACRUM 0:61b32e34bcbf 9 uint32_t address, seq;
MACRUM 0:61b32e34bcbf 10
MACRUM 0:61b32e34bcbf 11 // SJIS to kuten code conversion
MACRUM 0:61b32e34bcbf 12 c1 = (code>>8);
MACRUM 0:61b32e34bcbf 13 c2 = (code & 0xFF);
MACRUM 0:61b32e34bcbf 14 seq = (c1<=159 ? c1-129 : c1-193)*188 + (c2<=126 ? c2-64 : c2-65);
MACRUM 0:61b32e34bcbf 15 MSB = seq / 94 + 1;
MACRUM 0:61b32e34bcbf 16 LSB = seq % 94 + 1;
MACRUM 0:61b32e34bcbf 17 address = 0;
MACRUM 0:61b32e34bcbf 18
MACRUM 0:61b32e34bcbf 19 if( MSB >= 1 && MSB <= 15 && LSB >= 1 && LSB <= 94)
MACRUM 0:61b32e34bcbf 20 address =( (MSB - 1) * 94 + (LSB - 1))*32;
MACRUM 0:61b32e34bcbf 21 else if(MSB >= 16 && MSB <= 47 && LSB >= 1 && LSB <= 94)
MACRUM 0:61b32e34bcbf 22 address =( (MSB - 16) * 94 + (LSB - 1))*32 + 0x0AA40L;
MACRUM 0:61b32e34bcbf 23 else if(MSB >= 48 && MSB <= 84 && LSB >= 1 && LSB <= 94)
MACRUM 0:61b32e34bcbf 24 address = ((MSB - 48) * 94 + (LSB - 1))*32 + 0x21CDFL;
MACRUM 0:61b32e34bcbf 25 else if(MSB == 85 && LSB >= 1 && LSB <= 94)
MACRUM 0:61b32e34bcbf 26 address = ((MSB - 85) * 94 + (LSB - 1))*32 + 0x3C4A0L;
MACRUM 0:61b32e34bcbf 27 else if(MSB >= 88 && MSB <= 89 && LSB >= 1 && LSB <= 94)
MACRUM 0:61b32e34bcbf 28 address = ((MSB - 88) * 94 + (LSB - 1))*32 + 0x3D060L;
MACRUM 0:61b32e34bcbf 29
MACRUM 0:61b32e34bcbf 30 // Deselect the device
MACRUM 0:61b32e34bcbf 31 _CS = 1;
MACRUM 0:61b32e34bcbf 32
MACRUM 0:61b32e34bcbf 33 // Setup the spi for 8 bit data, high steady state clock
MACRUM 0:61b32e34bcbf 34 _spi.format(8,3);
MACRUM 0:61b32e34bcbf 35 _spi.frequency(1000000);
MACRUM 0:61b32e34bcbf 36
MACRUM 0:61b32e34bcbf 37 // Select the device by seting chip select low
MACRUM 0:61b32e34bcbf 38 _CS = 0;
MACRUM 0:61b32e34bcbf 39 _spi.write(0x03); // Read data byte
MACRUM 0:61b32e34bcbf 40 _spi.write(address>>16 & 0xff);
MACRUM 0:61b32e34bcbf 41 _spi.write(address>>8 & 0xff);
MACRUM 0:61b32e34bcbf 42 _spi.write(address & 0xff);
MACRUM 0:61b32e34bcbf 43
MACRUM 0:61b32e34bcbf 44 // Send a dummy byte to receive the contents of the WHOAMI register
MACRUM 0:61b32e34bcbf 45 for(int i=0; i<32; i++)
MACRUM 0:61b32e34bcbf 46 {
MACRUM 0:61b32e34bcbf 47 bitmap[i] = _spi.write(0x00);
MACRUM 0:61b32e34bcbf 48 }
MACRUM 0:61b32e34bcbf 49
MACRUM 0:61b32e34bcbf 50 // Deselect the device
MACRUM 0:61b32e34bcbf 51 _CS = 1;
MACRUM 0:61b32e34bcbf 52 }