Add support JIS X 0201.
Fork of GT20L16J1Y_font by
Revision 2:aed20a7685b9, committed 2014-09-04
- Comitter:
- MACRUM
- Date:
- Thu Sep 04 06:54:40 2014 +0000
- Parent:
- 1:cacab63ea210
- Child:
- 3:48c4a173bdab
- Commit message:
- Added read_kuten() function to support kuten code
Changed in this revision
| GT20L16J1Y_font.h | Show annotated file Show diff for this revision Revisions of this file |
| GT20L16Y1J_font.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/GT20L16J1Y_font.h Sun Apr 20 05:36:32 2014 +0000
+++ b/GT20L16J1Y_font.h Thu Sep 04 06:54:40 2014 +0000
@@ -1,15 +1,8 @@
#include "mbed.h"
-/**
-* GT20L16J1Y font ROM access class
-*/
+
class GT20L16J1Y_FONT {
public:
- /** Default constructor
- */
GT20L16J1Y_FONT();
-
- /** Destructor
- */
virtual ~GT20L16J1Y_FONT() {};
/** Create a GT20L16J1Y font ROM connected to the specified pins
@@ -19,7 +12,7 @@
* @param sclk Serial clock input pin to connect to
* @param cs Chip enable input pin to connect to
*/
- GT20L16J1Y_FONT(PinName mosi, PinName miso, PinName sclk, PinName cs) : _spi(mosi, miso, sclk), _CS(cs) {};
+ GT20L16J1Y_FONT(PinName mosi, PinName miso, PinName sclk, PinName cs);
/** Read font data from SJIS code
*
@@ -27,6 +20,13 @@
*/
void read(unsigned short code);
+ /** Read font data from Ku-Ten code
+ *
+ * @param code Japanese Kanji font code (Kuten code [15:8] Ku, [7:0] Ten)
+ * @return font width (8 or 16)
+ */
+ int read_kuten(unsigned short code);
+
unsigned char bitmap[32];
private:
--- 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);
+}
ban4jp -
