各位大佬,
前些天在用LCD0802做频率计,总觉得显示不好看,想改用12864(12832比较难买)。碰到的问题是用16点阵字体太小,一屏四行也用不完,想改成24点阵的。用PCTOLCD2000建了只0-9再加上小数点的小字库,如下:
const unsigned char code F12X24[][36]=
{
{0x00,0x00,0x00,0x00,0x7F,0x80,0x01,0xFF,0xE0,0x03,0x80,0x70,0x06,0x00,0x18,0x04},
{0x00,0x08,0x04,0x00,0x08,0x06,0x00,0x18,0x03,0x80,0x70,0x01,0xFF,0xE0,0x00,0x7F},
{0x80,0x00,0x00,0x00},/*"0",0*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x08,0x02,0x00,0x08,0x02,0x00,0x08,0x03},
{0xFF,0xF8,0x07,0xFF,0xF8,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00},
{0x00,0x00,0x00,0x00},/*"1",1*/
{0x00,0x00,0x00,0x01,0xC0,0x18,0x02,0xC0,0x38,0x04,0x00,0x48,0x04,0x00,0x88,0x04},
{0x03,0x08,0x04,0x06,0x08,0x06,0x0C,0x08,0x03,0xF8,0x08,0x01,0xE0,0x78,0x00,0x00},
{0x00,0x00,0x00,0x00},/*"2",2*/
{0x00,0x00,0x00,0x03,0x80,0x70,0x03,0x80,0x70,0x04,0x00,0x08,0x04,0x08,0x08,0x04},
{0x08,0x08,0x06,0x18,0x08,0x03,0xF4,0x18,0x01,0xE7,0xF0,0x00,0x01,0xE0,0x00,0x00},
{0x00,0x00,0x00,0x00},/*"3",3*/
{0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x05,0x00,0x00,0x19,0x00,0x00,0x21,0x00,0x00},
{0xC1,0x08,0x01,0x01,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x00,0x01,0x08,0x00,0x01},
{0x08,0x00,0x01,0x00},/*"4",4*/
{0x00,0x00,0x00,0x00,0x00,0xE0,0x07,0xFC,0xD0,0x04,0x08,0x08,0x04,0x10,0x08,0x04},
{0x10,0x08,0x04,0x10,0x08,0x04,0x18,0x38,0x04,0x0F,0xF0,0x04,0x07,0xC0,0x00,0x00},
{0x00,0x00,0x00,0x00},/*"5",5*/
{0x00,0x00,0x00,0x00,0x3F,0x80,0x01,0xFF,0xE0,0x03,0x84,0x30,0x02,0x08,0x18,0x04},
{0x10,0x08,0x04,0x10,0x08,0x04,0x10,0x08,0x07,0x18,0x10,0x03,0x0F,0xF0,0x00,0x07},
{0xC0,0x00,0x00,0x00},/*"6",6*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x80,0x00,0x06,0x00,0x00,0x04,0x00,0x00,0x04},
{0x00,0xF8,0x04,0x07,0xF8,0x04,0x18,0x00,0x04,0xE0,0x00,0x07,0x00,0x00,0x06,0x00},
{0x00,0x00,0x00,0x00},/*"7",7*/
{0x00,0x00,0x00,0x01,0xC1,0xE0,0x03,0xF3,0xF0,0x06,0x36,0x10,0x04,0x18,0x08,0x04},
{0x08,0x08,0x04,0x0C,0x08,0x04,0x0C,0x08,0x06,0x16,0x18,0x03,0xF3,0xF0,0x01,0xC1},
{0xE0,0x00,0x00,0x00},/*"8",8*/
{0x00,0x00,0x00,0x00,0xF8,0x00,0x03,0xFC,0x30,0x03,0x06,0x38,0x04,0x02,0x08,0x04},
{0x02,0x08,0x04,0x02,0x08,0x04,0x04,0x10,0x03,0x08,0xF0,0x01,0xFF,0xC0,0x00,0x7F},
{0x00,0x00,0x00,0x00},/*"9",9*/
};
显示函数如下(24点阵):
else if(Char_Size ==24)
{
c=chr-'/';
OLED_Set_Pos(x, y);
for (i = 0; i < 12; i++)
OLED_WR_Byte(F12X24[c * 36 + i], OLED_DATA); //18*2
OLED_Set_Pos(x, y + 1);
for (i = 0; i < 12; i++)
OLED_WR_Byte(F12X24[c * 36 + i +12], OLED_DATA);
OLED_Set_Pos(x, y + 2);
for (i = 0; i < 12; i++)
OLED_WR_Byte(F12X24[c * 36 + i +24], OLED_DATA);
}
其中c=chr-'/'是取偏移后的值。因为小字库的第一位是‘0’,ASC值48,而‘/'是47,48-47=1,正好取首字符。
工作时16点阵正常,但在24点阵时仅能显示24点阵麻点方块,不是所需数字。
我对C语言的底层编程不内行,故特地向各位请教。
谢谢。
|