#适用于正点原子LCD,修改自博主@天道酬勤黄天不负我
//放头文件
struct typFNT_GB16 // 汉字字模数据结构体
{
u8 Index[2];// 汉字内码索引,汉字在内存中占两个字节
char Msk[32]; // 点阵码数据
};
//放C文件
//定义汉字点阵结构体,数据由正点原子赠送的取模软件获得
struct typFNT_GB16 code_GB_16[] = // 数据表
{
{“饼”, 0x20,0x00,0x21,0x08,0x20,0x90,0x3C,0x00,
0x47,0xFC,0x48,0x90,0xA0,0x90,0x20,0x94,
0x27,0xFE,0x20,0x90,0x20,0x90,0x24,0x90,
0x28,0x90,0x31,0x10,0x22,0x10,0x04,0x10},
{“昌”, 0x1F,0xF0,0x10,0x10,0x10,0x10,0x1F,0xF0,
0x10,0x10,0x10,0x10,0x1F,0xF0,0x00,0x08,
0x3F,0xFC,0x20,0x08,0x20,0x08,0x3F,0xF8,
0x20,0x08,0x20,0x08,0x3F,0xF8,0x20,0x08},
{“除”, 0x00,0x40,0x78,0x40,0x48,0xA0,0x50,0xA0,
0x51,0x10,0x62,0x0E,0x55,0xF4,0x48,0x40,
0x48,0x50,0x4F,0xFC,0x68,0x40,0x51,0x50,
0x42,0x4C,0x44,0x44,0x41,0x40,0x40,0x80},
};
void show_chinese(u16 x,u16 y,u8 *p,u16 Word_Color,u16 Back_Color)
{
u8 k=0,wordByte,color;
u8 wordNum;//字库字数
while(*p!=’\0’)//直到字符串写完
{
LCD_Set_Window(x,y,16,16);
LCD_SetCursor(x,y);
LCD_WriteRAM_Prepare();
for(wordNum=0;wordNum<3;wordNum++)
{
LED0=!LED0;
if((p==code_GB_16[wordNum].Index[0])&&((p+1)==code_GB_16[wordNum].Index[1]))//匹配汉字内码,汉字在内存中占两个字节
{
for(wordByte=0;wordByte<32;wordByte++)
{
color=code_GB_16[wordNum].Msk[wordByte];
for(k=0;k<8;k++)
{
if((color&0x80)==0x80)//1
{
LCD->LCD_RAM=Word_Color;
}
else
{
LCD->LCD_RAM=Back_Color;
}
color=color<<1;
}
}
p+=2;
x+=16;//下一个字
if(x>225) //下一行
{
x=0;
y+=16;
}
break;//匹配到了
}
}
}
}