第七讲 单片机驱动彩色液晶屏 控制RA8889软件:显示文字:Part3.自建字库

单片机驱动TFT彩色液晶屏系列讲座

目录

第一讲 单片机最小系统STM32F103C6T6通过RA8889驱动彩色液晶屏播放视频
第二讲 单片机最小系统STM32F103C6T6控制RA8889驱动彩色液晶屏硬件框架
第三讲 单片机驱动彩色液晶屏 控制RA8889软件:如何初始化
第四讲 单片机驱动彩色液晶屏 控制RA8889软件:绘图
第五讲 单片机驱动彩色液晶屏 控制RA8889软件:显示文字:Part1.内部字库
第六讲 单片机驱动彩色液晶屏 控制RA8889软件:显示文字:Part2.外接字库
第七讲 单片机驱动彩色液晶屏 控制RA8889软件:显示文字:Part3.自建字库
第八讲 单片机驱动彩色液晶屏 控制RA8889软件:显示图片
第九讲 单片机驱动彩色液晶屏 控制RA8889软件:显存操作
第十讲 单片机驱动彩色液晶屏 控制RA8889软件:图像运算
第十一讲 单片机驱动彩色液晶屏 控制RA8889软件:播放avi视频
第十二讲 单片机驱动彩色液晶屏 如何打包bin档
第十三讲单片机驱动彩色液晶屏 bin档的烧录方法

如何通过RA8889 / RA8876来显示文字?
UI界面需求最大的两个功能,第一个是显示图形,第二个是显示文字。文字部分有ASCII和中文,或者是多国语言,下面我们就专门针对RA8889如何显示文字展开介绍。

本章要介绍如何自建中文字库,以及单片机如何控制RA8889进行调用并显示。

本篇要展现的内容比较丰富,篇幅较长,需要多些耐心阅读。

三种文字显示方法的优缺比较:
在这里插入图片描述
通过上图比较,自建字库除了显示速度会慢一些,优势还是很大,设计灵活度也很高,同时还可以节省专用字库芯片的成本,具有一定的经效益,因此值得C友多加参考!

下面开始介绍单片机如何控制RA8889来驱动彩屏显示文字,这里主要是针对显示中文字体进行展开说明,若还有其他国家的字体也可以借鉴该方法进行设计,有兴趣的C友们可留言进行探讨。

一、需求的中文字数不多,采用以下方法
  1. 自建点阵字码表;
  2. 单片机获取字码数据,按点写入显存,同时指定前景、背景及透明色。

框架图:
在这里插入图片描述

调用函数:

void User_Font_Demo(void)
{Show_User_Font(25, 32, 350, 180, 0, color65k_red, color65k_green, "菱致电子瑞佑科技");Show_User_Font(25, 32, 260, 260, 1, color65k_black, color65k_red, "单片机驱动彩色液晶屏极简方案");delay_seconds(3);
}

子函数:

void Show_User_Font(unsigned int font_lib_size // 自建字库数组的文字个数,unsigned int font_size // 字模大小,比如32*32点阵写32,unsigned short x // 显示窗口的x轴坐标,unsigned short y // 显示窗口的y轴坐标,int Chroma_key // 是否透明:0-不透明 1-透明色,unsigned long Foreground_color // 前景色,unsigned long Background_color // 背景色,const unsigned char *str // 字符串
)
{unsigned int i, j = 0;unsigned int k, len; // len;字符串的长度unsigned char hanziCode[128];unsigned char strfont_0, strfont_1, Index_0, Index_1;Goto_Pixel_XY(x, y);strcpy((char *)hanziCode, str);len = strlen(hanziCode) / 2; // 一个中文汉字占两个字节for (k = 0; k < len; k++) {strfont_0 = *(hanziCode + j); // 字符值j++;strfont_1 = *(hanziCode + j);j++;for (i = 0; i < font_lib_size; i++) {Index_0 = code_GB_32[i].Index[0]; // 取出字库数组中汉字内码索引值Index_1 = code_GB_32[i].Index[1];if (strfont_0 == Index_0 && strfont_1 == Index_1) // 比较字符值与汉字内码索引值{if (Chroma_key == 1)BTE_MCU_Write_ColorExpansion_Chroma_key_MCU_8bit(0, canvas_image_width, x + font_size * k, y, font_size, font_size, Foreground_color, code_GB_32[i].Msk); // 透明色if (Chroma_key == 0)BTE_MCU_Write_ColorExpansion_MCU_8bit(0, canvas_image_width, x + font_size * k, y, font_size, font_size, Foreground_color, Background_color, code_GB_32[i].Msk); // 非透明色break;}}}
}

上例中BTE_MCU_Write_ColorExpansion_Chroma_key_MCU_8bitBTE_MCU_Write_ColorExpansion_MCU_8bit为瑞佑官方API接口程序,本文暂不缀述。实例显示效果如下图:
在这里插入图片描述
自建汉字每个字皆可单独取模,因此可展现不同字体。

附上自建汉字字模数组,汉字取模软件为横向8点左高位,从左到右,从上到下排列。取模的软件在网上可找到很多,也可以留言和我联络获取。

// ------------------  汉字字模的数据结构定义 ------------------------ //
typedef struct typFNT_GB32                // 汉字字模数据结构
{signed char Index[2];              // 汉字内码索引char Msk[128];                     // 点阵码数据:32*32/8=128
};/
// 汉字字模表                                                           //
// Font:32,横向取模左高位,数据排列:从左到右从上到下                       //
struct typFNT_GB32 code_GB_32[] =   // 菱致电子瑞佑科技单片机驱动彩色液晶屏极简方案
{
"菱", 0x00,0x00,0x00,0x00,0x00,0x60,0x06,0x00,0x00,0x60,0x06,0x00,0x00,0x60,0x06,0x00,0x3F,0xFF,0xFF,0xFC,0x00,0x60,0x06,0x00,0x00,0x61,0x06,0x00,0x00,0x41,0x84,0x00,0x0F,0xFF,0xFF,0xF0,0x0F,0xFF,0xFF,0xF0,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x60,0x0E,0x00,0x00,0xE0,0x07,0x00,0x03,0x88,0x01,0xC0,0x07,0x18,0x00,0x70,0x3C,0x30,0x00,0x38,0x30,0x7F,0xFF,0x0C,0x01,0xE0,0x03,0x00,0x03,0xB0,0x07,0x00,0x0E,0x18,0x0C,0x00,0x1C,0x0E,0x38,0x00,0x00,0x03,0xE0,0x00,0x00,0x03,0xC0,0x00,0x00,0x1F,0x78,0x00,0x01,0xF8,0x0F,0xE0,0x3F,0x80,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,"致", 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x3F,0xFF,0x10,0x00,0x3F,0xFF,0x10,0x00,0x03,0x00,0x30,0x00,0x02,0x08,0x3F,0xFC,0x06,0x0C,0x30,0x20,0x04,0x0C,0x30,0x20,0x0C,0x04,0x20,0x20,0x08,0x06,0x20,0x20,0x18,0x1E,0x70,0x20,0x3F,0xFF,0x70,0x60,0x10,0xC3,0x50,0x60,0x00,0xC1,0x50,0x60,0x00,0xC0,0xD8,0x40,0x00,0xC0,0x18,0x40,0x00,0xC0,0x08,0xC0,0x00,0xC0,0x0C,0xC0,0x3F,0xFE,0x0D,0x80,0x00,0xC0,0x07,0x80,0x00,0xC0,0x07,0x00,0x00,0xC0,0x03,0x00,0x00,0xC0,0x07,0x80,0x00,0xC0,0x0D,0x80,0x00,0xC7,0x18,0xC0,0x00,0xFE,0x30,0x60,0x03,0xF0,0x60,0x30,0x3F,0x01,0xC0,0x18,0x30,0x01,0x80,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,"电", 0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x0F,0xFF,0xFF,0xE0,0x1F,0xFF,0xFF,0xE0,0x10,0x03,0x00,0x20,0x10,0x03,0x00,0x20,0x10,0x03,0x00,0x20,0x10,0x03,0x00,0x20,0x10,0x03,0x00,0x20,0x1F,0xFF,0xFF,0xE0,0x1F,0xFF,0xFF,0xE0,0x10,0x03,0x00,0x20,0x10,0x03,0x00,0x20,0x10,0x03,0x00,0x20,0x10,0x03,0x00,0x20,0x10,0x03,0x00,0x20,0x10,0x03,0x00,0x20,0x10,0x03,0x00,0x20,0x1F,0xFF,0xFF,0xE0,0x07,0xFF,0xFF,0x80,0x00,0x03,0x00,0x06,0x00,0x03,0x00,0x06,0x00,0x03,0x00,0x06,0x00,0x03,0x00,0x04,0x00,0x03,0x00,0x0C,0x00,0x01,0xFF,0xFC,0x00,0x00,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,"子", 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0x80,0x07,0xFF,0xFF,0x80,0x00,0x00,0x03,0x80,0x00,0x00,0x06,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0xE0,0x00,0x00,0x03,0x80,0x00,0x00,0x07,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0xE0,0x00,0x3F,0xFF,0xFF,0xFE,0x3F,0xFF,0xFF,0xFE,0x00,0x00,0x30,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x18,0x00,0x01,0x00,0x18,0x00,0x01,0xC0,0x70,0x00,0x00,0xFF,0xE0,0x00,0x00,0x1F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,"瑞", 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x3F,0x00,0x00,0x07,0xBF,0x7C,0x3F,0xF7,0xBF,0x7C,0x7F,0xF7,0xBF,0x7C,0x7F,0xFF,0xBF,0x7C,0x7F,0xF7,0xFF,0xFC,0x3F,0xF7,0xFF,0xFC,0x0F,0xE7,0xFF,0xFC,0x0F,0xCF,0xFF,0xF8,0x0F,0xC0,0x00,0x00,0x0F,0xDF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFE,0x3F,0xFF,0xFF,0xFE,0x3F,0xFF,0xFF,0xFE,0x3F,0xDF,0xFF,0xFC,0x3F,0xC0,0x7E,0x00,0x1F,0xCF,0xFF,0xF8,0x0F,0xDF,0xFF,0xFC,0x0F,0xDF,0xFF,0xFC,0x0F,0xEF,0xFF,0xFC,0x3F,0xF7,0x77,0x7C,0x7F,0xF7,0x77,0x7C,0x7F,0xF7,0x77,0x7C,0x7F,0xF7,0x77,0x7C,0x7F,0xFF,0x76,0xFC,0x10,0x1F,0x75,0xFC,0x00,0x1F,0x75,0xFC,0x00,0x1F,0x75,0xFC,0x00,0x1F,0x75,0xFC,0x00,0x00,0x00,0x00,"佑", 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xF8,0x7F,0x00,0x01,0xF8,0x7F,0x00,0x03,0xF8,0x7F,0x00,0x03,0xE0,0x7F,0x00,0x03,0xCF,0xFF,0xFE,0x07,0xDF,0xFF,0xFF,0x07,0xDF,0xFF,0xFF,0x07,0xDF,0xFF,0xFF,0x0F,0xDF,0xFF,0xFF,0x1F,0xCF,0xFF,0xFE,0x1F,0xE3,0xFC,0x00,0x3F,0xE3,0xF8,0x00,0x3F,0xE7,0xC0,0x00,0x3F,0xEF,0x9F,0xF8,0x1F,0xCF,0xBF,0xFE,0x0F,0x9F,0xBF,0xFE,0x07,0xBF,0xBF,0xFE,0x07,0xBF,0xBF,0xFE,0x07,0xBF,0xBF,0xFE,0x07,0x9F,0x38,0x7E,0x07,0xCE,0x78,0x7E,0x07,0xE0,0xF8,0x7E,0x07,0xE1,0xF8,0x7E,0x07,0xE1,0xFF,0xFE,0x07,0xE1,0xFF,0xFE,0x07,0xE1,0xFF,0xFE,0x07,0xE1,0xFF,0xFE,0x07,0xE1,0xFF,0xFE,0x07,0xE0,0xFF,0xFC,0x00,0x00,0x00,0x00,"科", 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFE,0x01,0xF0,0x3F,0xFE,0x63,0xF8,0x3F,0xFC,0xF9,0xF8,0x3F,0xFD,0xFC,0xF8,0x3F,0xFD,0xFE,0x78,0x1F,0xF9,0xFF,0x78,0x07,0xF1,0xFF,0x78,0x3F,0xFE,0x3E,0x78,0x7F,0xFE,0x0C,0xF8,0x7F,0xFD,0xF1,0xF8,0x7F,0xFD,0xF9,0xF8,0x7F,0xFB,0xFE,0xF8,0x3F,0x81,0xFE,0x78,0x07,0x31,0xFE,0x78,0x0E,0xF8,0x7E,0xF8,0x0E,0xFC,0x1C,0xF8,0x1E,0xFE,0x01,0xFC,0x3E,0x7E,0x07,0xFE,0x7F,0x7E,0xFF,0xFE,0x7F,0xBC,0xFF,0xFE,0x7F,0x89,0xFF,0xFE,0x7F,0xE7,0xFF,0xFE,0x3F,0xF7,0xFF,0xF8,0x07,0xF3,0x83,0xF8,0x07,0xF0,0x03,0xF8,0x07,0xF0,0x03,0xF8,0x07,0xF0,0x03,0xF8,0x07,0xF0,0x03,0xF8,0x03,0xE0,0x01,0xF8,0x00,0x00,0x00,0x00,"技", 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x07,0xC0,0x3F,0x00,0x07,0xE0,0x3F,0x00,0x07,0xE0,0x3F,0x00,0x07,0xE0,0x7F,0x80,0x0F,0xE7,0xFF,0xFC,0x3F,0xEF,0xFF,0xFE,0x7F,0xEF,0xFF,0xFE,0x7F,0xEF,0xFF,0xFE,0x7F,0xEF,0xFF,0xFC,0x7F,0xF3,0xFF,0xF8,0x1F,0xF0,0x3F,0x00,0x07,0xE1,0xFF,0xF0,0x07,0xE7,0xFF,0xF8,0x07,0xF7,0xFF,0xFC,0x3F,0xF7,0xFF,0xFC,0x7F,0xF7,0xFF,0xFC,0x7F,0xF7,0xF1,0xF8,0x7F,0xF3,0xF1,0xF8,0x7F,0xF3,0xFF,0xF8,0x3F,0xE1,0xFF,0xF0,0x07,0xE1,0xFF,0xE0,0x07,0xE0,0xFF,0xC0,0x07,0xE3,0xFF,0xF0,0x3F,0xCF,0xFF,0xFC,0x3F,0xDF,0xFF,0xFE,0x7F,0xDF,0xFF,0xFE,0x7F,0xDF,0xF3,0xFE,0x7F,0xDF,0xE0,0xFE,0x3F,0xCF,0x80,0x7C,0x00,0x00,0x00,0x00,"单", 0x00,0x00,0x00,0x00,0x00,0x01,0x38,0x00,0x00,0x03,0x3C,0x00,0x00,0x3E,0x38,0x00,0x00,0x3E,0x70,0x00,0x00,0x3C,0xE0,0x00,0x00,0x1C,0xE0,0x00,0x00,0x1D,0xFC,0x00,0x00,0x07,0xFE,0x00,0x00,0x0F,0xCF,0x00,0x00,0xB3,0x8F,0x00,0x00,0xC3,0xCF,0x00,0x00,0xEF,0xFE,0x00,0x00,0x7F,0xDC,0x00,0x00,0x7F,0x9C,0x00,0x00,0x63,0xF8,0x00,0x00,0x7F,0xF8,0x00,0x00,0x3F,0xF0,0x00,0x00,0x1F,0x9F,0xC0,0x00,0x07,0xFF,0xE0,0x00,0x3F,0x80,0x60,0x01,0xFB,0x80,0x00,0x0F,0xC3,0x80,0x00,0x0F,0x03,0x80,0x00,0x0C,0x03,0x80,0x00,0x00,0x03,0x80,0x00,0x00,0x03,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,"片", 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x38,0x00,0x00,0x20,0x38,0x00,0x00,0x38,0x30,0x00,0x00,0x1C,0x30,0x00,0x00,0x1C,0x7C,0x00,0x00,0x1C,0x7E,0x00,0x00,0x1B,0xFE,0x00,0x00,0x1F,0xF0,0x00,0x00,0x19,0xC0,0x00,0x00,0x1A,0x00,0x00,0x00,0x18,0x1F,0x80,0x00,0x19,0xFF,0xC0,0x00,0x1F,0xD8,0x00,0x00,0x1E,0x18,0x00,0x00,0x18,0x18,0x00,0x00,0x38,0x18,0x00,0x00,0x30,0x18,0x00,0x00,0x30,0x18,0x00,0x00,0x70,0x18,0x00,0x00,0xE0,0x18,0x00,0x00,0xC0,0x18,0x00,0x00,0x40,0x18,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,"机", 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x18,0x06,0x00,0x00,0x38,0x0F,0x00,0x00,0x3D,0x1F,0x80,0x00,0x3E,0xBF,0x00,0x00,0xFC,0xC7,0x00,0x01,0xF0,0xC6,0x00,0x2F,0xF0,0xC6,0x00,0x1F,0xB4,0xC6,0x00,0x1F,0x34,0x8E,0x00,0x06,0x78,0x8C,0x00,0x00,0x70,0x8C,0x40,0x00,0xF1,0x8C,0x20,0x03,0xE1,0x8C,0x30,0x07,0xE1,0x8C,0x10,0x07,0xE1,0x8C,0x18,0x03,0x61,0x0E,0x1C,0x00,0x63,0x07,0xFE,0x00,0x62,0x01,0xF8,0x00,0x60,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,"驱", 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x03,0xC0,0x00,0xFF,0x1F,0xC0,0x00,0x7F,0x0F,0x80,0x00,0x3F,0x10,0x00,0x00,0x0E,0x20,0x00,0x00,0x8E,0x31,0xC0,0x00,0x8E,0x30,0xE0,0x01,0x8C,0x30,0xE0,0x01,0x9C,0x38,0xE0,0x01,0x9C,0x3E,0xC0,0x01,0x9C,0x3F,0xC0,0x01,0xFF,0x23,0xE0,0x03,0xFF,0xA3,0xE0,0x03,0xC3,0xA7,0xF0,0x01,0x83,0xBF,0x70,0x00,0x33,0x6C,0x30,0x03,0xE3,0x60,0x00,0x1F,0xC7,0x60,0x70,0x1F,0x87,0x7F,0xF8,0x0E,0x8E,0x3F,0xFC,0x08,0x7E,0x18,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,"动", 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x7E,0x07,0x00,0x00,0x7F,0x07,0x00,0x00,0x3F,0x0B,0x00,0x00,0x1E,0x0B,0x00,0x00,0x38,0x07,0xC0,0x00,0x60,0x1F,0xE0,0x01,0xC7,0x3F,0xE0,0x03,0x3F,0xFE,0x60,0x04,0xFE,0x4C,0x60,0x0F,0xFC,0xDC,0x60,0x0F,0xFC,0x9C,0x60,0x0F,0xFB,0x98,0xC0,0x07,0x73,0x98,0xC0,0x00,0xE7,0xB8,0xC0,0x01,0xDF,0xB8,0xC0,0x01,0xFD,0xE8,0xC0,0x01,0xF0,0x6D,0x80,0x00,0xE0,0x47,0x80,0x00,0x40,0xC7,0x80,0x00,0x00,0x87,0x00,0x00,0x01,0x02,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,"彩", 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x07,0x80,0x00,0x00,0x0F,0x84,0x00,0x00,0x3F,0x87,0x00,0x00,0x70,0x07,0xC0,0x00,0xC7,0xC3,0xC0,0x00,0x7C,0xC3,0xC0,0x01,0x99,0xC7,0x80,0x01,0x8B,0x8E,0x00,0x01,0xCF,0x1E,0x00,0x00,0xDF,0x9F,0x80,0x00,0x7F,0xA1,0x80,0x01,0xFC,0x21,0xC0,0x07,0xEC,0x43,0x80,0x1F,0x8E,0x47,0x00,0x7F,0x0C,0x8F,0x00,0x7C,0x1D,0x1F,0xC0,0x00,0x3E,0x18,0xE0,0x00,0x7C,0x10,0xE0,0x03,0xF8,0x00,0xE0,0x07,0xF8,0x01,0xC0,0x07,0x98,0x03,0x80,0x00,0x08,0x07,0x00,0x00,0x08,0x0E,0x00,0x00,0x08,0x18,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,"色", 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x07,0x80,0x00,0x00,0x0F,0x80,0x00,0x00,0x1F,0xE0,0x00,0x00,0x3F,0xF0,0x00,0x00,0x38,0xF0,0x00,0x00,0x31,0xC0,0x00,0x00,0x23,0x80,0x00,0x00,0x07,0xF8,0x00,0x00,0x0F,0xFC,0x00,0x00,0x3F,0x1E,0x00,0x00,0xFF,0x9C,0x00,0x00,0xF3,0x98,0x00,0x00,0x63,0x38,0x00,0x00,0x67,0xF0,0x00,0x00,0x7F,0xF8,0x00,0x00,0xFC,0x00,0x00,0x00,0xF0,0x00,0x20,0x00,0xC0,0x00,0x20,0x00,0xC0,0x00,0x20,0x00,0xC0,0x00,0x60,0x00,0xC0,0x00,0x60,0x00,0x70,0x03,0xF0,0x00,0x3F,0xFF,0xF0,0x00,0x0F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,"液", 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x03,0xF0,0x00,0x00,0x83,0xF0,0x00,0x00,0xC2,0xF0,0x00,0x00,0xE3,0x90,0x00,0x00,0x76,0x38,0x00,0x00,0x71,0xFC,0x00,0x00,0xFF,0xFC,0x00,0x00,0x0F,0xF0,0x00,0x08,0x07,0xE0,0x00,0x18,0x01,0xFF,0x00,0x18,0x03,0x9F,0x00,0x1E,0x0F,0x3B,0x80,0x0F,0x1E,0x33,0x00,0x07,0x2E,0x77,0x00,0x07,0x3E,0xFE,0x00,0x07,0x3E,0xDC,0x00,0x06,0x77,0x9C,0x00,0x06,0xEF,0xF8,0x00,0x07,0x4C,0x78,0x00,0x07,0x0C,0x7C,0x00,0x07,0x0C,0x1F,0x00,0x07,0x0C,0x0F,0xE0,0x07,0x0C,0x07,0xF8,0x02,0x0C,0x01,0xFC,0x00,0x04,0x00,0x1C,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,"晶", 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xF8,0x00,0x00,0x07,0xFC,0x00,0x00,0x3F,0x9C,0x00,0x00,0x30,0x1C,0x00,0x00,0x18,0x1C,0x00,0x00,0x1F,0xD8,0x00,0x00,0x1F,0xD8,0x00,0x00,0x1E,0x18,0x00,0x00,0x18,0x18,0x00,0x00,0x1F,0xF8,0x00,0x00,0x1F,0xF0,0x00,0x00,0x08,0x7F,0x80,0x00,0x00,0x3F,0x80,0x00,0x0C,0xF3,0xC0,0x00,0x3E,0xC3,0xC0,0x01,0xC6,0xC3,0x80,0x01,0x86,0xFB,0x80,0x01,0xFE,0xFF,0x80,0x01,0xF6,0xC3,0x80,0x00,0xC6,0xC3,0x80,0x00,0xC6,0xFB,0x80,0x00,0xFE,0xFF,0x80,0x00,0xFE,0x43,0x80,0x00,0xE6,0x03,0x00,0x00,0x44,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,"屏", 0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x01,0xFE,0x00,0x00,0x07,0xFE,0x00,0x00,0x0B,0xFE,0x00,0x00,0x1C,0x9C,0x00,0x00,0x0C,0x38,0x00,0x00,0x1F,0xF8,0x00,0x00,0x1F,0xFC,0x00,0x00,0x3F,0x08,0x00,0x00,0x34,0x7E,0x00,0x00,0x37,0x8C,0x00,0x00,0x67,0x18,0x00,0x00,0x63,0x7C,0x00,0x00,0xC3,0xFC,0x00,0x00,0xDF,0xFC,0x00,0x01,0x87,0xCC,0x00,0x01,0x87,0x0C,0xC0,0x01,0x06,0xFF,0xE0,0x03,0x0F,0xFD,0xF0,0x07,0x3F,0x0C,0x00,0x06,0xFE,0x0C,0x00,0x0E,0xF6,0x0C,0x00,0x0C,0x06,0x0C,0x00,0x18,0x0E,0x0C,0x00,0x30,0x0E,0x0C,0x00,0x60,0x0C,0x0C,0x00,0x00,0x08,0x0C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,"极", 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x1C,0x06,0x00,0x00,0x1C,0x0F,0x00,0x00,0x1C,0x3D,0x80,0x00,0x3E,0x79,0x80,0x00,0xFE,0xF1,0x80,0x01,0xFD,0xF9,0x80,0x27,0xF8,0xF3,0x00,0x1F,0xF9,0x73,0x00,0x1F,0xBA,0x67,0x00,0x0F,0x3C,0xE3,0x80,0x06,0x38,0xC3,0x80,0x00,0x39,0xC0,0xC0,0x00,0x71,0xC0,0xC0,0x00,0xFF,0xF0,0xC0,0x01,0xF3,0xFD,0xC0,0x03,0xE3,0x1F,0x80,0x03,0xE7,0x0F,0xC0,0x01,0xE6,0x0F,0xE0,0x01,0x37,0x3F,0xF0,0x00,0x34,0xF8,0xF8,0x00,0x34,0x20,0x3C,0x00,0x10,0x00,0x1C,0x00,0x10,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,"简", 0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x0E,0x00,0x00,0x10,0x0E,0x00,0x00,0x18,0x1E,0x00,0x00,0x3C,0xBF,0xC0,0x00,0x79,0xBF,0xC0,0x00,0xFF,0x3F,0x80,0x01,0xFF,0x16,0x00,0x01,0xF6,0x1C,0x00,0x01,0xC0,0x7E,0x00,0x00,0x01,0xFF,0x00,0x00,0x07,0xCF,0x00,0x00,0x1C,0x07,0x80,0x00,0x18,0x07,0x80,0x00,0x3B,0xC3,0x80,0x00,0xA3,0xE3,0x80,0x00,0xCC,0x63,0x80,0x00,0xCC,0x63,0x80,0x00,0x8F,0xE3,0x80,0x00,0x4F,0x63,0x80,0x00,0x4C,0x67,0x80,0x00,0x8F,0xE7,0x80,0x00,0x8F,0xC7,0x80,0x00,0x86,0xC7,0x80,0x01,0x80,0x47,0x80,0x01,0x80,0x3F,0x80,0x00,0x80,0x1F,0x80,0x00,0x00,0x07,0x80,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,"方", 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x03,0xE0,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x03,0x80,0x00,0x00,0x1C,0x3F,0xE0,0x00,0x0F,0xE3,0xF0,0x00,0xFF,0xCE,0x00,0x0F,0xF8,0xF0,0x00,0x0F,0xE0,0xE0,0x00,0x0F,0x81,0xF8,0x00,0x06,0x01,0xFE,0x00,0x00,0x03,0x87,0x00,0x00,0x07,0x07,0x00,0x00,0x0E,0x07,0x00,0x00,0x1C,0x0E,0x00,0x00,0x3A,0x0E,0x00,0x00,0x72,0x1C,0x00,0x00,0xE2,0x38,0x00,0x01,0x83,0x78,0x00,0x01,0x03,0xF0,0x00,0x00,0x01,0xE0,0x00,0x00,0x01,0xC0,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,"案", 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0xCF,0x00,0x00,0x09,0x8F,0x00,0x00,0x0F,0x9E,0x00,0x00,0x1F,0xBC,0x00,0x00,0x3E,0xF8,0x00,0x00,0x1D,0x7B,0xE0,0x00,0x19,0xFF,0xF0,0x00,0x0F,0x70,0x00,0x01,0xFE,0x70,0x00,0x0F,0xCF,0xE0,0x00,0x1F,0x0F,0xF8,0x00,0x00,0x03,0xFE,0x00,0x00,0x0F,0x8E,0x00,0x00,0xFF,0xE3,0x00,0x00,0x00,0xFF,0x00,0x00,0x3F,0xE0,0x00,0x00,0x1C,0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x02,0x67,0x00,0x00,0x3C,0x63,0x80,0x00,0x38,0xE1,0x80,0x00,0x31,0xE0,0x80,0x00,0x20,0xC0,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
二、需求全套中文,字数多必然需要更多存储空间,那么可以存放到FLASH中。

这里所讲的FLASH是与RA8889 / RA8876连接的,一般是用来存放UI所需的图资,也可以将字库存放于此,这样不需要增加成本,但可节省掉外接字库芯片的成本!

框架图:
在这里插入图片描述

自建字库不限套数,单套占用容量不大,比如24x24点是576KB。这里提供的算法是通过RA8889 / RA8876的DMA(Direct Memory Access)功能获取到字符数据,再通过BTE(Block Transfer Engine)功能将文字显示出来。经过优化,目前显示速度还算不错,参考下方展示视频:

自建字库显示速度(分辨率800x480)

调用代码范例:

   // 演示自建字库调用BTE_Solid_Fill(display_address, canvas_image_width, 0, 0, 0x01, LCD_width, LCD_height); // 缓存显示区域:填充底色0x01;display_address此处自定义为canvas_image_width*LCD_height*24/8SPI_NOR_initial_DMA(0, Font_BUS, Font_CS, 1, 0);    //FLASH初始化User_Def_Font_Initial();    //显示自定义文字初始化Font_Size_ChromaKey_ForeColor_BackColor(24, 1, color256_red, color256_white);    //字体参数设定(最多256色)Show_User_Def_String("自建汉字库:宋体16x16演示", songti16, 16, 2, 50, 20);    //显示字符串Show_User_Def_String("自建汉字库:楷体16x16演示", kaiti16, 16, 2, 50, 45);    //显示字符串Show_User_Def_String("自建汉字库:黑体16x16演示", heiti16, 16, 2, 50, 70);    //显示字符串Font_Size_ChromaKey_ForeColor_BackColor(24, 1, color256_blue, color256_white);    //字体参数设定(最多256色)Show_User_Def_String("自建汉字库:宋体24x24演示", songti24, 24, 2, 50, 100);    //显示字符串Show_User_Def_String("自建汉字库:楷体24x24演示", kaiti24, 24, 2, 50, 125);    //显示字符串Show_User_Def_String("自建汉字库:黑体24x24演示", heiti24, 24, 2, 50, 150);    //显示字符串Font_Size_ChromaKey_ForeColor_BackColor(32, 0, color256_yellow, color256_black);    //字体参数设定(最多256色)Show_User_Def_String("自建汉字库:宋体32x32演示", songti32, 32, 0, 50, 200);    //显示字符串Show_User_Def_String("自建汉字库:楷体32x32演示", kaiti32, 32, 0, 50, 240);    //显示字符串Show_User_Def_String("自建汉字库:黑体32x32演示", heiti32, 32, 0, 50, 280);    //显示字符串// 图层S0色深恢复初始化状态#if defined(MCU_8bit_ColorDepth_8bpp)BTE_S0_Color_8bpp();#endif#if defined(MCU_8bit_ColorDepth_16bpp) || defined(MCU_16bit_ColorDepth_16bpp)BTE_S0_Color_16bpp();#endif#if defined(MCU_8bit_ColorDepth_24bpp) || defined(MCU_16bit_ColorDepth_24bpp_Mode_1) || defined(MCU_16bit_ColorDepth_24bpp_Mode_2)BTE_S0_Color_24bpp();#endifBTE_Memory_Copy_Chroma_key(display_address, canvas_image_width, 0, 0, 0, canvas_image_width, 0, 0, 0x01, LCD_width, LCD_height); // 缓存写好的文字搬移到显示层,剔除底色0x01

上方代码显示实例:
在这里插入图片描述

RA8889内建128Mb SDRAM作为显存,显存是自由定义的,这里我们设定为画布宽度(canvas_image_width)为800,测试的屏宽(LCD_width)为800,屏高(LCD_height)为480,将显存规划为主显示层、缓冲层S0、缓冲层S1…如下图示:
在这里插入图片描述
实际操作分为三步:

  1. DMA(线性):RA8889寻址获取字符数据并通过DMA方式写入缓存S1;
  2. 转置:MCU对缓存S1的数据转置后写入缓存S0,同时给文字加上前景、背景色或者透明色;
  3. BTE剔除底色:RA8889内建BTE功能,可将底色剔除后再复制到主显示层,因此可以形成文字的透明效果。

附上算法程序供参考:

/**************************************************************************************** @file	RA8889_Show_User_Def_FontLib_bitPic.c* @author	Weran* @version	3.0* @date	2023/08/16* @brief  	显示用户自定义字库或者单色位图,宽度为8的倍数,字形长宽相等,位图不限高度* @copyright www.lcdvision.com.cn****************************************************************************************/
#include "RA8889.h"
#include "RA8889_MCU_IF.h"
#include "RA8889_API.h"
#include "delay.h"
#include "RA8889_Show_User_Def_FontLib_bitPic.h"
#include "string.h"/*****************************************
// 自建汉字库初始化
******************************************/
void User_Def_Font_Initial(void)
{SPI_Clock_Period(2);Select_SFI_Single_Mode_Dummy_8T_0Bh();Enable_SFlash_SPI();#ifdef Over_128Mb // FLASH大小超过128Mb,切换为32位寻址switch_24bits_to_32bits(Font_BUS, Font_CS);Select_SFI_32bit_Address();#elseSelect_SFI_24bit_Address();#endifswitch (Font_CS) {case 0:Select_SFI_0();break;case 1:Select_SFI_1();break;case 2:Select_SFI_2();break;case 3:Select_SFI_3();break;}Select_SFI_DMA_Mode();SFI_DMA_Destination_Start_Address(cache_address);BTE_S0_Memory_Start_Address(cache_address); // 缓存图层BTE_S0_Image_Width(main_image_width);BTE_S0_Color_8bpp(); // 缓存色深固定8bit,不可变更BTE_Destination_Memory_Start_Address(display_address); // 显示到目的图层BTE_Destination_Image_Width(main_image_width);// 目的窗口色深#if defined(MCU_8bit_ColorDepth_8bpp)BTE_Destination_Color_8bpp();#endif#if defined(MCU_8bit_ColorDepth_16bpp) || defined(MCU_16bit_ColorDepth_16bpp)BTE_Destination_Color_16bpp();#endif#if defined(MCU_8bit_ColorDepth_24bpp) || defined(MCU_16bit_ColorDepth_24bpp_Mode_1) || defined(MCU_16bit_ColorDepth_24bpp_Mode_2)BTE_Destination_Color_24bpp();#endifBTE_Window_Size(8, 1); // 每次延展的区块大小:8x1BTE_ROP_Code(15);
}/*****************************************
// 字体显示效果设定函数
// Font_Size:字型大小
// ChromaKey:0-不透明;1-透明
// Foreground_color:前景色,最多256色
// Foreground_color:背景色,最多256色
******************************************/
void Font_Size_ChromaKey_ForeColor_BackColor(unsigned short Font_Size, unsigned char ChromaKey, unsigned char Foreground_color, unsigned char Background_color)
{SFI_DMA_Transfer_Number(Font_Size * Font_Size / 8); // DMA单个汉字字节数Foreground_color_256(Foreground_color);if (ChromaKey == 1 && Foreground_color == Background_color)Background_color_256(Background_color >> 1); // 当选择透明色时前景色与背景色不能一样,移1位区别elseBackground_color_256(Background_color);if (ChromaKey == 0)BTE_Operation_Code(14); // 背景非透明else if (ChromaKey == 1)BTE_Operation_Code(15); // 背景透明
}/*****************************************************
// 显示字符串函数
// str:字符串
// Font_Lib_Offset:汉字库在FLASH中地址偏移,宏定义预设
// Font_Size:字型大小
// Font_Gap:字符间距
// x & y:字符串显示坐标
******************************************************/
void Show_User_Def_String(char *str, unsigned int Font_Lib_Offset, unsigned short Font_Size, unsigned char Font_Gap, unsigned short x, unsigned short y)
{unsigned char i, len;unsigned short hanziIndex;const char hanziCode[200];strcpy((char *)hanziCode, str);len = strlen(&*hanziCode) / 2;for (i = 0; i < len; i++) {hanziIndex = 94 * (hanziCode[2 * i] - 0xA1) + (hanziCode[2 * i + 1] - 0xA1); // 汉字区码、位码均起始0xA1Show_User_Def_Font(hanziIndex, Font_Lib_Offset, Font_Size, x + Font_Size * i + Font_Gap * (i - 1), y);}
}/**********************************************************
// 显示自定义汉字函数
// 注意:字宽必须为8的倍数
// hanziIndex:汉字在国标码中的位置
// Font_Lib_Offset:汉字库在FLASH中地址偏移,宏定义预设
// Font_Size:字型大小
// x & y:字符显示坐标
**********************************************************/
void Show_User_Def_Font(unsigned short hanziIndex, unsigned int Font_Lib_Offset, unsigned short Font_Size, unsigned short x, unsigned short y)
{unsigned char i, j;unsigned short Width_Byte = Font_Size / 8; // 宽度按字节数unsigned short Font_Byte  = 0;             // 单个字体字节计数Memory_Linear_Mode(); // 线性模式SFI_DMA_Source_Start_Address(Font_Size * Font_Size / 8 * hanziIndex + Font_Lib_Offset);Start_SFI_DMA();Check_Busy_SFI_DMA();Memory_XY_Mode(); // 区块模式/*在8bpp模式下先进行转置并延展,再上色*/for (i = 0; i < Font_Size; i++) // 字高,每次处理1bit=1点{for (j = 0; j < Width_Byte; j++) // 字宽{BTE_S0_Window_Start_XY(Font_Byte++, 0);            // 每次处理1byte=8点BTE_Destination_Window_Start_XY(x + 8 * j, y + i); // 转置+延展BTE_Enable();Check_BTE_Busy();}}
}/*****************************************
// 单色位图显示初始化
// Pic_Width:图片宽度
// Pic_Height:图片高度
// ChromaKey:0-不透明;1-透明
// Foreground_color:前景色,最多256色
// Foreground_color:背景色,最多256色
******************************************/
void Bit_Picture_Initial(unsigned short Pic_Width, unsigned short Pic_Height, unsigned char ChromaKey, unsigned char Foreground_color, unsigned char Background_color)
{SPI_Clock_Period(2);Select_SFI_Single_Mode_Dummy_8T_0Bh();Enable_SFlash_SPI();#ifdef Over_128Mb // FLASH大小超过128Mb,切换为32位寻址switch_24bits_to_32bits(Font_BUS, Font_CS);Select_SFI_32bit_Address();#elseSelect_SFI_24bit_Address();#endifswitch (Font_CS) {case 0:Select_SFI_0();break;case 1:Select_SFI_1();break;case 2:Select_SFI_2();break;case 3:Select_SFI_3();break;}Select_SFI_DMA_Mode();SFI_DMA_Destination_Start_Address(cache_address);BTE_S0_Memory_Start_Address(cache_address); // 缓存图层BTE_S0_Image_Width(main_image_width);BTE_S0_Color_8bpp(); // 缓存色深固定8bit,不可变更BTE_Destination_Memory_Start_Address(display_address); // 显示到目的图层BTE_Destination_Image_Width(main_image_width);// 目的窗口色深#if defined(MCU_8bit_ColorDepth_8bpp)BTE_Destination_Color_8bpp();#endif#if defined(MCU_8bit_ColorDepth_16bpp) || defined(MCU_16bit_ColorDepth_16bpp)BTE_Destination_Color_16bpp();#endif#if defined(MCU_8bit_ColorDepth_24bpp) || defined(MCU_16bit_ColorDepth_24bpp_Mode_1) || defined(MCU_16bit_ColorDepth_24bpp_Mode_2)BTE_Destination_Color_24bpp();#endifBTE_Window_Size(8, 1);                               // 每次延展的区块大小:8x1SFI_DMA_Transfer_Number(Pic_Width * Pic_Height / 8); // DMA单张图片字节字节数Foreground_color_256(Foreground_color);if (ChromaKey == 1 && Foreground_color == Background_color)Background_color_256(Background_color >> 1); // 当选择透明色时前景色与背景色不能一样,移1位区别elseBackground_color_256(Background_color);BTE_ROP_Code(15);if (ChromaKey == 0)BTE_Operation_Code(14); // 背景非透明else if (ChromaKey == 1)BTE_Operation_Code(15); // 背景透明
}/**********************************************************
// 显示单色位图函数
// 注意:图片宽度必须为8的倍数
// Pic_Offset:图片在FLASH中地址偏移
// Pic_Width:图片宽度(必须为8的倍数)
// Pic_Height:图片高度
// x & y:图片显示坐标
**********************************************************/
void Show_Bit_Picture(unsigned int Pic_Offset, unsigned short Pic_Width, unsigned short Pic_Height, unsigned short x, unsigned short y)
{unsigned char i, j;unsigned short Pic_Width_Byte = Pic_Width / 8; // 宽度按字节数unsigned short Pic_Byte       = 0;             // 单张图片字节计数Memory_Linear_Mode(); // 线性模式SFI_DMA_Source_Start_Address(Pic_Offset);Start_SFI_DMA();Check_Busy_SFI_DMA();Memory_XY_Mode(); // 区块模式/*在8bpp模式下先进行转置并延展,再上色*/for (i = 0; i < Pic_Height; i++) // 图片高,每次处理1bit=1点{for (j = 0; j < Pic_Width_Byte; j++) // 图片宽度,按字节数{BTE_S0_Window_Start_XY(Pic_Byte++, 0);             // 每次处理1byte=8点BTE_Destination_Window_Start_XY(x + 8 * j, y + i); // 转置+延展BTE_Enable();Check_BTE_Busy();}}
}

函数声明及宏定义:

/***************************************************************************************** @file		RA8889_Show_User_Def_FontLib_bitPic.h* @author		Weran* @version	3.0* @date		2023/08/16* @brief  	显示用户自定义字库或者单色位图,宽度为8的倍数,字形长宽相等,位图不限高度* @copyright www.lcdvision.com.cn
*****************************************************************************************/
#ifndef __RA8889_SHOW_USER_DEF_FONTLIB_BITPIC_H
#define __RA8889_SHOW_USER_DEF_FONTLIB_BITPIC_H#include "UserDef.h"#define display_address				canvas_image_width*LCD_height*24/8		//延展后目标显示地址
#define	cache_address				canvas_image_width*LCD_height*24/8*2	//缓存地址 (8bpp),宽x高满足单字容量即可#define Font_BUS	1					//自建字库总线地址
#define Font_CS		2					//自建字库片选地址
//#define Over_128Mb					//FLASH容量超过128Mb/*字库可以多套合并,套数不限,但字宽必须为8的倍数,bin档可使用PackagingTool等软件合并*/
#define heiti16   0x00000000			//黑体16x16起始地址
#define heiti24   0x0003FE40			//黑体24x24起始地址
#define heiti32   0x000CFA50			//黑体32x32起始地址
#define songti16   0x001CF350			//宋体16x16起始地址
#define songti24   0x0020F190			//宋体24x24起始地址
#define songti32   0x0029EDA0			//宋体32x32起始地址
#define kaiti16   0x0039E6A0			//楷体16x16起始地址
#define kaiti24   0x003DE4E0			//楷体24x24起始地址
#define kaiti32   0x0046E0F0			//楷体32x32起始地址
#define pic		0x0056D9F0					//范例图片起始地址
#define bit_pic		0x00BE35F0			//范例单色位图起始地址,数字0~9void User_Def_Font_Initial(void);
void Font_Size_ChromaKey_ForeColor_BackColor(unsigned short Font_Size,unsigned char ChromaKey,unsigned char Foreground_color,unsigned char Background_color);
void Show_User_Def_String(char *str,unsigned int Font_Lib_Offset,unsigned short Font_Size,unsigned char Font_Gap,unsigned short x,unsigned short y);
void Show_User_Def_Font(unsigned short hanziIndex, unsigned int Font_Lib_Offset, unsigned short Font_Size, unsigned short x, unsigned short y);void Bit_Picture_Initial(unsigned short Pic_Width, unsigned short Pic_Height, unsigned char ChromaKey,unsigned char Foreground_color,unsigned char Background_color);
void Show_Bit_Picture(unsigned int Pic_Offset, unsigned short Pic_Width, unsigned short Pic_Height, unsigned short x, unsigned short y);#endif /*__RA8889_SHOW_USER_DEF_FONTLIB_BITPIC_H*/

自建字库的大小理论上不限,有些用户想要使用矢量字库,那么只需要多做几套各种尺寸的字库一起打包即可,不过点阵越大,容量需求也是指数级增加。

能读到这里不容易,为了您的耐心,我再奉献一个彩蛋!

该功能也适合做数字表,先做好单色(1bit)点阵图片,可以使用Windows自带的“画图”另存即可。图片如下 :
在这里插入图片描述
图片只要确保宽度为8的倍数即可,高度不限,打包好烧写进FLASH之后再进行调用。操作方式与显示文字的方式类似,通过上面提供的函数Show_Bit_Picture进行调用。

显示数字表范例:

/*该函数演示用户自定义位图的调用,位图宽度必须为8的倍数*/
void Show_Bit_Pic_Demo(void)
{unsigned short n1, n2, n3, num = 0;// 背景图显示,FLASH≦128Mb#ifndef Over_128MbSPI_NOR_initial_DMA(0, Font_BUS, Font_CS, 1, 0);#if defined(MCU_8bit_ColorDepth_8bpp)DMA_24bit(2, 0, 0, LCD_width, LCD_height, 800, pic); // 读取FLASH图片,8bit#endif#if defined(MCU_8bit_ColorDepth_16bpp) || defined(MCU_16bit_ColorDepth_16bpp)DMA_24bit(2, 0, 0, LCD_width, LCD_height, 800, pic + 384000); // 读取FLASH图片,16bit#endif#if defined(MCU_8bit_ColorDepth_24bpp) || defined(MCU_16bit_ColorDepth_24bpp_Mode_1) || defined(MCU_16bit_ColorDepth_24bpp_Mode_2)DMA_24bit(2, 0, 0, LCD_width, LCD_height, 800, pic + 1152000); // 读取FLASH图片,24bit#endif#endif /*Not Over_128Mb*/// 背景图显示,FLASH>128Mb#ifdef Over_128MbSPI_NOR_initial_DMA(0, Font_BUS, Font_CS, 1, 1);#if defined(MCU_8bit_ColorDepth_8bpp)DMA_32bit(2, 0, 0, LCD_width, LCD_height, 800, pic); // 读取FLASH图片,8bit#endi #if defined(MCU_8bit_ColorDepth_16bpp) || defined(MCU_16bit_ColorDepth_16bpp)DMA_32bit(2, 0, 0, LCD_width, LCD_height, 800, pic + 384000); // 读取FLASH图片,16bit#endif#if defined(MCU_8bit_ColorDepth_24bpp) || defined(MCU_16bit_ColorDepth_24bpp_Mode_1) || defined(MCU_16bit_ColorDepth_24bpp_Mode_2)DMA_32bit(2, 0, 0, LCD_width, LCD_height, 800, pic + 1152000); // 读取FLASH图片,24bit#endif#endif /*Over_128Mb*/// 当前显示画面数字表显示区(100,100)之240x120区块备份到延展后显示目标图层(0,0)(0,120)两份BTE_Memory_Copy(0, canvas_image_width, 100, 100, 0, canvas_image_width, 0, 0, display_address, canvas_image_width, 0, 0, 12, 240, 120);BTE_Memory_Copy(0, canvas_image_width, 100, 100, 0, canvas_image_width, 0, 0, display_address, canvas_image_width, 0, 120, 12, 240, 120);for (num = 0; num < 198; num++) {Bit_Picture_Initial(80, 120, 0, color256_white, 0x0);n1 = num / 100;Show_Bit_Picture(bit_pic + BINARY_INFO[n1].start_addr, 80, 120, 0, 240); // 显示百位0  延展目标层(0,240)n2 = (num / 10) % 10;Show_Bit_Picture(bit_pic + BINARY_INFO[n2].start_addr, 80, 120, 80, 240); // 显示十位0n3 = num % 10;Show_Bit_Picture(bit_pic + BINARY_INFO[n3].start_addr, 80, 120, 160, 240); // 显示个位0// 图层S0色深恢复初始化状态#if defined(MCU_8bit_ColorDepth_8bpp)BTE_S0_Color_8bpp();#endif#if defined(MCU_8bit_ColorDepth_16bpp) || defined(MCU_16bit_ColorDepth_16bpp)BTE_S0_Color_16bpp();#endif#if defined(MCU_8bit_ColorDepth_24bpp) || defined(MCU_16bit_ColorDepth_24bpp_Mode_1) || defined(MCU_16bit_ColorDepth_24bpp_Mode_2)BTE_S0_Color_24bpp();#endif// 备份图(0,120)先复制到(0,0)BTE_Memory_Copy(display_address, canvas_image_width, 0, 120, 0, canvas_image_width, 0, 0, display_address, canvas_image_width, 0, 0, 12, 240, 120);// 延展图(0,240)剔除底色0x0后再叠加到(0,0)BTE_Memory_Copy_Chroma_key(display_address, canvas_image_width, 0, 240, display_address, canvas_image_width, 0, 0, 0x0, 240, 120);// 处理好的图(0,0)复制到主显示画面(100,100)BTE_Memory_Copy(display_address, canvas_image_width, 0, 0, 0, canvas_image_width, 0, 0, 0, canvas_image_width, 100, 100, 12, 240, 120);delay_ms(10);}
}

显示效果如下:

自建数字表显示效果演示

看完了有没有收获?满满干货全部奉献,期待您的点赞、分享、留言!!!

关注我,了解更多更好用的的液晶屏驱动方法!

第七讲 THE END

了解更多信息:http://www.lcdvision.com.cn

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/617648.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Flink定制化功能开发,demo代码

前言&#xff1a; 这是一个Flink自定义开发的基础教学。本文将通过flink的DataStream模块API&#xff0c;以kafka为数据源&#xff0c;构建一个基础测试环境&#xff1b;包含一个kafka生产者线程工具&#xff0c;一个自定义FilterFunction算子&#xff0c;一个自定义MapFunctio…

redis夯实之路-集群详解

Redis有单机模式和集群模式。 集群是 Redis 提供的分布式数据库方案&#xff0c;集群通过分片( sharding )来实现数据共享&#xff0c;并提供复制和故障转移。集群模式可以有多个 master 。使用集群模式可以进一步提升 Redis 性能&#xff0c;分布式部署实现高可用性&#xff…

Linux中断 -- 中断应答、嵌套、

接上文&#xff0c;本文继续介绍Linux软件部分逻辑。 参考内核版本&#xff1a;kernel-4.19 目录 1.中断信号在各级中断控制器中的应答 2.supports_deactivate_key意义 3.中断嵌套 1.中断信号在各级中断控制器中的应答 本章主要从内核软件层面来看各中断控制器对中断信号处…

Android开发基础(三)

Android开发基础&#xff08;三&#xff09; 本篇将介绍Android权限管理。 Android权限管理 Android权限管理主要是为了保护用户的隐私和设备的安全性&#xff1b; 在Android系统中&#xff0c;应用在请求权限时必须进行明确的申请&#xff0c;根据权限的保护级别&#xff0…

软件测试最新项目合集【商城、外卖、银行、金融等等.......】

​项目一&#xff1a;ShopNC商城 项目概况&#xff1a; ShopNC商城是一个电子商务B2C电商平台系统&#xff0c;功能强大&#xff0c;安全便捷。适合企业及个人快速构建个性化网上商城。 包含PCIOS客户端Adroid客户端微商城&#xff0c;系统PC后台是基于ThinkPHP MVC构架开发的…

NAND新一代接口Separate Command Address (SCA) 简介

通过NAND Flash总线传输的信号分为三种类型&#xff1a;命令&#xff08;Commands&#xff09;、地址&#xff08;Addresses&#xff09;和数据&#xff08;Data&#xff09;。这些信号利用DQ[7:0]时间分时复用技术&#xff0c;在不同的时间段分别进行传输。其中&#xff0c;数…

BikeDNA(五)参考数据的内在分析1

BikeDNA&#xff08;五&#xff09;参考数据的内在分析1 该笔记本分析用户提供的给定区域的参考自行车基础设施数据集的质量。 质量评估是“内在的”&#xff0c;即仅基于一个输入数据集&#xff0c;并且不使用数据集外部的信息。 对于将参考数据集与相应 OSM 数据进行比较的外…

redis — redis cluster集群模式下如何实现批量可重入锁?

一、redis cluster 集群版 在Redis 3.0版本以后,Redis发布了Redis Cluster。该集群主要支持搞并发和海量数据处理等优势,当 Redis 在集群模式下运行时,它处理数据存储的方式与作为单个实例运行时不同。这是因为它应该准备好跨多个节点分发数据,从而实现水平可扩展性。具体能…

Java内存结构

前文&#xff1a; 《Java8之类的加载》 《Java8之类加载机制class源码分析》 写在开头&#xff1a;本文为学习后的总结&#xff0c;可能有不到位的地方&#xff0c;错误的地方&#xff0c;欢迎各位指正。 JVM 在执行 Java 程序的过程中会把它所管理的内存划分为若干个不同的数…

Ubuntu server配置ssh远程登录

使用如下命令进行安装 apt-get install ssh 安装好后启动 service ssh start 然后查看运行状态 然后用本机ping虚拟机 关闭本机和虚拟机防火墙 ufw disable 然后打开Xshell进行连接

14、MySQL高频面试题

1、内连接和外连接的区别 内连接和外连接都是数据库进行多表联查时使用的连接方式&#xff0c;区别在于二者获取的数据集不同 内连接指的是使用左表中的每一条数据分别去连接右表中的每一条数据&#xff0c;仅仅显示出匹配成功的那部分 外连接有分为左外连接和右外连接 左外…

重磅!OpenAI正式发布,自定义ChatGPT商店!

1月11日凌晨&#xff0c;OpenAI在官网正式发布了&#xff0c;自定义GPT商店&#xff0c;可以帮助用户找到目前最好用、流行的自定义ChatGPT助手。 在2024年第一季度&#xff0c;OpenAI将启动GPT 开发者收入计划。首先&#xff0c;美国地区的开发者将根据用户对其 GPT 的使用情…

day-07 统计出现过一次的公共字符串

思路 用哈希表统计words1和words2中各个字符串的出现次数&#xff0c;次数皆为1的字符串符合题意 解题方法 //用于存储words1中各个字符串的出现次数 HashMap<String,Integer> hashMap1new HashMap<>(); //用于存储words2中各个字符串的出现次数 HashMap<Stri…

小程序系列-5.WXML 模板语法

一、数据绑定 1、在 data 中定义页面的数据 动态绑定内容&#xff1a; 动态绑定属性&#xff1a; 2. Mustache 语法的格式 3. Mustache 语法的应用场景 4. 三元运算 5.算数运算 二、 事件绑定 1. 什么是事件&#xff1f; 2. 小程序中常用的事件 3. 事件对象的属性列表 4.…

Linux基础工具的使用(yum,vim,gcc,g++,gdb,make/makefile)【详解】

目录 linux软件包管理器-yum什么是软件包&#xff1f;查找软件包如何安装软件卸载软件 linux编辑器 - vimvim的基本概念vim模式之间的切换vim命令模式各命令汇总vim底行模式各命令汇总 Linux编译器 - gcc/ggcc/g的作用gcc/g选项预处理编译汇编链接静态库与动态库 Linux调试器 -…

详细分析Java中的@Transactional注解

目录 前言1. 基本知识2. 常用属性3. Demo4. 总结 前言 Transactional 是 Spring 框架中用于管理事务的注解。 该注解来源于Spring&#xff0c;对于Spring的基础知识可看我之前的文章&#xff1a; Spring框架从入门到学精&#xff08;全&#xff09; 该注解也可用在xxl-job框架…

自动化测试框架pytest系列之8个常用的装饰器函数

自动化测试框架pytest系列之基础概念介绍(一)-CSDN博客 自动化测试框架pytest系列之21个命令行参数介绍(二)-CSDN博客 自动化测试框架pytest系列之强大的fixture功能&#xff0c;为什么fixture强大&#xff1f;一文拆解它的功能参数。(三)-CSDN博客 接上文 3.5 pytest的8…

Vant4在Vue3.3中如何按需导入组件和样式

前言 最近我在Vue 3.3的项目中对Vant4做按需导入时&#xff0c;尽管按照Vant4的官方指南进行操作&#xff0c;但样式仍然无法正确加载。经过深入研究和多篇文章的比较&#xff0c;我终于找到了在Vue3中如何正确的按需导入Vant 4组件和样式的方法。由于Vue3.3和Vant4相对较新&am…

多无人机编队避障(人工势场法)

matlab2020正常运行&#xff0c;预设编队类型&#xff0c;目标位置&#xff0c;障碍物 多无人机编队避障&#xff08;人工势场法&#xff09;资源-CSDN文库

浅析链表结构

一、单向链表 C语言中数组是常用的一种数据类型&#xff0c;但可惜数组长度是固定大小的&#xff0c;不能动态扩展&#xff0c;使用起来有时不是很方便。然后就有了自定义的动态数组结构&#xff0c;动态数组就比较好用了&#xff0c;长度可以任意扩展&#xff0c;但还有一个问…