// GxEPD2_HelloWorld.ino by Jean-Marc Zingg
// see GxEPD2_wiring_examples.h for wiring suggestions and examples
// if you use a different wiring, you need to adapt the constructor parameters!
#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
//#include <GxEPD2_7C.h>
#include <Adafruit_GFX.h> // Include Adafruit_GFX library
#include <Fonts/FreeMonoBold9pt7b.h>
#include "GxEPD2_display_selection.h"
// pin constants
const int EPD_CS = 53;
const int EPD_DC = 39;
const int EPD_RST = 37;
const int EPD_BSY = 35;
const char HelloWorld[] = "Hello World!";
// select the display class and display driver class in the following file (new style):
//#include "GxEPD2_display_selection_new_style.h"
// or select the display constructor line in one of the following files (old style):
//#include "GxEPD2_display_selection.h"
//#include "GxEPD2_display_selection_added.h"
// or,
// alternately you can copy the constructor from GxEPD2_display_selection.h or GxEPD2_display_selection_added.h to here
// e.g. for Wemos D1 mini:
//GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(/*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4)); // GDEH0154D67
//GxEPD2_BW<GxEPD2_290, GxEPD2_290::HEIGHT> display(GxEPD2_290(/*CS=5*/ EPD_CS, /*DC=*/ EPD_DC, /*RST=*/ EPD_RST, /*BUSY=*/ EPD_BSY)); // GDEH029A1 128x296, SSD1608 (IL3820)
void setup()
{
Serial.begin(115200);
Serial.println("Starting...");
//display.init(115200); // default 10ms reset pulse, e.g. for bare panels with DESPI-C02
display.init(115200, true, 2, false); // USE THIS for Waveshare boards with "clever" reset circuit, 2ms reset pulse
helloWorld();
delay(10000);
display.hibernate();
}
void helloWorld()
{
display.setRotation(1);
display.setFont(&FreeMonoBold9pt7b);
display.setTextColor(GxEPD_WHITE);
int16_t tbx, tby; uint16_t tbw, tbh;
display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
// center the bounding box by transposition of the origin:
uint16_t x = ((display.width() - tbw) / 2) - tbx;
uint16_t y = ((display.height() - tbh) / 2) - tby;
Serial.print("Width: ");
Serial.println(((display.width() - tbw) / 2) - tbx);
Serial.print("Height: ");
Serial.println(((display.height() - tbh) / 2) - tby);
display.setFullWindow();
display.firstPage();
do
{
display.fillScreen(GxEPD_BLACK);
display.setCursor(x, y);
display.print(HelloWorld);
}
while (display.nextPage());
}
void loop() {};