花了半天时间研究TI的LM3S8962开发板自带OLED显示,在rit128x96x4.c中自己添加了一个RIT128x96x4HZStringDraw函数,实现16*16中文汉字显示,现在汉字存储在内部FLASH中,下一步准备把字库存储到外部FLASH中:D
void RIT128x96x4HZStringDraw(const char *pcStr, unsigned long ulX,
unsigned long ulY, unsigned char ucLevel)
{
unsigned long ulIdx1, ulIdx2, k, hzxx;
unsigned char ucTemp;
unsigned short hzTemp;
g_pucBuffer[0] = 0x15;
g_pucBuffer[1] = ulX / 2;
g_pucBuffer[2] = 63;
RITWriteCommand(g_pucBuffer, 3);
g_pucBuffer[0] = 0x75;
g_pucBuffer[1] = ulY;
g_pucBuffer[2] = ulY + 15;
RITWriteCommand(g_pucBuffer, 3);
RITWriteCommand(g_pucRIT128x96x4VerticalInc,
sizeof(g_pucRIT128x96x4VerticalInc));
while(*pcStr != 0)
{
ucTemp = *pcStr++;
if(ucTemp > 0x7f)
{
hzTemp = ucTemp;
hzTemp <<= 8;
ucTemp = *pcStr++;
hzTemp |= ucTemp;
hzxx = findHzIndex(hzTemp);
k = 7;
for(ulIdx1 = 0; ulIdx1 < 8; ulIdx1++)
{
for(ulIdx2 = 0; ulIdx2 < 16; ulIdx2++)
{
g_pucBuffer[ulIdx2] = 0;
if(ulIdx1 < 4)
{
if(GB_16[hzxx].Msk[ulIdx2*2] & (1 << k))
{
g_pucBuffer[ulIdx2] = (ucLevel << 4) & 0xf0;
}
if(GB_16[hzxx].Msk[ulIdx2*2] & (1 << (k-1)))
{
g_pucBuffer[ulIdx2] |= (ucLevel) & 0x0f;
}
}
else
{
if(GB_16[hzxx].Msk[ulIdx2*2+1] & (1 << k))
{
g_pucBuffer[ulIdx2] = (ucLevel << 4) & 0xf0;
}
if(GB_16[hzxx].Msk[ulIdx2*2+1] & (1 << (k-1)))
{
g_pucBuffer[ulIdx2] |= (ucLevel) & 0x0f;
}
}
}
if(k <= 1) k = 7;
else k-=2;
RITWriteData(g_pucBuffer, 16);
ulX += 2;
if(ulX == 128)
{
return;
}
}
}
else
{
hzxx = (ucTemp-32);
k = 7;
for(ulIdx1 = 0; ulIdx1 < 4; ulIdx1++)
{
for(ulIdx2 = 0; ulIdx2 < 16; ulIdx2++)
{
g_pucBuffer[ulIdx2] = 0;
if(ASCII[hzxx][ulIdx2] & (1 << k))
{
g_pucBuffer[ulIdx2] = (ucLevel << 4) & 0xf0;
}
if(ASCII[hzxx][ulIdx2] & (1 << (k-1)))
{
g_pucBuffer[ulIdx2] |= (ucLevel) & 0x0f;
}
}
if(k <= 1) k = 7;
else k-=2;
RITWriteData(g_pucBuffer, 16);
ulX += 2;
if(ulX == 128)
{
return;
}
}
}
}
}