mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-09 06:32:06 +00:00
feat: more toggles for InkHUD menu (#6469)
GPS on/off Wifi off -> Bluetooth on 12 / 24 hour clock
This commit is contained in:
parent
f626f02005
commit
da26ff5b95
@ -582,9 +582,12 @@ std::string InkHUD::Applet::getTimeString(uint32_t epochSeconds)
|
|||||||
uint32_t hour = hms / SEC_PER_HOUR;
|
uint32_t hour = hms / SEC_PER_HOUR;
|
||||||
uint32_t min = (hms % SEC_PER_HOUR) / SEC_PER_MIN;
|
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];
|
char clockStr[11];
|
||||||
|
if (config.display.use_12h_clock)
|
||||||
sprintf(clockStr, "%u:%02u %s", (hour % 12 == 0 ? 12 : hour % 12), min, hour > 11 ? "PM" : "AM");
|
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;
|
return clockStr;
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,17 @@ enum MenuAction {
|
|||||||
SEND_POSITION,
|
SEND_POSITION,
|
||||||
SHUTDOWN,
|
SHUTDOWN,
|
||||||
NEXT_TILE,
|
NEXT_TILE,
|
||||||
|
TOGGLE_BACKLIGHT,
|
||||||
|
TOGGLE_GPS,
|
||||||
|
ENABLE_BLUETOOTH,
|
||||||
TOGGLE_APPLET,
|
TOGGLE_APPLET,
|
||||||
ACTIVATE_APPLETS, // Todo: remove? Possible redundant, handled by TOGGLE_APPLET?
|
|
||||||
TOGGLE_AUTOSHOW_APPLET,
|
TOGGLE_AUTOSHOW_APPLET,
|
||||||
SET_RECENTS,
|
SET_RECENTS,
|
||||||
ROTATE,
|
ROTATE,
|
||||||
LAYOUT,
|
LAYOUT,
|
||||||
TOGGLE_BATTERY_ICON,
|
TOGGLE_BATTERY_ICON,
|
||||||
TOGGLE_NOTIFICATIONS,
|
TOGGLE_NOTIFICATIONS,
|
||||||
TOGGLE_BACKLIGHT,
|
TOGGLE_12H_CLOCK,
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace NicheGraphics::InkHUD
|
} // namespace NicheGraphics::InkHUD
|
||||||
|
@ -5,8 +5,13 @@
|
|||||||
#include "RTC.h"
|
#include "RTC.h"
|
||||||
|
|
||||||
#include "airtime.h"
|
#include "airtime.h"
|
||||||
|
#include "main.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
|
|
||||||
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
|
#include "GPS.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace NicheGraphics;
|
using namespace NicheGraphics;
|
||||||
|
|
||||||
static constexpr uint8_t MENU_TIMEOUT_SEC = 60; // How many seconds before menu auto-closes
|
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:
|
case TOGGLE_APPLET:
|
||||||
settings->userApplets.active[cursor] = !settings->userApplets.active[cursor];
|
settings->userApplets.active[cursor] = !settings->userApplets.active[cursor];
|
||||||
inkhud->updateAppletSelection();
|
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;
|
break;
|
||||||
|
|
||||||
case TOGGLE_AUTOSHOW_APPLET:
|
case TOGGLE_AUTOSHOW_APPLET:
|
||||||
@ -205,6 +204,25 @@ void InkHUD::MenuApplet::execute(MenuItem item)
|
|||||||
backlight->latch();
|
backlight->latch();
|
||||||
break;
|
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:
|
default:
|
||||||
LOG_WARN("Action not implemented");
|
LOG_WARN("Action not implemented");
|
||||||
}
|
}
|
||||||
@ -242,13 +260,21 @@ void InkHUD::MenuApplet::showPage(MenuPage page)
|
|||||||
|
|
||||||
case OPTIONS:
|
case OPTIONS:
|
||||||
// Optional: backlight
|
// Optional: backlight
|
||||||
if (settings->optionalMenuItems.backlight) {
|
if (settings->optionalMenuItems.backlight)
|
||||||
assert(backlight);
|
|
||||||
items.push_back(MenuItem(backlight->isLatched() ? "Backlight Off" : "Keep Backlight On", // Label
|
items.push_back(MenuItem(backlight->isLatched() ? "Backlight Off" : "Keep Backlight On", // Label
|
||||||
MenuAction::TOGGLE_BACKLIGHT, // Action
|
MenuAction::TOGGLE_BACKLIGHT, // Action
|
||||||
MenuPage::EXIT // Exit once complete
|
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("Applets", MenuPage::APPLETS));
|
||||||
items.push_back(MenuItem("Auto-show", MenuPage::AUTOSHOW));
|
items.push_back(MenuItem("Auto-show", MenuPage::AUTOSHOW));
|
||||||
@ -260,26 +286,14 @@ void InkHUD::MenuApplet::showPage(MenuPage page)
|
|||||||
&settings->optionalFeatures.notifications));
|
&settings->optionalFeatures.notifications));
|
||||||
items.push_back(MenuItem("Battery Icon", MenuAction::TOGGLE_BATTERY_ICON, MenuPage::OPTIONS,
|
items.push_back(MenuItem("Battery Icon", MenuAction::TOGGLE_BATTERY_ICON, MenuPage::OPTIONS,
|
||||||
&settings->optionalFeatures.batteryIcon));
|
&settings->optionalFeatures.batteryIcon));
|
||||||
|
items.push_back(
|
||||||
// TODO - GPS and Wifi switches
|
MenuItem("12-Hour Clock", MenuAction::TOGGLE_12H_CLOCK, MenuPage::OPTIONS, &config.display.use_12h_clock));
|
||||||
/*
|
|
||||||
// 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("Exit", MenuPage::EXIT));
|
items.push_back(MenuItem("Exit", MenuPage::EXIT));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case APPLETS:
|
case APPLETS:
|
||||||
populateAppletPage();
|
populateAppletPage();
|
||||||
items.push_back(MenuItem("Exit", MenuAction::ACTIVATE_APPLETS));
|
items.push_back(MenuItem("Exit", MenuPage::EXIT));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AUTOSHOW:
|
case AUTOSHOW:
|
||||||
@ -293,7 +307,6 @@ void InkHUD::MenuApplet::showPage(MenuPage page)
|
|||||||
|
|
||||||
case EXIT:
|
case EXIT:
|
||||||
sendToBackground(); // Menu applet dismissed, allow normal behavior to resume
|
sendToBackground(); // Menu applet dismissed, allow normal behavior to resume
|
||||||
// requestUpdate(Drivers::EInk::UpdateTypes::FULL);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user