Add OME_Funcall to call a function.

With the introduction of the CME_Menu, OME_Submenu became unsuitable
for general function calls. Actually, it works and call the designated
function, but attempt to externally traverse the menu structure fail
because it expects CME_Menu * as data for OME_Submenu.
This commit is contained in:
jflyper 2016-11-08 05:27:09 +09:00
parent c12942ed41
commit 576ad19914
3 changed files with 4 additions and 1 deletions

View File

@ -246,6 +246,7 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row)
}
break;
case OME_Submenu:
case OME_Funcall:
if (IS_PRINTVALUE(p)) {
cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, ">");
CLR_PRINTVALUE(p);
@ -639,6 +640,7 @@ static uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
switch (p->type) {
case OME_Submenu:
case OME_Funcall:
case OME_OSD_Exit:
if (p->func && key == KEY_RIGHT) {
p->func(pDisplay, p->data);

View File

@ -93,7 +93,7 @@ static OSD_Entry cmsx_menuBlackboxEntries[] =
{ "RATE DENOM", OME_UINT8, NULL, &(OSD_UINT8_t){ &masterConfig.blackbox_rate_denom,1,32,1 }, 0 },
#ifdef USE_FLASHFS
{ "ERASE FLASH", OME_Submenu, cmsx_EraseFlash, NULL, 0 },
{ "ERASE FLASH", OME_Funcall, cmsx_EraseFlash, NULL, 0 },
#endif // USE_FLASHFS
{ "BACK", OME_Back, NULL, NULL, 0 },

View File

@ -32,6 +32,7 @@ typedef enum
OME_Back,
OME_OSD_Exit,
OME_Submenu,
OME_Funcall,
OME_Bool,
OME_INT8,
OME_UINT8,