diff --git a/src/main/cms/cms.c b/src/main/cms/cms.c index 388fd6b037..5cae422e91 100644 --- a/src/main/cms/cms.c +++ b/src/main/cms/cms.c @@ -234,6 +234,13 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row) case OME_Funcall: if (IS_PRINTVALUE(p)) { cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, ">"); + + // Special case of sub menu entry with func used as a function + // returning a string to print on the right column. + if (p->type == OME_Submenu && p->func) { + if (p->flags & OPTSTRING) + cnt += displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay) + 1, row, ((CMSMenuOptFuncPtr)p->func)()); + } CLR_PRINTVALUE(p); } break; @@ -645,6 +652,11 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key) switch (p->type) { case OME_Submenu: + if (p->func && key == KEY_RIGHT) { + cmsMenuChange(pDisplay, p->data); + res = BUTTON_PAUSE; + } + break; case OME_Funcall: case OME_OSD_Exit: if (p->func && key == KEY_RIGHT) { diff --git a/src/main/cms/cms_types.h b/src/main/cms/cms_types.h index 427e1d38e6..5650ca97ac 100644 --- a/src/main/cms/cms_types.h +++ b/src/main/cms/cms_types.h @@ -66,6 +66,7 @@ typedef struct #define PRINT_VALUE 0x01 // Value has been changed, need to redraw #define PRINT_LABEL 0x02 // Text label should be printed #define DYNAMIC 0x04 // Value should be updated dynamically +#define OPTSTRING 0x08 // (Temporary) Flag for OME_Submenu, indicating func should be called to get a string to display. #define IS_PRINTVALUE(p) ((p)->flags & PRINT_VALUE) #define SET_PRINTVALUE(p) { (p)->flags |= PRINT_VALUE; } @@ -153,3 +154,7 @@ typedef struct { char *val; } OSD_String_t; + +// This is a function used in the func member if the type is OME_Submenu. + +typedef char * (*CMSMenuOptFuncPtr)(void); diff --git a/src/main/io/vtx_smartaudio.c b/src/main/io/vtx_smartaudio.c index 81a60daf63..565ea15bf6 100644 --- a/src/main/io/vtx_smartaudio.c +++ b/src/main/io/vtx_smartaudio.c @@ -1064,6 +1064,15 @@ static long saCmsSetPORFreq(displayPort_t *pDisp, const void *self) return 0; } +static char *saCmsORFreqGetString(void) +{ + static char pbuf[5]; + + tfp_sprintf(pbuf, "%4d", saCmsORFreq); + + return pbuf; +} + static OSD_UINT16_t saCmsEntUserFreq = { &saCmsUserFreq, 5000, 5900, 0 }; static OSD_UINT16_t saCmsEntUserFreqNew = { &saCmsUserFreqNew, 5000, 5900, 1 }; @@ -1127,7 +1136,7 @@ static OSD_Entry menu_smartAudioConfigEntries[] = { { "OP MODEL", OME_TAB, saCmsConfigOpModelByGvar, &saCmsEntOpModel, 0 }, { "FREQ MODE", OME_TAB, saCmsConfigFreqModeByGvar, &saCmsEntFreqMode, 0 }, { "PIT FMODE", OME_TAB, saCmsConfigPitFModeByGvar, &saCmsEntPitFMode, 0 }, - { "POR FREQ", OME_Submenu, cmsMenuChange, &saCmsMenuPORFreq, 0 }, + { "POR FREQ", OME_Submenu, (CMSEntryFuncPtr)saCmsORFreqGetString, &saCmsMenuPORFreq, OPTSTRING }, { "STATX", OME_Submenu, cmsMenuChange, &menu_smartAudioStats, 0 }, { "BACK", OME_Back, NULL, NULL, 0 }, { NULL, OME_END, NULL, NULL, 0 }