以下是字符显示的函数调用:
LCD_showChar(240,400,16,'!',WHITE);
LCD_showChar(260,400,16,'#',WHITE);
LCD_showNChar(240,420,16,"!#!",WHITE);
其对应的字库如下:
u8 ASCII_16X8[][16]=
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xCC,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x00,0x00,
0x02,0x20,0x03,0xFC,0x1E,0x20,0x02,0x20,0x03,0xFC,0x1E,0x20,0x02,0x20,0x00,0x00,
};
显示字符函数
void LCD_showchar(vu16 Xpos,vu16 Ypos,u8 size,u8 showchar,u16 color)
{
u8 CSize;
u8 i,j;
u8 tmp;
u16 Y0;
Y0=Ypos;
u8 RowNum;
CSize=(size/8+(size%8?1:0))*size/2;
RowNum=showchar-' ';
if(RowNum>(sizeof(ASCII_16X8)/CSize))
return;
for(i=0;i<CSize;i++)
{
if(size== 16)
tmp=ASCII_16X8[RowNum][i];
else
return;
for(j=0;j<8;j++)
{
if(tmp&0x80)
LCD_WritePoint(Xpos,Ypos,color);
Ypos++;
tmp<<=1;
if(Xpos>lcddev.width || Ypos>lcddev.height)
return;
if((Ypos-Y0)==size)
{
Xpos++;
Ypos=Y0;
break;
}
}
}
}
显示字符串函数
void LCD_showNchar(vu16 Xpos,vu16 Ypos,u8 size,u8 *str,u16 color)
{
while(*str)
{
LCD_showchar(Xpos,Ypos,size,*str,color);
Xpos+=size/2;
str++;
}
}
首先ASCII码字符显示的大小:长是宽是两倍。
|