Here is short tutorial on how to display any image on OLED display.
You should be familiar with basic of displaying text on OLED display with Arduino or some kind of microcontroller. For those who wants to follow this tutorial can read my previous blog post on how to use OLED display with Arduino. Specifically, there are two types of OLED module driver, the SSD1306 and the SH1106 drivers. For my case my OLED did not work the the SSD1306 driver so I used the SH1106 library. Below is the link to the tutorial:
Beginner's Guide to Testing an OLED Display with Arduino
Once you have a working hardware and program working you can follow the steps outlined here to display picture on the OLED screen. So here I am using 1.3 inch OLED screen. The circuit diagram below shows how to interface the OLED display and Arduino Uno.
The picture above also shows the actual picture being displayed.
The first thing to do is to have your picture converted to byte oriented code and then paste that picture byte code in your Arduino Sketch.
Here for example, I have used the following picture and generated that image byte code and then pasted in the arduino code.
Then go to the following url to convert your image to arduino readable byte code.
https://javl.github.io/image2cpp
As shown in the image below, choose and upload your picture. Set the canvas size to 128 pixel by 64 pixel. Then see the preview of your image and if everything is fine click on the generate code button. Then click on the copy button and paste it in your Arduino code.
Below is an example of the arduino code that is generated by the above online image to byte converter for OLED LCD Display.
// 'bear', 128x64px
const unsigned char epd_bitmap_bear [] PROGMEM = {
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 02 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 8c , 0x 01 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 03 , 0x 00 , 0x 3b , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 05 , 0x 82 , 0x 83 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 04 , 0x 03 , 0x 01 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 06 , 0x 01 , 0x 01 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 01 , 0x 81 , 0x 03 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 01 , 0x 00 , 0x 04 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 02 , 0x 00 , 0x 61 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 02 , 0x 00 , 0x 02 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 04 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 18 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 04 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 08 , 0x 00 , 0x 02 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 06 , 0x 00 , 0x 06 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 09 , 0x 00 , 0x 08 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 02 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 20 , 0x a0 , 0x 05 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x e0 , 0x 00 , 0x 02 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 40 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 01 , 0x 80 , 0x 00 , 0x 02 , 0x 44 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 60 , 0x 18 , 0x 20 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 01 , 0x 00 , 0x 08 , 0x 62 , 0x 00 , 0x 0c , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 07 , 0x 78 , 0x 00 , 0x 02 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 01 , 0x 00 , 0x 11 , 0x 20 , 0x 00 , 0x 28 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 20 , 0x 00 , 0x 6c , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 80 , 0x 02 , 0x 00 , 0x 00 , 0x 6e , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 80 , 0x 00 , 0x 00 , 0x 01 , 0x 82 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 02 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 20 , 0x 00 , 0x 80 , 0x 04 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 04 , 0x 38 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 0c , 0x 40 , 0x 00 , 0x 40 , 0x 78 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 08 , 0x 02 , 0x 01 , 0x 04 , 0x 40 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 01 , 0x 00 , 0x 40 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 2b , 0x 01 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 10 , 0x 00 , 0x 02 , 0x 06 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 30 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 30 , 0x 00 , 0x 00 , 0x 02 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 20 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 20 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 30 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 10 , 0x 00 , 0x 00 , 0x 04 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 30 , 0x 00 , 0x 00 , 0x 04 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 40 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 30 , 0x 00 , 0x 00 , 0x 08 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 01 , 0x 00 , 0x 30 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 30 , 0x 00 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 30 , 0x 00 , 0x 80 , 0x 40 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 20 , 0x 00 , 0x 81 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 88 , 0x 20 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 12 , 0x 30 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 40 , 0x 20 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 50 , 0x 20 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 40 , 0x 20 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 08 , 0x 00 , 0x 00 , 0x 60 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 08 , 0x 00 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 08 , 0x 00 , 0x c0 , 0x 70 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 0c , 0x 01 , 0x 82 , 0x a8 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 0c , 0x 02 , 0x 1c , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 05 , 0x 40 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 03 , 0x 85 , 0x 40 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x ba , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 06 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 1040)
const int epd_bitmap_allArray_LEN = 1 ;
const unsigned char * epd_bitmap_allArray [ 1 ] = {
epd_bitmap_bear
};
Now copy the code and paste it in your Arduino code. The complete code is below.
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>
// Declaration for an SH1106 display connected to I2C (SDA, SCL pins)
// The pins for I2C are defined by the Wire-library.
// On an arduino UNO: A4(SDA), A5(SCL)
// On an arduino MEGA 2560: 20(SDA), 21(SCL)
// On an arduino LEONARDO: 2(SDA), 3(SCL), ...
#define OLED_RESET 4
Adafruit_SH1106 display (OLED_RESET);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define SCREEN_ADDRESS 0x 3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define LOGO16_GLCD_HEIGHT 128
#define LOGO16_GLCD_WIDTH 64
// 'bear', 128x64px
const unsigned char epd_bitmap_bear [] PROGMEM = {
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 02 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 8c , 0x 01 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 03 , 0x 00 , 0x 3b , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 05 , 0x 82 , 0x 83 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 04 , 0x 03 , 0x 01 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 06 , 0x 01 , 0x 01 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 01 , 0x 81 , 0x 03 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 01 , 0x 00 , 0x 04 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 02 , 0x 00 , 0x 61 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 02 , 0x 00 , 0x 02 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 04 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 18 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 04 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 08 , 0x 00 , 0x 02 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 06 , 0x 00 , 0x 06 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 09 , 0x 00 , 0x 08 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 02 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 20 , 0x a0 , 0x 05 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x e0 , 0x 00 , 0x 02 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 40 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 01 , 0x 80 , 0x 00 , 0x 02 , 0x 44 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 60 , 0x 18 , 0x 20 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 01 , 0x 00 , 0x 08 , 0x 62 , 0x 00 , 0x 0c , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 07 , 0x 78 , 0x 00 , 0x 02 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 01 , 0x 00 , 0x 11 , 0x 20 , 0x 00 , 0x 28 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 20 , 0x 00 , 0x 6c , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 80 , 0x 02 , 0x 00 , 0x 00 , 0x 6e , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 80 , 0x 00 , 0x 00 , 0x 01 , 0x 82 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 02 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 20 , 0x 00 , 0x 80 , 0x 04 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 04 , 0x 38 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 0c , 0x 40 , 0x 00 , 0x 40 , 0x 78 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 08 , 0x 02 , 0x 01 , 0x 04 , 0x 40 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 01 , 0x 00 , 0x 40 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 2b , 0x 01 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 10 , 0x 00 , 0x 02 , 0x 06 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 30 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 30 , 0x 00 , 0x 00 , 0x 02 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 20 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 20 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 30 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 10 , 0x 00 , 0x 00 , 0x 04 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 30 , 0x 00 , 0x 00 , 0x 04 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 40 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 30 , 0x 00 , 0x 00 , 0x 08 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 01 , 0x 00 , 0x 30 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 30 , 0x 00 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 30 , 0x 00 , 0x 80 , 0x 40 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 20 , 0x 00 , 0x 81 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 88 , 0x 20 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 12 , 0x 30 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 40 , 0x 20 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 50 , 0x 20 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 40 , 0x 20 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 08 , 0x 00 , 0x 00 , 0x 60 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 08 , 0x 00 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 08 , 0x 00 , 0x c0 , 0x 70 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 0c , 0x 01 , 0x 82 , 0x a8 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 0c , 0x 02 , 0x 1c , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 05 , 0x 40 , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 03 , 0x 85 , 0x 40 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x ba , 0x 80 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 ,
0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 06 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00 , 0x 00
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 1040)
const int epd_bitmap_allArray_LEN = 1 ;
const unsigned char * epd_bitmap_allArray [ 1 ] = {
epd_bitmap_bear
};
#if ( SH1106_LCDHEIGHT != 64 )
#error ("Height incorrect, please fix Adafruit_SH1106.h!");
#endif
void setup () {
Serial . begin ( 9600 ) ;
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display . begin ( SH1106_SWITCHCAPVCC, SCREEN_ADDRESS ) ; // initialize with the I2C addr 0x3C (for the 128x64)
// init done
// Show image buffer on the display hardware.
// Since the buffer is intialized with an Adafruit splashscreen
// internally, this will display the splashscreen.
display . display () ;
delay ( 2000 ) ;
// Clear the buffer.
display . clearDisplay () ;
// text display tests
display . setTextSize ( 1 ) ;
display . setTextColor ( WHITE ) ;
display . setCursor ( 20 , 30 ) ;
display . println ( "direct-media.com" ) ;
display . display () ;
delay ( 2000 ) ;
// miniature bitmap display
display . clearDisplay () ;
display . drawBitmap ( 0 , 0 , epd_bitmap_bear, 128 , 64 , WHITE ) ;
display . display () ;
delay ( 2000 ) ;
// draw a bitmap icon and 'animate' movement
testdrawbitmap ( epd_bitmap_bear, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH ) ;
display . display () ;
delay ( 2000 ) ;
}
void loop () {
}
void testdrawbitmap ( const uint8_t *bitmap, uint8_t w, uint8_t h ) {
uint8_t icons [NUMFLAKES][ 3 ];
// initialize
for ( uint8_t f= 0 ; f< NUMFLAKES; f++ ) {
icons [f][XPOS] = random ( display . width ()) ;
icons [f][YPOS] = 0 ;
icons [f][DELTAY] = random ( 5 ) + 1 ;
Serial . print ( "x: " ) ;
Serial . print ( icons [f][XPOS], DEC ) ;
Serial . print ( " y: " ) ;
Serial . print ( icons [f][YPOS], DEC ) ;
Serial . print ( " dy: " ) ;
Serial . println ( icons [f][DELTAY], DEC ) ;
}
while ( 1 ) {
// draw each icon
for ( uint8_t f= 0 ; f< NUMFLAKES; f++ ) {
display . drawBitmap ( icons [f][XPOS], icons [f][YPOS], epd_bitmap_bear, w, h, WHITE ) ;
}
display . display () ;
delay ( 200 ) ;
// then erase it + move it
for ( uint8_t f= 0 ; f< NUMFLAKES; f++ ) {
display . drawBitmap ( icons [f][XPOS], icons [f][YPOS], epd_bitmap_bear, w, h, BLACK ) ;
// move it
icons [f][YPOS] += icons [f][DELTAY];
// if its gone, reinit
if ( icons [f][YPOS] > display . height ()) {
icons [f][XPOS] = random ( display . width ()) ;
icons [f][YPOS] = 0 ;
icons [f][DELTAY] = random ( 5 ) + 1 ;
}
}
}
}
Now upload it and you should see your image being displayed. You should note that in the above code there is bit of animation of the image.
See also the animation of the prototyping and check the validity of the program code for custom image display with the help of electronics design software Proteus Professional.
VIDEO
And below is video showing the actual physical demonstration of image displayed on OLED display.
VIDEO