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.
#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 NoneCreates 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
| Type | Name | Description |
|---|---|---|
uint8_t | mode | INKPLATE_1BIT or INKPLATE_3BIT. |
Serial.begin(unsigned long baud)returns voidArduino function that starts the serial port.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
unsigned long | baud | Baud rate. The example uses 115200. |
display.begin()returns voidInitializes the library and the display. Call it once, at the start of `setup()`.
ReturnsNothing.
display.clearDisplay()returns voidClears the frame buffer in memory. It does not change what the panel shows until you call `display()`.
ReturnsNothing.
display.display(bool _leaveOn = 0)returns voidDoes 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
| Type | Name | Description |
|---|---|---|
bool | _leaveOn | Keeps the panel supply on after the update when true. Defaults to 0. |
display.setTextSize(uint8_t s)returns voidScales text by an integer factor. The base font is 5 x 7 pixels.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
uint8_t | s | Scale 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 voidMeasures 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
| Type | Name | Description |
|---|---|---|
const char * | string | The text to measure. |
int16_t | x | Horizontal position the text would start at. |
int16_t | y | Vertical position the text would start at. |
int16_t * | x1 | Receives the left edge of the text box. |
int16_t * | y1 | Receives the top edge of the text box. |
uint16_t * | w | Receives the width of the text box. |
uint16_t * | h | Receives the height of the text box. |
display.einkOn()returns intTurns 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_tReturns 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 voidDraws a filled rectangle into the frame buffer.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
int16_t | x | Left edge in pixels. |
int16_t | y | Top edge in pixels. |
int16_t | w | Width in pixels. |
int16_t | h | Height in pixels. |
uint16_t | color | Fill color, for example BLACK. |
display.setCursor(int16_t x, int16_t y)returns voidSets where the next `print()` starts, in pixels from the top left corner.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
int16_t | x | Horizontal position in pixels. |
int16_t | y | Vertical position in pixels. |
display.setTextColor(uint16_t c)returns voidSets the text color.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
uint16_t | c | Text color, for example BLACK. |
display.print(value)returns size_tPrints 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
| Type | Name | Description |
|---|---|---|
text, number or char | value | What to print. |
int | second 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_tRefreshes 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
| Type | Name | Description |
|---|---|---|
bool | _forced | Forces a partial update in cases the library would otherwise do a full one (advanced use with deep sleep). Defaults to false. |
bool | leaveOn | Keeps the panel supply on after the update when true. Defaults to false. |
delay(unsigned long ms)returns voidArduino function that pauses the sketch.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
unsigned long | ms | Time to wait in milliseconds. |
display.einkOff()returns voidTurns 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.