本帖最后由 jinglixixi 于 2017-10-14 11:40 编辑
在常规的Arduino UNO驱动库中,对于LCD5110的驱动程序一般是缺少中文支持的,恰逢圣诞来临之际,就以“圣诞快乐”的界面制作来介绍一下实现中文显示的方法。 1. 以3310液晶显示屏绘制提取程序来提取汉字字模,其操作如图1所示。
2. 建立一个名为chinese.h的头文件,将字模存入该文件。 const unsigned char chinese_character[][24]= { //圣 {0x40,0x42,0x26,0x2A,0x12,0xD2,0x12,0x2A,0x26,0x42,0x40,0x00,0x08,0x08,0x09,0x09,0x09,0x0F,0x09,0x09,0x09,0x08,0x08,0x00}, //诞 {0x11,0xF2,0x00,0x72,0xCE,0x00,0xF2,0x02,0xFE,0x11,0x11,0x00,0x00,0x07,0x0A,0x04,0x0B,0x08,0x09,0x09,0x09,0x09,0x09,0x00}, //快 {0x78,0x00,0xFF,0x48,0x44,0x44,0xFF,0x44,0x44,0x7C,0x40,0x00,0x00,0x00,0x0F,0x08,0x04,0x03,0x00,0x03,0x04,0x08,0x08,0x00}, //乐 {0x00,0x3E,0xA2,0x22,0x22,0xFA,0x21,0x21,0xA1,0x20,0x00,0x00,0x04,0x02,0x01,0x08,0x08,0x0F,0x00,0x00,0x00,0x01,0x06,0x00}, }; }
3. 将Arduino UNO与LCD5110连接起来,其连接关系如下: VCC -- 3.3V GND -- GND LCD_CS -- 4 LCD_DIN -- 5 LCD_CLK -- 6 LCD_RST -- 7 LCD_DC -- 8 VO -- 3.3V
4. 在LCD5110驱动库中添加语句 #include "chinese.h",以引入自行构建的小字库。然后再添加如下的汉字显示函数。 void LCD_write_hanzi(uint8_t X,uint8_t Y,uint8_t s) { do { char line; NOKIA5110_set_XY(X,Y); for (line=0; line<12; line++) { NOKIA5110_write_byte(chinese_character[line], NOKIA5110_DATA); } NOKIA5110_set_XY(X,Y+1);//LCD_set_XY(X,Y+1); for (line=12; line<24; line++) { NOKIA5110_write_byte(chinese_character[line], NOKIA5110_DATA); } }while(0); }
此外,再添加如下的主处理函数。 void Main_Deal () { NOKIA5110_init(); NOKIA5110_clear_screen(); LCD_write_hanzi(0,0,0); LCD_write_hanzi(12,0,1); LCD_write_hanzi(24,0,2); LCD_write_hanzi(36,0,4); NOKIA5110_display_8x6_text (0, 2, "merry christmas"); NOKIA5110_display_8x6_text (0, 4, " 2016.12.24"); while (1); }
5. 经编译与下载,其显示效果如图2所示。 |