From 127eadc7850c4f1debca262b592caf66d3c9ed25 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Mon, 3 Jun 2024 16:03:03 -0400 Subject: [PATCH] test just header --- platformio.ini | 1 + src/boards_pinout.h | 6 ++++++ src/display.cpp | 40 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index 2e4b49c..8427c8e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -118,6 +118,7 @@ build_flags = -DELEGANTOTA_USE_ASYNC_WEBSERVER=1 lib_deps = ${common.lib_deps} + zinggjm/GxEPD2@^1.5.4 [env:heltec_ht-ct62] diff --git a/src/boards_pinout.h b/src/boards_pinout.h index cbc6a49..136f8d8 100644 --- a/src/boards_pinout.h +++ b/src/boards_pinout.h @@ -183,6 +183,12 @@ #define VEXT_CTRL 45 #define BOARD_I2C_SDA 37 #define BOARD_I2C_SCL 36 + #define EPAPER_BUSY 7 + #define EPAPER_RST 6 + #define EPAPER_DC 5 + #define EPAPER_CS 4 + #define EPAPER_SCL 3 + #define EPAPER_SDA 2 #endif #ifdef ESP32_C3_DIY_LoRa diff --git a/src/display.cpp b/src/display.cpp index abbf0db..6b6de86 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -17,7 +17,11 @@ #endif #else #ifdef HAS_EPAPER - // + #include + #include + #include + #define ENABLE_GxEPD2_GFX 0 // enable or disable GxEPD2_GFX base class + GxEPD2_BW display(GxEPD2_213_BN(EPAPER_CS, EPAPER_DC, EPAPER_RST, EPAPER_BUSY)); // DEPG0213BN 122x250, SSD1680 #else #include #include @@ -54,7 +58,7 @@ void setup_display() { tft.fillScreen(TFT_BLACK); #else #ifdef HAS_EPAPER - // + display.init(115200, true, 50, false); #else #ifdef OLED_DISPLAY_HAS_RST_PIN pinMode(OLED_RST, OUTPUT); @@ -156,7 +160,21 @@ void show_display(const String& header, const String& line1, const String& line2 tft.print(line3); #else #ifdef HAS_EPAPER - // + display.setRotation(1); + display.setFont(&FreeMonoBold9pt7b); + display.setTextColor(GxEPD_BLACK); + int16_t tbx, tby; uint16_t tbw, tbh; + display.getTextBounds(header, 0, 0, &tbx, &tby, &tbw, &tbh); + uint16_t x = ((display.width() - tbw) / 2) - tbx; // center bounding box by transposition of origin: + uint16_t y = ((display.height() - tbh) / 2) - tby; + display.setFullWindow(); + display.firstPage(); + do { + display.fillScreen(GxEPD_WHITE); + display.setCursor(x, y); + display.print(header); + } + while (display.nextPage()); #else display.clearDisplay(); display.setTextColor(WHITE); @@ -203,7 +221,21 @@ void show_display(const String& header, const String& line1, const String& line2 tft.print(line6); #else #ifdef HAS_EPAPER - // + display.setRotation(1); + display.setFont(&FreeMonoBold9pt7b); + display.setTextColor(GxEPD_BLACK); + int16_t tbx, tby; uint16_t tbw, tbh; + display.getTextBounds(header, 0, 0, &tbx, &tby, &tbw, &tbh); + uint16_t x = ((display.width() - tbw) / 2) - tbx; // center bounding box by transposition of origin: + uint16_t y = ((display.height() - tbh) / 2) - tby; + display.setFullWindow(); + display.firstPage(); + do { + display.fillScreen(GxEPD_WHITE); + display.setCursor(x, y); + display.print(header); + } + while (display.nextPage()); #else display.clearDisplay(); display.setTextColor(WHITE);