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;
static const char **optionsArrayPtr;
#if HAS_TFT
static const char *optionsArray[] = {"Back", "Beeps Action", "Switch to MUI"};
options = 3;
static const char *optionsArray[] = {"Back", "Beeps Action", "Reboot", "Switch to MUI"};
options = 4;
#endif
#if defined(HELTEC_MESH_NODE_T114) || defined(HELTEC_VISION_MASTER_T190)
static const char *optionsArray[] = {"Back", "Beeps Action", "Screen Color"};
options = 3;
static const char *optionsArray[] = {"Back", "Beeps Action", "Reboot", "Screen Color"};
options = 4;
#endif
#if !defined(HELTEC_MESH_NODE_T114) && !defined(HELTEC_VISION_MASTER_T190) && !HAS_TFT
static const char *optionsArray[] = {"Back", "Beeps Action"};
options = 2;
static const char *optionsArray[] = {"Back", "Beeps Action", "Reboot"};
options = 3;
#endif
optionsArrayPtr = optionsArray;
screen->showOverlayBanner("System Action", 30000, optionsArrayPtr, options, [](int selected) -> void {
@ -323,6 +323,10 @@ void menuHandler::systemBaseMenu()
screen->setInterval(0);
runASAP = true;
} else if (selected == 2) {
menuHandler::menuQueue = menuHandler::reboot_menu;
screen->setInterval(0);
runASAP = true;
} else if (selected == 3) {
#if HAS_TFT
menuHandler::menuQueue = menuHandler::mui_picker;
#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()
{
switch (menuQueue) {
@ -572,6 +588,9 @@ void menuHandler::handleMenuSwitch()
case tftcolormenupicker:
TFTColorPickerMenu();
break;
case reboot_menu:
rebootMenu();
break;
}
menuQueue = menu_none;
}

View File

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