#include <GxEPD2_3C.h>
#include <Adafruit_GFX.h>
#include <Fonts/FreeMonoBold12pt7b.h>
#include <Fonts/FreeMonoBold9pt7b.h>
SPIClass hspi(HSPI);
// Set up the e-paper display
GxEPD2_3C<GxEPD2_290_C90c, GxEPD2_290_C90c::HEIGHT> display(GxEPD2_290_C90c(/*CS=*/ 5, /*DC=*/ 4, /*RST=*/ 21, /*BUSY=*/ 22));
const char HelloWorld[] = "Hello World!";
void helloWorld()
{
//Serial.println("helloWorld");
display.setRotation(1);
display.setFont(&FreeMonoBold9pt7b);
display.setTextColor(GxEPD_BLACK);
int16_t tbx, tby; uint16_t tbw, tbh;
display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
// center bounding box by transposition of origin:
uint16_t x = ((display.width() - tbw) / 2) - tbx;
uint16_t y = ((display.height() - tbh) / 2) - tby;
display.setFullWindow();
display.firstPage();
do
{
display.fillScreen(GxEPD_WHITE);
display.setCursor(x, y);
display.print(HelloWorld);
}
while (display.nextPage());
//Serial.println("helloWorld done");
}
void setup() {
Serial.begin(115200);
hspi.begin(18, -1, 19, -1);
display.epd2.selectSPI(hspi, SPISettings(2500000, MSBFIRST, SPI_MODE0));
// Initialize the e-paper display
display.init();
display.setRotation(1);
}
void loop() {
/*
// Clear the display
display.fillScreen(GxEPD_WHITE);
// Draw "Hello World" in the center of the display
display.setFont(&FreeMonoBold12pt7b);
display.setTextColor(GxEPD_BLACK);
display.setCursor((display.width() - 11) / 2, display.height() / 2);
display.println("Hello World");
// Update the display
display.display();
*/
helloWorld();
// Wait for 10 seconds before clearing the display and drawing "Hello World" again
delay(10000);
}Loading
epaper-2in9
epaper-2in9