Zum Hauptinhalt springen

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.

Select Board
Inkplate10_Partial_Update.ino
#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 None

Creates 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

TypeNameDescription
uint8_tmodeDisplay mode, INKPLATE_1BIT or INKPLATE_3BIT.
display.begin()returns void

Initializes the display hardware. Call it once in `setup()` before you draw anything.

ReturnsNothing.

display.clearDisplay()returns void

Clears 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 void

Sends the frame buffer to the panel with a full refresh.

ReturnsNothing.

Parameters

TypeNameDescription
bool_leaveOnOptional. When true, the panel supply stays on after the refresh. Defaults to false.
display.setTextColor(uint16_t c, uint16_t bg)returns void

Sets the text color and, optionally, the background color drawn behind each character.

ReturnsNothing.

Parameters

TypeNameDescription
uint16_tcText color.
uint16_tbgBackground color. Leave it out for a transparent background.
display.setTextSize(uint8_t s)returns void

Sets the text size as a multiple of the default 5 × 7 pixel font.

ReturnsNothing.

Parameters

TypeNameDescription
uint8_tsMagnification factor. 1 is the default size.
display.setTextWrap(bool w)returns void

Turns automatic text wrapping at the screen edge on or off.

ReturnsNothing.

Parameters

TypeNameDescription
boolwFalse disables wrapping, so text can run off the edge.
display.setFullUpdateThreshold(uint16_t _numberOfPartialUpdates)returns void

Sets how many partial updates are allowed before the library performs a full update by itself. 0 disables the automatic full update.

ReturnsNothing.

Parameters

TypeNameDescription
uint16_t_numberOfPartialUpdatesNumber of partial updates between full updates.
display.setCursor(int16_t x, int16_t y)returns void

Sets the position where the next `print()` call starts writing text.

ReturnsNothing.

Parameters

TypeNameDescription
int16_txHorizontal position in pixels.
int16_tyVertical position in pixels.
display.print(text)returns size_t

Prints 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

TypeNameDescription
const char *textThe text to print.
display.partialUpdate(bool _forced = false, bool leaveOn = false)returns uint32_t

Updates 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

TypeNameDescription
bool_forcedFor advanced use, such as forcing a partial update in deep sleep workflows.
boolleaveOnWhen 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.