Skip to main content

Faster partial updates

What this example shows​

Speeding up repeated partial updates by keeping the e-paper panel powered between them. Normally the library switches the panel supply on before each refresh and off afterwards. Calling einkOn() keeps it on, so a run of partialUpdate() calls is faster. Partial updates only work in INKPLATE_1BIT mode.

Example code​

Trimmed from the pinned example: only the file header comment is removed, the code is unchanged.

Select Board
Inkplate10_Fastest_Display_Refreshes.ino
#if !defined(ARDUINO_INKPLATE10) && !defined(ARDUINO_INKPLATE10V2)
#error "Wrong board selection for this example, please select e-radionica Inkplate10 or Soldered Inkplate10 in the boards menu."
#endif

#include "Inkplate.h"

// 1-bit mode supports partial update
Inkplate display(INKPLATE_1BIT);

const char *text = "Inkplate partial update scrolling demo";
int textY = 300; // Vertical position of text
int textSpeed = 8; // Pixels per frame

void setup()
{
Serial.begin(115200);
display.begin();

display.clearDisplay();
display.display(); // Full refresh once at start
}

void loop()
{
int16_t x1, y1;
uint16_t w, h;

// Measure text width
display.setTextSize(4);
display.getTextBounds(text, 0, textY, &x1, &y1, &w, &h);

// Start off-screen on the left
int x = -w;

// Turn E-Ink power ON once for faster partial updates
display.einkOn();

while (x < display.width())
{
// Clear only the previous text area
display.fillRect(0, textY - h, display.width(), h + 10, WHITE);

// Draw text at new position
display.setCursor(x, textY);
display.setTextColor(BLACK);
display.print(text);

// Partial update, keep panel powered
display.partialUpdate(0, 1);

x += textSpeed;
delay(80); // Controls scroll speed
}

// Turn E-Ink power OFF to save energy
display.einkOff();

delay(5000); // Pause before repeating
}

Functions used​

Inkplate(uint8_t mode)returns None

Creates the display object. `INKPLATE_1BIT` is black and white and supports partial updates. `INKPLATE_3BIT` gives 8 levels of grey but only full updates.

ReturnsConstructor; no return value.

Parameters

TypeNameDescription
uint8_tmodeINKPLATE_1BIT or INKPLATE_3BIT.
Serial.begin(unsigned long baud)returns void

Arduino function that starts the serial port.

ReturnsNothing.

Parameters

TypeNameDescription
unsigned longbaudBaud rate. The example uses 115200.
display.begin()returns void

Initializes the library and the display. Call it once, at the start of `setup()`.

ReturnsNothing.

display.clearDisplay()returns void

Clears the frame buffer in memory. It does not change what the panel shows until you call `display()`.

ReturnsNothing.

display.display(bool _leaveOn = 0)returns void

Does a full refresh: sends the frame buffer to the panel. If `_leaveOn` is true, the panel supply stays on after the refresh, which saves time on the next update.

ReturnsNothing.

Parameters

TypeNameDescription
bool_leaveOnKeeps the panel supply on after the update when true. Defaults to 0.
display.setTextSize(uint8_t s)returns void

Scales text by an integer factor. The base font is 5 x 7 pixels.

ReturnsNothing.

Parameters

TypeNameDescription
uint8_tsScale factor.
display.getTextBounds(const char *string, int16_t x, int16_t y, int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h)returns void

Measures how much space a piece of text takes with the current font and text size, without drawing it.

ReturnsNothing. The results are written through the pointers.

Parameters

TypeNameDescription
const char *stringThe text to measure.
int16_txHorizontal position the text would start at.
int16_tyVertical position the text would start at.
int16_t *x1Receives the left edge of the text box.
int16_t *y1Receives the top edge of the text box.
uint16_t *wReceives the width of the text box.
uint16_t *hReceives the height of the text box.
display.einkOn()returns int

Turns on the supply for the e-paper panel. Calling it yourself keeps the supply on across several refreshes.

Returns`1` if the supply turned on, `0` if it failed.

display.width()returns int16_t

Returns the width of the display in pixels.

ReturnsDisplay width in pixels.

display.fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)returns void

Draws a filled rectangle into the frame buffer.

ReturnsNothing.

Parameters

TypeNameDescription
int16_txLeft edge in pixels.
int16_tyTop edge in pixels.
int16_twWidth in pixels.
int16_thHeight in pixels.
uint16_tcolorFill color, for example BLACK.
display.setCursor(int16_t x, int16_t y)returns void

Sets where the next `print()` starts, in pixels from the top left corner.

ReturnsNothing.

Parameters

TypeNameDescription
int16_txHorizontal position in pixels.
int16_tyVertical position in pixels.
display.setTextColor(uint16_t c)returns void

Sets the text color.

ReturnsNothing.

Parameters

TypeNameDescription
uint16_tcText color, for example BLACK.
display.print(value)returns size_t

Prints text or a number at the cursor. The `print` functions come from the Arduino `Print` class that `Adafruit_GFX` builds on. For a number, an optional second argument sets the decimal places of a float or the number base of an integer.

ReturnsNumber of bytes printed.

Parameters

TypeNameDescription
text, number or charvalueWhat to print.
intsecond argument (optional)Decimal places for a float, or the base for an integer, for example DEC.
display.partialUpdate(bool _forced = false, bool leaveOn = false)returns uint32_t

Refreshes only the parts of the screen that changed, without a full refresh. It works only in `INKPLATE_1BIT` mode.

ReturnsNumber of pixels that changed from black to white, which can leave blur.

Parameters

TypeNameDescription
bool_forcedForces a partial update in cases the library would otherwise do a full one (advanced use with deep sleep). Defaults to false.
boolleaveOnKeeps the panel supply on after the update when true. Defaults to false.
delay(unsigned long ms)returns void

Arduino function that pauses the sketch.

ReturnsNothing.

Parameters

TypeNameDescription
unsigned longmsTime to wait in milliseconds.
display.einkOff()returns void

Turns the e-paper panel supply off.

ReturnsNothing.

What to expect​

The sketch does one full refresh at startup. Then the text Inkplate partial update scrolling demo scrolls from the left edge to the right edge of the screen with partial updates, pauses for 5 seconds and repeats. Nothing is printed to Serial.

Keeping the panel supply on increases power consumption. The example header says to call einkOff() before long idle periods or deep sleep, and the sketch does that after each scroll.