diff --git a/src/graphics/niche/InkHUD/Applet.cpp b/src/graphics/niche/InkHUD/Applet.cpp index 9fda9a87e..459f30213 100644 --- a/src/graphics/niche/InkHUD/Applet.cpp +++ b/src/graphics/niche/InkHUD/Applet.cpp @@ -582,9 +582,12 @@ std::string InkHUD::Applet::getTimeString(uint32_t epochSeconds) uint32_t hour = hms / SEC_PER_HOUR; uint32_t min = (hms % SEC_PER_HOUR) / SEC_PER_MIN; - // Format the clock string + // Format the clock string, either 12 hour or 24 hour char clockStr[11]; - sprintf(clockStr, "%u:%02u %s", (hour % 12 == 0 ? 12 : hour % 12), min, hour > 11 ? "PM" : "AM"); + if (config.display.use_12h_clock) + sprintf(clockStr, "%u:%02u %s", (hour % 12 == 0 ? 12 : hour % 12), min, hour > 11 ? "PM" : "AM"); + else + sprintf(clockStr, "%02u:%02u", hour, min); return clockStr; } diff --git a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuAction.h b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuAction.h index 6950bb110..4f8205647 100644 --- a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuAction.h +++ b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuAction.h @@ -22,15 +22,17 @@ enum MenuAction { SEND_POSITION, SHUTDOWN, NEXT_TILE, + TOGGLE_BACKLIGHT, + TOGGLE_GPS, + ENABLE_BLUETOOTH, TOGGLE_APPLET, - ACTIVATE_APPLETS, // Todo: remove? Possible redundant, handled by TOGGLE_APPLET? TOGGLE_AUTOSHOW_APPLET, SET_RECENTS, ROTATE, LAYOUT, TOGGLE_BATTERY_ICON, TOGGLE_NOTIFICATIONS, - TOGGLE_BACKLIGHT, + TOGGLE_12H_CLOCK, }; } // namespace NicheGraphics::InkHUD diff --git a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp index 7397f7e9f..4c411bb85 100644 --- a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp +++ b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp @@ -5,8 +5,13 @@ #include "RTC.h" #include "airtime.h" +#include "main.h" #include "power.h" +#if !MESHTASTIC_EXCLUDE_GPS +#include "GPS.h" +#endif + using namespace NicheGraphics; static constexpr uint8_t MENU_TIMEOUT_SEC = 60; // How many seconds before menu auto-closes @@ -161,12 +166,6 @@ void InkHUD::MenuApplet::execute(MenuItem item) case TOGGLE_APPLET: settings->userApplets.active[cursor] = !settings->userApplets.active[cursor]; inkhud->updateAppletSelection(); - // requestUpdate(Drivers::EInk::UpdateTypes::FULL); // Select FULL, seeing how this action doesn't auto exit - break; - - case ACTIVATE_APPLETS: - // Todo: remove this action? Already handled by TOGGLE_APPLET? - inkhud->updateAppletSelection(); break; case TOGGLE_AUTOSHOW_APPLET: @@ -205,6 +204,25 @@ void InkHUD::MenuApplet::execute(MenuItem item) backlight->latch(); break; + case TOGGLE_12H_CLOCK: + config.display.use_12h_clock = !config.display.use_12h_clock; + nodeDB->saveToDisk(SEGMENT_CONFIG); + break; + + case TOGGLE_GPS: + gps->toggleGpsMode(); + nodeDB->saveToDisk(SEGMENT_CONFIG); + break; + + case ENABLE_BLUETOOTH: + // This helps users recover from a bad wifi config + LOG_INFO("Enabling Bluetooth"); + config.network.wifi_enabled = false; + config.bluetooth.enabled = true; + nodeDB->saveToDisk(); + rebootAtMsec = millis() + 2000; + break; + default: LOG_WARN("Action not implemented"); } @@ -242,13 +260,21 @@ void InkHUD::MenuApplet::showPage(MenuPage page) case OPTIONS: // Optional: backlight - if (settings->optionalMenuItems.backlight) { - assert(backlight); + if (settings->optionalMenuItems.backlight) items.push_back(MenuItem(backlight->isLatched() ? "Backlight Off" : "Keep Backlight On", // Label MenuAction::TOGGLE_BACKLIGHT, // Action MenuPage::EXIT // Exit once complete )); - } + + // Optional: GPS + if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_DISABLED) + items.push_back(MenuItem("Enable GPS", MenuAction::TOGGLE_GPS, MenuPage::EXIT)); + if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED) + items.push_back(MenuItem("Disable GPS", MenuAction::TOGGLE_GPS, MenuPage::EXIT)); + + // Optional: Enable Bluetooth, in case of lost wifi connection + if (!config.bluetooth.enabled || config.network.wifi_enabled) + items.push_back(MenuItem("Enable Bluetooth", MenuAction::ENABLE_BLUETOOTH, MenuPage::EXIT)); items.push_back(MenuItem("Applets", MenuPage::APPLETS)); items.push_back(MenuItem("Auto-show", MenuPage::AUTOSHOW)); @@ -260,26 +286,14 @@ void InkHUD::MenuApplet::showPage(MenuPage page) &settings->optionalFeatures.notifications)); items.push_back(MenuItem("Battery Icon", MenuAction::TOGGLE_BATTERY_ICON, MenuPage::OPTIONS, &settings->optionalFeatures.batteryIcon)); - - // TODO - GPS and Wifi switches - /* - // Optional: has GPS - if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_DISABLED) - items.push_back(MenuItem("Enable GPS", MenuPage::EXIT)); // TODO - if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED) - items.push_back(MenuItem("Disable GPS", MenuPage::EXIT)); // TODO - - // Optional: using wifi - if (!config.bluetooth.enabled) - items.push_back(MenuItem("Enable Bluetooth", MenuPage::EXIT)); // TODO: escape hatch if wifi configured wrong - */ - + items.push_back( + MenuItem("12-Hour Clock", MenuAction::TOGGLE_12H_CLOCK, MenuPage::OPTIONS, &config.display.use_12h_clock)); items.push_back(MenuItem("Exit", MenuPage::EXIT)); break; case APPLETS: populateAppletPage(); - items.push_back(MenuItem("Exit", MenuAction::ACTIVATE_APPLETS)); + items.push_back(MenuItem("Exit", MenuPage::EXIT)); break; case AUTOSHOW: @@ -293,7 +307,6 @@ void InkHUD::MenuApplet::showPage(MenuPage page) case EXIT: sendToBackground(); // Menu applet dismissed, allow normal behavior to resume - // requestUpdate(Drivers::EInk::UpdateTypes::FULL); break; default: