Merge pull request #7919 from codecae/cms_flag_fix

Updated CMS to pass flags by reference into cmsDrawMenuEntry
This commit is contained in:
Michael Keller 2019-04-04 01:43:28 +13:00 committed by GitHub
commit 22b9f34532
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 25 deletions

View File

@ -364,7 +364,7 @@ static int cmsDrawMenuItemValue(displayPort_t *pDisplay, char *buff, uint8_t row
return cnt; return cnt;
} }
static int cmsDrawMenuEntry(displayPort_t *pDisplay, const OSD_Entry *p, uint8_t row, bool selectedRow, uint8_t flags) static int cmsDrawMenuEntry(displayPort_t *pDisplay, const OSD_Entry *p, uint8_t row, bool selectedRow, uint8_t *flags)
{ {
#define CMS_DRAW_BUFFER_LEN 12 #define CMS_DRAW_BUFFER_LEN 12
#define CMS_NUM_FIELD_LEN 5 #define CMS_NUM_FIELD_LEN 5
@ -383,20 +383,20 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, const OSD_Entry *p, uint8_t
switch (p->type) { switch (p->type) {
case OME_String: case OME_String:
if (IS_PRINTVALUE(flags) && p->data) { if (IS_PRINTVALUE(*flags) && p->data) {
strncpy(buff, p->data, CMS_DRAW_BUFFER_LEN); strncpy(buff, p->data, CMS_DRAW_BUFFER_LEN);
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_DRAW_BUFFER_LEN); cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_DRAW_BUFFER_LEN);
CLR_PRINTVALUE(flags); CLR_PRINTVALUE(*flags);
} }
break; break;
case OME_Submenu: case OME_Submenu:
case OME_Funcall: case OME_Funcall:
if (IS_PRINTVALUE(flags)) { if (IS_PRINTVALUE(*flags)) {
buff[0]= 0x0; buff[0]= 0x0;
if ((p->type == OME_Submenu) && p->func && (flags & OPTSTRING)) { if ((p->type == OME_Submenu) && p->func && (*flags & OPTSTRING)) {
// Special case of sub menu entry with optional value display. // Special case of sub menu entry with optional value display.
@ -407,12 +407,12 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, const OSD_Entry *p, uint8_t
row = smallScreen ? row - 1 : row; row = smallScreen ? row - 1 : row;
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, strlen(buff)); cnt = cmsDrawMenuItemValue(pDisplay, buff, row, strlen(buff));
CLR_PRINTVALUE(flags); CLR_PRINTVALUE(*flags);
} }
break; break;
case OME_Bool: case OME_Bool:
if (IS_PRINTVALUE(flags) && p->data) { if (IS_PRINTVALUE(*flags) && p->data) {
if (*((uint8_t *)(p->data))) { if (*((uint8_t *)(p->data))) {
strcpy(buff, "YES"); strcpy(buff, "YES");
} else { } else {
@ -420,23 +420,23 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, const OSD_Entry *p, uint8_t
} }
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, 3); cnt = cmsDrawMenuItemValue(pDisplay, buff, row, 3);
CLR_PRINTVALUE(flags); CLR_PRINTVALUE(*flags);
} }
break; break;
case OME_TAB: case OME_TAB:
if (IS_PRINTVALUE(flags)) { if (IS_PRINTVALUE(*flags)) {
OSD_TAB_t *ptr = p->data; OSD_TAB_t *ptr = p->data;
char * str = (char *)ptr->names[*ptr->val]; char * str = (char *)ptr->names[*ptr->val];
strncpy(buff, str, CMS_DRAW_BUFFER_LEN); strncpy(buff, str, CMS_DRAW_BUFFER_LEN);
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_DRAW_BUFFER_LEN); cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_DRAW_BUFFER_LEN);
CLR_PRINTVALUE(flags); CLR_PRINTVALUE(*flags);
} }
break; break;
#ifdef USE_OSD #ifdef USE_OSD
case OME_VISIBLE: case OME_VISIBLE:
if (IS_PRINTVALUE(flags) && p->data) { if (IS_PRINTVALUE(*flags) && p->data) {
uint16_t *val = (uint16_t *)p->data; uint16_t *val = (uint16_t *)p->data;
bool cursorBlink = millis() % (2 * CMS_CURSOR_BLINK_DELAY_MS) < CMS_CURSOR_BLINK_DELAY_MS; bool cursorBlink = millis() % (2 * CMS_CURSOR_BLINK_DELAY_MS) < CMS_CURSOR_BLINK_DELAY_MS;
for (unsigned x = 1; x < OSD_PROFILE_COUNT + 1; x++) { for (unsigned x = 1; x < OSD_PROFILE_COUNT + 1; x++) {
@ -455,61 +455,61 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, const OSD_Entry *p, uint8_t
} }
} }
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, 3); cnt = cmsDrawMenuItemValue(pDisplay, buff, row, 3);
CLR_PRINTVALUE(flags); CLR_PRINTVALUE(*flags);
} }
break; break;
#endif #endif
case OME_UINT8: case OME_UINT8:
if (IS_PRINTVALUE(flags) && p->data) { if (IS_PRINTVALUE(*flags) && p->data) {
OSD_UINT8_t *ptr = p->data; OSD_UINT8_t *ptr = p->data;
itoa(*ptr->val, buff, 10); itoa(*ptr->val, buff, 10);
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_NUM_FIELD_LEN); cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_NUM_FIELD_LEN);
CLR_PRINTVALUE(flags); CLR_PRINTVALUE(*flags);
} }
break; break;
case OME_INT8: case OME_INT8:
if (IS_PRINTVALUE(flags) && p->data) { if (IS_PRINTVALUE(*flags) && p->data) {
OSD_INT8_t *ptr = p->data; OSD_INT8_t *ptr = p->data;
itoa(*ptr->val, buff, 10); itoa(*ptr->val, buff, 10);
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_NUM_FIELD_LEN); cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_NUM_FIELD_LEN);
CLR_PRINTVALUE(flags); CLR_PRINTVALUE(*flags);
} }
break; break;
case OME_UINT16: case OME_UINT16:
if (IS_PRINTVALUE(flags) && p->data) { if (IS_PRINTVALUE(*flags) && p->data) {
OSD_UINT16_t *ptr = p->data; OSD_UINT16_t *ptr = p->data;
itoa(*ptr->val, buff, 10); itoa(*ptr->val, buff, 10);
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_NUM_FIELD_LEN); cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_NUM_FIELD_LEN);
CLR_PRINTVALUE(flags); CLR_PRINTVALUE(*flags);
} }
break; break;
case OME_INT16: case OME_INT16:
if (IS_PRINTVALUE(flags) && p->data) { if (IS_PRINTVALUE(*flags) && p->data) {
OSD_UINT16_t *ptr = p->data; OSD_UINT16_t *ptr = p->data;
itoa(*ptr->val, buff, 10); itoa(*ptr->val, buff, 10);
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_NUM_FIELD_LEN); cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_NUM_FIELD_LEN);
CLR_PRINTVALUE(flags); CLR_PRINTVALUE(*flags);
} }
break; break;
case OME_FLOAT: case OME_FLOAT:
if (IS_PRINTVALUE(flags) && p->data) { if (IS_PRINTVALUE(*flags) && p->data) {
OSD_FLOAT_t *ptr = p->data; OSD_FLOAT_t *ptr = p->data;
cmsFormatFloat(*ptr->val * ptr->multipler, buff); cmsFormatFloat(*ptr->val * ptr->multipler, buff);
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_NUM_FIELD_LEN); cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_NUM_FIELD_LEN);
CLR_PRINTVALUE(flags); CLR_PRINTVALUE(*flags);
} }
break; break;
case OME_Label: case OME_Label:
if (IS_PRINTVALUE(flags) && p->data) { if (IS_PRINTVALUE(*flags) && p->data) {
// A label with optional string, immediately following text // A label with optional string, immediately following text
cnt = displayWrite(pDisplay, leftMenuColumn + 1 + (uint8_t)strlen(p->text), row, p->data); cnt = displayWrite(pDisplay, leftMenuColumn + 1 + (uint8_t)strlen(p->text), row, p->data);
CLR_PRINTVALUE(flags); CLR_PRINTVALUE(*flags);
} }
break; break;
@ -609,7 +609,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
if (IS_PRINTVALUE(runtimeEntryFlags[i])) { if (IS_PRINTVALUE(runtimeEntryFlags[i])) {
bool selectedRow = i == currentCtx.cursorRow; bool selectedRow = i == currentCtx.cursorRow;
room -= cmsDrawMenuEntry(pDisplay, p, top + i * linesPerMenuItem, selectedRow, runtimeEntryFlags[i]); room -= cmsDrawMenuEntry(pDisplay, p, top + i * linesPerMenuItem, selectedRow, &runtimeEntryFlags[i]);
if (room < 30) if (room < 30)
return; return;
} }