赞
踩
最近突然想显示汉字,然后翻了一圈发现版本好多,所以就挑了一个合适的。然后我的目的主要是驱动OLED0.96寸显示汉字,所以很简单,就是先配置驱动的模型库
- const uint8_t OLED_F10x16[][40]=
- {
- 0x00,0x00,0x10,0x10,0x12,0xFE,0x90,0x10,0x10,0x7E,0x50,0x50,0x50,0x48,0x48,0x44,
- 0x44,0x70,0x40,0x00,0x00,0x02,0x02,0x42,0x41,0x3F,0x00,0x00,0x00,0x41,0x7E,0x2A,
- 0x2A,0x2A,0x2A,0x2A,0x7F,0x00,0x00,0x00,/*"指",0*/
-
- 0x00,0x40,0x60,0x50,0x48,0xC6,0x60,0x20,0x10,0x10,0xF0,0x12,0x1C,0x10,0x90,0x70,
- 0x10,0x18,0x10,0x00,0x00,0x20,0x24,0x26,0x15,0x94,0x52,0x52,0x40,0x20,0x20,0x13,
- 0x0C,0x1C,0x33,0x20,0x60,0x40,0x00,0x00,/*"纹",1*/
-
- 0x00,0x40,0x40,0x40,0x44,0x54,0x54,0x54,0x54,0xD4,0xD4,0x54,0x54,0x54,0x7C,0xC0,
- 0x40,0x40,0x40,0x00,0x00,0x20,0x20,0x10,0x10,0x13,0x0E,0x48,0x44,0x7F,0x3F,0x02,
- 0x04,0x0A,0x12,0x31,0x21,0x20,0x20,0x00,/*"录",2*/
-
- 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x04,0xC4,0x78,0x70,0x80,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x40,0x20,0x20,0x10,0x08,0x04,0x03,0x01,0x00,0x00,0x01,
- 0x03,0x0C,0x18,0x10,0x30,0x20,0x20,0x00,/*"入",3*/
-
- 0x00,0x80,0x80,0xFC,0x84,0xFC,0x84,0x80,0xFC,0x84,0x84,0xFC,0x80,0x80,0xF8,0x08,
- 0x00,0xFE,0x02,0x00,0x00,0x40,0x38,0x27,0x20,0x3F,0x40,0x38,0x47,0x40,0x40,0x3F,
- 0x00,0x00,0x0F,0x40,0x40,0x7F,0x00,0x00,/*"删",4*/
-
- 0x00,0x00,0xFC,0x04,0x64,0x94,0x8C,0x44,0x20,0x60,0x58,0x4C,0xC2,0x4C,0x50,0x70,
- 0x20,0x60,0x00,0x00,0x00,0x00,0x7F,0x04,0x08,0x08,0x47,0x20,0x12,0x0E,0x42,0xC2,
- 0x7F,0x02,0x02,0x0A,0x12,0x22,0x00,0x00,/*"除",5*/
-
- };
在font.h添加这一段库,直接在代码下面添加即可。然后如果想要自己取模就下载PctolLCD2002这个取模软件,搜索百度就可以,免费的。将软件设置成这样
在中间那个横框里面输入汉字就可以得到模型,将模型复制到font.h库里面的OLED_F10x16[][40]里面,将多余的括号删除,然后将尾部的数字编号修改成顺序。
在OLED.c里面添加驱动函数
- void OLED_ShowCN(uint8_t Line, uint8_t Column, uint8_t Num)
- {
- uint8_t i;
- uint8_t wide=20;//字宽
-
- OLED_SetCursor((Line-1)*2, (Column-1)*wide); //参数1:把光标设置在第几页. 参数2:把光标设置在第几列
- for (i = 0; i < wide; i++)
- {
- OLED_WriteData(OLED_F10x16[Num][i]); //显示上半部分内容
- }
-
- OLED_SetCursor((Line-1)*2+1,(Column-1)*wide);
- for (i = 0; i < wide; i++)
- {
- OLED_WriteData(OLED_F10x16[Num][i+wide]); //显示下半部分内容
- }
-
- }
第一个参数是行,第二个参数是列,第三个是汉字库编号(取模的尾部那个编号)。不要忘了将驱动函数添加到.h里面,
在主函数里面驱动就行了,一个汉字对比showstring的显示是两个半的位置,一行最多显示六个汉字,注意一下就行。然后就可以让OELD显示汉字,到这里就结束了。
取模软件的网盘
链接:https://pan.baidu.com/s/1wO_kxJC7oXwP9K385qUSjw
提取码:15jh
代码源码提取
链接:https://pan.baidu.com/s/10ni7bzTj-sJj64--r-_Xnw
提取码:yp5a
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。