1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 21:05:35 +03:00

Trial for displaying optional string on right column for submenus

This commit is contained in:
jflyper 2016-11-24 16:33:21 +09:00
parent 457afbcaf0
commit ed09ee4a9b
3 changed files with 27 additions and 1 deletions

View file

@ -234,6 +234,13 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row)
case OME_Funcall: case OME_Funcall:
if (IS_PRINTVALUE(p)) { if (IS_PRINTVALUE(p)) {
cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, ">"); 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); CLR_PRINTVALUE(p);
} }
break; break;
@ -645,6 +652,11 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
switch (p->type) { switch (p->type) {
case OME_Submenu: case OME_Submenu:
if (p->func && key == KEY_RIGHT) {
cmsMenuChange(pDisplay, p->data);
res = BUTTON_PAUSE;
}
break;
case OME_Funcall: case OME_Funcall:
case OME_OSD_Exit: case OME_OSD_Exit:
if (p->func && key == KEY_RIGHT) { if (p->func && key == KEY_RIGHT) {

View file

@ -66,6 +66,7 @@ typedef struct
#define PRINT_VALUE 0x01 // Value has been changed, need to redraw #define PRINT_VALUE 0x01 // Value has been changed, need to redraw
#define PRINT_LABEL 0x02 // Text label should be printed #define PRINT_LABEL 0x02 // Text label should be printed
#define DYNAMIC 0x04 // Value should be updated dynamically #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 IS_PRINTVALUE(p) ((p)->flags & PRINT_VALUE)
#define SET_PRINTVALUE(p) { (p)->flags |= PRINT_VALUE; } #define SET_PRINTVALUE(p) { (p)->flags |= PRINT_VALUE; }
@ -153,3 +154,7 @@ typedef struct
{ {
char *val; char *val;
} OSD_String_t; } OSD_String_t;
// This is a function used in the func member if the type is OME_Submenu.
typedef char * (*CMSMenuOptFuncPtr)(void);

View file

@ -1064,6 +1064,15 @@ static long saCmsSetPORFreq(displayPort_t *pDisp, const void *self)
return 0; 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 saCmsEntUserFreq = { &saCmsUserFreq, 5000, 5900, 0 };
static OSD_UINT16_t saCmsEntUserFreqNew = { &saCmsUserFreqNew, 5000, 5900, 1 }; 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 }, { "OP MODEL", OME_TAB, saCmsConfigOpModelByGvar, &saCmsEntOpModel, 0 },
{ "FREQ MODE", OME_TAB, saCmsConfigFreqModeByGvar, &saCmsEntFreqMode, 0 }, { "FREQ MODE", OME_TAB, saCmsConfigFreqModeByGvar, &saCmsEntFreqMode, 0 },
{ "PIT FMODE", OME_TAB, saCmsConfigPitFModeByGvar, &saCmsEntPitFMode, 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 }, { "STATX", OME_Submenu, cmsMenuChange, &menu_smartAudioStats, 0 },
{ "BACK", OME_Back, NULL, NULL, 0 }, { "BACK", OME_Back, NULL, NULL, 0 },
{ NULL, OME_END, NULL, NULL, 0 } { NULL, OME_END, NULL, NULL, 0 }