Skip to content

Commit

Permalink
Enable/disable MQTT menu based on activeWIFI status and prevent unnec…
Browse files Browse the repository at this point in the history
…essary screen fill when wifiChanged and not inMenu

Fix WiFi initialitation issues with display and menu when WiFi activated from menu
  • Loading branch information
melkati committed Jan 30, 2024
1 parent d6ab6a3 commit 152baf7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 7 additions & 1 deletion CO2_Gadget_Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -1013,8 +1013,14 @@ void menuLoop() {
return;
}

if (activeWIFI) {
activeMQTTMenu[0].enable();
} else {
activeMQTTMenu[0].disable();
}

#if defined(SUPPORT_TFT)
if (wifiChanged) {
if ((wifiChanged) && (!inMenu)) {
wifiChanged = false;
tft.fillScreen(TFT_BLACK);
}
Expand Down
4 changes: 2 additions & 2 deletions CO2_Gadget_WIFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -723,15 +723,15 @@ void wifiClientLoop() {

// This is a workaround until I can directly determine whether the Wi-Fi data has been changed via BLE
// Only checks for SSID changed (not password)
if (WiFi.SSID() != wifiSSID) {
if ((WiFi.SSID() != wifiSSID) && (!inMenu)) {
Serial.println("-->[WiFi] Wi-Fi SSID changed. Old SSID: " + wifiSSID + ", new SSID: " + WiFi.SSID());
wifiSSID = WiFi.SSID();
putPreferences();
// initWifi();
wifiChanged = true;
}

if (wifiChanged) {
if ((wifiChanged) && (!inMenu)) {
wifiChanged = false;
initWifi();
}
Expand Down
6 changes: 3 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ build_flags =
'-DWIFI_PW_CREDENTIALS=""'

-D MQTT_BROKER_SERVER="\"192.168.1.145"\"
-D CO2_GADGET_VERSION="\"0.8."\"
-D CO2_GADGET_REV="\"092-development"\"
-D CO2_GADGET_VERSION="\"0.9."\"
-D CO2_GADGET_REV="\"001-development"\"
-D CORE_DEBUG_LEVEL=0
-DNEOPIXEL_PIN=26 ; Pinnumber for button for down/next and back / exit actions
-DNEOPIXEL_COUNT=16 ; How many neopixels to control
Expand All @@ -84,7 +84,7 @@ build_flags =
-DMQTT_DISCOVERY_PREFIX="\"homeassistant/\""
-DESPNOW_PEER_MAC_ADDRESS="{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}" ; MAC Address of the ESP-NOW receiver (STA MAC). For unicast use peer address, as: {0xE8, 0x68, 0xE7, 0x0F, 0x08, 0x90}
-DESPNOW_WIFI_CH=1 ; ESP-NOW WiFi Channel. Must be same as gateway
; -DDEBUG_ARDUINOMENU
-DUEBUG_ARDUINOMENU
; -DMENU_DEBUG ; Needs streamFlow library
-Os ; Optimize compilation for use memory
-w ; Supress compilation warnings
Expand Down

0 comments on commit 152baf7

Please sign in to comment.