Partial update
What this example shows
Scrolling text across the screen with partialUpdate(), which redraws only what changed, so there is no full-screen flicker. The sketch also asks the library to force a full update after a set number of partial updates, to keep the picture clean.
Example code
The listing is the library example without its header comment and board-check lines. Partial update works in 1-bit mode only.
#include "Inkplate.h" //Include Inkplate library to the sketch
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1-bit mode (BW)
// Char array where you can store your text that will be scrolled.
const char text[] = "This is partial update on Inkplate 10 e-paper display! :)";
// This variable is used for moving the text (scrolling)
int offset = 1200;
// This variable is used to define the number of partial updates before doing a full update
int partialUpdates = 9;
void setup()
{
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
display.clearDisplay(); // Clear frame buffer of display
display.display(); // Put clear image on display
display.setTextColor(BLACK, WHITE); // Set text color to be black and background color to be white
display.setTextSize(4); // Set text to be 4 times bigger than classic 5x7 px text
display.setTextWrap(false); // Disable text wraping
// Set the number of partial updates before doing a full update
display.setFullUpdateThreshold(partialUpdates);
}
void loop()
{
display.clearDisplay(); // Clear content in frame buffer
display.setCursor(offset, 300); // Set new position for text
display.print(text); // Write text at new position
// Update only the changed parts of the screen
display.partialUpdate(false, true);
offset -= 20; // Move text into new position
if (offset < 0)
offset = 800; // Text is scrolled till the end of the screen? Get it back on the start!
delay(500); // Delay between refreshes.
}
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.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. |
display.setTextColor(uint16_t c, uint16_t bg)returns voidSets the text color and, optionally, the background color drawn behind each character.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
uint16_t | c | Text color. |
uint16_t | bg | Background color. Leave it out for a transparent background. |
display.setTextSize(uint8_t s)returns voidSets the text size as a multiple of the default 5 × 7 pixel font.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
uint8_t | s | Magnification factor. 1 is the default size. |
display.setTextWrap(bool w)returns voidTurns automatic text wrapping at the screen edge on or off.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
bool | w | False disables wrapping, so text can run off the edge. |
display.setFullUpdateThreshold(uint16_t _numberOfPartialUpdates)returns voidSets how many partial updates are allowed before the library performs a full update by itself. 0 disables the automatic full update.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
uint16_t | _numberOfPartialUpdates | Number of partial updates between full updates. |
display.setCursor(int16_t x, int16_t y)returns voidSets the position where the next `print()` call starts writing text.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
int16_t | x | Horizontal position in pixels. |
int16_t | y | Vertical position in pixels. |
display.print(text)returns size_tPrints text at the cursor position. This is the standard Arduino `Print` function, which the library inherits through the Adafruit GFX base class.
ReturnsNumber of bytes printed.
Parameters
| Type | Name | Description |
|---|---|---|
const char * | text | The text to print. |
display.partialUpdate(bool _forced = false, bool leaveOn = false)returns uint32_tUpdates only the changed parts of the screen, which avoids a full-screen flicker. Available in 1-bit mode.
ReturnsA count reported by the driver. The example ignores it.
Parameters
| Type | Name | Description |
|---|---|---|
bool | _forced | For advanced use, such as forcing a partial update in deep sleep workflows. |
bool | leaveOn | When true, the panel supply stays on after the update, which makes consecutive updates faster. |
What to expect
The panel does one full refresh, then the text scrolls from right to left in steps of 20 pixels every half second. After every 9 partial updates the library forces a full update, so you see a short flicker at that point.
Run a full refresh every 5 to 10 partial updates, as the example header recommends.