通过对源程序的分析可以发现该套件是能够实现中文显示的,该函数为void PUTchar8x16(unsigned char row,unsigned char col,unsigned char *pcStr,unsigned char flag);
其中,row为行位置,col为列位置,pcStr为中文字符串, flag为显示标志列位置。
由于LCM_12864自身不带中文字库,所以使用的字库必须构建在程序中,其字库结构如下:
const unsigned char CHINESE[]=
{
0x40,0x40,0x42,0xCC,0x00,0x00,0xFC,0x24,0xA4,0x24,0x22,0x22,0xA3,0x62,0x00,0x00,
0x00,0x40,0x20,0x1F,0x20,0x58,0x47,0x50,0x48,0x45,0x42,0x45,0x48,0x50,0x40,0x00,/*"退",0*/
0x00,0x00,0xFE,0x02,0x02,0xF2,0x12,0x12,0x12,0xF2,0x02,0x02,0xFE,0x00,0x00,0x00,
0x00,0x00,0x7F,0x20,0x20,0x27,0x24,0x24,0x24,0x27,0x20,0x20,0x7F,0x00,0x00,0x00,/*"出",1*/
0x10,0x60,0x02,0x8C,0x00,0x0C,0xA4,0xA4,0xA5,0xE6,0xA4,0xA4,0xA4,0x0C,0x00,0x00,
0x04,0x04,0x7E,0x01,0x00,0x80,0x4F,0x2A,0x0A,0x0F,0x0A,0x2A,0x4F,0x80,0x00,0x00,/*"演",2*/
0x40,0x40,0x42,0x42,0x42,0x42,0x42,0xC2,0x42,0x42,0x42,0x42,0x42,0x40,0x40,0x00,
0x20,0x10,0x08,0x06,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x02,0x04,0x08,0x30,0x00,/*"示",3*/
};
要想实现图1的显示效果,对PUTchar8x16()的使用方法为:
LcmClear();
PUTchar16x16(6,10,"演",0); //演示
PUTchar16x16(6,12,"示",0); //4行8列,32字
图1 中文显示效果
那如何来构建自己的小字库呢?
经比对使用3310液晶显示屏汉字提取程序即可构建与PUTchar8x16()相匹配的字库。
图2字模提取
此外,为了保证显示的正常,在自行构建字库后,还要适当地修改该字库索引数组。
const unsigned int GBC_Index[]=
{
2321,/*"退" 0*/
2756,/*"出", 1*/
4961,/*"演", 2*/
4230,/*"示", 3*/
};
值得注意的是在索引数组中,每行注释前的数字为对应字模的区位码,可使用图3所示的内码查看工具来获得。
图3 内码查看工具 |