建议先写一个单字符显示函数,这样调用起来更方便,移植也方便;
然后显示字符串
参考函数如下:
typedef struct typFNT_GB16 /1216 汉字字模显示数据结构 /
{
char Index[2];
char Msk[32];
}HZ;
//HZ code HzLib[] = { / 宋体 9小五 显示为1216 /
struct typFNT_GB16 code HzLib[] = { / 字大小为1616 /
"深",0x40,0x00,0x27,0xFE,0x24,0x04,0x01,0x20,0x81,0x18,0x56,0x08,0x50,0x40,0x10,0x40,0x27,0xFC,0x20,0x40,0xC0,0xE0,0x41,0x58,0x46,0x4E,0x58,0x44,0x40,0x40,0x40,0x40,//深0
"圳",0x00,0x00,0x12,0x04,0x12,0x44,0x12,0x44,0xFE,0x44,0x12,0x44,0x12,0x44,0x12,0x44,0x12,0x44,0x12,0x44,0x3A,0x44,0xC4,0x44,0x04,0x44,0x08,0x04,0x10,0x04,0x00,0x00,//圳1
"睿",0x00,0x00,0x01,0xF0,0x01,0x00,0x7F,0xFC,0x40,0x04,0x3F,0xF8,0x12,0x90,0x24,0x48,0x1F,0xF0,0x70,0x1C,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x00,0x00,
"宇",0x00,0x00,0x02,0x00,0x01,0x00,0x7F,0xFC,0x40,0x04,0x00,0x00,0x1F,0xF0,0x01,0x00,0x01,0x00,0x01,0x00,0x7F,0xFC,0x01,0x00,0x01,0x00,0x01,0x00,0x07,0x00,0x00,0x00, //宇3
"科",0x06,0x08,0x78,0x88,0x08,0x48,0x08,0x48,0xFE,0x08,0x18,0x88,0x1C,0x48,0x2A,0x48,0x28,0x0E,0x48,0x78,0x8B,0x88,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,//科4
"技",0x10,0x20,0x10,0x20,0x10,0x20,0xFD,0xFE,0x10,0x20,0x14,0x20,0x19,0xFC,0x31,0x08,0xD0,0x88,0x10,0x90,0x10,0x60,0x10,0x60,0x10,0x90,0x11,0x0E,0x56,0x04,0x20,0x00,//技5
"电",0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x01,0x02,0x01,0x02,0x00,0xFE,0x00,0x00,//电6
"子",0x00,0x00,0x3F,0xF0,0x00,0x20,0x00,0x40,0x00,0x80,0x01,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,//子7
"有",0x01,0x00,0x01,0x00,0x7F,0xFE,0x02,0x00,0x04,0x00,0x0F,0xF0,0x18,0x10,0x28,0x10,0x4F,0xF0,0x88,0x10,0x08,0x10,0x0F,0xF0,0x08,0x10,0x08,0x90,0x08,0x70,0x08,0x20,//有8
"限",0x00,0x00,0xFB,0xF8,0x92,0x08,0x93,0xF8,0xA2,0x08,0xA2,0x08,0x93,0xF8,0x8A,0x80,0x8A,0x48,0xAA,0x50,0x92,0x20,0x82,0x20,0x82,0x10,0x82,0x8E,0x83,0x04,0x82,0x00,//限9
"公",0x00,0x00,0x04,0x40,0x06,0x40,0x04,0x40,0x08,0x20,0x08,0x10,0x10,0x18,0x22,0x0E,0x43,0x04,0x02,0x00,0x04,0x20,0x08,0x10,0x11,0xF8,0x3F,0x18,0x10,0x10,0x00,0x00,//公10
"司",0x00,0x00,0x3F,0xFC,0x00,0x04,0x00,0x04,0x7F,0xE4,0x00,0x04,0x00,0x04,0x3F,0xC4,0x20,0x44,0x20,0x44,0x3F,0xC4,0x20,0x44,0x20,0x04,0x00,0x14,0x00,0x08,0x00,0x00,//司11
};
/
名 称: DrawSingleHz
功 能: 在指定的位置显示汉字
参 数: 坐标:x
坐标:y
字符的颜色:LineColor
字符背景颜色:FillColor
/
void DrawSingleHz(U16 x, U16 y, U8 pHz, U16 LineColor,U16 FillColor, U8 Mod)
{
U16 i=0,j=0,k=0;
U16 str,len;
//---------------------------查找该字是否已在字库中
len=sizeof(HzLib)/sizeof(HzLib[0]);
for(i=0;i<sizeof(HzLib)/sizeof(HzLib[0]);i++)
if((U8)HzLib[i]Index[0]==pHz[0]&&(U8)HzLib[i]Index[1]==pHz[1])break;
//--------------------------
if(i<len) //j<len,说明该字已经在汉字中出现
{
LCD_SetWindows(x, y, x+15, y+15);
for (j=0;j<16;j++)
{
str = (U8)HzLib[i]Msk[j2]<<8|(U8)HzLib[i]Msk[j2+1];
for (k=0;k<16;k++)
{
if ( str & (0x8000>>k) ) //通过移位逐位发送数据
{
LCD_WrDat((U16)(LineColor&0xffff));
}
else
{
if (Mod == NORMAL)
{
LCD_WrDat((U16)(FillColor&0xffff));
}
else
{
LCD_SetGramPoit(x+k+1,y+j); //跳过这一点,即保留该点原有的信息
}
}
}
}
}
}
/
名 称: DrawString
功 能: 在指定的位置显示多个字符
参 数: 坐标:x
坐标:y
字符的颜色:LineColor
字符背景颜色:FillColor
返 回 值: 无
/
void DrawString(U16 x, U16 y, U8 pStr, U16 LineColor,U16 FillColor, U8 Mod)
{ //把字符串的第一个字符的地址赋给字符指针变量pstr,
//不是pStr=" "详见濉跺《C程序设计》-谭浩强P252
while(1)
{
if (pStr == 0)
{
return;
}
if (pStr > 0x80) //大于0x80的为汉字
{
DrawSingleHz(x, y, pStr, LineColor, FillColor, Mod); //调用显示单个汉字函数处理
x += 16;
pStr += 2;
} //移动指针
else //英文字符
{
DrawSingleAscii(x, y, pStr, LineColor, FillColor, Mod); //调用显示单个字符函数处理
x += 8;
pStr += 1; //移动指针
}
}
}
void main()
{
LCD_Init();
while(1)
{
Display_full_screen_color(BLACK);
DispSmallPic(0, 0,32,20,Picture);
DelayMs(1000) ;
DispSmallPic(100, 190,82,45,Picture);
DrawString(83,0,"深圳睿宇电子",RED,BLACK);
DelayMs(1000) ;
}
Img2Lcdexe和电脑自带的画图软件。
打开画图软件,然后将画图区域调整到合适的大小,将画图区域填充一种自己想要的颜色然后点击保存,在保存时将保存的文件类型选择为JPEG格式,接下来,打开另外一个软件Img2Lcdexe,找到刚刚保存的文件,打开它,保存取出的文件数组,取出相邻的两个十六进制代码组合成一个就是自己需要颜色的代码了。例如:取出0x84和0x10,组合成0x8410。
LCD的PWM芯片的VCC电压和启动脚的电压分别是220V和2-10mV。
LCD,即液晶显示器。LCD 的构造是在两片平行的玻璃基板当中放置液晶盒,下基板玻璃上设置TFT(薄膜晶体管),上基板玻璃上设置彩色滤光片,通过TFT上的信号与电压改变来控制液晶分子的转动方向,从而达到控制每个像素点偏振光出射与否而达到显示目的。
在User_Setuph文件内,定义要使用的系统自带字体,不用的直接省略掉
以7段数字显示为例,看TFT_eSPIh文件的定义
再看Font7srleh文件
再看Font7srlec文件
取模略,使用的软件是PCtoLCD2002
HanZi16h,16X16大小,用的宋体,相当于12号字
主程序
以上就是关于C51中TFT彩屏无法显示出汉字,但程序编译没问题全部的内容,包括:C51中TFT彩屏无法显示出汉字,但程序编译没问题、TFT显示屏的代码怎么写、如何编写tft液晶屏上显示波形c程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)