最近在用到OLED显示汉字,但用到自己的汉字字模的时候总是出问题,有的能正常显示,但有的不行,甚至乱码。在显示 "不疚正慢"时,分开一个一个显示只能显示不和疚字,四个一起显示只能显示"不疚正",慢字不能显示,但我用例子的字符代码倒全部都能正常显示,换成我的代码就不行了,以下是汉字字符显示函数,请高手指点:
/*****************************************************************************
函 数 名 : LED_P14x16Str
功能描述 : 写入一组14x16的中文字符串(字符串表格中需含有此字)
输入参数 : UCHAR8 ucIdxX 为显示的横坐标0~114
UCHAR8 ucIdxY 为页范围0~3
UCHAR8 ucDataStr[] 要显示的中文字符串
输出参数 : NONE
返 回 值 : NONE
*****************************************************************************/
void LED_P14x16Str(uchar ucIdxX,uchar ucIdxY,uchar ucDataStr[])
{
// uchar i;
unsigned int usAddress,i,j;
// ucIdxY <<= 1;
j = 0;
while(ucDataStr[j] != ' ')
{
i = 0;
usAddress = 1;
while(F14x16_Idx[i] > 127) //高手能否解释下这句的意思
{
if(F14x16_Idx[i] == ucDataStr[j])
{
if(F14x16_Idx[i + 1] == ucDataStr[j + 1])
{
usAddress = i * 14;
break;
}
}
i += 2;
}
if(ucIdxX > 114) //是否超过8个汉字
{
ucIdxX = 0;
ucIdxY += 2;
}
if(usAddress != 1)// 显示汉字
{
LED_SetPos(ucIdxX, ucIdxY);
for(i = 0; i < 14; i++)
{
LED_WrDat(F14x16[usAddress]);
usAddress++;
}
LED_SetPos(ucIdxX,ucIdxY + 1);
for(i = 0;i < 14;i++)
{
LED_WrDat(F14x16[usAddress]);
usAddress++;
}
j += 2;
}
else //显示空字符
{
LED_SetPos(ucIdxX,ucIdxY);
for(i = 0;i < 14;i++)
{
LED_WrDat(0);
}
LED_SetPos(ucIdxX,ucIdxY + 1);
for(i = 0;i < 14;i++)
{
LED_WrDat(0);
}
j++;
}
ucIdxX += 14;
}
return;
}
//中文字符串原字
const uchar code F14x16_Idx[] =
{
"不疚正慢"
};
//中文字符串编码
const uchar code F14x16[] =
{
0x02,0x02,0x02,0x82,0x42,0xFE,0x06,0x42,0xC2,0x82,0x02,0x03,0x02,0x00,
0x04,0x02,0x01,0x00,0x00,0x7F,0x00,0x00,0x00,0x01,0x07,0x02,0x00,0x00,/*"不",0*/
0x00,0xFC,0x04,0x04,0xC4,0x3C,0x25,0x26,0xE4,0x24,0x04,0x04,0x04,0x00,
0x1C,0x03,0x82,0x41,0x20,0x10,0x08,0x06,0x09,0x10,0x60,0xC0,0x40,0x00,/*"疚",1*/
0x00,0x02,0x02,0xC2,0x02,0x02,0x02,0xFE,0x82,0x82,0x82,0x82,0x82,0x02,
0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x40,0x40,0x40,/*"正",2*/
0xF0,0x00,0xFF,0x08,0x10,0xC0,0x5F,0x55,0xD5,0x55,0xD5,0x55,0x5F,0xC0,
0x00,0x00,0xFF,0x00,0x80,0x83,0x4A,0x5A,0x2B,0x2A,0x2B,0x5A,0x4A,0x83,/*"慢",3*/
}
同一个显示函数,但例子的汉字都能显示正常,换成上面的就不行。
//中文字符串原字
const uchar code F14x16_Idx[] =
{
"信电子科技屏幕测试"
};
//中文字符串编码
const uchar code F14x16[] =
{
0x01,0x00,0x7F,0x00,0x00,0x01,0x7D,0x45,0x45,0x45,0x45,0x7C,0x00,0x00,/*"信",0*/
0x00,0x20,0x20,0xA8,0xA8,0xB8,0xA6,0xA8,0xB8,0x68,0xA8,0x20,0x20,0x00,
0x00,0x40,0x30,0x0F,0x76,0x46,0x4E,0x56,0x46,0x76,0x17,0x10,0x60,0x00,/*"意",1*/
0x00,0x00,0xF0,0x90,0x90,0x90,0xFE,0x90,0x90,0x90,0xF0,0x10,0x00,0x00,
0x00,0x00,0x0F,0x08,0x08,0x08,0x7F,0x48,0x48,0x48,0x4F,0x50,0x60,0x00,/*"电",2*/
0x00,0x00,0x04,0x04,0x04,0x04,0x04,0xE4,0x14,0x0C,0x04,0x84,0x80,0x00,
0x00,0x00,0x01,0x01,0x01,0x41,0x41,0x3F,0x01,0x01,0x01,0x00,0x00,0x00,/*"子",3*/
0x00,0x00,0x48,0xFC,0x44,0x42,0x00,0x88,0x30,0x00,0xFE,0x02,0x00,0x00,
0x00,0x0C,0x02,0x7F,0x01,0x01,0x08,0x08,0x05,0x04,0xFF,0x04,0x02,0x00,/*"科",4*/
0x00,0x00,0x20,0xFE,0x20,0x90,0x20,0x20,0x20,0xFE,0x20,0xA0,0x10,0x00,
0x00,0x02,0x41,0x7F,0x81,0x80,0x41,0x47,0x29,0x18,0x27,0x41,0x40,0x00,/*"技",5*/
0x00,0x00,0xFE,0x14,0x14,0x34,0x54,0x14,0x94,0x74,0x14,0x9C,0x00,0x00,
0x00,0x30,0x0F,0x88,0x48,0x39,0x0F,0x09,0x08,0x7F,0x09,0x04,0x04,0x00,/*"屏",6*/
0x00,0x04,0x04,0xF4,0x54,0xCE,0x54,0x54,0x4E,0x4C,0xF4,0x04,0x04,0x00,
0x00,0x08,0x0A,0x3E,0x0A,0x09,0x7E,0x0A,0x0A,0x7A,0x0E,0x0A,0x09,0x00,/*"幕",7*/
0x00,0x20,0x04,0x80,0xFC,0x04,0xF4,0x04,0xFC,0x00,0xF0,0xFC,0x00,0x00,
0x00,0x00,0x7F,0x40,0x27,0x18,0x07,0x10,0x67,0x00,0x4F,0xFF,0x00,0x00,/*"测",8*/
0x00,0x80,0x88,0x98,0x20,0x20,0x20,0x20,0xA0,0xFE,0x24,0x2C,0x10,0x00,
0x00,0x00,0x1F,0x60,0x10,0x28,0x21,0x1F,0x10,0x13,0x1C,0x20,0x70,0x00,/*"试",9*/
0x04,0x04,0xFF,0xA4,0xA4,0xA4,0xA4,0xA4,0xFF,0x04,0x04,0x04,0x00,0x00,
}
void LED_P14x16Str(uchar ucIdxX,uchar ucIdxY,uchar ucDataStr[]),我用这种方式会出问题。
如果用写字符方式就不会有问题:
void LED_P14x16Ch(unsigned char x,unsigned char y,unsigned char N)
你是用51还是32?
一周热门 更多>