GxEPD2 E-Paper and E-Ink Display Guide
This guide walks you from an empty Lopaka canvas to working GxEPD2 C++ code on Waveshare, Good Display, and other SPI e-paper panels. Lopaka generates the layout, named GxEPD_* color calls, GFX font includes, and 1-bit bitmaps; you choose the panel driver class, wiring, refresh mode, and power management.
What is GxEPD2?
GxEPD2 is a widely used Arduino and ESP32 library for SPI e-paper (e-ink) displays from Waveshare, Good Display (GDEY / GDEW / GDEM), and similar vendors. Because GxEPD2 subclasses Adafruit GFX, it shares the standard drawLine(), drawRect(), drawBitmap(), and GFX font API while adding e-paper refresh cycles, paged drawing, and hibernation.
Check the GxEPD2 repository to find the exact driver class for your panel model.
Before you start
You need:
- An ESP32, ESP8266, RP2040, or Arduino board and an SPI e-paper module (for example Waveshare 2.9", 4.2", or 7.5").
- The exact panel model code (often printed on the flex cable, such as
GDEY029T94orGDEW042T2) and SPI/control pins (CS,DC,RST,BUSY). - Arduino IDE or PlatformIO with GxEPD2 and Adafruit GFX Library installed.
WARNING
E-paper panels with identical diagonal sizes often use incompatible controllers and LUT waveforms. Confirm the exact GxEPD2 panel class with a stock library example before adding Lopaka code.
Step 0: Install and test GxEPD2
- Arduino IDE: open Tools → Manage Libraries, install GxEPD2 by Jean-Marc Zingg and Adafruit GFX Library (version 1.12.2 or later if you use ellipse layers).
- PlatformIO: add
zinggjm/GxEPD2andadafruit/Adafruit GFX Librarytolib_depsinplatformio.ini.
Open File → Examples → GxEPD2 → GxEPD2_HelloWorld, uncomment the matching panel definition in GxEPD2_display_selection_new_style.h, set your pins, and upload it. Once "Hello World!" refreshes cleanly, keep that panel constructor as your base sketch.
Step 1: Create the Lopaka project
- Open lopaka.app and create a project.
- Select GxEPD2 (e-paper) as the platform.
- Set Screen Size to the logical width and height after any
display.setRotation()call in your sketch (for example296 × 128for a landscape 2.9" panel). - Keep the default
#f8f8f8light-grey editor background, which approximates e-paper white and exports asGxEPD_WHITE.
Step 2: Design a screen with the e-ink palette
Indexed 9-color palette
Lopaka's GxEPD2 platform constrains colors to 9 named constants supported across monochrome, grayscale, tri-color, and 7-color e-paper panels:
| Editor color | Generated GxEPD2 constant | Typical panel support |
|---|---|---|
#000000 | GxEPD_BLACK | All panels |
#f8f8f8 / #ffffff | GxEPD_WHITE | All panels |
#808080 | GxEPD_DARKGREY | 4-level grayscale panels |
#c0c0c0 | GxEPD_LIGHTGREY | 4-level grayscale panels |
#ff0000 | GxEPD_RED | 3-color (BWR) & 7-color |
#ffff00 | GxEPD_YELLOW | 3-color (BWY) & 7-color |
#0000ff | GxEPD_BLUE | 7-color ACeP / Spectra panels |
#00ff00 | GxEPD_GREEN | 7-color ACeP / Spectra panels |
#ff8000 | GxEPD_ORANGE | 7-color ACeP panels |
Off-palette hex colors snap automatically to the nearest constant. Stick to the subset your physical panel supports — for example GxEPD_BLACK, GxEPD_WHITE, and GxEPD_RED on a Waveshare 3-color module.
Supported layers
| Lopaka layer | Generated GxEPD2 (display) output |
|---|---|
| Line | display.drawLine() |
| Rectangle | display.drawRect() / display.fillRect() |
| Rounded rectangle | display.drawRoundRect() / display.fillRoundRect() |
| Circle | display.drawCircle() / display.fillCircle() |
| Ellipse | display.drawEllipse() / display.fillEllipse() (Adafruit GFX ≥ 1.12.2) |
| Triangle | display.drawTriangle() / display.fillTriangle() |
| Polygon | Generated helper calling closed display.drawLine() calls |
| Text | setTextColor(), setTextSize(), setFont(), setCursor(), print() |
| Paint, icon, image | 1-bit PROGMEM bitmap + display.drawBitmap(x, y, ..., color) |
Step 3: Export bitmaps and GFX fonts
Monochrome and tri-color bitmaps
All GxEPD2 images export as 1-bit bitmaps (image_<Name>_bits[]) drawn with display.drawBitmap(..., color). On a tri-color panel, you can color an icon GxEPD_RED or GxEPD_BLACK directly in the Inspector, or stack two separate 1-bit layers (one black, one red) at the same coordinates for crisp two-color artwork.
Enable Include image files in Code Settings to place bitmap arrays in downloadable .h files instead of inline in your sketch. For quick standalone conversion with no account, use the free Image Converter.
GFX fonts
GxEPD2 inherits Adafruit GFX fonts:
- Built-in Adafruit fonts (
FreeSans,FreeMono,FreeSerif,Org_01,Picopixel,TomThumb) emit#include <Fonts/FontName.h>automatically. - Uploaded custom
.h,.bdf,.ttf,.otf, or.wofffonts emit#include "FontName.h"and are downloadable from Code Settings → Fonts.
To convert standalone TTF or BDF files into .h GFX headers, use the free Font Converter.
Step 4: Integrate with full refresh or paged drawing
Full-buffer sketch (ESP32 / boards with enough RAM)
Lopaka's default GxEPD2 output wraps your screen in void draw{ScreenName}(void) and ends with display.display();, which triggers an e-paper refresh in full-buffer mode:
#include <GxEPD2_BW.h>
#include <Fonts/FreeSansBold12pt7b.h>
// Hardware-specific: replace with your panel class and pinout.
GxEPD2_BW<GxEPD2_290_T94_V2, GxEPD2_290_T94_V2::HEIGHT> display(
GxEPD2_290_T94_V2(/*CS=*/5, /*DC=*/17, /*RST=*/16, /*BUSY=*/4)
);
// BEGIN LOPAKA GENERATED CODE
void drawDashboard(void) {
display.fillScreen(GxEPD_WHITE);
display.setTextColor(GxEPD_BLACK);
display.setFont(&FreeSansBold12pt7b);
display.setCursor(12, 34);
display.print("21.4 C");
display.drawRect(4, 4, 288, 120, GxEPD_BLACK);
display.display();
}
// END LOPAKA GENERATED CODE
void setup() {
display.init(115200, true, 2, false);
display.setRotation(1);
display.setFullWindow();
drawDashboard();
display.hibernate();
}
void loop() {}Paged drawing (firstPage / nextPage) and partial refresh
On boards with limited RAM (AVR, ESP8266, or large 7.5"+ panels), allocate a reduced page height in the constructor and draw inside GxEPD2's picture loop. Disable Wrapper function (or remove the trailing display.display(); line) so nextPage() handles the refresh:
void renderPaged() {
display.setFullWindow();
display.firstPage();
do {
drawDashboardBody(); // Lopaka drawing calls without display.display()
} while (display.nextPage());
}For fast partial updates on monochrome panels that support them (such as updating a clock minute or sensor readout), restrict the update region with display.setPartialWindow(x, y, w, h) where x and w are multiples of 8 pixels. Run a full refresh every several partial updates to clear ghosting, and call display.hibernate() when your device enters deep sleep.
Tri-color panels and partial refresh
Most black/white/red and black/white/yellow e-paper panels do not support fast partial refresh — a full refresh takes 10–20 seconds. Plan update intervals around your panel's datasheet to avoid display degradation.
Note on Inkplate e-paper boards
If you build on Soldered Inkplate boards (Inkplate 2, 4 TEMPERA, 5, 6, 6COLOR, 10), the Inkplate Arduino library also extends Adafruit GFX, using 8 grayscale levels (0 through 7) and display.display(). Keep in mind that Inkplate's vendored Adafruit_GFX omits drawEllipse() and fillEllipse(), so use circles, rectangles, lines, and bitmaps when targeting Inkplate hardware.
For real-world e-paper UI inspiration built with Lopaka, see the ClockSat e-ink clock showcase, WeatherPaper ESP32 e-paper dashboard, and CineInk e-paper UI showcase.
Lopaka handles vs. you handle
| Lopaka handles | You handle |
|---|---|
Pixel layout and 9-color GxEPD_* constant mapping | Exact GxEPD2 panel template class and SPI/BUSY pin wiring |
| Adafruit GFX drawing calls and polygon helpers | display.init(), setRotation(), and SPI bus setup |
Built-in GFX includes and custom .h font export | Full vs. partial refresh windows (setPartialWindow) |
1-bit PROGMEM bitmap declarations | Paged firstPage() / nextPage() loop when RAM is tight |
| Variable declarations for live sensor/time text | Ghosting prevention, deep sleep, and display.hibernate() |
Troubleshooting
The display stays blank or Busy Timeout! appears in Serial Monitor
Check your BUSY pin wiring, SPI clock/data pins, and the reset pulse length in display.init(115200, true, 2, false) (Waveshare "clever reset" boards often require 2 ms instead of the default 10 ms).
Nothing updates inside firstPage() / nextPage()
Remove the trailing display.display(); line from Lopaka's generated function when calling it inside a do { ... } while (display.nextPage()); loop. nextPage() transfers each page and refreshes the panel automatically.
Red or yellow shapes print as black or disappear
Verify that your sketch uses GxEPD2_3C (or GxEPD2_7C) rather than GxEPD2_BW, and that your physical panel actually supports the GxEPD_* color constant you selected in Lopaka.
drawEllipse is not a member of GxEPD2_BW
Update Adafruit GFX Library to 1.12.2 or later, which added drawEllipse() and fillEllipse().
FAQ
Which colors does Lopaka emit for GxEPD2?
Lopaka maps colors to 9 named GxEPD2 constants: GxEPD_BLACK, GxEPD_WHITE, GxEPD_DARKGREY, GxEPD_LIGHTGREY, GxEPD_RED, GxEPD_YELLOW, GxEPD_BLUE, GxEPD_GREEN, and GxEPD_ORANGE. Any off-palette hex color snaps to the nearest constant. Use only the colors your physical e-paper panel supports.
How do I use Lopaka code inside GxEPD2's firstPage() / nextPage() loop?
Lopaka's GxEPD2 template ends drawScreen() with display.display(), which works in full-buffer mode. For paged drawing with firstPage() and nextPage() on low-RAM boards, remove display.display() from the generated function (or disable Wrapper function) and call the drawing statements inside the do { ... } while (display.nextPage()); loop.
How do I convert an image to a GxEPD2 bitmap?
Import PNG, BMP, or GIF files into a GxEPD2 project in Lopaka, or use the free Image Converter. Lopaka converts images to 1-bit monochrome PROGMEM bitmaps drawn with display.drawBitmap(x, y, image_bits, w, h, color).
Does Lopaka handle full refresh vs. partial refresh in GxEPD2?
No. Lopaka generates the drawing calls and assets. Your sketch chooses display.setFullWindow() or display.setPartialWindow(x, y, w, h), manages periodic full refreshes to clear ghosting, and calls display.hibernate() to save battery.
What about tri-color e-paper or Inkplate displays?
For tri-color Waveshare or Good Display panels (black, white, red or yellow), pick GxEPD_BLACK, GxEPD_WHITE, and GxEPD_RED or GxEPD_YELLOW in Lopaka. For Soldered Inkplate boards, Inkplate also builds on Adafruit GFX with 8 grayscale levels (0–7), though its vendored GFX omits drawEllipse() and fillEllipse().