From f80c314247af673bce101f38dfea47d9d57cd846 Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Sat, 30 Mar 2024 16:33:45 +0100 Subject: [PATCH] Add IP address to splash screen --- src/config.cpp | 1 + src/epd.cpp | 33 ++++++++++++++++++++++++++------- src/epd.hpp | 3 ++- src/main.cpp | 2 -- src/shared.hpp | 1 + 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index a9ebdf8..2486370 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -154,6 +154,7 @@ void setupWifi() Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); + epdShowIp(); // WiFi.setTxPower(WIFI_POWER_8_5dBm); // enableWiFi(); } diff --git a/src/epd.cpp b/src/epd.cpp index 65a50cf..ec23ee6 100644 --- a/src/epd.cpp +++ b/src/epd.cpp @@ -22,14 +22,14 @@ void setupDisplay() display.setRotation(1); display.setFont(&Antonio_SemiBold20pt7b); display.setTextColor(GxEPD_WHITE); - int16_t tbx, tby; - uint16_t tbw, tbh; - display.getTextBounds("OrangeBTClock", 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; + // int16_t tbx, tby; + // uint16_t tbw, tbh; + // display.getTextBounds("OrangeBTClock", 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; display.fillScreen(GxEPD_BLACK); - display.setCursor(x, y); + // display.setCursor(x, y); // display.print("OrangeBTClock"); // display.drawImage(epd_bitmap_allArray[0], GxEPD_WHITE, 0,0 250,37); @@ -39,6 +39,9 @@ void setupDisplay() display.drawBitmap(xPos,yPos, epd_bitmap_oclogo, 250, 37, GxEPD_WHITE); display.display(false); + display.setCursor(0, 37); + + // display.fillScreen(GxEPD_WHITE); // display.drawLine(0, 10, display.width(), 10, GxEPD_BLACK); // display.drawLine(0, row2, display.width(), row2, GxEPD_BLACK); @@ -70,6 +73,22 @@ void setupDisplay() // display.display(true); } +void epdShowIp() { + display.setRotation(1); + display.setFont(&LibreFranklin_SemiBold10pt7b); + display.setTextColor(GxEPD_WHITE); + String ipStr = WiFi.localIP().toString(); + int16_t tbx, tby; + uint16_t tbw, tbh; + display.getTextBounds(ipStr, 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 + 37; + display.setCursor(x, y); + display.println(WiFi.localIP()); + display.display(true); +} + void updateRow2(String c, char icon) { if (c.equals(currentRow2) && icon == currentIcon2) diff --git a/src/epd.hpp b/src/epd.hpp index 44d00b2..c566001 100644 --- a/src/epd.hpp +++ b/src/epd.hpp @@ -9,4 +9,5 @@ void showSetupText(String t); void updateRow1(String c, char icon); void updateRow2(String c, char icon); void updateRow3(String c, char icon); -void updateRows(String row1Content, String row2Content, String row3Content); \ No newline at end of file +void updateRows(String row1Content, String row2Content, String row3Content); +void epdShowIp(); \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 2647688..fe130cc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,8 +42,6 @@ void setup() { // setCpuFrequencyMhz(40); Serial.begin(115200); - delay(2500); - Serial.println("Hello"); #ifndef IS_ORANGECLOCK pinMode(LED_BUILTIN, OUTPUT); diff --git a/src/shared.hpp b/src/shared.hpp index 2d99256..f0264e8 100644 --- a/src/shared.hpp +++ b/src/shared.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #ifdef VERSION_EPD_2_13 #define EPD_CLASS GxEPD2_213_B74