本帖最后由 ahsssxd 于 2016-6-4 10:50 编辑
采用液晶是2.2TFT spi屏,资料如下
QDtech_2.2寸天马串口模块资料_Rev1.2.zip
(16.17 MB, 下载次数: 176)
2016-6-3 20:55 上传
点击文件名下载附件
中间的乱码,其实显示是32*16 数字5
相关代码如下
void Gui_DrawFont_GBK16(u16 x, u16 y, u16 fc, u16 bc, u8 *s) //数字字符均正常
{
unsigned char i,j;
unsigned short k,x0;
x0=x;
while(*s)
{
if((*s) < 128)
{
k=*s;
if (k==13)
{
x=x0;
y+=16;
}
else
{
if (k>32) k-=32; else k=0;
for(i=0;i<16;i++) //刷Y方向,16次
{
for(j=0;j<8;j++)
{
if(asc16[k*16+i]&(0x80>>j)) //刷X方向,8次
Gui_DrawPoint(x+j,y+i,fc);
else
{
if (fc!=bc) Gui_DrawPoint(x+j,y+i,bc);
}
}
//printf("
%d",asc16[k*16+i]);
}
x+=8;
}
s++;
// printf("
");
// printf("1111111111111111
");
}
else
{
for (k=0;k<hz16_num;k++)
{
if ((hz16[k].Index[0]==*(s))&&(hz16[k].Index[1]==*(s+1)))
{
for(i=0;i<16;i++)
{
for(j=0;j<8;j++)
{
if(hz16[k].Msk[i*2]&(0x80>>j)) Gui_DrawPoint(x+j,y+i,fc);
else {
if (fc!=bc) Gui_DrawPoint(x+j,y+i,bc);
}
}
for(j=0;j<8;j++)
{
if(hz16[k].Msk[i*2+1]&(0x80>>j)) Gui_DrawPoint(x+j+8,y+i,fc);
else
{
if (fc!=bc) Gui_DrawPoint(x+j+8,y+i,bc);
}
}
}
}
}
s+=2;x+=16;
}
}
}
//下面代码是我根据上面驱动源码修改过来的,可能理解还不是很透彻,希望写过液晶驱动的的大神帮忙看看
void Gui_DrawFont_GBK32(u16 x, u16 y, u16 fc, u16 bc, u8 *s)//文字显示正常,字符乱码
{
unsigned char i,j;
unsigned short k;
while(*s)
{
if( *s < 0x80 )
{
k=*s;
if (k>32) k-=32; else k=0;
for(i=0;i<32;i++)
{
for(j=0;j<8;j++)
{
if(asc32[k*32+i]&(0x80>>j))
Gui_DrawPoint(x+j,y+i,fc);
else
{
if (fc!=bc) Gui_DrawPoint(x+j,y+i,bc);
}
}
for(j=0;j<8;j++)
{
if(asc32[k*32+8+i]&(0x80>>j))
Gui_DrawPoint(x+j+8,y+i,fc);
else
{
if (fc!=bc) Gui_DrawPoint(x+j+8,y+i,bc);
}
}
}
s+=2;x+=16;
}
else
{
for (k=0;k<hz32_num;k++)
{
if ((hz32[k].Index[0]==*(s))&&(hz32[k].Index[1]==*(s+1)))
{
for(i=0;i<32;i++)
{
for(j=0;j<8;j++)
{
if(hz32[k].Msk[i*4]&(0x80>>j))
Gui_DrawPoint(x+j,y+i,fc);
else
{
if (fc!=bc) Gui_DrawPoint(x+j,y+i,bc);
}
}
for(j=0;j<8;j++)
{
if(hz32[k].Msk[i*4+1]&(0x80>>j)) Gui_DrawPoint(x+j+8,y+i,fc);
else {
if (fc!=bc) Gui_DrawPoint(x+j+8,y+i,bc);
}
}
for(j=0;j<8;j++)
{
if(hz32[k].Msk[i*4+2]&(0x80>>j))
Gui_DrawPoint(x+j+16,y+i,fc);
else
{
if (fc!=bc) Gui_DrawPoint(x+j+16,y+i,bc);
}
}
for(j=0;j<8;j++)
{
if(hz32[k].Msk[i*4+3]&(0x80>>j))
Gui_DrawPoint(x+j+24,y+i,fc);
else
{
if (fc!=bc) Gui_DrawPoint(x+j+24,y+i,bc);
}
}
}
}
}
s+=2;x+=32;
}
}
}
{
k=*s;/*"~",0*/
// printf("kkkkkk%dkkkk ",k);
if (k>32) k-=32; else k=0;
for(i=0;i<32;i++)
{
for(j=0;j<8;j++)
{
if(asc32[k*64+2*i+1]&(0x80>>j))
Gui_DrawPoint(x+j+8,y+i,fc);
else
{
if (fc!=bc) Gui_DrawPoint(x+j+8,y+i,bc);
}
if(asc32[k*64+2*i+2]&(0x80>>j))
Gui_DrawPoint(x+j,y+i+1,fc);
else
{
if (fc!=bc) Gui_DrawPoint(x+j,y+i+1,bc);
}
}
}
s+=1;x+=16;
// printf("123456789 ");
}
{
k=*s;/*"~",0*/
// printf("kkkkkk%dkkkk ",k);
if (k>32) k-=32; else k=0;
for(i=0;i<32;i++)
{
for(j=0;j<8;j++)
{
if(asc32[k*64+2*i+1]&(0x80>>j))
Gui_DrawPoint(x+j+8,y+i,fc);
else
{
if (fc!=bc) Gui_DrawPoint(x+j+8,y+i,bc);
}
if(asc32[k*64+2*i+2]&(0x80>>j))
Gui_DrawPoint(x+j,y+i+1,fc);
else
{
if (fc!=bc) Gui_DrawPoint(x+j,y+i+1,bc);
}
}
}
s+=1;x+=16;
// printf("123456789 ");
}
一周热门 更多>