From c01a72cf914ee817e3014372a6640a9bd3a7d846 Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Wed, 15 Sep 2021 00:07:46 +0200 Subject: [PATCH] OTA display output fix for TFT --- RX_FSK/RX_FSK.ino | 29 +++++++++++++++++++---------- RX_FSK/src/Display.cpp | 1 + RX_FSK/src/Sonde.h | 2 ++ RX_FSK/src/geteph.cpp | 2 +- RX_FSK/src/geteph.h | 2 +- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index 197b05f..ffeedfa 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -1029,6 +1029,7 @@ const char *handleEditPost(AsyncWebServerRequest *request) { return ""; } +// will be removed. its now in data/upd.html (for GET; POST to update.html still handled here) const char *createUpdateForm(boolean run) { char *ptr = message; strcpy(ptr, "
"); @@ -2865,17 +2866,25 @@ void execOTA() { int contentLength = 0; bool isValidContentType = false; sonde.clearDisplay(); - disp.rdis->setFont(FONT_SMALL); - disp.rdis->drawString(0, 0, "C:"); - String dispHost = updateHost.substring(0, 14); - disp.rdis->drawString(2, 0, dispHost.c_str()); + uint8_t dispxs, dispys; + if( ISOLED(sonde.config) ) { + disp.rdis->setFont(FONT_SMALL); + dispxs = dispys = 1; + } else { + disp.rdis->setFont(5); + dispxs = 18; + dispys = 20; + } + + String dispHost = updateHost.substring(0, 16); + disp.rdis->drawString(0, 0, dispHost.c_str()); Serial.println("Connecting to: " + updateHost); // Connect to Update host if (client.connect(updateHost.c_str(), updatePort)) { // Connection succeeded, fecthing the bin Serial.println("Fetching bin: " + String(*updateBin)); - disp.rdis->drawString(0, 1, "Fetching update"); + disp.rdis->drawString(0, 1 * dispys, "Fetching update"); // Get the contents of the bin file client.print(String("GET ") + *updateBin + " HTTP/1.1\r\n" + @@ -2968,22 +2977,22 @@ void execOTA() { // Check what is the contentLength and if content type is `application/octet-stream` Serial.println("contentLength : " + String(contentLength) + ", isValidContentType : " + String(isValidContentType)); - disp.rdis->drawString(0, 2, "Len: "); + disp.rdis->drawString(0, 2 * dispys, "Len: "); String cls = String(contentLength); - disp.rdis->drawString(5, 2, cls.c_str()); + disp.rdis->drawString(5 * dispxs, 2 * dispys, cls.c_str()); // check contentLength and content type if (contentLength && isValidContentType) { // Check if there is enough to OTA Update bool canBegin = Update.begin(contentLength); - disp.rdis->drawString(0, 4, "Starting update"); + disp.rdis->drawString(0, 4 * dispys, "Starting update"); // If yes, begin if (canBegin) { Serial.println("Begin OTA. This may take 2 - 5 mins to complete. Things might be quite for a while.. Patience!"); // No activity would appear on the Serial monitor // So be patient. This may take 2 - 5mins to complete - disp.rdis->drawString(0, 5, "Please wait!"); + disp.rdis->drawString(0, 5 * dispys, "Please wait!"); size_t written = Update.writeStream(client); if (written == contentLength) { @@ -2998,7 +3007,7 @@ void execOTA() { Serial.println("OTA done!"); if (Update.isFinished()) { Serial.println("Update successfully completed. Rebooting."); - disp.rdis->drawString(0, 7, "Rebooting...."); + disp.rdis->drawString(0, 7 * dispys, "Rebooting...."); delay(1000); ESP.restart(); } else { diff --git a/RX_FSK/src/Display.cpp b/RX_FSK/src/Display.cpp index 0ab5b4c..54d51ac 100644 --- a/RX_FSK/src/Display.cpp +++ b/RX_FSK/src/Display.cpp @@ -336,6 +336,7 @@ const struct gfxoffset_t gfxoffsets[]={ { 13, 18 }, // 17+13-12 "j" { 17, 23 }, // 23+17-17 { 4, 6}, // 6+4-4 + { 25, 34 }, // 34 25 -25 }; static int ngfx = sizeof(gfl)/sizeof(GFXfont *); diff --git a/RX_FSK/src/Sonde.h b/RX_FSK/src/Sonde.h index 524b725..768cb28 100644 --- a/RX_FSK/src/Sonde.h +++ b/RX_FSK/src/Sonde.h @@ -60,6 +60,8 @@ extern const char *sondeTypeLongStr[NSondeTypes]; extern const char sondeTypeChar[NSondeTypes]; extern const char *manufacturer_string[NSondeTypes]; +#define ISOLED(cfg) ((cfg).disptype==0 || (cfg).disptype==2) + #define TYPE_IS_DFM(t) ( (t)==STYPE_DFM ) #define TYPE_IS_METEO(t) ( (t)==STYPE_M10 || (t)==STYPE_M20 ) diff --git a/RX_FSK/src/geteph.cpp b/RX_FSK/src/geteph.cpp index 898e72a..c6f1d86 100644 --- a/RX_FSK/src/geteph.cpp +++ b/RX_FSK/src/geteph.cpp @@ -14,7 +14,7 @@ extern WiFiClient client; char outbuf[128]; uint8_t ephstate = EPH_NOTUSED; //enum EPHSTATE { EPH_NOTUSED, EPH_PENDING, EPH_TIMEERR, EPH_ERROR, EPH_EPHERROR, EPH_GOOD }; -char *ephtxt[] = { "Disabled", "Pending", "Time error", "Fetch error", "Read error", "Good" }; +const char *ephtxt[] = { "Disabled", "Pending", "Time error", "Fetch error", "Read error", "Good" }; uint8_t getreply() { String s = client.readStringUntil('\n'); diff --git a/RX_FSK/src/geteph.h b/RX_FSK/src/geteph.h index 908208d..eca58f0 100644 --- a/RX_FSK/src/geteph.h +++ b/RX_FSK/src/geteph.h @@ -7,5 +7,5 @@ void geteph(); enum EPHSTATE { EPH_NOTUSED, EPH_PENDING, EPH_TIMEERR, EPH_ERROR, EPH_EPHERROR, EPH_GOOD }; extern uint8_t ephstate; -extern char *ephtxt[]; +extern const char *ephtxt[]; #endif