最近搞个一下汉字显示,虽然这样的文章很多,但这毕竟是自己写的意义不一样。本例程实用显示字数不多的情况,本例程是基于蓝桥杯嵌入式开发板。字模逆向取,话不多说上代码。
unsigned cha rconst hanzi[3][72]={{0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x10,0xE0,0x7F,0x0C,0x20,0x40,0x04,0x20,0x40,0x00,0xE0,0x7F,0x01,0x20,0x40,0x41,0x20,0x40,0x32,0x20,0x40,0x12,0xE0,0x7F,0x12,0x20,0x40,0x04,0x00,0x00,0x04,0xF8,0xFF,0x04,0x10,0x89,0x04,0x10,0x89,0x08,0x10,0x89,0x78,0x10,0x89,0x18,0x10,0x89,0x18,0x10,0x89,0x18,0x14,0x89,0x18,0xFE,0xFF,0x1F,0x00,0x00,0x00,0x00,0x00,0x00},/*"温",0*/
{0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x0C,0x00,0x08,0x0C,0x00,0xFC,0xFF,0x0F,0x80,0x40,0x08,0xC0,0x20,0x08,0x88,0x20,0x08,0xFC,0xFF,0x0F,0x80,0x20,0x08,0x80,0x20,0x08,0x80,0x3F,0x08,0x80,0x20,0x08,0x00,0x00,0x08,0xE0,0xFF,0x19,0x40,0x20,0x18,0x80,0x20,0x10,0x00,0x11,0x10,0x00,0x0A,0x10,0x00,0x0E,0x20,0xC0,0x31,0x20,0x7E,0xC0,0x40,0x08,0x00,0x07,0x00,0x00,0x00},/*"度",1*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x80,0x1F,0x12,0x68,0x30,0x12,0x18,0x60,0x12,0x18,0xC0,0x0C,0x08,0x80,0x00,0x08,0x80,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x80,0x00,0x00,0xC0,0x00,0x10,0xC0,0x00,0x20,0x60,0x00,0xC0,0x38,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}};
void Show_Font(u16 x,u16 y)
{
u16 y0=y;
u16 x0=x;//保存原始坐标
u32 index = 0, i = 0;
u8 temp,m;
for( m = 0 ; m < 3 ; m++ )//3个汉字
{
for( index = 0; index < 72; index++ )//每个汉字72个数据 24*24的
{
LCD_SetCursor(x, y);//设置光标
temp = hanzi[m][index];
LCD_WriteRAM_Prepare(); /* Prepare to write GRAM *///写入寄存器
for(i = 0; i < 8; i++)//8位一个
{
if(temp&0x80)//按位读取
{
LCD_WriteRAM(Blue);//字体颜 {MOD}
}
else
{
LCD_WriteRAM(White);//背景颜 {MOD}
}
temp<<=1;//位移
y++;//纵坐标加1 计数
if((y-y0)==24)//24*24字体
{
y=y0;
x++;
break;
}
}
}
/////////////下面代码是改变下一个汉字的纵坐标沿着Y轴向上显示。 去掉下面汉字会沿着x轴显示
x = x0;
y0 = y-24;//
y = y0;
}
}
一周热门 更多>