Inhibit 'Save & Exit' menu when in RC preview. (#9267)
Inhibit 'Save & Exit' menu when in RC preview.
This commit is contained in:
commit
457581a753
|
@ -190,6 +190,8 @@ static uint8_t pageMaxRow; // Max row in the current page
|
||||||
|
|
||||||
static cmsCtx_t currentCtx;
|
static cmsCtx_t currentCtx;
|
||||||
|
|
||||||
|
static bool saveMenuInhibited = false;
|
||||||
|
|
||||||
#ifdef CMS_MENU_DEBUG // For external menu content creators
|
#ifdef CMS_MENU_DEBUG // For external menu content creators
|
||||||
|
|
||||||
static char menuErrLabel[21 + 1] = "RANDOM DATA";
|
static char menuErrLabel[21 + 1] = "RANDOM DATA";
|
||||||
|
@ -217,8 +219,6 @@ static CMS_Menu menuErr = {
|
||||||
debug[1] = currentCtx.page; \
|
debug[1] = currentCtx.page; \
|
||||||
debug[2] = pageMaxRow; \
|
debug[2] = pageMaxRow; \
|
||||||
debug[3] = currentCtx.cursorRow; } struct _dummy
|
debug[3] = currentCtx.cursorRow; } struct _dummy
|
||||||
#else
|
|
||||||
#define cmsPageDebug()
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void cmsUpdateMaxRow(displayPort_t *instance)
|
static void cmsUpdateMaxRow(displayPort_t *instance)
|
||||||
|
@ -555,6 +555,8 @@ STATIC_UNIT_TESTED const void *cmsMenuBack(displayPort_t *pDisplay)
|
||||||
return currentCtx.menu->onExit(pageTop + currentCtx.cursorRow);
|
return currentCtx.menu->onExit(pageTop + currentCtx.cursorRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveMenuInhibited = false;
|
||||||
|
|
||||||
if (!menuStackIdx) {
|
if (!menuStackIdx) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -564,7 +566,9 @@ STATIC_UNIT_TESTED const void *cmsMenuBack(displayPort_t *pDisplay)
|
||||||
cmsMenuCountPage(pDisplay);
|
cmsMenuCountPage(pDisplay);
|
||||||
cmsPageSelect(pDisplay, currentCtx.page);
|
cmsPageSelect(pDisplay, currentCtx.page);
|
||||||
|
|
||||||
|
#if defined(CMS_PAGE_DEBUG)
|
||||||
cmsPageDebug();
|
cmsPageDebug();
|
||||||
|
#endif
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -610,7 +614,9 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
|
||||||
currentCtx.cursorRow++;
|
currentCtx.cursorRow++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CMS_PAGE_DEBUG)
|
||||||
cmsPageDebug();
|
cmsPageDebug();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pDisplay->cursorRow >= 0 && currentCtx.cursorRow != pDisplay->cursorRow) {
|
if (pDisplay->cursorRow >= 0 && currentCtx.cursorRow != pDisplay->cursorRow) {
|
||||||
room -= displayWrite(pDisplay, leftMenuColumn, top + pDisplay->cursorRow * linesPerMenuItem, DISPLAYPORT_ATTR_NONE, " ");
|
room -= displayWrite(pDisplay, leftMenuColumn, top + pDisplay->cursorRow * linesPerMenuItem, DISPLAYPORT_ATTR_NONE, " ");
|
||||||
|
@ -685,6 +691,8 @@ const void *cmsMenuChange(displayPort_t *pDisplay, const void *ptr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (pMenu != currentCtx.menu) {
|
if (pMenu != currentCtx.menu) {
|
||||||
|
saveMenuInhibited = false;
|
||||||
|
|
||||||
// Stack the current menu and move to a new menu.
|
// Stack the current menu and move to a new menu.
|
||||||
if (menuStackIdx >= CMS_MENU_STACK_LIMIT - 1) {
|
if (menuStackIdx >= CMS_MENU_STACK_LIMIT - 1) {
|
||||||
// menu stack limit reached - prevent array overflow
|
// menu stack limit reached - prevent array overflow
|
||||||
|
@ -715,7 +723,9 @@ const void *cmsMenuChange(displayPort_t *pDisplay, const void *ptr)
|
||||||
cmsPageSelect(pDisplay, cursorAbs / maxMenuItems);
|
cmsPageSelect(pDisplay, cursorAbs / maxMenuItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CMS_PAGE_DEBUG)
|
||||||
cmsPageDebug();
|
cmsPageDebug();
|
||||||
|
#endif
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -871,13 +881,10 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, cms_key_e key)
|
||||||
return BUTTON_PAUSE;
|
return BUTTON_PAUSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == CMS_KEY_SAVEMENU) {
|
if (key == CMS_KEY_SAVEMENU && !saveMenuInhibited) {
|
||||||
osdElementEditing = false;
|
osdElementEditing = false;
|
||||||
if (getRebootRequired()) {
|
cmsMenuChange(pDisplay, getSaveExitMenu());
|
||||||
cmsMenuChange(pDisplay, &cmsx_menuSaveExitReboot);
|
|
||||||
} else {
|
|
||||||
cmsMenuChange(pDisplay, &cmsx_menuSaveExit);
|
|
||||||
}
|
|
||||||
return BUTTON_PAUSE;
|
return BUTTON_PAUSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1290,4 +1297,9 @@ void cmsInit(void)
|
||||||
cmsCurrentDevice = -1;
|
cmsCurrentDevice = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void inhibitSaveMenu(void)
|
||||||
|
{
|
||||||
|
saveMenuInhibited = true;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // CMS
|
#endif // CMS
|
||||||
|
|
|
@ -51,6 +51,7 @@ void cmsMenuOpen(void);
|
||||||
const void *cmsMenuChange(displayPort_t *pPort, const void *ptr);
|
const void *cmsMenuChange(displayPort_t *pPort, const void *ptr);
|
||||||
const void *cmsMenuExit(displayPort_t *pPort, const void *ptr);
|
const void *cmsMenuExit(displayPort_t *pPort, const void *ptr);
|
||||||
void cmsSetExternKey(cms_key_e extKey);
|
void cmsSetExternKey(cms_key_e extKey);
|
||||||
|
void inhibitSaveMenu(void);
|
||||||
|
|
||||||
#define CMS_STARTUP_HELP_TEXT1 "MENU:THR MID"
|
#define CMS_STARTUP_HELP_TEXT1 "MENU:THR MID"
|
||||||
#define CMS_STARTUP_HELP_TEXT2 "+ YAW LEFT"
|
#define CMS_STARTUP_HELP_TEXT2 "+ YAW LEFT"
|
||||||
|
|
|
@ -92,11 +92,8 @@ static const void *cmsx_SaveExitMenu(displayPort_t *pDisplay, const void *ptr)
|
||||||
{
|
{
|
||||||
UNUSED(ptr);
|
UNUSED(ptr);
|
||||||
|
|
||||||
if (getRebootRequired()) {
|
cmsMenuChange(pDisplay, getSaveExitMenu());
|
||||||
cmsMenuChange(pDisplay, &cmsx_menuSaveExitReboot);
|
|
||||||
} else {
|
|
||||||
cmsMenuChange(pDisplay, &cmsx_menuSaveExit);
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,13 +60,21 @@
|
||||||
// Misc
|
// Misc
|
||||||
//
|
//
|
||||||
|
|
||||||
|
static const void *cmsx_menuRcOnEnter(void)
|
||||||
|
{
|
||||||
|
inhibitSaveMenu();
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static const void *cmsx_menuRcConfirmBack(const OSD_Entry *self)
|
static const void *cmsx_menuRcConfirmBack(const OSD_Entry *self)
|
||||||
{
|
{
|
||||||
if (self && self->type == OME_Back)
|
if (self && self->type == OME_Back) {
|
||||||
return NULL;
|
return NULL;
|
||||||
else
|
} else {
|
||||||
return MENU_CHAIN_BACK;
|
return MENU_CHAIN_BACK;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// RC preview
|
// RC preview
|
||||||
|
@ -94,7 +102,7 @@ CMS_Menu cmsx_menuRcPreview = {
|
||||||
.GUARD_text = "XRCPREV",
|
.GUARD_text = "XRCPREV",
|
||||||
.GUARD_type = OME_MENU,
|
.GUARD_type = OME_MENU,
|
||||||
#endif
|
#endif
|
||||||
.onEnter = NULL,
|
.onEnter = cmsx_menuRcOnEnter,
|
||||||
.onExit = cmsx_menuRcConfirmBack,
|
.onExit = cmsx_menuRcConfirmBack,
|
||||||
.onDisplayUpdate = NULL,
|
.onDisplayUpdate = NULL,
|
||||||
.entries = cmsx_menuRcEntries
|
.entries = cmsx_menuRcEntries
|
||||||
|
|
|
@ -44,7 +44,7 @@ static const OSD_Entry cmsx_menuSaveExitEntries[] =
|
||||||
{ NULL, OME_END, NULL, NULL, 0 }
|
{ NULL, OME_END, NULL, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
CMS_Menu cmsx_menuSaveExit = {
|
static CMS_Menu cmsx_menuSaveExit = {
|
||||||
#ifdef CMS_MENU_DEBUG
|
#ifdef CMS_MENU_DEBUG
|
||||||
.GUARD_text = "MENUSAVE",
|
.GUARD_text = "MENUSAVE",
|
||||||
.GUARD_type = OME_MENU,
|
.GUARD_type = OME_MENU,
|
||||||
|
@ -64,7 +64,7 @@ static const OSD_Entry cmsx_menuSaveExitRebootEntries[] =
|
||||||
{ NULL, OME_END, NULL, NULL, 0 }
|
{ NULL, OME_END, NULL, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
CMS_Menu cmsx_menuSaveExitReboot = {
|
static CMS_Menu cmsx_menuSaveExitReboot = {
|
||||||
#ifdef CMS_MENU_DEBUG
|
#ifdef CMS_MENU_DEBUG
|
||||||
.GUARD_text = "MENUSAVE",
|
.GUARD_text = "MENUSAVE",
|
||||||
.GUARD_type = OME_MENU,
|
.GUARD_type = OME_MENU,
|
||||||
|
@ -75,5 +75,12 @@ CMS_Menu cmsx_menuSaveExitReboot = {
|
||||||
.entries = cmsx_menuSaveExitRebootEntries
|
.entries = cmsx_menuSaveExitRebootEntries
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CMS_Menu *getSaveExitMenu(void)
|
||||||
|
{
|
||||||
|
if (getRebootRequired()) {
|
||||||
|
return &cmsx_menuSaveExitReboot;
|
||||||
|
} else {
|
||||||
|
return &cmsx_menuSaveExit;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,5 +20,4 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
extern CMS_Menu cmsx_menuSaveExit;
|
CMS_Menu *getSaveExitMenu(void);
|
||||||
extern CMS_Menu cmsx_menuSaveExitReboot;
|
|
||||||
|
|
Loading…
Reference in New Issue