二、软件参考,正点原子开发板
//放头文件
struct typFNT_GB16 // 汉字字模数据结构体
{
u8 Index[2];// 汉字内码索引,汉字在内存中占两个字节
char Msk[128]; // 点阵码数据
};
//放C文件
//定义汉字点阵结构体,数据由正点原子赠送的取模软件获得
struct typFNT_GB16 code_GB_16[] = // 数据表
{
{"华",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x70,0x00,0x00,0xF0,0x70,0x00,0x00,0xE0,0x70,0x20,0x01,0xC0,0x70,0x70,0x01,0xC0,0x70,0xF8,0x03,0xC0,0x73,0xC0,0x07,0xC0,0x7F,0x80,
0x0F,0xC0,0x7E,0x00,0x1D,0xC0,0xF8,0x00,0x3D,0xC7,0xF0,0x00,0x39,0xCF,0x70,0x00,0x11,0xC4,0x70,0x08,0x01,0xC0,0x70,0x0E,0x01,0xC0,0x70,0x1C,0x01,0xC0,0x7F,0xFC,0x01,0xC0,0x3F,0xF8,
0x01,0xC3,0x80,0x00,0x00,0x03,0x80,0x00,0x00,0x03,0x80,0x00,0x00,0x03,0x80,0x00,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x03,0x80,0x00,0x00,0x03,0x80,0x00,0x00,0x03,0x80,0x00,
0x00,0x03,0x80,0x00,0x00,0x03,0x80,0x00,0x00,0x03,0x80,0x00,0x00,0x03,0x80,0x00,0x00,0x00,0x00,0x00},
{"达",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x38,0x00,0x0C,0x00,0x38,0x00,0x0E,0x00,0x38,0x00,0x07,0x00,0x38,0x00,0x03,0x80,0x38,0x00,0x03,0xC0,0x38,0x00,0x01,0x80,0x38,0x00,
0x00,0x1F,0xFF,0xF8,0x00,0x1F,0xFF,0xF8,0x00,0x1F,0xFF,0xF8,0x00,0x00,0x38,0x00,0x3F,0x00,0x38,0x00,0x3F,0x00,0x30,0x00,0x03,0x00,0x70,0x00,0x03,0x00,0x72,0x00,0x03,0x00,0x6F,0x00,
0x03,0x00,0xE7,0x80,0x03,0x01,0xC3,0xC0,0x03,0x01,0xC1,0xE0,0x03,0x03,0x80,0xF0,0x03,0x07,0x00,0x70,0x03,0x1E,0x00,0x38,0x03,0x9C,0x00,0x38,0x07,0xC8,0x00,0x10,0x0F,0xE0,0x00,0x00,
0x1C,0x7C,0x00,0x00,0x78,0x3F,0xFF,0xFC,0x10,0x0F,0xFF,0xFC,0x00,0x00,0x7F,0xFC,0x00,0x00,0x00,0x00},
{"川",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x01,0xC0,0x00,0x70,0x01,0x80,0xC0,0x70,0x01,0x80,0xC0,0x70,0x01,0x80,0xC0,0x70,0x01,0x80,0xC0,0x70,
0x01,0x80,0xC0,0x70,0x01,0x80,0xC0,0x70,0x01,0x80,0xC0,0x70,0x01,0x80,0xC0,0x70,0x01,0x80,0xC0,0x70,0x01,0x80,0xC0,0x70,0x01,0x80,0xC0,0x70,0x01,0x80,0xC0,0x70,0x01,0x80,0xC0,0x70,
0x03,0x80,0xC0,0x70,0x03,0x80,0xC0,0x70,0x03,0x80,0xC0,0x70,0x03,0x00,0xC0,0x70,0x03,0x00,0xC0,0x70,0x07,0x00,0xC0,0x70,0x07,0x00,0xC0,0x70,0x0E,0x00,0xC0,0x70,0x0E,0x00,0xC0,0x70,
0x1C,0x00,0xC0,0x70,0x3C,0x00,0xC0,0x70,0x18,0x00,0x00,0x70,0x08,0x00,0x00,0x70,0x00,0x00,0x00,0x00},
};
void show_chinese(u16 x,u16 y,u8 size,u8 *p,u16 Word_Color,u16 Back_Color)
{
u8 k=0,wordByte,color;
u8 wordNum;//字库字数
while(*p!='\0')//直到字符串写完
{
LCD_Set_Window(x,y,size,size);
LCD_SetCursor(x,y);
LCD_WriteRAM_Prepare();
for(wordNum=0;wordNum<3;wordNum++)
{
if((*p==code_GB_16[wordNum].Index[0])&&(*(p+1)==code_GB_16[wordNum].Index[1]))//匹配汉字内码,汉字在内存中占两个字节
{
for(wordByte=0;wordByte<128;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+=size;//下一个字
if(x>225) //下一行
{
x=0;
y+=size;
}
break;//匹配到了
}
}
}
}
三、函数调用 show_chinese(30,80,32,"华达川",BLACK,WHITE);
|