极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9820|回复: 4

张老师Microduino-OLED12864显示器显示图片的问题

[复制链接]
发表于 2013-8-2 22:40:06 | 显示全部楼层 |阅读模式
本帖最后由 tom 于 2013-8-3 08:33 编辑

张老师Microduino-OLED12864显示器显示图片的问题
本显示器驱动芯片是SSD1306
显示器如何连接,和显示字符串看另一个贴子http://www.geek-workshop.com/thread-5483-1-1.html

买了这款显示器后,折腾了好几天。使用u8glib V1.12显示图片,经过多次测试,使用该库的范例显示自己提取的图片字模,不管是郝弘毅在12864教程中提供的字模提取软件,还是在网上下载的字模提取V2.1,在显示图片的时候都会出现严重的变形,不能正常显示图片。

后来我用U8glib V1.13版,依然不能正常显示图片,具体原因不明。
为了能显示图片,折腾了好几天,浪费了很多时间。

使用zcbzjx提供的范例,则可以正常显示图片。
特记录下来,希望后来者,不必浪费时间。

用photoshop 生成一个128*64像素大小的图片
S01.jpg




S02.jpg


S03.jpg

从百度搜索,下载字模提取软件V2.2

打开软件,显示如下画面S04.jpg



打开图片
如图S05.jpg


选择取模方式,点击C51方式
S06.jpg







选择生成代码,如图下列代码

  1. *--  调入了一幅图像:           --*/
  2. /*--  宽度x高度=128x64  --*/
  3. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  4. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  5. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  6. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  7. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  8. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  9. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  10. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  11. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  12. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  13. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  14. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  15. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  16. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  17. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18. 0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x0E,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  19. 0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x0E,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  20. 0x00,0x00,0x00,0x1C,0xC0,0x00,0x30,0x06,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  21. 0x00,0x00,0x00,0x1D,0xE0,0x00,0xF8,0x06,0x0C,0x01,0x86,0x00,0x00,0x00,0x00,0x00,
  22. 0x00,0x00,0x00,0x0F,0xF0,0x03,0xF8,0x06,0x04,0x01,0xC7,0x00,0x00,0x00,0x00,0x00,
  23. 0x00,0x00,0x00,0x0F,0xF0,0x0F,0xF0,0x06,0x00,0x01,0xC7,0x00,0x00,0x00,0x00,0x00,
  24. 0x00,0x00,0x00,0x3E,0xF0,0x1F,0xC0,0x06,0x00,0xC0,0xC7,0x00,0x40,0x00,0x00,0x00,
  25. 0x00,0x00,0x01,0xF8,0xE0,0x1F,0x80,0x04,0x07,0xC0,0xC6,0x00,0x60,0x00,0x00,0x00,
  26. 0x00,0x00,0x01,0xE0,0xC0,0x01,0x80,0x0F,0x7F,0xE0,0x0F,0x00,0x60,0x00,0x00,0x00,
  27. 0x00,0x00,0x01,0xBA,0x00,0x01,0x80,0x1F,0xFF,0xE0,0x0F,0x00,0x60,0x00,0x00,0x00,
  28. 0x00,0x01,0x03,0xBF,0x00,0x01,0x80,0x3F,0xF8,0x00,0x0F,0x80,0x60,0x00,0x00,0x00,
  29. 0x00,0x03,0x83,0xBF,0x00,0x01,0x80,0x3C,0x18,0x00,0x1D,0x80,0x60,0x00,0x00,0x00,
  30. 0x00,0x07,0x83,0x3F,0x00,0x01,0x80,0x0C,0x18,0x01,0x19,0xC0,0x60,0x00,0x00,0x00,
  31. 0x03,0x8F,0x83,0x77,0x00,0x01,0x80,0x0C,0x18,0x03,0xB8,0xE0,0x67,0x00,0x00,0x00,
  32. 0x03,0x9F,0x00,0x76,0x00,0x01,0x80,0x0C,0x3F,0x0F,0xB0,0xE3,0xF3,0xE0,0x00,0x00,
  33. 0x01,0xBF,0x00,0x7E,0x00,0x01,0x80,0x0D,0xBF,0x1F,0xF8,0xF1,0xFB,0xF0,0x00,0x00,
  34. 0x01,0xBF,0x00,0xDE,0x00,0x01,0x80,0x0F,0xBF,0x1F,0xFD,0x79,0xF8,0x70,0x00,0x00,
  35. 0x01,0xEF,0x00,0xCE,0x00,0x01,0x80,0x0F,0x73,0x83,0xCD,0xFC,0x60,0x00,0x00,0x00,
  36. 0x01,0xCF,0x80,0x9F,0x80,0x01,0x80,0x0E,0x73,0x03,0x0D,0x80,0x7E,0x00,0x00,0x00,
  37. 0x03,0x8F,0x80,0x1F,0xC0,0x01,0x80,0x1E,0x67,0x03,0x0B,0xC0,0x5F,0xE0,0x00,0x00,
  38. 0x07,0x99,0x80,0x3B,0xF0,0x01,0x9E,0x3C,0xE7,0x03,0x0F,0x80,0xC7,0xF8,0x00,0x00,
  39. 0x0F,0xD9,0x80,0x39,0xFE,0x01,0xFF,0x78,0xC6,0x03,0x1E,0x00,0xC3,0xBC,0x00,0x00,
  40. 0x03,0xDD,0x80,0x73,0xFE,0x07,0xFF,0x79,0xC6,0x03,0x78,0x00,0xFB,0x8C,0x00,0x00,
  41. 0x03,0xDF,0x80,0xFF,0xFE,0x7F,0xFF,0x71,0xC6,0x03,0xF8,0x47,0xF7,0xC0,0x00,0x00,
  42. 0x07,0xB7,0x01,0xFF,0xD0,0xFF,0x00,0x23,0x8E,0x03,0xD8,0x47,0xC6,0xE0,0x00,0x00,
  43. 0x07,0xB3,0x83,0xF9,0xC0,0x7C,0x00,0x03,0x3E,0x03,0x98,0x43,0x8C,0x60,0x00,0x00,
  44. 0x0F,0xF7,0xC7,0xB1,0x80,0x20,0x00,0x07,0x3C,0x07,0x98,0xC0,0x1F,0xF0,0x00,0x00,
  45. 0x0D,0xE7,0xF6,0x31,0x80,0x00,0x00,0x06,0x3C,0x07,0x1D,0xE0,0x1F,0xF0,0x00,0x00,
  46. 0x19,0xEE,0xF8,0x37,0x80,0x00,0x00,0x0C,0x1C,0x07,0x0F,0xE0,0x18,0x30,0x00,0x00,
  47. 0x01,0xD8,0xF8,0x3F,0x80,0x00,0x00,0x00,0x18,0x02,0x0F,0xC0,0x00,0x30,0x00,0x00,
  48. 0x01,0xB0,0x00,0x3F,0x00,0x00,0x00,0x00,0x10,0x00,0x07,0x80,0x00,0x00,0x00,0x00,
  49. 0x01,0x80,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  50. 0x01,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  51. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  52. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  53. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  54. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  55. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  56. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  57. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  58. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  59. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  60. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  61. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  62. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  63. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  64. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  65. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  66. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
复制代码


Arduino 代码如下:

  1. /*********************************************************************
  2. *
  3. * // # Update the Adafruit SSD1306 library to make it work
  4. * // # Description:
  5. * // #                 show a simple animation
  6. *
  7. * // # Connection:
  8. * // #        SCL  -> A5(Uno)/D3(Leonardo)
  9. * // #        SDA  -> A4(Uno)/D2(Leonardo)
  10. * // #        RST  -> D4
  11. * // #        DC  -> GND
  12. * // #        3.3  -> 3.3v
  13. * // #        g  -> GND
  14. * // #
  15. *
  16. * This is an example for OLED based on SSD1306 drivers
  17. *
  18. *
  19. * This example is for a 128x64 size display using I2C to communicate
  20. *
  21. * Adafruit invests time and resources providing this open source code,
  22. * please support Adafruit and open-source hardware by purchasing
  23. * products from Adafruit!
  24. *
  25. * All text above, and the splash screen must be included in any redistribution
  26. *********************************************************************/

  27. #include <Wire.h>
  28. #include <Adafruit_GFX.h>
  29. #include <Adafruit_SSD1306.h>

  30. #define OLED_RESET 4
  31. SSD1306 display(OLED_RESET);

  32. #define NUMFLAKES 10
  33. #define XPOS 0
  34. #define YPOS 1
  35. #define DELTAY 2


  36. #define LOGO16_GLCD_HEIGHT 64 //图片高度
  37. #define LOGO16_GLCD_WIDTH  128 //图片宽度
  38. static unsigned char PROGMEM logo16_glcd_bmp[] =
  39. {
  40.   /*--  宽度x高度=128x64  --*/
  41.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  42.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  43.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  44.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  45.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  46.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  47.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  48.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  49.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  50.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  51.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  52.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  53.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  54.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  55.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  56.   0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x0E,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  57.   0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x0E,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  58.   0x00,0x00,0x00,0x1C,0xC0,0x00,0x30,0x06,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  59.   0x00,0x00,0x00,0x1D,0xE0,0x00,0xF8,0x06,0x0C,0x01,0x86,0x00,0x00,0x00,0x00,0x00,
  60.   0x00,0x00,0x00,0x0F,0xF0,0x03,0xF8,0x06,0x04,0x01,0xC7,0x00,0x00,0x00,0x00,0x00,
  61.   0x00,0x00,0x00,0x0F,0xF0,0x0F,0xF0,0x06,0x00,0x01,0xC7,0x00,0x00,0x00,0x00,0x00,
  62.   0x00,0x00,0x00,0x3E,0xF0,0x1F,0xC0,0x06,0x00,0xC0,0xC7,0x00,0x40,0x00,0x00,0x00,
  63.   0x00,0x00,0x01,0xF8,0xE0,0x1F,0x80,0x04,0x07,0xC0,0xC6,0x00,0x60,0x00,0x00,0x00,
  64.   0x00,0x00,0x01,0xE0,0xC0,0x01,0x80,0x0F,0x7F,0xE0,0x0F,0x00,0x60,0x00,0x00,0x00,
  65.   0x00,0x00,0x01,0xBA,0x00,0x01,0x80,0x1F,0xFF,0xE0,0x0F,0x00,0x60,0x00,0x00,0x00,
  66.   0x00,0x01,0x03,0xBF,0x00,0x01,0x80,0x3F,0xF8,0x00,0x0F,0x80,0x60,0x00,0x00,0x00,
  67.   0x00,0x03,0x83,0xBF,0x00,0x01,0x80,0x3C,0x18,0x00,0x1D,0x80,0x60,0x00,0x00,0x00,
  68.   0x00,0x07,0x83,0x3F,0x00,0x01,0x80,0x0C,0x18,0x01,0x19,0xC0,0x60,0x00,0x00,0x00,
  69.   0x03,0x8F,0x83,0x77,0x00,0x01,0x80,0x0C,0x18,0x03,0xB8,0xE0,0x67,0x00,0x00,0x00,
  70.   0x03,0x9F,0x00,0x76,0x00,0x01,0x80,0x0C,0x3F,0x0F,0xB0,0xE3,0xF3,0xE0,0x00,0x00,
  71.   0x01,0xBF,0x00,0x7E,0x00,0x01,0x80,0x0D,0xBF,0x1F,0xF8,0xF1,0xFB,0xF0,0x00,0x00,
  72.   0x01,0xBF,0x00,0xDE,0x00,0x01,0x80,0x0F,0xBF,0x1F,0xFD,0x79,0xF8,0x70,0x00,0x00,
  73.   0x01,0xEF,0x00,0xCE,0x00,0x01,0x80,0x0F,0x73,0x83,0xCD,0xFC,0x60,0x00,0x00,0x00,
  74.   0x01,0xCF,0x80,0x9F,0x80,0x01,0x80,0x0E,0x73,0x03,0x0D,0x80,0x7E,0x00,0x00,0x00,
  75.   0x03,0x8F,0x80,0x1F,0xC0,0x01,0x80,0x1E,0x67,0x03,0x0B,0xC0,0x5F,0xE0,0x00,0x00,
  76.   0x07,0x99,0x80,0x3B,0xF0,0x01,0x9E,0x3C,0xE7,0x03,0x0F,0x80,0xC7,0xF8,0x00,0x00,
  77.   0x0F,0xD9,0x80,0x39,0xFE,0x01,0xFF,0x78,0xC6,0x03,0x1E,0x00,0xC3,0xBC,0x00,0x00,
  78.   0x03,0xDD,0x80,0x73,0xFE,0x07,0xFF,0x79,0xC6,0x03,0x78,0x00,0xFB,0x8C,0x00,0x00,
  79.   0x03,0xDF,0x80,0xFF,0xFE,0x7F,0xFF,0x71,0xC6,0x03,0xF8,0x47,0xF7,0xC0,0x00,0x00,
  80.   0x07,0xB7,0x01,0xFF,0xD0,0xFF,0x00,0x23,0x8E,0x03,0xD8,0x47,0xC6,0xE0,0x00,0x00,
  81.   0x07,0xB3,0x83,0xF9,0xC0,0x7C,0x00,0x03,0x3E,0x03,0x98,0x43,0x8C,0x60,0x00,0x00,
  82.   0x0F,0xF7,0xC7,0xB1,0x80,0x20,0x00,0x07,0x3C,0x07,0x98,0xC0,0x1F,0xF0,0x00,0x00,
  83.   0x0D,0xE7,0xF6,0x31,0x80,0x00,0x00,0x06,0x3C,0x07,0x1D,0xE0,0x1F,0xF0,0x00,0x00,
  84.   0x19,0xEE,0xF8,0x37,0x80,0x00,0x00,0x0C,0x1C,0x07,0x0F,0xE0,0x18,0x30,0x00,0x00,
  85.   0x01,0xD8,0xF8,0x3F,0x80,0x00,0x00,0x00,0x18,0x02,0x0F,0xC0,0x00,0x30,0x00,0x00,
  86.   0x01,0xB0,0x00,0x3F,0x00,0x00,0x00,0x00,0x10,0x00,0x07,0x80,0x00,0x00,0x00,0x00,
  87.   0x01,0x80,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  88.   0x01,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  89.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  90.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  91.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  92.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  93.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  94.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  95.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  96.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  97.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  98.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  99.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  100.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  101.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  102.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  103.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  104.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

  105. };

  106. #if (SSD1306_LCDHEIGHT != 64)
  107. #error("Height incorrect, please fix Adafruit_SSD1306.h!");
  108. #endif

  109. void setup()   {               
  110.   Serial.begin(9600);

  111.   display.begin(SSD1306_SWITCHCAPVCC, 0x3c);  // initialize with the I2C addr 0x3C (for the 128x64)
  112.   // init done
  113.   //初始化12864屏幕
  114.   display.display(); // show splashscreen
  115.   //显示闪屏,我理解是12864中固化的图片

  116.   delay(2000);
  117.   display.clearDisplay();   // clears the screen and buffer
  118.   //清屏


  119.   display.clearDisplay();
  120.   display.drawBitmap(0, 0,  logo16_glcd_bmp, LOGO16_GLCD_WIDTH, LOGO16_GLCD_HEIGHT, 1);
  121.   //在指定的位置绘出图形
  122.   display.display();
  123.   //在12864液晶屏中显示出来

  124. }


  125. void loop() {

  126. }
复制代码

程序运行后,先显示Micoduino文字,清屏,再显示想显示的图片
显示效果,摄像头不好,拍的有点模糊。S08.bmp




后记,如果是其它的非128*64大小的图片。
假如是一张50*50大小的图片,字模处理软件生成的代码,它会自动调整成56*50大小的,在软件中,一定要按原始大小填定数据,不然会出现和原图不同的效果。

另外,如果将图片数据,放入U8glib V1.12 或是 V1.13版中的显示图片例程,得到效果是和原图完全不同。

需要注意的是本程序中用的的库有版本要求,请去维基百科下载,否则该程序不能得到如上效果。http://wiki.microduino.net/index.php?title=Microduino-OLED

还是把库附上吧。
s01.jpg
s02.jpg
S06.jpg
s03.jpg
s04.jpg
s05.jpg
s08.bmp

Adafruit_SSD1306(1).zip

21.44 KB, 下载次数: 139

评分

参与人数 1 +3 收起 理由
Microduino + 3 很给力!

查看全部评分

回复

使用道具 举报

发表于 2013-11-15 09:43:04 来自手机 | 显示全部楼层
关注一下图片显示
回复 支持 反对

使用道具 举报

发表于 2014-2-24 10:49:55 | 显示全部楼层
不错的教程~~~~
回复 支持 反对

使用道具 举报

发表于 2014-4-23 01:08:45 | 显示全部楼层
想在12864OLED上任意显示一个点,但是ssd1306驱动的OLED没有读的功能,所以我用在芯片上开辟显存的方法,用STM32试了下,能达任意显示"点"的效果,但是用STC12C5A60S2却不行,是内存不足还是什么原因?如果用51单片机在OLED12864上实现任意显示"点",应该如何写?
回复 支持 反对

使用道具 举报

发表于 2014-4-23 01:50:17 | 显示全部楼层
xz1992 发表于 2014-4-23 01:08
想在12864OLED上任意显示一个点,但是ssd1306驱动的OLED没有读的功能,所以我用在芯片上开辟显存的方法,用 ...

我也做了一個相同的庫, 為了要顯示單獨一個點, 只好自建顯存.  但12864 的顯示, 就要用去1KB 的記憶.
再加上字型, 如果不能放到 flash, 基本上單單為了 OLED 的顯示, 就要用到 1.5KB 左右.

STC12C5A60S2 的 SRAM 只有 1280,  單是 顯存已用了 1024, 餘下 256byte 可用, 再加上宇庫, 以為一般程式中用到的變數,  實在太勉強了.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊 ( 浙ICP备09023225号 )

GMT+8, 2020-9-27 15:37 , Processed in 0.053138 second(s), 28 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表