Add reboot menu

This commit is contained in:
Jonathan Bennett 2025-06-30 15:29:08 -05:00
parent 29b13efa6e
commit 90b95e8e45
2 changed files with 28 additions and 7 deletions

View File

@ -305,16 +305,16 @@ void menuHandler::systemBaseMenu()
int options; int options;
static const char **optionsArrayPtr; static const char **optionsArrayPtr;
#if HAS_TFT #if HAS_TFT
static const char *optionsArray[] = {"Back", "Beeps Action", "Switch to MUI"}; static const char *optionsArray[] = {"Back", "Beeps Action", "Reboot", "Switch to MUI"};
options = 3; options = 4;
#endif #endif
#if defined(HELTEC_MESH_NODE_T114) || defined(HELTEC_VISION_MASTER_T190) #if defined(HELTEC_MESH_NODE_T114) || defined(HELTEC_VISION_MASTER_T190)
static const char *optionsArray[] = {"Back", "Beeps Action", "Screen Color"}; static const char *optionsArray[] = {"Back", "Beeps Action", "Reboot", "Screen Color"};
options = 3; options = 4;
#endif #endif
#if !defined(HELTEC_MESH_NODE_T114) && !defined(HELTEC_VISION_MASTER_T190) && !HAS_TFT #if !defined(HELTEC_MESH_NODE_T114) && !defined(HELTEC_VISION_MASTER_T190) && !HAS_TFT
static const char *optionsArray[] = {"Back", "Beeps Action"}; static const char *optionsArray[] = {"Back", "Beeps Action", "Reboot"};
options = 2; options = 3;
#endif #endif
optionsArrayPtr = optionsArray; optionsArrayPtr = optionsArray;
screen->showOverlayBanner("System Action", 30000, optionsArrayPtr, options, [](int selected) -> void { screen->showOverlayBanner("System Action", 30000, optionsArrayPtr, options, [](int selected) -> void {
@ -323,6 +323,10 @@ void menuHandler::systemBaseMenu()
screen->setInterval(0); screen->setInterval(0);
runASAP = true; runASAP = true;
} else if (selected == 2) { } else if (selected == 2) {
menuHandler::menuQueue = menuHandler::reboot_menu;
screen->setInterval(0);
runASAP = true;
} else if (selected == 3) {
#if HAS_TFT #if HAS_TFT
menuHandler::menuQueue = menuHandler::mui_picker; menuHandler::menuQueue = menuHandler::mui_picker;
#endif #endif
@ -531,6 +535,18 @@ void menuHandler::TFTColorPickerMenu()
}); });
} }
void menuHandler::rebootMenu()
{
static const char *optionsArray[] = {"Yes", "No"};
screen->showOverlayBanner("Reboot Device?", 30000, optionsArray, 2, [](int selected) -> void {
if (selected == 0) {
IF_SCREEN(screen->showOverlayBanner("Rebooting...", 0));
nodeDB->saveToDisk();
rebootAtMsec = millis() + DEFAULT_REBOOT_SECONDS * 1000;
}
});
}
void menuHandler::handleMenuSwitch() void menuHandler::handleMenuSwitch()
{ {
switch (menuQueue) { switch (menuQueue) {
@ -572,6 +588,9 @@ void menuHandler::handleMenuSwitch()
case tftcolormenupicker: case tftcolormenupicker:
TFTColorPickerMenu(); TFTColorPickerMenu();
break; break;
case reboot_menu:
rebootMenu();
break;
} }
menuQueue = menu_none; menuQueue = menu_none;
} }

View File

@ -18,7 +18,8 @@ class menuHandler
reset_node_db_menu, reset_node_db_menu,
buzzermodemenupicker, buzzermodemenupicker,
mui_picker, mui_picker,
tftcolormenupicker tftcolormenupicker,
reboot_menu
}; };
static screenMenus menuQueue; static screenMenus menuQueue;
@ -40,6 +41,7 @@ class menuHandler
static void TFTColorPickerMenu(); static void TFTColorPickerMenu();
static void nodeListMenu(); static void nodeListMenu();
static void resetNodeDBMenu(); static void resetNodeDBMenu();
static void rebootMenu();
}; };
} // namespace graphics } // namespace graphics