{"id":2955,"date":"2020-02-23T01:35:55","date_gmt":"2020-02-22T16:35:55","guid":{"rendered":"https:\/\/programresource.net\/?p=2955"},"modified":"2020-02-23T01:36:03","modified_gmt":"2020-02-22T16:36:03","slug":"show-bitmap-image-on-oled-display-with-arduino-esp-board-tool-provided","status":"publish","type":"post","link":"https:\/\/programresource.net\/en\/2020\/02\/23\/2955.html","title":{"rendered":"Show bitmap image on OLED display with Arduino\/ESP board (Tool provided)"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/programresource.net\/images\/2020\/02\/P_20200223_002338_vHDR_Auto-1024x577.jpg\" alt=\"\" class=\"wp-image-2944\" srcset=\"https:\/\/programresource.net\/images\/2020\/02\/P_20200223_002338_vHDR_Auto-1024x577.jpg 1024w, https:\/\/programresource.net\/images\/2020\/02\/P_20200223_002338_vHDR_Auto-300x169.jpg 300w, https:\/\/programresource.net\/images\/2020\/02\/P_20200223_002338_vHDR_Auto-768x433.jpg 768w, https:\/\/programresource.net\/images\/2020\/02\/P_20200223_002338_vHDR_Auto.jpg 1437w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>I2C connection Monochrome OLED display is very handy to use. Easy wiring and various libraries provided, such as Adafruit GFX, u8glib, u8g2lib.<\/p>\n\n\n\n<p>Monochrome bitmap can also be displayed. You need to prepare bitmap image and convert to hex data. There are tools you can download, but I couldn&#8217;t find one that is easy to use.<\/p>\n\n\n\n<p>So, I&#8217;ve created easy-to-use tool to convert bmp file to hex data (for Windows).<\/p>\n\n\n\n<p>Built with Visual Studio \/ C++. Use freely, no support, use at your own risk.<\/p>\n\n\n\n<div class=\"wp-block-file\"><a href=\"https:\/\/programresource.net\/images\/2020\/02\/nfBmptoHex.zip\">nfBmptoHex.zip<\/a><a href=\"https:\/\/programresource.net\/images\/2020\/02\/nfBmptoHex.zip\" class=\"wp-block-file__button\" download>Download<\/a><\/div>\n\n\n\n<div class=\"wp-block-file\"><a href=\"https:\/\/programresource.net\/images\/2020\/02\/nfbmptohex.src_.7z\">nfbmptohex.src.7z<\/a><a href=\"https:\/\/programresource.net\/images\/2020\/02\/nfbmptohex.src_.7z\" class=\"wp-block-file__button\" download>Download<\/a><\/div>\n\n\n\n<p>Simply create bitmap file with MS paintbrush for example, save as 24bit bmp file.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/programresource.net\/images\/2020\/02\/xbmp1.jpg\" alt=\"\" class=\"wp-image-2950\" srcset=\"https:\/\/programresource.net\/images\/2020\/02\/xbmp1.jpg 518w, https:\/\/programresource.net\/images\/2020\/02\/xbmp1-300x198.jpg 300w\" sizes=\"(max-width: 518px) 100vw, 518px\" \/><\/figure>\n\n\n\n<p> Launch tool, drag and drop bmp file to tool. You get hex code, copy to your sketch.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/programresource.net\/images\/2020\/02\/xbmp2.jpg\" alt=\"\" class=\"wp-image-2952\" srcset=\"https:\/\/programresource.net\/images\/2020\/02\/xbmp2.jpg 560w, https:\/\/programresource.net\/images\/2020\/02\/xbmp2-300x142.jpg 300w\" sizes=\"(max-width: 560px) 100vw, 560px\" \/><\/figure>\n\n\n\n<p>For Arduino, change definition to like below.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\nconst unsigned char bmpdata&#91;] PROGMEM = {\n<\/pre><\/div>\n\n\n<p>Then, use bitmap function with location and size parameter.<\/p>\n\n\n\n<p>Below are some examples with combination of different library. Since using ESP8266 and Adafruit GFX library results slow display, <a href=\"https:\/\/github.com\/cmmakerclub\/ESP_Adafruit_SSD1306\">ESP_Adafruit_SSD1306<\/a> library is used.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Arduino + u8glib<\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n#include &lt;U8glib.h&gt;\n\nconst unsigned char bootimg&#91;] PROGMEM = {\n\t0x00, ... 0x00,\n};\n\nU8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE | U8G_I2C_OPT_DEV_0);   \/\/ I2C \/ TWI\n\nvoid setup() {\n\tu8g.begin();\n\tu8g.setColorIndex(1);\n\tu8g.firstPage();\n\tdo {\n\t\tu8g.drawXBMP( 0, 0, 128, 64, bootimg); \n\t} while ( u8g.nextPage() );\n}\n\nvoid loop() {\n}\n<\/pre><\/div>\n\n\n<h4 class=\"wp-block-heading\">ESP8266 + Adafruit GFX<\/h4>\n\n\n\n<p>GPIO4 \/ GPIO5 used for I2C communication.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n#include &lt;Wire.h&gt;\n#include &lt;Adafruit_GFX.h&gt;\n#include &lt;ESP_Adafruit_SSD1306.h&gt;\n\nstatic unsigned char bootimg&#91;] PROGMEM = {\n\t0x00, ... 0x00,\n};\n\n#define PIN_D1 5\n#define PIN_D2 4\nstatic const uint8_t ALT_SDA = PIN_D2;\nstatic const uint8_t ALT_SCL = PIN_D1;\n\nAdafruit_SSD1306 display(-1);\n#if (SSD1306_LCDHEIGHT != 64)\n#error(&quot;Height incorrect, please fix Adafruit_SSD1306.h!&quot;);\n#endif\n\nvoid setup() {\n\tWire.begin(ALT_SDA, ALT_SCL);\n\tdisplay.begin(SSD1306_SWITCHCAPVCC, 0x3C);\n\tdisplay.clearDisplay();\n\tdisplay.drawXBitmap(0, 0,  bootimg, 128, 64, 1);\n\tdisplay.display();\n}\n\nvoid loop() {\n}\n<\/pre><\/div>\n\n\n<h4 class=\"wp-block-heading\">ESP32 + u8g2<\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n#include &lt;U8g2lib.h&gt;\n\nU8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, \/* reset=*\/ U8X8_PIN_NONE);\n\nstatic unsigned char bootimg&#91;] PROGMEM = {\n\t0x00, ... 0x00,\n};\n\nvoid setup() {\n     u8g2.begin();\n     u8g2.clearBuffer();\n     u8g2.setBitmapMode(false \/* solid *\/);\n     u8g2.setDrawColor(1);\n     u8g2.drawXBM( 0, 0, 128, 64, bootimg);\n     u8g2.sendBuffer();\n}\n\nvoid loop() {\n}\n<\/pre><\/div>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I2C connection Monochrome OLED display is very handy to use. Easy wiring and various libraries provided, such as Adafruit GFX, u8glib, u8g2lib. Monochrome bitmap can also be displayed. You need to prepare bitmap image and convert to hex data. There are tools you can download, but I couldn&#8217;t find one that is easy to use. So, I&#8217;ve created easy-to-use tool to convert bmp file to hex data (for Windows). Built with Visual Studio \/ C++. Use freely, no support, use at your own risk. Simply create bitmap file with MS paintbrush for example, save as 24bit bmp file. Launch tool, drag and drop bmp file to tool. You get hex &#8230;<\/p>\n","protected":false},"author":2,"featured_media":2945,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[866,868],"tags":[862,896,898,893,894,897,895],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/programresource.net\/images\/2020\/02\/P_20200223_002338_vHDR_Auto.jpg","jetpack_shortlink":"https:\/\/wp.me\/p3pJyQ-LF","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/posts\/2955"}],"collection":[{"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/comments?post=2955"}],"version-history":[{"count":2,"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/posts\/2955\/revisions"}],"predecessor-version":[{"id":2958,"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/posts\/2955\/revisions\/2958"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/media\/2945"}],"wp:attachment":[{"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/media?parent=2955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/categories?post=2955"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/tags?post=2955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}