Add support JIS X 0201.
Fork of GT20L16J1Y_font by
Diff: GT20L16Y1J_font.cpp
- Revision:
- 2:aed20a7685b9
- Parent:
- 0:61b32e34bcbf
- Child:
- 3:48c4a173bdab
--- a/GT20L16Y1J_font.cpp Sun Apr 20 05:36:32 2014 +0000 +++ b/GT20L16Y1J_font.cpp Thu Sep 04 06:54:40 2014 +0000 @@ -1,19 +1,25 @@ #include "mbed.h" #include "GT20L16J1Y_font.h" +#if defined(TARGET_LPC1768) GT20L16J1Y_FONT::GT20L16J1Y_FONT() : _spi(p11, p12, p13), _CS(p10) { } +#endif -void GT20L16J1Y_FONT::read(unsigned short code) { - unsigned char c1, c2, MSB,LSB; - uint32_t address, seq; +GT20L16J1Y_FONT::GT20L16J1Y_FONT(PinName mosi, PinName miso, PinName sclk, PinName cs) : _spi(mosi, miso, sclk, NC), _CS(cs) +{ + // Setup the spi for 8 bit data, high steady state clock + _spi.format(8,3); + _spi.frequency(10000000); +} + +int GT20L16J1Y_FONT::read_kuten(unsigned short code) { + unsigned char MSB, LSB; + uint32_t address; + int ret; - // SJIS to kuten code conversion - c1 = (code>>8); - c2 = (code & 0xFF); - seq = (c1<=159 ? c1-129 : c1-193)*188 + (c2<=126 ? c2-64 : c2-65); - MSB = seq / 94 + 1; - LSB = seq % 94 + 1; + MSB = (code & 0xFF00) >> 8; + LSB = code & 0x00FF; address = 0; if( MSB >= 1 && MSB <= 15 && LSB >= 1 && LSB <= 94) @@ -26,13 +32,11 @@ address = ((MSB - 85) * 94 + (LSB - 1))*32 + 0x3C4A0L; else if(MSB >= 88 && MSB <= 89 && LSB >= 1 && LSB <= 94) address = ((MSB - 88) * 94 + (LSB - 1))*32 + 0x3D060L; + else if(MSB == 0 && LSB >= 0x20 && LSB <= 0x7F) + address = (LSB - 0x20)*16 + 255968; // Deselect the device _CS = 1; - - // Setup the spi for 8 bit data, high steady state clock - _spi.format(8,3); - _spi.frequency(1000000); // Select the device by seting chip select low _CS = 0; @@ -41,12 +45,39 @@ _spi.write(address>>8 & 0xff); _spi.write(address & 0xff); - // Send a dummy byte to receive the contents of the WHOAMI register - for(int i=0; i<32; i++) - { - bitmap[i] = _spi.write(0x00); + if(MSB == 0 && LSB >= 0x20 && LSB <= 0x7F) { + for(int i=0; i<16; i++) + { + bitmap[i] = _spi.write(0x00); + } + ret = 8; + } + else { + for(int i=0; i<32; i++) + { + bitmap[i] = _spi.write(0x00); + } + ret = 16; } // Deselect the device _CS = 1; + + return ret; } + +void GT20L16J1Y_FONT::read(unsigned short code) { + unsigned char c1, c2, MSB, LSB; + uint32_t seq; + uint16_t address; + + // SJIS to kuten code conversion + c1 = (code>>8); + c2 = (code & 0xFF); + seq = (c1<=159 ? c1-129 : c1-193)*188 + (c2<=126 ? c2-64 : c2-65); + MSB = seq / 94 + 1; + LSB = seq % 94 + 1; + + address = ((MSB << 8) | LSB); + read_kuten(address); +}