oled_showchinese(u8 x,u8 y,u8 num,u8 size1,u8 mode)
时间: 2023-05-09 20:01:08 浏览: 245
oled_showchinese(u8 x,u8 y,u8 num,u8 size1,u8 mode)是一个显示中文字符的函数,其中参数x和y表示字符显示的横纵坐标,num表示要显示的中文字符的编码,size1表示显示字符的大小,mode表示显示模式。
其中num参数与中文编码有关,比如"你"的编码是0xC4E3,而"好"的编码是0xBAF3。size1参数表示显示的字符大小,通常有16号、24号、32号等几种选择。mode参数则表示字符的显示模式,通常有正常显示和反白显示两种选择。
该函数主要使用在oled显示屏的应用中,可以在屏幕上实现中文字符的显示。同时,该函数需要与其他显示函数进行配合才能在屏幕上完整显示一行字符(比如通过循环调用该函数,按顺序显示一个字符串中每个字符)。
总之,oled_showchinese函数在中文字符的显示上发挥了重要作用,在实际的嵌入式系统中广泛应用。
相关问题
void OLED_ShowCHinese(u8 x,u8 y,u8 no)
这段代码是用来在 OLED 显示屏上显示汉字的函数。其中,x 和 y 表示汉字显示的起始坐标,no 表示要显示的汉字的编码。
具体实现需要根据 OLED 显示屏的具体型号和通信协议来确定。一般来说,需要先将汉字转换为 OLED 显示屏所支持的字库格式,然后再通过通信协议将数据传输到 OLED 显示屏上进行显示。
编写程序void OLED_ShowChinese(u8 x,u8 y,u8 chr,u8 size,u8 mode)实现在oled上显示汉字
这是一个基于Arduino平台的OLED显示屏库,可以在OLED上显示汉字:
```
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_ADDR 0x3C
#define OLED_RESET -1
Adafruit_SSD1306 display(OLED_RESET);
// 字库数组
const unsigned char F8X16[] PROGMEM = {
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
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,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",0*/
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,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,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,/*" ",1*/
};
void OLED_Init() {
display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
display.clearDisplay();
display.display();
}
void OLED_ShowChinese(unsigned char x, unsigned char y, unsigned char chr, unsigned char size, unsigned char mode) {
unsigned char c = 0, i = 0;
unsigned char ch = chr - ' ';
unsigned char chi = ch * 16;
unsigned char x0 = x, y0 = y;
if (size == 16) {
for (i = 0; i < 16; i++) {
c = pgm_read_byte(&F8X16[chi + i]);
for (unsigned char j = 0; j < 8; j++) {
if ((c >> (7 - j)) & 0x01) {
display.drawPixel(x + j, y + i, 1);
}
else {
if (mode) display.drawPixel(x + j, y + i, 0);
}
}
}
}
display.display();
}
void setup() {
OLED_Init();
}
void loop() {
OLED_ShowChinese(0, 0, '中', 16, 1);
delay(5000);
OLED_ShowChinese(20, 0, '国', 16, 1);
delay(5000);
}
```
这个程序中使用了F8X16字库,可以在16x16的区域中显示汉字。可以根据实际情况修改字库和代码。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)