前言
PCtoLCD工具链接下载:
链接:https://pan.baidu.com/s/1KxyWcgbkp3vRlvovru3gGw
提取码:bl3e
一、取模汉字
1.设置
(1)选择字符模式
(2)字符设置
(3)字体设置
这里的字宽和字高一般和显示字符里面的大小一致
(4)输入汉字
保存字模数据
2.显示汉字
把数据添加到一个二维数组里面
static const uint8_t text[][60] =
{
//心(0) 率(1) 血(2) 氧(3)
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFF,0x00,0xE0,0xFF,0x01,0x04,0x00,0x01,0x08,0x00,0x01,0x38,0x00,0x01,0x70,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0xF8,0x01,0x00,0x81,0x00,0x00,0x06,0x00,0x00,0x1C,0x00,0x00,0x08,0x00,0x00,0x00,0x00},/*"心",0*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x00,0x28,0x24,0x00,0x48,0x24,0x00,0x08,0x22,0x00,0x88,0x20,0x00,0xC8,0x2C,0x00,0xA8,0x2A,0x00,0x9E,0xF9,0x07,0x8C,0x24,0x00,0x48,0x26,0x00,0x48,0x24,0x00,0x88,0x20,0x00,0x48,0x22,0x00,0x68,0x24,0x00,0x08,0x24,0x00,0x08,0x20,0x00,0x00,0x20,0x00,0x00,0x00,0x00},/*"率",1*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x01,0xE0,0xFF,0x01,0x20,0x00,0x01,0x20,0x00,0x01,0xE0,0xFF,0x01,0x3C,0x00,0x01,0x26,0x00,0x01,0x20,0x00,0x01,0xC0,0xFF,0x01,0x20,0x00,0x01,0x20,0x00,0x01,0x20,0x00,0x01,0xE0,0xFF,0x01,0x00,0x00,0x01,0x00,0x80,0x01,0x00,0x00,0x01,0x00,0x00,0x00},/*"血",2*/
{0x00,0x00,0x00,0x80,0x00,0x00,0x40,0x40,0x00,0x30,0x44,0x00,0x1C,0x54,0x00,0x8E,0x56,0x00,0xA8,0x56,0x00,0xA8,0xF8,0x07,0xA8,0x54,0x00,0xA8,0x56,0x00,0x28,0x55,0x00,0xA8,0x54,0x00,0xA8,0x44,0x00,0xA8,0x00,0x00,0xA8,0x3F,0x00,0xA8,0xC0,0x01,0x08,0x00,0x03,0x00,0x00,0x02,0x00,0xC0,0x07,0x00,0x00,0x00},/*"氧",3*/
};
这里用得是ESP32,要显示汉字直接调用函数
// 显示心率
oled.drawFastImage(4, 5, 20, 20, text[0]);
oled.drawFastImage(4 + 20*1, 5, 20, 20, text[1]);
oled.drawFastImage(4, 30, 20, 20, text[2]);
oled.drawFastImage(4 + 20*1, 30, 20, 20, text[3]);
oled.display(); // 将缓存里的文字在屏幕上显示
二、显示图片
1.照片格式转换
将要显示的照片进行格式转化,并且转换成像素为128*64以内的大小,
这里使用的是Img2lcd
软件链接:
链接:https://pan.baidu.com/s/15OdCL9BIIbN8rZ9OcEmlSw
提取码:qe87
按照如图设置好,注意输出图像大小不用超出128x64即可,保存文件
2.图片取模
按如下设置
注意选择图形模式
然后将生成的像素点数组复制到新建一个image.h文件中的数组中,因为图片很大,所以我们需要通过PROGMEM关键字声明将其存放到程序存储空间
// 通过PROGMEM关键字声明将其存放到程序存储空间
const uint8_t image[] PROGMEM =
{
// C:\Users\xiaochao\Desktop\11111.bmp(0)
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFD,0xFF,0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