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