From b4ee49c7317dfb5180e8f689ec9f5ee66313ae9f Mon Sep 17 00:00:00 2001 From: richonguzman Date: Sat, 11 Nov 2023 12:17:09 -0300 Subject: [PATCH] menu update --- src/LoRa_APRS_Tracker.cpp | 3 +- src/bluetooth_utils.cpp | 5 ++- src/keyboard_utils.cpp | 16 ++++---- src/menu_utils.cpp | 80 +++++++++++++++++++++++++++------------ src/menu_utils.h | 4 +- 5 files changed, 72 insertions(+), 36 deletions(-) diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index 9b01899..8e0c7b4 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -33,7 +33,7 @@ TinyGPSPlus gps; BluetoothSerial SerialBT; OneButton userButton = OneButton(BUTTON_PIN, true, true); -String versionDate = "2023.11.07"; +String versionDate = "2023.11.11"; int myBeaconsIndex = 0; int myBeaconsSize = Config.beacons.size(); @@ -55,6 +55,7 @@ bool sendStandingUpdate = false; bool statusState = true; uint32_t statusTime = millis(); bool bluetoothConnected = false; +bool bluetoothActive = Config.bluetooth; bool messageLed = false; uint32_t messageLedTime = millis(); diff --git a/src/bluetooth_utils.cpp b/src/bluetooth_utils.cpp index c7f7555..5b331ee 100644 --- a/src/bluetooth_utils.cpp +++ b/src/bluetooth_utils.cpp @@ -13,6 +13,7 @@ extern BluetoothSerial SerialBT; extern logging::Logger logger; extern TinyGPSPlus gps; extern bool bluetoothConnected; +extern bool bluetoothActive; namespace BLUETOOTH_Utils { String serialReceived; @@ -20,7 +21,7 @@ namespace BLUETOOTH_Utils { bool useKiss = false; void setup() { - if (!Config.bluetooth) { + if (!bluetoothActive) { btStop(); esp_bt_controller_disable(); logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "BT controller disabled"); @@ -136,7 +137,7 @@ namespace BLUETOOTH_Utils { } void sendPacket(const String& packet) { - if (Config.bluetooth && !packet.isEmpty()) { + if (bluetoothActive && !packet.isEmpty()) { if (useKiss) { logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "BT RX Kiss", "%s", serialReceived.c_str()); diff --git a/src/keyboard_utils.cpp b/src/keyboard_utils.cpp index 483638d..13ab29a 100644 --- a/src/keyboard_utils.cpp +++ b/src/keyboard_utils.cpp @@ -47,10 +47,10 @@ namespace KEYBOARD_Utils { if (menuDisplay < 10) { menuDisplay = 12; } - } else if (menuDisplay >= 20 && menuDisplay <= 25) { + } else if (menuDisplay >= 20 && menuDisplay <= 26) { menuDisplay--; if (menuDisplay < 20) { - menuDisplay = 25; + menuDisplay = 26; } } else if (menuDisplay >= 210 && menuDisplay <= 211) { menuDisplay--; @@ -106,9 +106,9 @@ namespace KEYBOARD_Utils { menuDisplay = 11; } - else if (menuDisplay >= 20 && menuDisplay <= 25) { + else if (menuDisplay >= 20 && menuDisplay <= 26) { menuDisplay++; - if (menuDisplay > 25) { + if (menuDisplay > 26) { menuDisplay = 20; } } else if (menuDisplay >= 210 && menuDisplay <= 211) { @@ -201,11 +201,11 @@ namespace KEYBOARD_Utils { show_display("_SCREEN___", "", "SCREEN BRIGHTNESS MIN", 1000); screenBrightness = 1; } - } else if (menuDisplay == 220) { - show_display("_STATUS___", "", "WRITE STATUS","STILL IN DEVELOPMENT!", 2000); ///////////////////////// - } else if (menuDisplay == 221) { - show_display("_STATUS___", "", "SELECT STATUS","STILL IN DEVELOPMENT!", 2000); ///////////////////////// } else if (menuDisplay == 230) { + show_display("_STATUS___", "", "WRITE STATUS","STILL IN DEVELOPMENT!", 2000); ///////////////////////// + } else if (menuDisplay == 231) { + show_display("_STATUS___", "", "SELECT STATUS","STILL IN DEVELOPMENT!", 2000); ///////////////////////// + } else if (menuDisplay == 240) { show_display("_NOTIFIC__", "", "NOTIFICATIONS","STILL IN DEVELOPMENT!", 2000); ///////////////////////// } diff --git a/src/menu_utils.cpp b/src/menu_utils.cpp index 22c0d70..77e6648 100644 --- a/src/menu_utils.cpp +++ b/src/menu_utils.cpp @@ -27,11 +27,30 @@ extern String messageCallsign; extern String messageText; extern bool digirepeaterActive; extern bool sosActive; +extern bool bluetoothActive; +extern bool displayEcoMode; +extern bool screenBrightness; -String digi, sos; +//String digi, sos, bt; namespace MENU_Utils { + String checkProcessActive(bool process) { + if (process) { + return "ON"; + } else { + return "OFF"; + } + } + + String checkScreenBrightness(int bright) { + if (bright == 255) { + return "MAX"; + } else { + return "MIN"; + } + } + void showOnScreen() { String lastLine; uint32_t lastMenuTime = millis() - menuTime; @@ -106,57 +125,70 @@ namespace MENU_Utils { show_display("DELETE_MSG", "", " DELETE ALL?", "", "", " Confirm = LP or '>'"); break; - case 20: // 2.Configuration ---> Callsign - show_display("_CONFIG___", " Power Off", "> Callsign Change"," Display", " Status",lastLine); + show_display("_CONFIG___", " Power Off", "> Callsign Change"," Display", " Bluetooth (" + checkProcessActive(bluetoothActive) + ")",lastLine); break; case 21: // 2.Configuration ---> Display - show_display("_CONFIG___", " Callsign Change", "> Display", " Status", " Notifications",lastLine); + show_display("_CONFIG___", " Callsign Change", "> Display", " Bluetooth (" + checkProcessActive(bluetoothActive) + ")", " Status",lastLine); break; - case 22: // 2.Configuration ---> Status - show_display("_CONFIG___", " Display", "> Status", " Notifications", " Reboot", lastLine); + case 22: // 2.Configuration ---> Bluetooth + show_display("_CONFIG___", " Display", "> Bluetooth (" + checkProcessActive(bluetoothActive) + ")", " Status", " Notifications", lastLine); break; - case 23: // 2.Configuration ---> Notifications - show_display("_CONFIG___", " Status","> Notifications", " Reboot", " Power Off",lastLine); + case 23: // 2.Configuration ---> Status + show_display("_CONFIG___", " Bluetooth (" + checkProcessActive(bluetoothActive) + ")", "> Status"," Notifications", " Reboot",lastLine); break; - case 24: // 2.Configuration ---> Reboot + case 24: // 2.Configuration ---> Notifications + show_display("_CONFIG___", " Status", "> Notifications", " Reboot", " Power Off",lastLine); + break; + case 25: // 2.Configuration ---> Reboot show_display("_CONFIG___", " Notifications", "> Reboot", " Power Off", " Callsign Change",lastLine); break; - case 25: // 2.Configuration ---> Power Off + case 26: // 2.Configuration ---> Power Off show_display("_CONFIG___", " Reboot", "> Power Off", " Callsign Change", " Display",lastLine); break; - + case 200: // 2.Configuration ---> Callsign show_display("_CALLSIGN_", ""," Confirm Change?","",""," Display ---> ECO Mode - show_display("_DISPLAY__", "", "> ECO Mode"," Brightness","",lastLine); + show_display("_DISPLAY__", "", "> ECO Mode (" + checkProcessActive(displayEcoMode) + ")"," Brightness (" + checkScreenBrightness(screenBrightness) + ")","",lastLine); break; case 211: // 2.Configuration ---> Display ---> Brightness - show_display("_DISPLAY__", "", " ECO Mode","> Brightness","",lastLine); + show_display("_DISPLAY__", "", " ECO Mode (" + checkProcessActive(displayEcoMode) + ")","> Brightness (" + checkScreenBrightness(screenBrightness) + ")","",lastLine); break; - case 220: // 2.Configuration ---> Status + case 220: + if (bluetoothActive) { + bluetoothActive = false; + show_display("BLUETOOTH", "", " Bluetooth --> OFF", 1000); + } else { + bluetoothActive = true; + show_display("BLUETOOTH", "", " Bluetooth --> ON", 1000); + } + menuDisplay = 22; + break; + + case 230: // 2.Configuration ---> Status show_display("_STATUS___", "", "> Write"," Select","",lastLine); break; - case 221: // 2.Configuration ---> Status + case 231: // 2.Configuration ---> Status show_display("_STATUS___", "", " Write","> Select","",lastLine); break; - case 230: // 2.Configuration ---> Notifications + case 240: // 2.Configuration ---> Notifications show_display("_NOTIFIC__", "> Turn Off Sound/Led","","","",lastLine); break; - case 240: // 2.Configuration ---> Reboot + case 250: // 2.Configuration ---> Reboot if (keyDetected) { show_display("_REBOOT?__", "","Confirm Reboot...","",""," Power Off + case 260: // 2.Configuration ---> Power Off if (keyDetected) { show_display("POWER_OFF?", "","Confirm Power Off...","",""," Digirepeater - if (digirepeaterActive) { + /*if (digirepeaterActive) { digi = "ON"; } else { digi = "OFF"; @@ -184,11 +216,11 @@ namespace MENU_Utils { sos = "ON"; } else { sos = "OFF"; - } - show_display("EMERGENCY_", "", "> DigiRepeater (" + digi + ")", " S.O.S. (" + sos + ")","",lastLine); + }*/ + show_display("EMERGENCY_", "", "> DigiRepeater (" + checkProcessActive(digirepeaterActive) + ")", " S.O.S. (" + checkProcessActive(sosActive) + ")","",lastLine); break; case 61: // 6. Emergency ---> S.O.S. - if (digirepeaterActive) { + /*if (digirepeaterActive) { digi = "ON"; } else { digi = "OFF"; @@ -197,8 +229,8 @@ namespace MENU_Utils { sos = "ON"; } else { sos = "OFF"; - } - show_display("EMERGENCY_", "", " DigiRepeater (" + digi + ")", "> S.O.S. (" + sos + ")","",lastLine); + }*/ + show_display("EMERGENCY_", "", " DigiRepeater (" + checkProcessActive(digirepeaterActive) + ")", "> S.O.S. (" + checkProcessActive(sosActive) + ")","",lastLine); break; case 0: ///////////// MAIN MENU ////////////// diff --git a/src/menu_utils.h b/src/menu_utils.h index 5da2855..9ada262 100644 --- a/src/menu_utils.h +++ b/src/menu_utils.h @@ -5,7 +5,9 @@ namespace MENU_Utils { -void showOnScreen(); + String checkProcessActive(bool process); + String checkScreenBrightness(int bright); + void showOnScreen(); }