From 0f2e28ebeeeb515c1ebb674ce7633ee7a48602ec Mon Sep 17 00:00:00 2001 From: Clemens <41959005+Martinius79@users.noreply.github.com> Date: Thu, 31 Oct 2024 22:52:45 +0100 Subject: [PATCH] Added different text colours to the setup sequence (#94) * Added some colours to the setup sequence * Removed format stuff --- EleksTubeHAX_pio/src/WiFi_WPS.cpp | 25 ++++++----- EleksTubeHAX_pio/src/main.cpp | 75 +++++++++++++++++++++---------- 2 files changed, 64 insertions(+), 36 deletions(-) diff --git a/EleksTubeHAX_pio/src/WiFi_WPS.cpp b/EleksTubeHAX_pio/src/WiFi_WPS.cpp index de267ea..4ebe350 100644 --- a/EleksTubeHAX_pio/src/WiFi_WPS.cpp +++ b/EleksTubeHAX_pio/src/WiFi_WPS.cpp @@ -98,9 +98,9 @@ void WifiBegin() { } else { // data is saved, connect now // WiFi credentials are known, connect - tfts.println("Joining wifi"); + tfts.println("Joining WiFi"); tfts.println(stored_config.config.wifi.ssid); - Serial.print("Joining wifi "); + Serial.print("Joining WiFi "); Serial.println(stored_config.config.wifi.ssid); // https://stackoverflow.com/questions/48024780/esp32-wps-reconnect-on-power-on @@ -121,18 +121,20 @@ void WifiBegin() { } } } -#else ////NO WPS -- Hard coded credentials +#else //NO WPS -- Try using hard coded credentials WiFi.begin(WIFI_SSID, WIFI_PASSWD); WiFi.onEvent(WiFiEvent); unsigned long StartTime = millis(); while ((WiFi.status() != WL_CONNECTED)) { delay(500); - tfts.print("."); - Serial.print("."); + tfts.print(">"); + Serial.print(">"); if ((millis() - StartTime) > (WIFI_CONNECT_TIMEOUT_SEC * 1000)) { - Serial.println("\r\nWiFi connection timeout!"); + tfts.setTextColor(TFT_RED, TFT_BLACK); tfts.println("\nTIMEOUT!"); + tfts.setTextColor(TFT_WHITE, TFT_BLACK); + Serial.println("\r\nWiFi connection timeout!"); WifiState = disconnected; return; // exit loop, exit procedure, continue clock startup } @@ -142,10 +144,9 @@ void WifiBegin() { WifiState = connected; - - tfts.println("\n Connected!"); - tfts.println(WiFi.localIP()); + tfts.println("\nConnected! IP:"); + tfts.println(WiFi.localIP()); Serial.println(""); Serial.print("Connected to "); Serial.println(WiFi.SSID()); @@ -168,7 +169,7 @@ void WiFiStartWps() { sprintf(stored_config.config.wifi.ssid, ""); sprintf(stored_config.config.wifi.password, ""); stored_config.config.wifi.WPS_connected = 0x11; // invalid = different than 0x55 - Serial.print("Saving config."); + Serial.println(""); Serial.print("Saving config! Triggered from WPS start..."); stored_config.save(); Serial.println(" Done."); @@ -199,13 +200,13 @@ void WiFiStartWps() { Serial.print("."); } tfts.setTextColor(TFT_WHITE, TFT_BLACK); - Serial.print("Saving config."); - sprintf(stored_config.config.wifi.ssid, "%s", WiFi.SSID()); + sprintf(stored_config.config.wifi.ssid, "%s", WiFi.SSID()); // memset(stored_config.config.wifi.ssid, '\0', sizeof(stored_config.config.wifi.ssid)); // strcpy(stored_config.config.wifi.ssid, WiFi.SSID()); sprintf(stored_config.config.wifi.password, ""); // can't save a password from WPS stored_config.config.wifi.WPS_connected = StoredConfig::valid; + Serial.println(); Serial.print("Saving config! Triggered from WPS success..."); stored_config.save(); Serial.println(" WPS finished."); } diff --git a/EleksTubeHAX_pio/src/main.cpp b/EleksTubeHAX_pio/src/main.cpp index 00ab517..8d1cad9 100644 --- a/EleksTubeHAX_pio/src/main.cpp +++ b/EleksTubeHAX_pio/src/main.cpp @@ -74,26 +74,33 @@ void setup() { buttons.begin(); menu.begin(); -#ifdef HARDWARE_NovelLife_SE_CLOCK // NovelLife_SE Clone XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - //Init the Gesture sensor - tfts.println("Gesture sensor start"); - GestureStart(); //TODO put into class -#endif - // Setup the displays (TFTs) initaly and show bootup message(s) tfts.begin(); // and count number of clock faces available tfts.fillScreen(TFT_BLACK); tfts.setTextColor(TFT_WHITE, TFT_BLACK); tfts.setCursor(0, 0, 2); // Font 2. 16 pixel high - tfts.println("setup..."); + tfts.println("Starting Setup..."); + +#ifdef HARDWARE_NovelLife_SE_CLOCK // NovelLife_SE Clone XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + //Init the Gesture sensor + tfts.setTextColor(TFT_ORANGE, TFT_BLACK); + tfts.print("Gest start..."); + Serial.print("Gesture Sensor start..."); + GestureStart(); //TODO put into class + tfts.println("Done!"); + Serial.println("Done!"); + tfts.setTextColor(TFT_WHITE, TFT_BLACK); +#endif // Setup WiFi connection. Must be done before setting up Clock. // This is done outside Clock so the network can be used for other things. -// WiFiBegin(&stored_config.config.wifi); - tfts.println("WiFi start"); + tfts.setTextColor(TFT_DARKGREEN, TFT_BLACK); + tfts.println("WiFi start..."); + Serial.println("WiFi start..."); WifiBegin(); - - // wait for a bit before querying NTP + tfts.setTextColor(TFT_WHITE, TFT_BLACK); + + // wait a bit (5x100ms = 0.5 sec) before querying NTP for (uint8_t ndx=0; ndx < 5; ndx++) { tfts.print(">"); delay(100); @@ -101,25 +108,44 @@ void setup() { tfts.println(""); // Setup the clock. It needs WiFi to be established already. - tfts.println("Clock start"); + tfts.setTextColor(TFT_MAGENTA, TFT_BLACK); + tfts.print("Clock start..."); + Serial.print("Clock start..."); uclock.begin(&stored_config.config.uclock); + tfts.println("Done!"); + Serial.println("Done!"); + tfts.setTextColor(TFT_WHITE, TFT_BLACK); // Setup MQTT - tfts.println("MQTT start"); + tfts.setTextColor(TFT_YELLOW, TFT_BLACK); + tfts.print("MQTT start..."); + Serial.print("MQTT start..."); MqttStart(); + tfts.println("Done!"); + Serial.println("Done!"); + tfts.setTextColor(TFT_WHITE, TFT_BLACK); #ifdef GEOLOCATION_ENABLED - tfts.println("Geoloc query"); + tfts.setTextColor(TFT_NAVY, TFT_BLACK); + tfts.println("GeoLoc query..."); + Serial.println("GeoLoc query..."); if (GetGeoLocationTimeZoneOffset()) { tfts.print("TZ: "); + Serial.print("TZ: "); tfts.println(GeoLocTZoffset); + Serial.println(GeoLocTZoffset); uclock.setTimeZoneOffset(GeoLocTZoffset * 3600); - Serial.print("Saving config..."); - stored_config.save(); - Serial.println(" Done."); + Serial.println(); + Serial.print("Saving config! Triggerd by timezone change..."); + stored_config.save(); + tfts.println("Done!"); + Serial.println("Done!"); + tfts.setTextColor(TFT_WHITE, TFT_BLACK); } else { - Serial.println("Geolocation failed."); - tfts.println("Geo FAILED"); + tfts.setTextColor(TFT_RED, TFT_BLACK); + tfts.println("GeoLoc FAILED"); + Serial.println("GeoLoc failed!"); + tfts.setTextColor(TFT_WHITE, TFT_BLACK); } #endif @@ -133,9 +159,11 @@ void setup() { } tfts.current_graphic = uclock.getActiveGraphicIdx(); - tfts.println("Done with setup."); + tfts.setTextColor(TFT_WHITE, TFT_BLACK); + tfts.println("Done with Setup!"); + Serial.println("Done with Setup!"); - // Leave boot up messages on screen for a few seconds. + // Leave boot up messages on screen for a few seconds (10x200ms = 2 sec) for (uint8_t ndx=0; ndx < 10; ndx++) { tfts.print(">"); delay(200); @@ -144,7 +172,7 @@ void setup() { // Start up the clock displays. tfts.fillScreen(TFT_BLACK); uclock.loop(); - updateClockDisplay(TFTs::force); + updateClockDisplay(TFTs::force); // Draw all the clock digits Serial.println("Setup finished."); } @@ -383,8 +411,7 @@ void loop() { EveryFullHour(true); // night or daytime - // Update the clock. - updateClockDisplay(); + updateClockDisplay(); // Draw only the changed clock digits! UpdateDstEveryNight();