From e70efe35d7f7250ea42bcebee939687fd237bf4b Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Sat, 26 Dec 2020 18:09:11 +0100 Subject: [PATCH] Display message before restarting --- operame.ino | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/operame.ino b/operame.ino index 8f191d8..367bf5e 100644 --- a/operame.ino +++ b/operame.ino @@ -102,6 +102,12 @@ void display_logo() { sprite.pushSprite(0, 0); } +void panic(const String& message) { + display_big(message, TFT_RED); + delay(5000); + ESP.restart(); +} + void setup_ota() { ArduinoOTA.setHostname(WiFiSettings.hostname.c_str()); ArduinoOTA.setPassword(WiFiSettings.password.c_str()); @@ -284,7 +290,9 @@ void setup() { break; } } - if (portal_phase == 0 && millis() > 10*60*1000) ESP.restart(); + if (portal_phase == 0 && millis() > 10*60*1000) { + panic("Tijd verstreken"); + } if (ota_enabled) ArduinoOTA.handle(); if (!digitalRead(portalbutton)) { @@ -311,7 +319,7 @@ void connect_mqtt() { failures = 0; } else { failures++; - if (failures >= max_failures) ESP.restart(); + if (failures >= max_failures) panic("MQTT onbereikbaar"); } } @@ -391,7 +399,7 @@ int get_co2() { if (driver == MHZ) return mhz_get_co2(); // Should be unreachable - ESP.restart(); + panic("driverfout"); return -1; // suppress warning }