Images and the Image Converter
What this example shows
Showing a picture on the panel. The Soldered Image Converter turns an image into a header file with a byte array, and the sketch draws that array with display.image.draw().
Example code
The listing is the library example without its header comment and board-check lines. The sketch also needs the generated header image.h, which in the library example holds a 1200 × 825 pixel, 1 bit per pixel image. Open the source link to get both files.
To make your own image.h, follow the steps in the example header:
- Open the Image Converter.
- Upload your image and select Inkplate 10 as the target board.
- Choose the display mode: 1-bit (black and white) for the fastest refresh and highest contrast, or 3-bit (grayscale) for 8 shades of gray. For 3-bit, also change the sketch to
INKPLATE_3BIT. - Adjust dithering, size and the other options as needed.
- Save the generated
image.hin the same folder as the sketch. It definesimage_wandimage_hfor you.
#include "Inkplate.h" // Include the Inkplate library
#include "image.h" // Include the image header generated by the Image Converter tool
Inkplate display(INKPLATE_1BIT); // 1-bit mode (black & white)
//Inkplate display(INKPLATE_3BIT); // Uncomment for 3-bit mode (grayscale, 8 shades)
void setup() {
display.begin(); // Initialize the display hardware
display.clearDisplay(); // Clear the frame buffer (does NOT clear the physical screen)
display.image.draw(image, 0, 0, image_w, image_h); // Arguments are: array variable name, start X, start Y, size X, size Y
display.display(); // Refresh the e-paper display to show the image
}
void loop() {
// No code needed here for this example
}
Functions used
Inkplate(uint8_t mode)returns NoneCreates the Inkplate object. The mode decides how many bits describe each pixel: `INKPLATE_1BIT` for black and white, `INKPLATE_3BIT` for grayscale.
ReturnsConstructor; no return value.
Parameters
| Type | Name | Description |
|---|---|---|
uint8_t | mode | Display mode, INKPLATE_1BIT or INKPLATE_3BIT. |
display.begin()returns voidInitializes the display hardware. Call it once in `setup()` before you draw anything.
ReturnsNothing.
display.clearDisplay()returns voidClears the frame buffer in the ESP32 memory. It does not change what the panel currently shows; call `display()` for that.
ReturnsNothing.
display.image.draw(const uint8_t *buf, int x, int y, int16_t w, int16_t h, uint8_t c = 1, uint8_t bg = 0xFF)returns boolDraws a bitmap stored in an array, such as the header file produced by the Soldered Image Converter.
ReturnsTrue if the image was drawn, otherwise false.
Parameters
| Type | Name | Description |
|---|---|---|
const uint8_t * | buf | The bitmap array. |
int | x | Left edge in pixels. |
int | y | Top edge in pixels. |
int16_t | w | Bitmap width in pixels. |
int16_t | h | Bitmap height in pixels. |
uint8_t | c | Drawing color. Defaults to 1. |
uint8_t | bg | Background value. Defaults to 0xFF. |
display.display(bool _leaveOn = 0)returns voidSends the frame buffer to the panel with a full refresh.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
bool | _leaveOn | Optional. When true, the panel supply stays on after the refresh. Defaults to false. |
What to expect
The panel shows the picture from image.h filling the screen after one full refresh. The example prints nothing to the Serial Monitor.