1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 12:55:19 +03:00

OME_Funcall now chains functions based on p->func's return value

This commit is contained in:
jflyper 2016-11-25 22:01:28 +09:00
parent f1035c52eb
commit fc1c8d7596
2 changed files with 13 additions and 2 deletions

View file

@ -675,7 +675,16 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
}
break;
case OME_Funcall:
case OME_Funcall:;
long retval;
if (p->func && key == KEY_RIGHT) {
retval = p->func(pDisplay, p->data);
if (retval == MENU_CHAIN_BACK)
cmsMenuBack(pDisplay);
res = BUTTON_PAUSE;
}
break;
case OME_OSD_Exit:
if (p->func && key == KEY_RIGHT) {
p->func(pDisplay, p->data);

View file

@ -78,9 +78,11 @@ typedef struct
#define IS_DYNAMIC(p) ((p)->flags & DYNAMIC)
typedef long (*CMSMenuFuncPtr)(void);
// Special return value(s) for function chaining by CMSMenuFuncPtr
#define MENU_CHAIN_BACK (-1) // Causes automatic cmsMenuBack
/*
onExit function is called with self:
(1) Pointer to an OSD_Entry when cmsMenuBack() was called.