diff --git a/Platformio/src/gui_general_and_keys/guiBase.cpp b/Platformio/src/gui_general_and_keys/guiBase.cpp index fd8724c..a54d477 100644 --- a/Platformio/src/gui_general_and_keys/guiBase.cpp +++ b/Platformio/src/gui_general_and_keys/guiBase.cpp @@ -6,7 +6,7 @@ lv_obj_t* panel; lv_color_t color_primary = lv_color_hex(0x303030); // gray -lv_obj_t* WifiLabel; +lv_obj_t* WifiLabel = NULL; lv_obj_t* BluetoothLabel; lv_obj_t* objBattPercentage; lv_obj_t* objBattIcon; diff --git a/Platformio/src/hardware/mqtt.cpp b/Platformio/src/hardware/mqtt.cpp index 7ab3ea9..3c80c19 100644 --- a/Platformio/src/hardware/mqtt.cpp +++ b/Platformio/src/hardware/mqtt.cpp @@ -21,10 +21,10 @@ void WiFiEvent(WiFiEvent_t event){ // Set status bar icon based on WiFi status if (event == ARDUINO_EVENT_WIFI_STA_GOT_IP || event == ARDUINO_EVENT_WIFI_STA_GOT_IP6) { - lv_label_set_text(WifiLabel, LV_SYMBOL_WIFI); + if (WifiLabel != NULL) {lv_label_set_text(WifiLabel, LV_SYMBOL_WIFI);} } else if (event == ARDUINO_EVENT_WIFI_STA_DISCONNECTED) { - lv_label_set_text(WifiLabel, ""); + if (WifiLabel != NULL) {lv_label_set_text(WifiLabel, "");} // automatically try to reconnect Serial.printf("WiFi got disconnected. Will try to reconnect.\r\n"); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); @@ -32,7 +32,7 @@ void WiFiEvent(WiFiEvent_t event){ } else { // e.g. ARDUINO_EVENT_WIFI_STA_CONNECTED or many others // connected is not enough, will wait for IP - lv_label_set_text(WifiLabel, ""); + if (WifiLabel != NULL) {lv_label_set_text(WifiLabel, "");} } }