Skip to content

Instantly share code, notes, and snippets.

@mischief
Created July 5, 2023 05:02
Show Gist options
  • Save mischief/2a07386956b774e330ffc5b2f745e382 to your computer and use it in GitHub Desktop.
Save mischief/2a07386956b774e330ffc5b2f745e382 to your computer and use it in GitHub Desktop.
epaper code GxEPD2
#include <Arduino.h>
#include <GxEPD2_3C.h>
#include <Fonts/FreeMonoBold9pt7b.h>
GxEPD2_3C<GxEPD2_290_Z13c, GxEPD2_290_Z13c::HEIGHT> pdisplay(GxEPD2_290_Z13c(/*CS=D8*/ D8, /*DC=D3*/ D0, /*RST=D4*/ D1, /*BUSY=D2*/ D2)); // GDEH029Z13 128x296, UC8151D
const char HelloWorld[] = "Hello World!";
void setup() {
Serial.begin(115200);
Serial.println("Hello world");
pdisplay.init(115200, true, 2, false);
pdisplay.setRotation(1);
pdisplay.setFont(&FreeMonoBold9pt7b);
pdisplay.setTextColor(GxEPD_BLACK);
int16_t tbx, tby; uint16_t tbw, tbh;
pdisplay.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
// center the bounding box by transposition of the origin:
uint16_t x = ((pdisplay.width() - tbw) / 2) - tbx;
uint16_t y = ((pdisplay.height() - tbh) / 2) - tby;
pdisplay.setFullWindow();
pdisplay.firstPage();
do
{
pdisplay.fillScreen(GxEPD_WHITE);
pdisplay.setCursor(x, y);
pdisplay.print(HelloWorld);
}
while (pdisplay.nextPage());
}
void loop() {}
[env]
upload_speed = 115200
monitor_speed = 115200
lib_deps =
zinggjm/GxEPD2@^1.4.9
[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment