mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 04:45:24 +03:00
Trial for displaying optional string on right column for submenus
This commit is contained in:
parent
457afbcaf0
commit
ed09ee4a9b
3 changed files with 27 additions and 1 deletions
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue