Zum Hauptinhalt springen

Hello world and printing text

What this example shows​

The smallest Inkplate 10 sketch: it initializes the display, writes Hello World! into the frame buffer and refreshes the panel. It also shows the main habit of e-paper programming. Drawing functions change the frame buffer only, and display() pushes the buffer to the screen.

Example code​

The listing is the library example without its header comment and board-check lines.

Select Board
Inkplate10_Hello_World.ino
#include "Inkplate.h" // Include the Inkplate library
Inkplate display(INKPLATE_1BIT); // Create an Inkplate object in 1-bit (black and white) mode

void setup() {
display.begin(); // Initialize the display hardware
display.clearDisplay(); // Clear the frame buffer (does NOT clear the physical screen)
display.setCursor(10, 10); // Set the text position to (10, 10) pixels
display.setTextSize(6); // Set text size to 6 (default is 1)
display.print("Hello World!"); // Print "Hello World!" at the set position
display.display(); // Refresh the e-paper display to show changes
}

void loop() {
// No code needed here for this example
}

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.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.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.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.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.

What to expect​

The panel refreshes once and Hello World! appears in large letters near the top-left corner. The example prints nothing to the Serial Monitor.