1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-26 01:35:35 +03:00

Move CMS entries and menus from RAM to FLASH

Use a global array in cms.c to keep track of the dirty elements
that need redrawing. This lets us avoid modifying the entry flags
to keep track of it, so they can now be completely read only. This
in turn lets us also move all the menus to the text section.

This commit saves 6112 bytes of RAM in F3, so we have some room
to play again without resorting to disabling features.
This commit is contained in:
Alberto García Hierro 2018-03-06 00:28:17 +00:00
parent 0131e3e066
commit d6c75bd6f5
21 changed files with 147 additions and 140 deletions

View file

@ -74,6 +74,20 @@
#define CMS_MAX_DEVICE 4 #define CMS_MAX_DEVICE 4
#endif #endif
// Should be as big as the maximum number of rows displayed
// simultaneously in the tallest supported screen.
static uint8_t entry_flags[32];
#define IS_PRINTVALUE(p, row) (entry_flags[row] & PRINT_VALUE)
#define SET_PRINTVALUE(p, row) { entry_flags[row] |= PRINT_VALUE; }
#define CLR_PRINTVALUE(p, row) { entry_flags[row] &= ~PRINT_VALUE; }
#define IS_PRINTLABEL(p, row) (entry_flags[row] & PRINT_LABEL)
#define SET_PRINTLABEL(p, row) { entry_flags[row] |= PRINT_LABEL; }
#define CLR_PRINTLABEL(p, row) { entry_flags[row] &= ~PRINT_LABEL; }
#define IS_DYNAMIC(p) ((p)->flags & DYNAMIC)
static displayPort_t *pCurrentDisplay; static displayPort_t *pCurrentDisplay;
static displayPort_t *cmsDisplayPorts[CMS_MAX_DEVICE]; static displayPort_t *cmsDisplayPorts[CMS_MAX_DEVICE];
@ -146,7 +160,7 @@ static cmsCtx_t menuStack[10];
static uint8_t menuStackIdx = 0; static uint8_t menuStackIdx = 0;
static int8_t pageCount; // Number of pages in the current menu static int8_t pageCount; // Number of pages in the current menu
static OSD_Entry *pageTop; // First entry for the current page static const OSD_Entry *pageTop; // First entry for the current page
static uint8_t pageMaxRow; // Max row in the current page static uint8_t pageMaxRow; // Max row in the current page
static cmsCtx_t currentCtx; static cmsCtx_t currentCtx;
@ -155,7 +169,7 @@ static cmsCtx_t currentCtx;
static char menuErrLabel[21 + 1] = "RANDOM DATA"; static char menuErrLabel[21 + 1] = "RANDOM DATA";
static OSD_Entry menuErrEntries[] = { static const OSD_Entry menuErrEntries[] = {
{ "BROKEN MENU", OME_Label, NULL, NULL, 0 }, { "BROKEN MENU", OME_Label, NULL, NULL, 0 },
{ menuErrLabel, OME_Label, NULL, NULL, 0 }, { menuErrLabel, OME_Label, NULL, NULL, 0 },
@ -163,7 +177,7 @@ static OSD_Entry menuErrEntries[] = {
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu menuErr = { static const CMS_Menu menuErr = {
"MENUERR", "MENUERR",
OME_MENU, OME_MENU,
NULL, NULL,
@ -269,7 +283,7 @@ static void cmsPadToSize(char *buf, int size)
buf[size] = 0; buf[size] = 0;
} }
static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row) static int cmsDrawMenuEntry(displayPort_t *pDisplay, const OSD_Entry *p, uint8_t row, uint8_t screenRow)
{ {
#define CMS_DRAW_BUFFER_LEN 32u #define CMS_DRAW_BUFFER_LEN 32u
char buff[CMS_DRAW_BUFFER_LEN]; char buff[CMS_DRAW_BUFFER_LEN];
@ -277,15 +291,15 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row)
switch (p->type) { switch (p->type) {
case OME_String: case OME_String:
if (IS_PRINTVALUE(p) && p->data) { if (IS_PRINTVALUE(p, screenRow) && p->data) {
cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, p->data); cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, p->data);
CLR_PRINTVALUE(p); CLR_PRINTVALUE(p, screenRow);
} }
break; break;
case OME_Submenu: case OME_Submenu:
case OME_Funcall: case OME_Funcall:
if (IS_PRINTVALUE(p)) { if (IS_PRINTVALUE(p, screenRow)) {
int colPos = RIGHT_MENU_COLUMN(pDisplay); int colPos = RIGHT_MENU_COLUMN(pDisplay);
@ -300,43 +314,43 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row)
cnt += displayWrite(pDisplay, colPos, row, ">"); cnt += displayWrite(pDisplay, colPos, row, ">");
CLR_PRINTVALUE(p); CLR_PRINTVALUE(p, screenRow);
} }
break; break;
case OME_Bool: case OME_Bool:
if (IS_PRINTVALUE(p) && p->data) { if (IS_PRINTVALUE(p, screenRow) && p->data) {
if (*((uint8_t *)(p->data))) { if (*((uint8_t *)(p->data))) {
cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, "YES"); cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, "YES");
} else { } else {
cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, "NO "); cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, "NO ");
} }
CLR_PRINTVALUE(p); CLR_PRINTVALUE(p, screenRow);
} }
break; break;
case OME_BoolFunc: case OME_BoolFunc:
if (IS_PRINTVALUE(p) && p->data) { if (IS_PRINTVALUE(p, screenRow) && p->data) {
bool (*func)(bool *arg) = p->data; bool (*func)(bool *arg) = p->data;
cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, func(NULL) ? "YES" : "NO "); cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, func(NULL) ? "YES" : "NO ");
CLR_PRINTVALUE(p); CLR_PRINTVALUE(p, screenRow);
} }
break; break;
case OME_TAB: case OME_TAB:
if (IS_PRINTVALUE(p)) { if (IS_PRINTVALUE(p, screenRow)) {
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];
memcpy(buff, str, MAX(CMS_DRAW_BUFFER_LEN, strlen(str))); memcpy(buff, str, MAX(CMS_DRAW_BUFFER_LEN, strlen(str)));
cmsPadToSize(buff, CMS_DRAW_BUFFER_LEN); cmsPadToSize(buff, CMS_DRAW_BUFFER_LEN);
cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, buff); cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, buff);
CLR_PRINTVALUE(p); CLR_PRINTVALUE(p, screenRow);
} }
break; break;
#ifdef USE_OSD #ifdef USE_OSD
case OME_VISIBLE: case OME_VISIBLE:
if (IS_PRINTVALUE(p) && p->data) { if (IS_PRINTVALUE(p, screenRow) && p->data) {
uint16_t *val = (uint16_t *)p->data; uint16_t *val = (uint16_t *)p->data;
if (VISIBLE(*val)) { if (VISIBLE(*val)) {
@ -344,63 +358,63 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row)
} else { } else {
cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, "NO "); cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, "NO ");
} }
CLR_PRINTVALUE(p); CLR_PRINTVALUE(p, screenRow);
} }
break; break;
#endif #endif
case OME_UINT8: case OME_UINT8:
if (IS_PRINTVALUE(p) && p->data) { if (IS_PRINTVALUE(p, screenRow) && p->data) {
OSD_UINT8_t *ptr = p->data; OSD_UINT8_t *ptr = p->data;
itoa(*ptr->val, buff, 10); itoa(*ptr->val, buff, 10);
cmsPadToSize(buff, 5); cmsPadToSize(buff, 5);
cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, buff); cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, buff);
CLR_PRINTVALUE(p); CLR_PRINTVALUE(p, screenRow);
} }
break; break;
case OME_INT8: case OME_INT8:
if (IS_PRINTVALUE(p) && p->data) { if (IS_PRINTVALUE(p, screenRow) && p->data) {
OSD_INT8_t *ptr = p->data; OSD_INT8_t *ptr = p->data;
itoa(*ptr->val, buff, 10); itoa(*ptr->val, buff, 10);
cmsPadToSize(buff, 5); cmsPadToSize(buff, 5);
cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, buff); cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, buff);
CLR_PRINTVALUE(p); CLR_PRINTVALUE(p, screenRow);
} }
break; break;
case OME_UINT16: case OME_UINT16:
if (IS_PRINTVALUE(p) && p->data) { if (IS_PRINTVALUE(p, screenRow) && p->data) {
OSD_UINT16_t *ptr = p->data; OSD_UINT16_t *ptr = p->data;
itoa(*ptr->val, buff, 10); itoa(*ptr->val, buff, 10);
cmsPadToSize(buff, 5); cmsPadToSize(buff, 5);
cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, buff); cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, buff);
CLR_PRINTVALUE(p); CLR_PRINTVALUE(p, screenRow);
} }
break; break;
case OME_INT16: case OME_INT16:
if (IS_PRINTVALUE(p) && p->data) { if (IS_PRINTVALUE(p, screenRow) && p->data) {
OSD_UINT16_t *ptr = p->data; OSD_UINT16_t *ptr = p->data;
itoa(*ptr->val, buff, 10); itoa(*ptr->val, buff, 10);
cmsPadToSize(buff, 5); cmsPadToSize(buff, 5);
cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, buff); cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, buff);
CLR_PRINTVALUE(p); CLR_PRINTVALUE(p, screenRow);
} }
break; break;
case OME_FLOAT: case OME_FLOAT:
if (IS_PRINTVALUE(p) && p->data) { if (IS_PRINTVALUE(p, screenRow) && 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);
cmsPadToSize(buff, 5); cmsPadToSize(buff, 5);
cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay) - 1, row, buff); // XXX One char left ??? cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay) - 1, row, buff); // XXX One char left ???
CLR_PRINTVALUE(p); CLR_PRINTVALUE(p, screenRow);
} }
break; break;
case OME_Setting: case OME_Setting:
if (IS_PRINTVALUE(p) && p->data) { if (IS_PRINTVALUE(p, screenRow) && p->data) {
buff[0] = '\0'; buff[0] = '\0';
OSD_SETTING_t *ptr = p->data; OSD_SETTING_t *ptr = p->data;
const setting_t *var = &settingsTable[ptr->val]; const setting_t *var = &settingsTable[ptr->val];
@ -465,13 +479,13 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row)
} }
cmsPadToSize(buff, 8); cmsPadToSize(buff, 8);
cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, buff); cnt = displayWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay), row, buff);
CLR_PRINTVALUE(p); CLR_PRINTVALUE(p, screenRow);
} }
break; break;
case OME_Label: case OME_Label:
case OME_LabelFunc: case OME_LabelFunc:
if (IS_PRINTVALUE(p)) { if (IS_PRINTVALUE(p, screenRow)) {
// A label with optional string, immediately following text // A label with optional string, immediately following text
const char *text = p->data; const char *text = p->data;
if (p->type == OME_LabelFunc) { if (p->type == OME_LabelFunc) {
@ -486,7 +500,7 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row)
if (text) { if (text) {
cnt = displayWrite(pDisplay, LEFT_MENU_COLUMN + 2 + strlen(p->text), row, text); cnt = displayWrite(pDisplay, LEFT_MENU_COLUMN + 2 + strlen(p->text), row, text);
} }
CLR_PRINTVALUE(p); CLR_PRINTVALUE(p, screenRow);
} }
break; break;
@ -514,7 +528,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
return; return;
uint8_t i; uint8_t i;
OSD_Entry *p; const OSD_Entry *p;
uint8_t top = (pDisplay->rows - pageMaxRow) / 2 - 1; uint8_t top = (pDisplay->rows - pageMaxRow) / 2 - 1;
// Polled (dynamic) value display denominator. // Polled (dynamic) value display denominator.
@ -530,15 +544,13 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
uint32_t room = displayTxBytesFree(pDisplay); uint32_t room = displayTxBytesFree(pDisplay);
if (pDisplay->cleared) { if (pDisplay->cleared) {
for (p = pageTop, i= 0; p->type != OME_END; p++, i++) { // Mark all labels and values for printing
SET_PRINTLABEL(p); memset(entry_flags, PRINT_LABEL | PRINT_VALUE, sizeof(entry_flags));
SET_PRINTVALUE(p);
}
pDisplay->cleared = false; pDisplay->cleared = false;
} else if (drawPolled) { } else if (drawPolled) {
for (p = pageTop ; p <= pageTop + pageMaxRow ; p++) { for (p = pageTop, i = 0 ; p <= pageTop + pageMaxRow ; p++, i++) {
if (IS_DYNAMIC(p)) if (IS_DYNAMIC(p))
SET_PRINTVALUE(p); SET_PRINTVALUE(p, i);
} }
} }
@ -566,11 +578,11 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
// Print text labels // Print text labels
for (i = 0, p = pageTop; i < MAX_MENU_ITEMS(pDisplay) && p->type != OME_END; i++, p++) { for (i = 0, p = pageTop; i < MAX_MENU_ITEMS(pDisplay) && p->type != OME_END; i++, p++) {
if (IS_PRINTLABEL(p)) { if (IS_PRINTLABEL(p, i)) {
uint8_t coloff = LEFT_MENU_COLUMN; uint8_t coloff = LEFT_MENU_COLUMN;
coloff += cmsElementIsLabel(p->type) ? 1 : 2; coloff += cmsElementIsLabel(p->type) ? 1 : 2;
room -= displayWrite(pDisplay, coloff, i + top, p->text); room -= displayWrite(pDisplay, coloff, i + top, p->text);
CLR_PRINTLABEL(p); CLR_PRINTLABEL(p, i);
if (room < 30) if (room < 30)
return; return;
} }
@ -582,8 +594,8 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
// XXX printed if not enough room in the middle of the list. // XXX printed if not enough room in the middle of the list.
for (i = 0, p = pageTop; i < MAX_MENU_ITEMS(pDisplay) && p->type != OME_END; i++, p++) { for (i = 0, p = pageTop; i < MAX_MENU_ITEMS(pDisplay) && p->type != OME_END; i++, p++) {
if (IS_PRINTVALUE(p)) { if (IS_PRINTVALUE(p, i)) {
room -= cmsDrawMenuEntry(pDisplay, p, top + i); room -= cmsDrawMenuEntry(pDisplay, p, top + i, i);
if (room < 30) if (room < 30)
return; return;
} }
@ -592,7 +604,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
static void cmsMenuCountPage(displayPort_t *pDisplay) static void cmsMenuCountPage(displayPort_t *pDisplay)
{ {
OSD_Entry *p; const OSD_Entry *p;
for (p = currentCtx.menu->entries; p->type != OME_END; p++); for (p = currentCtx.menu->entries; p->type != OME_END; p++);
pageCount = (p - currentCtx.menu->entries - 1) / MAX_MENU_ITEMS(pDisplay) + 1; pageCount = (p - currentCtx.menu->entries - 1) / MAX_MENU_ITEMS(pDisplay) + 1;
} }
@ -772,7 +784,7 @@ long cmsMenuExit(displayPort_t *pDisplay, const void *ptr)
STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key) STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
{ {
uint16_t res = BUTTON_TIME; uint16_t res = BUTTON_TIME;
OSD_Entry *p; const OSD_Entry *p;
if (!currentCtx.menu) if (!currentCtx.menu)
return res; return res;
@ -851,7 +863,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
*val = 1; *val = 1;
else else
*val = 0; *val = 0;
SET_PRINTVALUE(p); SET_PRINTVALUE(p, currentCtx.cursorRow);
} }
break; break;
@ -860,7 +872,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
bool (*func)(bool *arg) = p->data; bool (*func)(bool *arg) = p->data;
bool val = key == KEY_RIGHT; bool val = key == KEY_RIGHT;
func(&val); func(&val);
SET_PRINTVALUE(p); SET_PRINTVALUE(p, currentCtx.cursorRow);
} }
break; break;
@ -873,7 +885,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
*val |= VISIBLE_FLAG; *val |= VISIBLE_FLAG;
else else
*val %= ~VISIBLE_FLAG; *val %= ~VISIBLE_FLAG;
SET_PRINTVALUE(p); SET_PRINTVALUE(p, currentCtx.cursorRow);
} }
break; break;
#endif #endif
@ -890,7 +902,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
if (*ptr->val > ptr->min) if (*ptr->val > ptr->min)
*ptr->val -= ptr->step; *ptr->val -= ptr->step;
} }
SET_PRINTVALUE(p); SET_PRINTVALUE(p, currentCtx.cursorRow);
if (p->func) { if (p->func) {
p->func(pDisplay, p); p->func(pDisplay, p);
} }
@ -911,7 +923,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
} }
if (p->func) if (p->func)
p->func(pDisplay, p->data); p->func(pDisplay, p->data);
SET_PRINTVALUE(p); SET_PRINTVALUE(p, currentCtx.cursorRow);
} }
break; break;
@ -926,7 +938,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
if (*ptr->val > ptr->min) if (*ptr->val > ptr->min)
*ptr->val -= ptr->step; *ptr->val -= ptr->step;
} }
SET_PRINTVALUE(p); SET_PRINTVALUE(p, currentCtx.cursorRow);
if (p->func) { if (p->func) {
p->func(pDisplay, p); p->func(pDisplay, p);
} }
@ -944,7 +956,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
if (*ptr->val > ptr->min) if (*ptr->val > ptr->min)
*ptr->val -= ptr->step; *ptr->val -= ptr->step;
} }
SET_PRINTVALUE(p); SET_PRINTVALUE(p, currentCtx.cursorRow);
if (p->func) { if (p->func) {
p->func(pDisplay, p); p->func(pDisplay, p);
} }
@ -962,7 +974,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
if (*ptr->val > ptr->min) if (*ptr->val > ptr->min)
*ptr->val -= ptr->step; *ptr->val -= ptr->step;
} }
SET_PRINTVALUE(p); SET_PRINTVALUE(p, currentCtx.cursorRow);
if (p->func) { if (p->func) {
p->func(pDisplay, p); p->func(pDisplay, p);
} }
@ -1025,7 +1037,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
} }
break; break;
} }
SET_PRINTVALUE(p); SET_PRINTVALUE(p, currentCtx.cursorRow);
if (p->func) { if (p->func) {
p->func(pDisplay, p); p->func(pDisplay, p);
} }

View file

@ -75,7 +75,7 @@ static bool cmsx_Blackbox_Enabled(bool *enabled)
return featureConfigured(FEATURE_BLACKBOX); return featureConfigured(FEATURE_BLACKBOX);
} }
static OSD_Entry cmsx_menuBlackboxEntries[] = static const OSD_Entry cmsx_menuBlackboxEntries[] =
{ {
OSD_LABEL_ENTRY("-- BLACKBOX --"), OSD_LABEL_ENTRY("-- BLACKBOX --"),
OSD_BOOL_FUNC_ENTRY("ENABLED", cmsx_Blackbox_Enabled), OSD_BOOL_FUNC_ENTRY("ENABLED", cmsx_Blackbox_Enabled),
@ -89,7 +89,7 @@ static OSD_Entry cmsx_menuBlackboxEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
CMS_Menu cmsx_menuBlackbox = { const CMS_Menu cmsx_menuBlackbox = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "MENUBB", .GUARD_text = "MENUBB",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,

View file

@ -17,4 +17,4 @@
#pragma once #pragma once
extern CMS_Menu cmsx_menuBlackbox; extern const CMS_Menu cmsx_menuBlackbox;

View file

@ -73,7 +73,7 @@ static long cmsx_InfoInit(void)
return 0; return 0;
} }
static OSD_Entry menuInfoEntries[] = { static const OSD_Entry menuInfoEntries[] = {
OSD_LABEL_ENTRY("--- INFO ---"), OSD_LABEL_ENTRY("--- INFO ---"),
OSD_STRING_ENTRY("FWID", INAV_IDENTIFIER), OSD_STRING_ENTRY("FWID", INAV_IDENTIFIER),
OSD_STRING_ENTRY("FWVER", FC_VERSION_STRING), OSD_STRING_ENTRY("FWVER", FC_VERSION_STRING),
@ -84,7 +84,7 @@ static OSD_Entry menuInfoEntries[] = {
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu menuInfo = { static const CMS_Menu menuInfo = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "MENUINFO", .GUARD_text = "MENUINFO",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -97,7 +97,7 @@ static CMS_Menu menuInfo = {
// Features // Features
static OSD_Entry menuFeaturesEntries[] = static const OSD_Entry menuFeaturesEntries[] =
{ {
OSD_LABEL_ENTRY("--- FEATURES ---"), OSD_LABEL_ENTRY("--- FEATURES ---"),
OSD_SUBMENU_ENTRY("BLACKBOX", &cmsx_menuBlackbox), OSD_SUBMENU_ENTRY("BLACKBOX", &cmsx_menuBlackbox),
@ -123,7 +123,7 @@ static OSD_Entry menuFeaturesEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu menuFeatures = { static const CMS_Menu menuFeatures = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "MENUFEATURES", .GUARD_text = "MENUFEATURES",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -136,7 +136,7 @@ static CMS_Menu menuFeatures = {
// Main // Main
static OSD_Entry menuMainEntries[] = static const OSD_Entry menuMainEntries[] =
{ {
OSD_LABEL_ENTRY("-- MAIN --"), OSD_LABEL_ENTRY("-- MAIN --"),
@ -158,7 +158,7 @@ static OSD_Entry menuMainEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
CMS_Menu menuMain = { const CMS_Menu menuMain = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "MENUMAIN", .GUARD_text = "MENUMAIN",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,

View file

@ -19,4 +19,4 @@
#include "cms/cms_types.h" #include "cms/cms_types.h"
extern CMS_Menu menuMain; extern const CMS_Menu menuMain;

View file

@ -129,7 +129,7 @@ static long cmsx_PidWriteback(const OSD_Entry *self)
return 0; return 0;
} }
static OSD_Entry cmsx_menuPidEntries[] = static const OSD_Entry cmsx_menuPidEntries[] =
{ {
OSD_LABEL_DATA_ENTRY("-- PID --", profileIndexString), OSD_LABEL_DATA_ENTRY("-- PID --", profileIndexString),
@ -149,7 +149,7 @@ static OSD_Entry cmsx_menuPidEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu cmsx_menuPid = { static const CMS_Menu cmsx_menuPid = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XPID", .GUARD_text = "XPID",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -186,7 +186,7 @@ static long cmsx_menuPidAltMag_onExit(const OSD_Entry *self)
return 0; return 0;
} }
static OSD_Entry cmsx_menuPidAltMagEntries[] = static const OSD_Entry cmsx_menuPidAltMagEntries[] =
{ {
OSD_LABEL_DATA_ENTRY("-- ALT&MAG --", profileIndexString), OSD_LABEL_DATA_ENTRY("-- ALT&MAG --", profileIndexString),
@ -203,7 +203,7 @@ static OSD_Entry cmsx_menuPidAltMagEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu cmsx_menuPidAltMag = { static const CMS_Menu cmsx_menuPidAltMag = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XALTMAG", .GUARD_text = "XALTMAG",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -237,7 +237,7 @@ static long cmsx_menuPidGpsnav_onExit(const OSD_Entry *self)
return 0; return 0;
} }
static OSD_Entry cmsx_menuPidGpsnavEntries[] = static const OSD_Entry cmsx_menuPidGpsnavEntries[] =
{ {
OSD_LABEL_DATA_ENTRY("-- GPSNAV --", profileIndexString), OSD_LABEL_DATA_ENTRY("-- GPSNAV --", profileIndexString),
@ -251,7 +251,7 @@ static OSD_Entry cmsx_menuPidGpsnavEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu cmsx_menuPidGpsnav = { static const CMS_Menu cmsx_menuPidGpsnav = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XGPSNAV", .GUARD_text = "XGPSNAV",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -265,7 +265,7 @@ static CMS_Menu cmsx_menuPidGpsnav = {
// //
// MANUAL Rate & Expo // MANUAL Rate & Expo
// //
static OSD_Entry cmsx_menuManualRateProfileEntries[] = static const OSD_Entry cmsx_menuManualRateProfileEntries[] =
{ {
OSD_LABEL_DATA_ENTRY("-- MANUAL RATE --", profileIndexString), OSD_LABEL_DATA_ENTRY("-- MANUAL RATE --", profileIndexString),
@ -280,7 +280,7 @@ static OSD_Entry cmsx_menuManualRateProfileEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu cmsx_menuManualRateProfile = { static const CMS_Menu cmsx_menuManualRateProfile = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "MENUMANURATE", .GUARD_text = "MENUMANURATE",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -294,7 +294,7 @@ static CMS_Menu cmsx_menuManualRateProfile = {
// //
// Rate & Expo // Rate & Expo
// //
static OSD_Entry cmsx_menuRateProfileEntries[] = static const OSD_Entry cmsx_menuRateProfileEntries[] =
{ {
OSD_LABEL_DATA_ENTRY("-- RATE --", profileIndexString), OSD_LABEL_DATA_ENTRY("-- RATE --", profileIndexString),
@ -320,7 +320,7 @@ static OSD_Entry cmsx_menuRateProfileEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu cmsx_menuRateProfile = { static const CMS_Menu cmsx_menuRateProfile = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "MENURATE", .GUARD_text = "MENURATE",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -366,7 +366,7 @@ static long cmsx_profileOtherOnExit(const OSD_Entry *self)
return 0; return 0;
} }
static OSD_Entry cmsx_menuProfileOtherEntries[] = { static const OSD_Entry cmsx_menuProfileOtherEntries[] = {
{ "-- OTHER PP --", OME_Label, NULL, profileIndexString, 0 }, { "-- OTHER PP --", OME_Label, NULL, profileIndexString, 0 },
{ "D SETPT WT", OME_FLOAT, NULL, &(OSD_FLOAT_t){ &cmsx_dtermSetpointWeight, 0, 255, 1, 10 }, 0 }, { "D SETPT WT", OME_FLOAT, NULL, &(OSD_FLOAT_t){ &cmsx_dtermSetpointWeight, 0, 255, 1, 10 }, 0 },
@ -379,7 +379,7 @@ static OSD_Entry cmsx_menuProfileOtherEntries[] = {
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu cmsx_menuProfileOther = { static const CMS_Menu cmsx_menuProfileOther = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XPROFOTHER", .GUARD_text = "XPROFOTHER",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -394,7 +394,7 @@ static CMS_Menu cmsx_menuProfileOther = {
// //
// Per profile filters // Per profile filters
// //
static OSD_Entry cmsx_menuFilterPerProfileEntries[] = static const OSD_Entry cmsx_menuFilterPerProfileEntries[] =
{ {
OSD_LABEL_DATA_ENTRY("-- FILTER PP --", profileIndexString), OSD_LABEL_DATA_ENTRY("-- FILTER PP --", profileIndexString),
@ -407,7 +407,7 @@ static OSD_Entry cmsx_menuFilterPerProfileEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu cmsx_menuFilterPerProfile = { static const CMS_Menu cmsx_menuFilterPerProfile = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XFLTPP", .GUARD_text = "XFLTPP",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -418,7 +418,7 @@ static CMS_Menu cmsx_menuFilterPerProfile = {
.entries = cmsx_menuFilterPerProfileEntries, .entries = cmsx_menuFilterPerProfileEntries,
}; };
static OSD_Entry cmsx_menuGyroEntries[] = static const OSD_Entry cmsx_menuGyroEntries[] =
{ {
OSD_LABEL_DATA_ENTRY("-- GYRO GLB --", profileIndexString), OSD_LABEL_DATA_ENTRY("-- GYRO GLB --", profileIndexString),
@ -430,7 +430,7 @@ static OSD_Entry cmsx_menuGyroEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu cmsx_menuGyro = { static const CMS_Menu cmsx_menuGyro = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XGYROGLB", .GUARD_text = "XGYROGLB",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -441,7 +441,7 @@ static CMS_Menu cmsx_menuGyro = {
.entries = cmsx_menuGyroEntries, .entries = cmsx_menuGyroEntries,
}; };
static OSD_Entry cmsx_menuImuEntries[] = static const OSD_Entry cmsx_menuImuEntries[] =
{ {
OSD_LABEL_ENTRY("-- PID TUNING --"), OSD_LABEL_ENTRY("-- PID TUNING --"),
@ -470,7 +470,7 @@ static OSD_Entry cmsx_menuImuEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
CMS_Menu cmsx_menuImu = { const CMS_Menu cmsx_menuImu = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XIMU", .GUARD_text = "XIMU",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,

View file

@ -17,4 +17,4 @@
#pragma once #pragma once
extern CMS_Menu cmsx_menuImu; extern const CMS_Menu cmsx_menuImu;

View file

@ -56,7 +56,7 @@ static bool cmsx_FeatureLedStrip_Enabled(bool *enabled)
return featureConfigured(FEATURE_LED_STRIP); return featureConfigured(FEATURE_LED_STRIP);
} }
static OSD_Entry cmsx_menuLedstripEntries[] = static const OSD_Entry cmsx_menuLedstripEntries[] =
{ {
OSD_LABEL_ENTRY("-- LED STRIP --"), OSD_LABEL_ENTRY("-- LED STRIP --"),
OSD_BOOL_FUNC_ENTRY("ENABLED", cmsx_FeatureLedStrip_Enabled), OSD_BOOL_FUNC_ENTRY("ENABLED", cmsx_FeatureLedStrip_Enabled),
@ -65,7 +65,7 @@ static OSD_Entry cmsx_menuLedstripEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
CMS_Menu cmsx_menuLedstrip = { const CMS_Menu cmsx_menuLedstrip = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "MENULED", .GUARD_text = "MENULED",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,

View file

@ -17,4 +17,4 @@
#pragma once #pragma once
extern CMS_Menu cmsx_menuLedstrip; extern const CMS_Menu cmsx_menuLedstrip;

View file

@ -52,7 +52,7 @@ static long cmsx_menuRcConfirmBack(const OSD_Entry *self)
// //
// RC preview // RC preview
// //
static OSD_Entry cmsx_menuRcEntries[] = static const OSD_Entry cmsx_menuRcEntries[] =
{ {
OSD_LABEL_ENTRY("-- RC PREV --"), OSD_LABEL_ENTRY("-- RC PREV --"),
@ -70,7 +70,7 @@ static OSD_Entry cmsx_menuRcEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
CMS_Menu cmsx_menuRcPreview = { static const CMS_Menu cmsx_menuRcPreview = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XRCPREV", .GUARD_text = "XRCPREV",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -81,7 +81,7 @@ CMS_Menu cmsx_menuRcPreview = {
.entries = cmsx_menuRcEntries .entries = cmsx_menuRcEntries
}; };
static OSD_Entry menuMiscEntries[]= static const OSD_Entry menuMiscEntries[]=
{ {
OSD_LABEL_ENTRY("-- MISC --"), OSD_LABEL_ENTRY("-- MISC --"),
@ -106,7 +106,7 @@ static OSD_Entry menuMiscEntries[]=
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
CMS_Menu cmsx_menuMisc = { const CMS_Menu cmsx_menuMisc = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XMISC", .GUARD_text = "XMISC",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,

View file

@ -17,4 +17,4 @@
#pragma once #pragma once
extern CMS_Menu cmsx_menuMisc; extern const CMS_Menu cmsx_menuMisc;

View file

@ -38,7 +38,7 @@
#include "navigation/navigation.h" #include "navigation/navigation.h"
static OSD_Entry cmsx_menuNavSettingsEntries[] = static const OSD_Entry cmsx_menuNavSettingsEntries[] =
{ {
OSD_LABEL_ENTRY("-- BASIC SETTINGS --"), OSD_LABEL_ENTRY("-- BASIC SETTINGS --"),
@ -55,7 +55,7 @@ static OSD_Entry cmsx_menuNavSettingsEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu cmsx_menuNavSettings = { static const CMS_Menu cmsx_menuNavSettings = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "MENUNAVSETTINGS", .GUARD_text = "MENUNAVSETTINGS",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -66,7 +66,7 @@ static CMS_Menu cmsx_menuNavSettings = {
.entries = cmsx_menuNavSettingsEntries .entries = cmsx_menuNavSettingsEntries
}; };
static OSD_Entry cmsx_menuRTHEntries[] = static const OSD_Entry cmsx_menuRTHEntries[] =
{ {
OSD_LABEL_ENTRY("-- RTH --"), OSD_LABEL_ENTRY("-- RTH --"),
@ -86,7 +86,7 @@ static CMS_Menu cmsx_menuNavSettings = {
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu cmsx_menuRTH = { static const CMS_Menu cmsx_menuRTH = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "MENUNAVRTH", .GUARD_text = "MENUNAVRTH",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -97,7 +97,7 @@ static CMS_Menu cmsx_menuRTH = {
.entries = cmsx_menuRTHEntries .entries = cmsx_menuRTHEntries
}; };
static OSD_Entry cmsx_menuFixedWingEntries[] = static const OSD_Entry cmsx_menuFixedWingEntries[] =
{ {
OSD_LABEL_ENTRY("-- FIXED WING --"), OSD_LABEL_ENTRY("-- FIXED WING --"),
@ -114,7 +114,7 @@ static OSD_Entry cmsx_menuFixedWingEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu cmsx_menuFixedWing = { static const CMS_Menu cmsx_menuFixedWing = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "MENUNAVFW", .GUARD_text = "MENUNAVFW",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -125,7 +125,7 @@ static CMS_Menu cmsx_menuFixedWing = {
.entries = cmsx_menuFixedWingEntries .entries = cmsx_menuFixedWingEntries
}; };
static OSD_Entry cmsx_menuNavigationEntries[] = static const OSD_Entry cmsx_menuNavigationEntries[] =
{ {
OSD_LABEL_ENTRY("-- NAVIGATION --"), OSD_LABEL_ENTRY("-- NAVIGATION --"),
@ -137,7 +137,7 @@ static OSD_Entry cmsx_menuNavigationEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
CMS_Menu cmsx_menuNavigation = { const CMS_Menu cmsx_menuNavigation = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "MENUNAV", .GUARD_text = "MENUNAV",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,

View file

@ -26,4 +26,4 @@
#pragma once #pragma once
extern CMS_Menu cmsx_menuNavigation; extern const CMS_Menu cmsx_menuNavigation;

View file

@ -33,7 +33,7 @@
#include "io/osd.h" #include "io/osd.h"
OSD_Entry cmsx_menuAlarmsEntries[] = static const OSD_Entry cmsx_menuAlarmsEntries[] =
{ {
OSD_LABEL_ENTRY("--- ALARMS ---"), OSD_LABEL_ENTRY("--- ALARMS ---"),
@ -45,7 +45,7 @@ OSD_Entry cmsx_menuAlarmsEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
CMS_Menu cmsx_menuAlarms = { const CMS_Menu cmsx_menuAlarms = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "MENUALARMS", .GUARD_text = "MENUALARMS",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -74,7 +74,7 @@ static long menuOsdActiveElemsOnExit(const OSD_Entry *self)
#define OSD_OSD_ELEMENT_ENTRY(name, osd_id) {name, OME_VISIBLE, NULL, &osdConfig_item_pos[osd_id], 0} #define OSD_OSD_ELEMENT_ENTRY(name, osd_id) {name, OME_VISIBLE, NULL, &osdConfig_item_pos[osd_id], 0}
OSD_Entry menuOsdActiveElemsEntries[] = static const OSD_Entry menuOsdActiveElemsEntries[] =
{ {
OSD_LABEL_ENTRY("--- ACTIV ELEM ---"), OSD_LABEL_ENTRY("--- ACTIV ELEM ---"),
@ -112,7 +112,7 @@ OSD_Entry menuOsdActiveElemsEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
CMS_Menu menuOsdActiveElems = { const CMS_Menu menuOsdActiveElems = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "MENUOSDACT", .GUARD_text = "MENUOSDACT",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -123,7 +123,7 @@ CMS_Menu menuOsdActiveElems = {
.entries = menuOsdActiveElemsEntries .entries = menuOsdActiveElemsEntries
}; };
OSD_Entry cmsx_menuOsdLayoutEntries[] = static const OSD_Entry cmsx_menuOsdLayoutEntries[] =
{ {
OSD_LABEL_ENTRY("---SCREEN LAYOUT---"), OSD_LABEL_ENTRY("---SCREEN LAYOUT---"),
OSD_SUBMENU_ENTRY("ACTIVE ELEM", &menuOsdActiveElems), OSD_SUBMENU_ENTRY("ACTIVE ELEM", &menuOsdActiveElems),
@ -132,7 +132,7 @@ OSD_Entry cmsx_menuOsdLayoutEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
CMS_Menu cmsx_menuOsdLayout = { const CMS_Menu cmsx_menuOsdLayout = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "MENULAYOUT", .GUARD_text = "MENULAYOUT",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,

View file

@ -17,5 +17,5 @@
#pragma once #pragma once
extern CMS_Menu cmsx_menuAlarms; extern const CMS_Menu cmsx_menuAlarms;
extern CMS_Menu cmsx_menuOsdLayout; extern const CMS_Menu cmsx_menuOsdLayout;

View file

@ -114,7 +114,7 @@ static OSD_UINT8_t entryVtxMode = {&masterConfig.vtx_mode, 0, 2, 1};
static OSD_UINT16_t entryVtxMhz = {&masterConfig.vtx_mhz, 5600, 5950, 1}; static OSD_UINT16_t entryVtxMhz = {&masterConfig.vtx_mhz, 5600, 5950, 1};
#endif // VTX #endif // VTX
static OSD_Entry cmsx_menuVtxEntries[] = static const OSD_Entry cmsx_menuVtxEntries[] =
{ {
OSD_LABEL_ENTRY("--- VTX ---"), OSD_LABEL_ENTRY("--- VTX ---"),
OSD_BOOL_ENTRY("ENABLED", &cmsx_featureVtx), OSD_BOOL_ENTRY("ENABLED", &cmsx_featureVtx),
@ -132,7 +132,7 @@ static OSD_Entry cmsx_menuVtxEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
CMS_Menu cmsx_menuVtx = { const CMS_Menu cmsx_menuVtx = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "MENUVTX", .GUARD_text = "MENUVTX",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,

View file

@ -17,4 +17,4 @@
#pragma once #pragma once
extern CMS_Menu cmsx_menuVtx; extern const CMS_Menu cmsx_menuVtx;

View file

@ -306,7 +306,7 @@ static const char * const saCmsDeviceStatusNames[] = {
static OSD_TAB_t saCmsEntOnline = { &saCmsDeviceStatus, 2, saCmsDeviceStatusNames }; static OSD_TAB_t saCmsEntOnline = { &saCmsDeviceStatus, 2, saCmsDeviceStatusNames };
static OSD_Entry saCmsMenuStatsEntries[] = { static const OSD_Entry saCmsMenuStatsEntries[] = {
OSD_LABEL_ENTRY("- SA STATS -"), OSD_LABEL_ENTRY("- SA STATS -"),
OSD_TAB_DYN_ENTRY("STATUS", &saCmsEntOnline), OSD_TAB_DYN_ENTRY("STATUS", &saCmsEntOnline),
@ -322,7 +322,7 @@ static OSD_Entry saCmsMenuStatsEntries[] = {
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu saCmsMenuStats = { static const CMS_Menu saCmsMenuStats = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XSAST", .GUARD_text = "XSAST",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -476,7 +476,7 @@ static long saCmsConfigUserFreq(displayPort_t *pDisp, const void *self)
return MENU_CHAIN_BACK; return MENU_CHAIN_BACK;
} }
static OSD_Entry saCmsMenuPORFreqEntries[] = static const OSD_Entry saCmsMenuPORFreqEntries[] =
{ {
OSD_LABEL_ENTRY("- POR FREQ -"), OSD_LABEL_ENTRY("- POR FREQ -"),
@ -488,7 +488,7 @@ static OSD_Entry saCmsMenuPORFreqEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu saCmsMenuPORFreq = static const CMS_Menu saCmsMenuPORFreq =
{ {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XSAPOR", .GUARD_text = "XSAPOR",
@ -500,7 +500,7 @@ static CMS_Menu saCmsMenuPORFreq =
.entries = saCmsMenuPORFreqEntries, .entries = saCmsMenuPORFreqEntries,
}; };
static OSD_Entry saCmsMenuUserFreqEntries[] = static const OSD_Entry saCmsMenuUserFreqEntries[] =
{ {
OSD_LABEL_ENTRY("- USER FREQ -"), OSD_LABEL_ENTRY("- USER FREQ -"),
@ -512,7 +512,7 @@ static OSD_Entry saCmsMenuUserFreqEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu saCmsMenuUserFreq = static const CMS_Menu saCmsMenuUserFreq =
{ {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XSAUFQ", .GUARD_text = "XSAUFQ",
@ -526,21 +526,21 @@ static CMS_Menu saCmsMenuUserFreq =
static OSD_TAB_t saCmsEntFselMode = { &saCmsFselMode, 1, saCmsFselModeNames }; static OSD_TAB_t saCmsEntFselMode = { &saCmsFselMode, 1, saCmsFselModeNames };
static OSD_Entry saCmsMenuConfigEntries[] = static const OSD_Entry saCmsMenuConfigEntries[] =
{ {
OSD_LABEL_ENTRY("- SA CONFIG -"), OSD_LABEL_ENTRY("- SA CONFIG -"),
{ "OP MODEL", OME_TAB, saCmsConfigOpmodelByGvar, &(OSD_TAB_t){ &saCmsOpmodel, 2, saCmsOpmodelNames }, DYNAMIC }, { "OP MODEL", OME_TAB, saCmsConfigOpmodelByGvar, &(OSD_TAB_t){ &saCmsOpmodel, 2, saCmsOpmodelNames }, DYNAMIC },
{ "FSEL MODE", OME_TAB, saCmsConfigFreqModeByGvar, &saCmsEntFselMode, DYNAMIC }, { "FSEL MODE", OME_TAB, saCmsConfigFreqModeByGvar, &saCmsEntFselMode, DYNAMIC },
OSD_TAB_CALLBACK_ENTRY("PIT FMODE", saCmsConfigPitFModeByGvar, &saCmsEntPitFMode), OSD_TAB_CALLBACK_ENTRY("PIT FMODE", saCmsConfigPitFModeByGvar, &saCmsEntPitFMode),
{ "POR FREQ", OME_Submenu, (CMSEntryFuncPtr)saCmsORFreqGetString, &saCmsMenuPORFreq, OPTSTRING }, { "POR FREQ", OME_Submenu, (CMSEntryFuncPtr)saCmsORFreqGetString, (void *)&saCmsMenuPORFreq, OPTSTRING },
OSD_SUBMENU_ENTRY("STATX", &saCmsMenuStats), OSD_SUBMENU_ENTRY("STATX", &saCmsMenuStats),
OSD_BACK_ENTRY, OSD_BACK_ENTRY,
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu saCmsMenuConfig = { static const CMS_Menu saCmsMenuConfig = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XSACFG", .GUARD_text = "XSACFG",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -551,7 +551,7 @@ static CMS_Menu saCmsMenuConfig = {
.entries = saCmsMenuConfigEntries .entries = saCmsMenuConfigEntries
}; };
static OSD_Entry saCmsMenuCommenceEntries[] = static const OSD_Entry saCmsMenuCommenceEntries[] =
{ {
OSD_LABEL_ENTRY("CONFIRM"), OSD_LABEL_ENTRY("CONFIRM"),
OSD_FUNC_CALL_ENTRY("YES", saCmsCommence), OSD_FUNC_CALL_ENTRY("YES", saCmsCommence),
@ -560,7 +560,7 @@ static OSD_Entry saCmsMenuCommenceEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu saCmsMenuCommence = { static const CMS_Menu saCmsMenuCommence = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XVTXCOM", .GUARD_text = "XVTXCOM",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -571,7 +571,7 @@ static CMS_Menu saCmsMenuCommence = {
.entries = saCmsMenuCommenceEntries, .entries = saCmsMenuCommenceEntries,
}; };
static OSD_Entry saCmsMenuFreqModeEntries[] = static const OSD_Entry saCmsMenuFreqModeEntries[] =
{ {
OSD_LABEL_ENTRY("- SMARTAUDIO -"), OSD_LABEL_ENTRY("- SMARTAUDIO -"),
@ -585,7 +585,7 @@ static OSD_Entry saCmsMenuFreqModeEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static OSD_Entry saCmsMenuChanModeEntries[] = static const OSD_Entry saCmsMenuChanModeEntries[] =
{ {
OSD_LABEL_ENTRY("- SMARTAUDIO -"), OSD_LABEL_ENTRY("- SMARTAUDIO -"),
@ -601,7 +601,7 @@ static OSD_Entry saCmsMenuChanModeEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static OSD_Entry saCmsMenuOfflineEntries[] = static const OSD_Entry saCmsMenuOfflineEntries[] =
{ {
OSD_LABEL_ENTRY("- VTX SMARTAUDIO -"), OSD_LABEL_ENTRY("- VTX SMARTAUDIO -"),

View file

@ -196,7 +196,7 @@ static long trampCmsOnEnter(void)
return 0; return 0;
} }
static OSD_Entry trampCmsMenuCommenceEntries[] = { static const OSD_Entry trampCmsMenuCommenceEntries[] = {
OSD_LABEL_ENTRY("CONFIRM"), OSD_LABEL_ENTRY("CONFIRM"),
OSD_FUNC_CALL_ENTRY("YES", trampCmsCommence), OSD_FUNC_CALL_ENTRY("YES", trampCmsCommence),
@ -204,7 +204,7 @@ static OSD_Entry trampCmsMenuCommenceEntries[] = {
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
static CMS_Menu trampCmsMenuCommence = { static const CMS_Menu trampCmsMenuCommence = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XVTXTRC", .GUARD_text = "XVTXTRC",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,
@ -215,7 +215,7 @@ static CMS_Menu trampCmsMenuCommence = {
.entries = trampCmsMenuCommenceEntries, .entries = trampCmsMenuCommenceEntries,
}; };
static OSD_Entry trampMenuEntries[] = static const OSD_Entry trampMenuEntries[] =
{ {
OSD_LABEL_ENTRY("- TRAMP -"), OSD_LABEL_ENTRY("- TRAMP -"),
@ -232,7 +232,7 @@ static OSD_Entry trampMenuEntries[] =
OSD_END_ENTRY, OSD_END_ENTRY,
}; };
CMS_Menu cmsx_menuVtxTramp = { const CMS_Menu cmsx_menuVtxTramp = {
#ifdef CMS_MENU_DEBUG #ifdef CMS_MENU_DEBUG
.GUARD_text = "XVTXTR", .GUARD_text = "XVTXTR",
.GUARD_type = OME_MENU, .GUARD_type = OME_MENU,

View file

@ -19,4 +19,5 @@
#include "cms/cms.h" #include "cms/cms.h"
#include "cms/cms_types.h" #include "cms/cms_types.h"
extern CMS_Menu cmsx_menuVtxTramp;
extern const CMS_Menu cmsx_menuVtxTramp;

View file

@ -80,7 +80,11 @@ typedef struct
#define OSD_LABEL_DATA_DYN_ENTRY(label, data) ((OSD_Entry){ label, OME_Label, NULL, data, DYNAMIC }) #define OSD_LABEL_DATA_DYN_ENTRY(label, data) ((OSD_Entry){ label, OME_Label, NULL, data, DYNAMIC })
#define OSD_LABEL_FUNC_DYN_ENTRY(label, fn) ((OSD_Entry){ label, OME_LabelFunc, NULL, fn, DYNAMIC }) #define OSD_LABEL_FUNC_DYN_ENTRY(label, fn) ((OSD_Entry){ label, OME_LabelFunc, NULL, fn, DYNAMIC })
#define OSD_BACK_ENTRY ((OSD_Entry){ "BACK", OME_Back, NULL, NULL, 0 }) #define OSD_BACK_ENTRY ((OSD_Entry){ "BACK", OME_Back, NULL, NULL, 0 })
#define OSD_SUBMENU_ENTRY(label, menu) ((OSD_Entry){ label, OME_Submenu, cmsMenuChange, menu, 0 }) // Cast menus to (void *), since they should be declared as const to
// be able to save them in FLASH. Of course, this means that changing
// a entry->data pointer for a menu declared as const will result in
// UB.
#define OSD_SUBMENU_ENTRY(label, menu) ((OSD_Entry){ label, OME_Submenu, cmsMenuChange, (void *)menu, 0 })
#define OSD_FUNC_CALL_ENTRY(label, fn) ((OSD_Entry){ label, OME_Funcall, fn, NULL, 0 }) #define OSD_FUNC_CALL_ENTRY(label, fn) ((OSD_Entry){ label, OME_Funcall, fn, NULL, 0 })
#define OSD_BOOL_ENTRY(label, val) ((OSD_Entry){ label, OME_Bool, NULL, val, 0 }) #define OSD_BOOL_ENTRY(label, val) ((OSD_Entry){ label, OME_Bool, NULL, val, 0 })
#define OSD_BOOL_FUNC_ENTRY(label, fn) ((OSD_Entry){ label, OME_BoolFunc, NULL, fn, 0 }) #define OSD_BOOL_FUNC_ENTRY(label, fn) ((OSD_Entry){ label, OME_BoolFunc, NULL, fn, 0 })
@ -106,16 +110,6 @@ typedef enum {
// Use a function and data type to make sure switches are exhaustive // Use a function and data type to make sure switches are exhaustive
static inline CMSDataType_e CMS_DATA_TYPE(const OSD_Entry *entry) { return entry->flags & 0xF0; } static inline CMSDataType_e CMS_DATA_TYPE(const OSD_Entry *entry) { return entry->flags & 0xF0; }
#define IS_PRINTVALUE(p) ((p)->flags & PRINT_VALUE)
#define SET_PRINTVALUE(p) { (p)->flags |= PRINT_VALUE; }
#define CLR_PRINTVALUE(p) { (p)->flags &= ~PRINT_VALUE; }
#define IS_PRINTLABEL(p) ((p)->flags & PRINT_LABEL)
#define SET_PRINTLABEL(p) { (p)->flags |= PRINT_LABEL; }
#define CLR_PRINTLABEL(p) { (p)->flags &= ~PRINT_LABEL; }
#define IS_DYNAMIC(p) ((p)->flags & DYNAMIC)
typedef long (*CMSMenuFuncPtr)(void); typedef long (*CMSMenuFuncPtr)(void);
// Special return value(s) for function chaining by CMSMenuFuncPtr // Special return value(s) for function chaining by CMSMenuFuncPtr
@ -140,7 +134,7 @@ typedef struct
const CMSMenuFuncPtr onEnter; const CMSMenuFuncPtr onEnter;
const CMSMenuOnExitPtr onExit; const CMSMenuOnExitPtr onExit;
const CMSMenuFuncPtr onGlobalExit; const CMSMenuFuncPtr onGlobalExit;
OSD_Entry *entries; const OSD_Entry *entries;
} CMS_Menu; } CMS_Menu;
typedef struct typedef struct