当前位置:   article > 正文

STM32C8T6I2C驱动OLED显示汉字版本(江科大基础改编)_江苏科技oled显示汉字代码

江苏科技oled显示汉字代码

最近突然想显示汉字,然后翻了一圈发现版本好多,所以就挑了一个合适的。然后我的目的主要是驱动OLED0.96寸显示汉字,所以很简单,就是先配置驱动的模型库

  1. const uint8_t OLED_F10x16[][40]=
  2. {
  3. 0x00,0x00,0x10,0x10,0x12,0xFE,0x90,0x10,0x10,0x7E,0x50,0x50,0x50,0x48,0x48,0x44,
  4. 0x44,0x70,0x40,0x00,0x00,0x02,0x02,0x42,0x41,0x3F,0x00,0x00,0x00,0x41,0x7E,0x2A,
  5. 0x2A,0x2A,0x2A,0x2A,0x7F,0x00,0x00,0x00,/*"指",0*/
  6. 0x00,0x40,0x60,0x50,0x48,0xC6,0x60,0x20,0x10,0x10,0xF0,0x12,0x1C,0x10,0x90,0x70,
  7. 0x10,0x18,0x10,0x00,0x00,0x20,0x24,0x26,0x15,0x94,0x52,0x52,0x40,0x20,0x20,0x13,
  8. 0x0C,0x1C,0x33,0x20,0x60,0x40,0x00,0x00,/*"纹",1*/
  9. 0x00,0x40,0x40,0x40,0x44,0x54,0x54,0x54,0x54,0xD4,0xD4,0x54,0x54,0x54,0x7C,0xC0,
  10. 0x40,0x40,0x40,0x00,0x00,0x20,0x20,0x10,0x10,0x13,0x0E,0x48,0x44,0x7F,0x3F,0x02,
  11. 0x04,0x0A,0x12,0x31,0x21,0x20,0x20,0x00,/*"录",2*/
  12. 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x04,0xC4,0x78,0x70,0x80,0x00,0x00,0x00,0x00,
  13. 0x00,0x00,0x00,0x00,0x00,0x40,0x20,0x20,0x10,0x08,0x04,0x03,0x01,0x00,0x00,0x01,
  14. 0x03,0x0C,0x18,0x10,0x30,0x20,0x20,0x00,/*"入",3*/
  15. 0x00,0x80,0x80,0xFC,0x84,0xFC,0x84,0x80,0xFC,0x84,0x84,0xFC,0x80,0x80,0xF8,0x08,
  16. 0x00,0xFE,0x02,0x00,0x00,0x40,0x38,0x27,0x20,0x3F,0x40,0x38,0x47,0x40,0x40,0x3F,
  17. 0x00,0x00,0x0F,0x40,0x40,0x7F,0x00,0x00,/*"删",4*/
  18. 0x00,0x00,0xFC,0x04,0x64,0x94,0x8C,0x44,0x20,0x60,0x58,0x4C,0xC2,0x4C,0x50,0x70,
  19. 0x20,0x60,0x00,0x00,0x00,0x00,0x7F,0x04,0x08,0x08,0x47,0x20,0x12,0x0E,0x42,0xC2,
  20. 0x7F,0x02,0x02,0x0A,0x12,0x22,0x00,0x00,/*"除",5*/
  21. };

在font.h添加这一段库,直接在代码下面添加即可。然后如果想要自己取模就下载PctolLCD2002这个取模软件,搜索百度就可以,免费的。将软件设置成这样

 在中间那个横框里面输入汉字就可以得到模型,将模型复制到font.h库里面的OLED_F10x16[][40]里面,将多余的括号删除,然后将尾部的数字编号修改成顺序。

OLED.c里面添加驱动函数

  1. void OLED_ShowCN(uint8_t Line, uint8_t Column, uint8_t Num)
  2. {
  3. uint8_t i;
  4. uint8_t wide=20;//字宽
  5. OLED_SetCursor((Line-1)*2, (Column-1)*wide); //参数1:把光标设置在第几页. 参数2:把光标设置在第几列
  6. for (i = 0; i < wide; i++)
  7. {
  8. OLED_WriteData(OLED_F10x16[Num][i]); //显示上半部分内容
  9. }
  10. OLED_SetCursor((Line-1)*2+1,(Column-1)*wide);
  11. for (i = 0; i < wide; i++)
  12. {
  13. OLED_WriteData(OLED_F10x16[Num][i+wide]); //显示下半部分内容
  14. }
  15. }

第一个参数是行,第二个参数是列,第三个是汉字库编号(取模的尾部那个编号)。不要忘了将驱动函数添加到.h里面,

在主函数里面驱动就行了,一个汉字对比showstring的显示是两个半的位置,一行最多显示六个汉字,注意一下就行。然后就可以让OELD显示汉字,到这里就结束了。

取模软件的网盘

链接:https://pan.baidu.com/s/1wO_kxJC7oXwP9K385qUSjw 
提取码:15jh 

代码源码提取

链接:https://pan.baidu.com/s/10ni7bzTj-sJj64--r-_Xnw 
提取码:yp5a

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/590249
推荐阅读
相关标签
  

闽ICP备14008679号