mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +03:00
CMS exit/save popup menu
Adds a new exit/save menu that can be displayed at any time using the yaw-right stick command. Yaw-left still functions as "back". Allows the user to save their settings even while nested deep in multiple menus. Previously the user was required to back up all the way to the top level menu to save or exit.
This commit is contained in:
parent
d76807fd33
commit
5b5581fa2a
6 changed files with 109 additions and 2 deletions
|
@ -42,6 +42,7 @@
|
|||
|
||||
#include "cms/cms.h"
|
||||
#include "cms/cms_menu_builtin.h"
|
||||
#include "cms/cms_menu_saveexit.h"
|
||||
#include "cms/cms_types.h"
|
||||
|
||||
#include "common/maths.h"
|
||||
|
@ -743,11 +744,22 @@ long cmsMenuExit(displayPort_t *pDisplay, const void *ptr)
|
|||
switch (exitType) {
|
||||
case CMS_EXIT_SAVE:
|
||||
case CMS_EXIT_SAVEREBOOT:
|
||||
case CMS_POPUP_SAVE:
|
||||
case CMS_POPUP_SAVEREBOOT:
|
||||
|
||||
cmsTraverseGlobalExit(&menuMain);
|
||||
|
||||
if (currentCtx.menu->onExit)
|
||||
currentCtx.menu->onExit((OSD_Entry *)NULL); // Forced exit
|
||||
|
||||
if ((exitType == CMS_POPUP_SAVE) || (exitType == CMS_POPUP_SAVEREBOOT)) {
|
||||
// traverse through the menu stack and call their onExit functions
|
||||
for (int i = menuStackIdx - 1; i >= 0; i--) {
|
||||
if (menuStack[i].menu->onExit) {
|
||||
menuStack[i].menu->onExit((OSD_Entry *)NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
saveConfigAndNotify();
|
||||
break;
|
||||
|
@ -761,7 +773,7 @@ long cmsMenuExit(displayPort_t *pDisplay, const void *ptr)
|
|||
displayRelease(pDisplay);
|
||||
currentCtx.menu = NULL;
|
||||
|
||||
if (exitType == CMS_EXIT_SAVEREBOOT) {
|
||||
if ((exitType == CMS_EXIT_SAVEREBOOT) || (exitType == CMS_POPUP_SAVEREBOOT)) {
|
||||
displayClearScreen(pDisplay);
|
||||
displayWrite(pDisplay, 5, 3, "REBOOTING...");
|
||||
|
||||
|
@ -810,6 +822,12 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, cms_key_e key)
|
|||
return BUTTON_PAUSE;
|
||||
}
|
||||
|
||||
if (key == CMS_KEY_SAVEMENU) {
|
||||
osdElementEditing = false;
|
||||
cmsMenuChange(pDisplay, &cmsx_menuSaveExit);
|
||||
return BUTTON_PAUSE;
|
||||
}
|
||||
|
||||
if ((key == CMS_KEY_DOWN) && (!osdElementEditing)) {
|
||||
if (currentCtx.cursorRow < pageMaxRow) {
|
||||
currentCtx.cursorRow++;
|
||||
|
@ -1089,10 +1107,14 @@ void cmsUpdate(uint32_t currentTimeUs)
|
|||
else if (IS_HI(ROLL)) {
|
||||
key = CMS_KEY_RIGHT;
|
||||
}
|
||||
else if (IS_HI(YAW) || IS_LO(YAW))
|
||||
else if (IS_LO(YAW))
|
||||
{
|
||||
key = CMS_KEY_ESC;
|
||||
}
|
||||
else if (IS_HI(YAW))
|
||||
{
|
||||
key = CMS_KEY_SAVEMENU;
|
||||
}
|
||||
|
||||
if (key == CMS_KEY_NONE) {
|
||||
// No 'key' pressed, reset repeat control
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue