目标:
- 汉字取模软件的使用
- OLED显示屏显示汉字
Arduino UNO开发板
12864液晶显示屏
配套USB数据线
配套杜邦线若干
Arduino IDE软件
内容
OLED显示屏显示汉字“长度”
接线图
接线方式
Arduino UNO <------> 12864液晶显示屏
5V <------> VCC
GND <------> GND
10 <------> SCL
9 <------> SDA
13 <------> RES
11 <------> DC
12 <------> CS
需要使用到汉字取模软件
下载链接:https://pan.baidu.com/s/10v6drMyYFkyh1BtsyKj1RQ
提取码:hm0y
取模软件界面
选项设置
点击设置后,在字模选项中取模方式选择逐行式,自定义格式选择C51格式
输入汉字“长度”,选择字体和大小,点击生成字模,将生成的字模拷贝到程序中
程序实现代码
#include "stdio.h"
#include "stdlib.h"
#include "U8glib.h" //OLED显示屏库文件
U8GLIB_SSD1306_128X64 u8g(10, 9, 12, 11); //OLED显示屏引脚设置SCL=10,SDA=9,CS=12,DC=11
static const unsigned char changdu[2][32] PROGMEM={
{0x10,0x00,0x10,0x08,0x10,0x04,0x10,0x02,0x10,0x01,0x90,0x00,0x10,0x00,0xFF,0x7F,
0x50,0x00,0x90,0x00,0x10,0x01,0x10,0x02,0x90,0x04,0x50,0x18,0x30,0x60,0x10,0x00},/*"长",0*/
/* (16 X 16 , 宋体 )*/
{0x80,0x00,0x00,0x01,0xFC,0x7F,0x44,0x04,0x44,0x04,0xFC,0x3F,0x44,0x04,0x44,0x04,
0xC4,0x07,0x04,0x00,0xF4,0x0F,0x24,0x08,0x42,0x04,0x82,0x03,0x61,0x0C,0x1C,0x70},/*"度",1*/
/* (16 X 16 , 宋体 )*/
};
void draw(void) {
u8g.drawXBMP( 0, 0,16, 16, changdu[0]);
u8g.drawXBMP( 16, 0,16, 16, changdu[1]);
}
void setup(void) {
}
void loop(void) {
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
}
备注:生成的字模拷贝到程序后,把“长”和“度”的中间“{}”删掉,原先“长度”生成字模:
{0x10,0x00,0x10,0x08,0x10,0x04,0x10,0x02,0x10,0x01,0x90,0x00,0x10,0x00,0xFF,0x7F},
{0x50,0x00,0x90,0x00,0x10,0x01,0x10,0x02,0x90,0x04,0x50,0x18,0x30,0x60,0x10,0x00},/*"长",0*/
/* (16 X 16 , 宋体 )*/
{0x80,0x00,0x00,0x01,0xFC,0x7F,0x44,0x04,0x44,0x04,0xFC,0x3F,0x44,0x04,0x44,0x04},
{0xC4,0x07,0x04,0x00,0xF4,0x0F,0x24,0x08,0x42,0x04,0x82,0x03,0x61,0x0C,0x1C,0x70},/*"度",1*/
/* (16 X 16 , 宋体 )*/
OLED显示屏显示结果