本帖最后由 eltonchang2001 于 2022-11-9 11:54 编辑
利用ESK32-A2A31显示模块可以实现中文及图片显示,其实现方法如下: 1. 图片显示 在例程中提供了图片显示函数void LCD_PicDraw(u8 X_Location, u16 Y_Location, u8 Height, u16Width, uc8 *Pptr) ,它可以指定图片的显示位置、图片的长度与宽度等。 为了显示所需要的图片,可通过相应的工具来生成对应的数组文件,其后缀为*.h。 图1 生成工具
这样处理后,其显示效果如图2所示。 图2 显示效果
但此时所显示的图片效果与字符的显示方向是反向的,为此需要将显示函数改为如下的内容: - void LCD_PicDraw(u8 X_Location, u16 Y_Location, u8 Height, u16 Width, uc8 *Pptr)
- {
- u32 xid = 0;
- u32 ImgAdds = 0;
- u32 yid = 0;
- u32 i = 0, j = 0, color = 0;
- xid = Height + X_Location;
- yid = Y_Location;
- LCD_StarterSet(xid, yid);
- for (i = 0; i < Height; i++)
- {
- LCD_WriteRAMPrior();
- for (j = 0; j < Width; j++)
- {
- ImgAdds = (i * Width * 2) + (j * 2);
- color = Pptr[ImgAdds] << 8 | (Pptr[ImgAdds + 1]);
- LCD_WriteRAM(color);
- }
- xid++;
- LCD_StarterSet(xid, yid);
- }
- }
经修改,使用如下的主程序就可获得图3所示的效果。 - int main(void)
- {
- LCD_Init();
- LCD_Config();
- LCD_BackColorSet(Black);
- LCD_TextColorSet(Yellow);
- LCD_StringLineDisplay(Line3, " Photo ");
- LCD_PicDraw((50), (50), 80, 160, gImage_k);
- while (1);
- }
图3修正后的显示效果
2. 中文显示 要实现中文显示,可使用字模提取软件来构建字库,见图4所示。 图4 提取字模 为实现中文的显示,所配置的显示函数如下: - void LCD_hzDisplay(u32 Line_Num, u32 Column, u8 Ascii)
- {
- LCD_hzDraw (Line_Num, Column, &ASCII_FontA_Table[Ascii * 32]);
- }
-
- void LCD_hzDraw(u32 X_Location, u32 Y_Location, u8 *Cptr)
- {
- u32 xid = X_Location;
- u32 i = 0, j = 0;
- u16 u = 0;
- LCD_StarterSet(X_Location, Y_Location);
- for (i = 0; i < 16; i++)
- {
- LCD_WriteRAMPrior();
- u=Cptr[i*2];
- for (j = 8; j>0; j--)
- {
- if ((u & (1 << (j-1))) == 0x00)
- {
- LCD_WriteRAM(Color_Back);
- }
- else
- {
- LCD_WriteRAM(Color_Text);
- }
- }
- u=Cptr[i*2+1];
- for (j = 8; j>0; j--)
- {
- if ((u & (1 << (j-1))) == 0x00)
- {
- LCD_WriteRAM(Color_Back);
- }
- else
- {
- LCD_WriteRAM(Color_Text);
- }
- }
- xid++;
- LCD_StarterSet(xid, Y_Location);
- }
- }
这样通过下面的主程序就可获得图5所示的显示效果。 - int main(void)
- {
- LCD_Init();
- LCD_Config();
- LCD_BackColorSet(Black);
- LCD_TextColorSet(Yellow);
- LCD_hzDisplay(Line1, 70, 0);
- LCD_ hzDisplay (Line1, 90, 1);
- LCD _hzDisplay (Line1, 110, 2);
- LCD_ hzDisplay (Line1, 130, 3);
- LCD_ hzDisplay (Line1, 150, 4);
- while (1);
- }
图5 显示效果
|