字模软件的使用
为方便后期LCD的学习,先做一个简单的字模学习。
本实验是通过串口打印出我们想打印的字。
打印一个16×16的字
这里采取的取字模设置为如下所示:
阴码:字模软件上有颜色的点处为:1;空白的点处为:0;
阳码:字模软件上有颜色的点处为:0;空白的点处为:1;
取模方式在取模颜色哪那里都有显示效果,这里不再讲解。
每行显示数据,这里无关紧张,随便设置。
取模走向,这里关乎取数据的问题,比如我这里用顺向,表示最前面的第一个是高位,最后面是低位。如果是逆向,表示最前面是低位,最后面是高位;
输出数制,一般用16进制。
输出选项是问你需不需要把字模弄个索引文件之类的。
下面的代码是基于上述图中设置的效果。
unsigned char Guo_DisPlay[] =
{0x00,0x00,0x7F,0xFC,0x40,0x04,0x40,0x04,0x5F,0xF4,0x41,0x04,0x41,0x04,0x4F,
0xE4,0x41,0x04,0x41,0x44,0x41,0x24,0x5F,0xF4,0x40,0x04,0x40,0x04,0x7F,0xFC,
0x40,0x04};
void DisPlay_UserDefine(void)
{
unsigned int Row_number = 0,Byte_number = 0,Bit_number = 0;
for(Row_number=0;Row_number<16;Row_number++)
{
for(Byte_number=0;Byte_number<2;Byte_number++)
{
for(Bit_number=0;Bit_number<8;Bit_number++)
{
if(Guo_DisPlay[0+Row_number*2+Byte_number] & (0x80>>Bit_number))
{
printf("*");
}
else
{
printf(" ");
}
}
}
printf("\n");
}
}
实验结果是:
有人说,如果我要32×32的行不行?当然可以,随便你要多大的,只需要把上面的程序改一下即可,修改如下:
unsigned char Guo_DisPlay[] =
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFC,0x18,0x00,0x00,0x04,0x18,0x00,0x00,0x04,0x18,0x00,0x00,0x04,0x19,0xFF,0xFF,0xC4,
0x18,0x00,0x80,0x04,0x18,0x00,0x80,0x04,0x18,0x00,0x80,0x04,0x18,0x00,0x80,0x04,0x18,0xFF,0xFF,0x84,0x18,0x00,0x80,0x04,
0x18,0x00,0x88,0x04,0x18,0x00,0x86,0x04,0x18,0x00,0x83,0x04,0x18,0x00,0x80,0x04,0x19,0xFF,0xFF,0xC4,0x19,0xFF,0xFF,0xC4,
0x18,0x00,0x00,0x04,0x18,0x00,0x00,0x04,0x18,0x00,0x00,0x04,0x1F,0xFF,0xFF,0xFC,0x18,0x00,0x00,0x04,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
void DisPlay_UserDefine(void)
{
unsigned int Row_number = 0,Byte_number = 0,Bit_number = 0;
for(Row_number=0;Row_number<32;Row_number++)
{
for(Byte_number=0;Byte_number<4;Byte_number++)
{
for(Bit_number=0;Bit_number<8;Bit_number++)
{
if(Guo_DisPlay[0+Row_number*4+Byte_number] & (0x80>>Bit_number))
{
printf("*");
}
else
{
printf(" ");
}
}
}
printf("\n");
}
}
32-32实验效果如下(这个取模设置跟上面16-16的一摸一样):
那有人问,我输出2个字行不行,当然可以。
打印二个16×16的字
在上面我们已经显示了”中“,如果还想显示”国“,我们只需要给个偏移量即可。
unsigned char Guo_DisPlay[] =
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x02,0x00,0x7F,0xF0,0x42,0x10,0x42,0x10,0x7F,0xF0,0x02,0x00,0x02,0x00,
0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xF0,0x40,0x10,0x4F,0x90,0x42,0x10,0x4F,0x90,0x42,0x90,0x4F,0x90,0x40,0x10,
0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00};
void DisPlay_UserDefine(void)
{
unsigned int Row_number = 0,Byte_number = 0,Bit_number = 0;
for(Row_number=0;Row_number<16;Row_number++)
{
for(Byte_number=0;Byte_number<2;Byte_number++)
{
for(Bit_number=0;Bit_number<8;Bit_number++)
{
if(Guo_DisPlay[32+Row_number*2+Byte_number] & (0x80>>Bit_number))
{
printf("*");
}
else
{
printf(" ");
}
}
}
printf("\n");
}
}
实验结果:
|