OLED Draw显示图片

图片取模

使用Image2Lcd进行去取模

运行Img2Lcd.exe,点击打开,选择my car.bmp,输出数据类型:C语言数组(*.c),扫描模式:水平扫描,输出灰度:单色。

最大宽度和高度由输入图像的实际值决定,这里是101和46。点击保存,生成相应的数组。

具体设置如下图:


这里以默认的代码为例:

在Fonts.c中添加上面生成的数组:

  1. const uint8_t c_my_car[598] = { /* 0X00,0X01,0X65,0X00,0X2E,0X00, */
  2. 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X14,0X00,0X00,0X00,0X00,0X00,0X00,0X06,0X30,
  3. 0X01,0XE0,0X00,0X00,0X2A,0X00,0X00,0XD8,0X00,0X00,0X00,0X0F,0X7B,0X63,0XE0,0X00,
  4. 0X00,0X22,0X00,0X01,0X24,0X00,0X00,0X00,0X0F,0XFB,0X63,0X07,0X34,0X00,0X14,0X00,
  5. 0X01,0X04,0X00,0X00,0X00,0X0D,0XDB,0X63,0X01,0XBC,0X00,0X08,0X00,0X00,0X88,0X00,
  6. 0X00,0X00,0X0C,0X1B,0X63,0X07,0XB0,0X00,0X00,0X00,0X00,0X50,0X00,0X00,0X00,0X0C,
  7. 0X1B,0X63,0XED,0XB0,0XDB,0X00,0X01,0X00,0X20,0X00,0X00,0X00,0X0C,0X19,0XE1,0XE7,
  8. 0XB0,0XDB,0X00,0X02,0X00,0X00,0X00,0X00,0X00,0X0C,0X19,0XE1,0XE7,0XB0,0XDB,0X00,
  9. 0X02,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X60,0X00,0X00,0X00,0X00,0X04,0X00,0X00,
  10. 0X00,0X00,0X00,0X00,0X03,0XC0,0X00,0X00,0X00,0X00,0X08,0X00,0X00,0X00,0X00,0X00,
  11. 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X08,0X05,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
  12. 0X00,0X00,0X00,0X00,0X10,0X0A,0X80,0X00,0X00,0X00,0X00,0X00,0X0A,0X00,0X00,0XFF,
  13. 0XF8,0XE0,0X05,0X00,0X00,0X00,0X00,0X06,0XC0,0X15,0X00,0X1F,0XFF,0XFF,0XC0,0X02,
  14. 0X00,0X00,0X00,0X00,0X09,0X20,0X11,0X00,0XFB,0XFF,0XE1,0XF8,0X00,0X00,0X00,0X00,
  15. 0X00,0X08,0X20,0X0A,0X03,0X9F,0X00,0X9E,0X3E,0X00,0X00,0X00,0X00,0X00,0X04,0X40,
  16. 0X04,0X0E,0X70,0X00,0X81,0XC7,0X80,0X01,0X40,0X00,0X00,0X02,0X80,0X00,0X1D,0X80,
  17. 0X00,0XE0,0X61,0XE0,0X02,0XA0,0X00,0X00,0X01,0X00,0X00,0X77,0X9F,0XFC,0XF0,0X18,
  18. 0XF8,0X02,0X20,0X00,0X00,0X00,0X00,0X01,0XDF,0X00,0X00,0XF3,0X0C,0X3C,0X01,0X40,
  19. 0X00,0X00,0X00,0X00,0X03,0X9E,0X00,0X00,0XF8,0X06,0X1E,0X00,0X80,0X00,0X00,0X00,
  20. 0X00,0X07,0X0E,0X30,0X01,0XFC,0X7F,0X07,0X00,0X00,0X00,0X00,0X00,0X00,0X07,0X0E,
  21. 0X30,0X01,0XFC,0X7F,0X07,0X00,0X00,0X00,0X00,0X00,0X00,0X7E,0XFF,0XFF,0XFF,0XFF,
  22. 0XFF,0X83,0XC0,0X00,0X00,0X00,0X00,0X0F,0XFD,0XFF,0XFF,0XFF,0XFF,0XFC,0X01,0XF0,
  23. 0X00,0X00,0X00,0X00,0X3F,0X81,0XFF,0X00,0X00,0X00,0X00,0X1F,0XF0,0X00,0X00,0X00,
  24. 0X00,0XFE,0XF0,0X00,0X00,0X01,0X00,0X00,0XC0,0X1C,0X00,0X00,0X00,0X03,0XC0,0X07,
  25. 0X80,0X00,0X03,0XE0,0X07,0X00,0X1C,0X00,0X00,0X00,0X03,0X80,0X03,0X40,0X00,0X03,
  26. 0XE0,0X0C,0X00,0X0E,0X00,0X00,0X00,0X07,0X00,0X00,0XC0,0X00,0X00,0X20,0X18,0X00,
  27. 0X07,0X00,0X00,0X00,0X09,0X01,0X80,0X60,0X00,0X00,0X20,0X73,0X9F,0X03,0X80,0X00,
  28. 0X00,0X1E,0X0F,0XF2,0X20,0X00,0X00,0X20,0X67,0XFF,0XC1,0XC0,0X00,0X00,0X1E,0X1F,
  29. 0XF9,0X30,0X00,0X00,0X20,0XEF,0XFF,0XE0,0XE0,0X00,0X00,0X38,0X3F,0XFC,0X90,0X00,
  30. 0X00,0X20,0XCB,0XFF,0XF9,0XF0,0X00,0X00,0X7F,0X7F,0XFE,0X10,0X00,0X00,0X20,0XDB,
  31. 0XFF,0XFF,0XF0,0X00,0X00,0X6E,0XF9,0XBF,0X10,0X00,0X00,0X20,0XF7,0XED,0XFF,0XF0,
  32. 0X00,0X00,0X7C,0XFC,0X3F,0X10,0X00,0X00,0X20,0X67,0XE1,0XFD,0XE0,0X00,0X00,0X7C,
  33. 0XFC,0X3F,0X10,0X00,0X00,0X20,0X67,0XE1,0XFD,0XE0,0X00,0X00,0X38,0XFC,0X3F,0X18,
  34. 0X00,0X00,0X20,0X87,0XE0,0XFD,0XC0,0X00,0X00,0X38,0XF1,0X8F,0X18,0X00,0X1F,0XE7,
  35. 0X87,0X9C,0X7D,0XC0,0X00,0X00,0X1C,0XFE,0X1F,0X81,0XFF,0XFF,0XC0,0X0F,0XE0,0XFF,
  36. 0X80,0X00,0X00,0X0C,0XFC,0X3F,0X80,0X00,0X00,0X00,0X0F,0XE1,0XF8,0X00,0X00,0X00,
  37. 0X00,0XF9,0XBF,0XFF,0XFF,0XFF,0XFF,0XFF,0XEC,0XFE,0X00,0X00,0X00,0X03,0XF9,0XBF,
  38. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X00,0X00,0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,
  39. 0XFF,0XFF,0XFF,0XFF,0XC0,0X00,};

在Fonts.h中添加声明:

  1. extern const uint8_t c_my_car[598];

在main.c中修改代码如下即可:

  1. #include "LIB_Config.h"
  2.  
  3.  
  4. int main(void)
  5. {
  6. system_init();
  7.  
  8. ssd1306_clear_screen(0x00);//清屏
  9. ssd1306_draw_bitmap(0, 0, &c_my_car[0], 101, 46);//显示坐标为(0,0)
  10. ssd1306_refresh_gram();//更新GRAM
  11.  
  12. while (1) {
  13. }
  14. }

具体代码:0.96inch-OLED-Code-Draw

扩展

同样,汉字取模方法类似,这里使用LcmZimo(链接:https://pan.baidu.com/s/10sSyEJGG-ltjWEdqr7hiKw 提取码:hj21 )进行取模,默认按下图设置

其中红色部分不可修改,其它可按实际需要选择,点击确认参数后,开始输入相应的中文字符串进行取模。用显示图片类似的方法保存到工程中,调用时注意数组的边界,如使用16点阵,则在显示图片的大小都设置为16。

用户也可在函数ssd1306_draw_bitmap的基础上修改为相应的显示中文字符函数。


价格: ¥308
型号: 7.5inch e-Paper HAT (B)
制造商: 斑梨电子
SKU: 0106038