mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Drastically reduce the CMS RAM usage.
Previously the runtime page state was mixed with the page configuration. This resolves this by: a) making the configuration entries constant so they do not need to be in RAM. b) Maintaining page state independently.
This commit is contained in:
parent
fefa2a83e4
commit
78f38daa4f
14 changed files with 93 additions and 85 deletions
|
@ -158,7 +158,7 @@ bool cmsDisplayPortSelect(displayPort_t *instance)
|
|||
// 13 cols x 9 rows, top row printed as a Bold Heading
|
||||
// Needs the "smallScreen" adaptions
|
||||
|
||||
|
||||
#define CMS_MAX_ROWS 16
|
||||
|
||||
#define NORMAL_SCREEN_MIN_COLS 18 // Less is a small screen
|
||||
static bool smallScreen;
|
||||
|
@ -181,7 +181,7 @@ static cmsCtx_t menuStack[CMS_MENU_STACK_LIMIT];
|
|||
static uint8_t menuStackIdx = 0;
|
||||
|
||||
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 cmsCtx_t currentCtx;
|
||||
|
@ -239,10 +239,18 @@ static uint8_t cmsCursorAbsolute(displayPort_t *instance)
|
|||
return currentCtx.cursorRow + currentCtx.page * maxMenuItems;
|
||||
}
|
||||
|
||||
uint8_t runtimeEntryFlags[CMS_MAX_ROWS] = { 0 };
|
||||
|
||||
static void cmsPageSelect(displayPort_t *instance, int8_t newpage)
|
||||
{
|
||||
currentCtx.page = (newpage + pageCount) % pageCount;
|
||||
pageTop = ¤tCtx.menu->entries[currentCtx.page * maxMenuItems];
|
||||
|
||||
const OSD_Entry *p;
|
||||
int i;
|
||||
for (p = pageTop, i = 0; p->type != OME_END; p++, i++) {
|
||||
runtimeEntryFlags[i] = p->flags;
|
||||
}
|
||||
cmsUpdateMaxRow(instance);
|
||||
displayClearScreen(instance);
|
||||
}
|
||||
|
@ -351,7 +359,7 @@ static int cmsDrawMenuItemValue(displayPort_t *pDisplay, char *buff, uint8_t row
|
|||
return cnt;
|
||||
}
|
||||
|
||||
static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row, bool selectedRow)
|
||||
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_NUM_FIELD_LEN 5
|
||||
|
@ -370,20 +378,20 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row,
|
|||
|
||||
switch (p->type) {
|
||||
case OME_String:
|
||||
if (IS_PRINTVALUE(p) && p->data) {
|
||||
if (IS_PRINTVALUE(flags) && p->data) {
|
||||
strncpy(buff, p->data, CMS_DRAW_BUFFER_LEN);
|
||||
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_DRAW_BUFFER_LEN);
|
||||
CLR_PRINTVALUE(p);
|
||||
CLR_PRINTVALUE(flags);
|
||||
}
|
||||
break;
|
||||
|
||||
case OME_Submenu:
|
||||
case OME_Funcall:
|
||||
if (IS_PRINTVALUE(p)) {
|
||||
if (IS_PRINTVALUE(flags)) {
|
||||
|
||||
buff[0]= 0x0;
|
||||
|
||||
if ((p->type == OME_Submenu) && p->func && (p->flags & OPTSTRING)) {
|
||||
if ((p->type == OME_Submenu) && p->func && (flags & OPTSTRING)) {
|
||||
|
||||
// Special case of sub menu entry with optional value display.
|
||||
|
||||
|
@ -394,12 +402,12 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row,
|
|||
|
||||
row = smallScreen ? row - 1 : row;
|
||||
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, strlen(buff));
|
||||
CLR_PRINTVALUE(p);
|
||||
CLR_PRINTVALUE(flags);
|
||||
}
|
||||
break;
|
||||
|
||||
case OME_Bool:
|
||||
if (IS_PRINTVALUE(p) && p->data) {
|
||||
if (IS_PRINTVALUE(flags) && p->data) {
|
||||
if (*((uint8_t *)(p->data))) {
|
||||
strcpy(buff, "YES");
|
||||
} else {
|
||||
|
@ -407,23 +415,23 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row,
|
|||
}
|
||||
|
||||
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, 3);
|
||||
CLR_PRINTVALUE(p);
|
||||
CLR_PRINTVALUE(flags);
|
||||
}
|
||||
break;
|
||||
|
||||
case OME_TAB:
|
||||
if (IS_PRINTVALUE(p)) {
|
||||
if (IS_PRINTVALUE(flags)) {
|
||||
OSD_TAB_t *ptr = p->data;
|
||||
char * str = (char *)ptr->names[*ptr->val];
|
||||
strncpy(buff, str, CMS_DRAW_BUFFER_LEN);
|
||||
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_DRAW_BUFFER_LEN);
|
||||
CLR_PRINTVALUE(p);
|
||||
CLR_PRINTVALUE(flags);
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef USE_OSD
|
||||
case OME_VISIBLE:
|
||||
if (IS_PRINTVALUE(p) && p->data) {
|
||||
if (IS_PRINTVALUE(flags) && p->data) {
|
||||
uint16_t *val = (uint16_t *)p->data;
|
||||
bool cursorBlink = millis() % (2 * CMS_CURSOR_BLINK_DELAY_MS) < CMS_CURSOR_BLINK_DELAY_MS;
|
||||
for (unsigned x = 1; x < OSD_PROFILE_COUNT + 1; x++) {
|
||||
|
@ -442,61 +450,61 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row,
|
|||
}
|
||||
}
|
||||
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, 3);
|
||||
CLR_PRINTVALUE(p);
|
||||
CLR_PRINTVALUE(flags);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case OME_UINT8:
|
||||
if (IS_PRINTVALUE(p) && p->data) {
|
||||
if (IS_PRINTVALUE(flags) && p->data) {
|
||||
OSD_UINT8_t *ptr = p->data;
|
||||
itoa(*ptr->val, buff, 10);
|
||||
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_NUM_FIELD_LEN);
|
||||
CLR_PRINTVALUE(p);
|
||||
CLR_PRINTVALUE(flags);
|
||||
}
|
||||
break;
|
||||
|
||||
case OME_INT8:
|
||||
if (IS_PRINTVALUE(p) && p->data) {
|
||||
if (IS_PRINTVALUE(flags) && p->data) {
|
||||
OSD_INT8_t *ptr = p->data;
|
||||
itoa(*ptr->val, buff, 10);
|
||||
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_NUM_FIELD_LEN);
|
||||
CLR_PRINTVALUE(p);
|
||||
CLR_PRINTVALUE(flags);
|
||||
}
|
||||
break;
|
||||
|
||||
case OME_UINT16:
|
||||
if (IS_PRINTVALUE(p) && p->data) {
|
||||
if (IS_PRINTVALUE(flags) && p->data) {
|
||||
OSD_UINT16_t *ptr = p->data;
|
||||
itoa(*ptr->val, buff, 10);
|
||||
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_NUM_FIELD_LEN);
|
||||
CLR_PRINTVALUE(p);
|
||||
CLR_PRINTVALUE(flags);
|
||||
}
|
||||
break;
|
||||
|
||||
case OME_INT16:
|
||||
if (IS_PRINTVALUE(p) && p->data) {
|
||||
if (IS_PRINTVALUE(flags) && p->data) {
|
||||
OSD_UINT16_t *ptr = p->data;
|
||||
itoa(*ptr->val, buff, 10);
|
||||
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_NUM_FIELD_LEN);
|
||||
CLR_PRINTVALUE(p);
|
||||
CLR_PRINTVALUE(flags);
|
||||
}
|
||||
break;
|
||||
|
||||
case OME_FLOAT:
|
||||
if (IS_PRINTVALUE(p) && p->data) {
|
||||
if (IS_PRINTVALUE(flags) && p->data) {
|
||||
OSD_FLOAT_t *ptr = p->data;
|
||||
cmsFormatFloat(*ptr->val * ptr->multipler, buff);
|
||||
cnt = cmsDrawMenuItemValue(pDisplay, buff, row, CMS_NUM_FIELD_LEN);
|
||||
CLR_PRINTVALUE(p);
|
||||
CLR_PRINTVALUE(flags);
|
||||
}
|
||||
break;
|
||||
|
||||
case OME_Label:
|
||||
if (IS_PRINTVALUE(p) && p->data) {
|
||||
if (IS_PRINTVALUE(flags) && p->data) {
|
||||
// A label with optional string, immediately following text
|
||||
cnt = displayWrite(pDisplay, leftMenuColumn + 1 + (uint8_t)strlen(p->text), row, p->data);
|
||||
CLR_PRINTVALUE(p);
|
||||
CLR_PRINTVALUE(flags);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -528,7 +536,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
|
|||
return;
|
||||
|
||||
uint8_t i;
|
||||
OSD_Entry *p;
|
||||
const OSD_Entry *p;
|
||||
uint8_t top = smallScreen ? 1 : (pDisplay->rows - pageMaxRow)/2;
|
||||
|
||||
// Polled (dynamic) value display denominator.
|
||||
|
@ -545,14 +553,14 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
|
|||
|
||||
if (pDisplay->cleared) {
|
||||
for (p = pageTop, i= 0; p->type != OME_END; p++, i++) {
|
||||
SET_PRINTLABEL(p);
|
||||
SET_PRINTVALUE(p);
|
||||
SET_PRINTLABEL(runtimeEntryFlags[i]);
|
||||
SET_PRINTVALUE(runtimeEntryFlags[i]);
|
||||
}
|
||||
pDisplay->cleared = false;
|
||||
} else if (drawPolled) {
|
||||
for (p = pageTop ; p <= pageTop + pageMaxRow ; p++) {
|
||||
for (p = pageTop, i = 0; p <= pageTop + pageMaxRow ; p++, i++) {
|
||||
if (IS_DYNAMIC(p))
|
||||
SET_PRINTVALUE(p);
|
||||
SET_PRINTVALUE(runtimeEntryFlags[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -580,11 +588,11 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
|
|||
|
||||
// Print text labels
|
||||
for (i = 0, p = pageTop; i < maxMenuItems && p->type != OME_END; i++, p++) {
|
||||
if (IS_PRINTLABEL(p)) {
|
||||
if (IS_PRINTLABEL(runtimeEntryFlags[i])) {
|
||||
uint8_t coloff = leftMenuColumn;
|
||||
coloff += (p->type == OME_Label) ? 0 : 1;
|
||||
room -= displayWrite(pDisplay, coloff, top + i * linesPerMenuItem, p->text);
|
||||
CLR_PRINTLABEL(p);
|
||||
CLR_PRINTLABEL(runtimeEntryFlags[i]);
|
||||
if (room < 30)
|
||||
return;
|
||||
}
|
||||
|
@ -594,9 +602,9 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
|
|||
// XXX Polled values at latter positions in the list may not be
|
||||
// XXX printed if not enough room in the middle of the list.
|
||||
|
||||
if (IS_PRINTVALUE(p)) {
|
||||
if (IS_PRINTVALUE(runtimeEntryFlags[i])) {
|
||||
bool selectedRow = i == currentCtx.cursorRow;
|
||||
room -= cmsDrawMenuEntry(pDisplay, p, top + i * linesPerMenuItem, selectedRow);
|
||||
room -= cmsDrawMenuEntry(pDisplay, p, top + i * linesPerMenuItem, selectedRow, runtimeEntryFlags[i]);
|
||||
if (room < 30)
|
||||
return;
|
||||
}
|
||||
|
@ -817,7 +825,7 @@ long cmsMenuExit(displayPort_t *pDisplay, const void *ptr)
|
|||
STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, cms_key_e key)
|
||||
{
|
||||
uint16_t res = BUTTON_TIME;
|
||||
OSD_Entry *p;
|
||||
const OSD_Entry *p;
|
||||
|
||||
if (!currentCtx.menu)
|
||||
return res;
|
||||
|
@ -908,7 +916,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, cms_key_e key)
|
|||
*val = 1;
|
||||
else
|
||||
*val = 0;
|
||||
SET_PRINTVALUE(p);
|
||||
SET_PRINTVALUE(runtimeEntryFlags[currentCtx.cursorRow]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -939,7 +947,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, cms_key_e key)
|
|||
*val &= ~OSD_PROFILE_FLAG(osdProfileCursor);
|
||||
}
|
||||
}
|
||||
SET_PRINTVALUE(p);
|
||||
SET_PRINTVALUE(runtimeEntryFlags[currentCtx.cursorRow]);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
@ -956,7 +964,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, cms_key_e key)
|
|||
if (*ptr->val > ptr->min)
|
||||
*ptr->val -= ptr->step;
|
||||
}
|
||||
SET_PRINTVALUE(p);
|
||||
SET_PRINTVALUE(runtimeEntryFlags[currentCtx.cursorRow]);
|
||||
if (p->func) {
|
||||
p->func(pDisplay, p);
|
||||
}
|
||||
|
@ -977,7 +985,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, cms_key_e key)
|
|||
}
|
||||
if (p->func)
|
||||
p->func(pDisplay, p->data);
|
||||
SET_PRINTVALUE(p);
|
||||
SET_PRINTVALUE(runtimeEntryFlags[currentCtx.cursorRow]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -992,7 +1000,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, cms_key_e key)
|
|||
if (*ptr->val > ptr->min)
|
||||
*ptr->val -= ptr->step;
|
||||
}
|
||||
SET_PRINTVALUE(p);
|
||||
SET_PRINTVALUE(runtimeEntryFlags[currentCtx.cursorRow]);
|
||||
if (p->func) {
|
||||
p->func(pDisplay, p);
|
||||
}
|
||||
|
@ -1010,7 +1018,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, cms_key_e key)
|
|||
if (*ptr->val > ptr->min)
|
||||
*ptr->val -= ptr->step;
|
||||
}
|
||||
SET_PRINTVALUE(p);
|
||||
SET_PRINTVALUE(runtimeEntryFlags[currentCtx.cursorRow]);
|
||||
if (p->func) {
|
||||
p->func(pDisplay, p);
|
||||
}
|
||||
|
@ -1028,7 +1036,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, cms_key_e key)
|
|||
if (*ptr->val > ptr->min)
|
||||
*ptr->val -= ptr->step;
|
||||
}
|
||||
SET_PRINTVALUE(p);
|
||||
SET_PRINTVALUE(runtimeEntryFlags[currentCtx.cursorRow]);
|
||||
if (p->func) {
|
||||
p->func(pDisplay, p);
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ static long cmsx_Blackbox_onExit(const OSD_Entry *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_Entry cmsx_menuBlackboxEntries[] =
|
||||
static const OSD_Entry cmsx_menuBlackboxEntries[] =
|
||||
{
|
||||
{ "-- BLACKBOX --", OME_Label, NULL, NULL, 0},
|
||||
{ "DEVICE", OME_TAB, NULL, &cmsx_BlackboxDeviceTable, 0 },
|
||||
|
|
|
@ -78,7 +78,7 @@ static long cmsx_InfoInit(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_Entry menuInfoEntries[] = {
|
||||
static const OSD_Entry menuInfoEntries[] = {
|
||||
{ "--- INFO ---", OME_Label, NULL, NULL, 0 },
|
||||
{ "FWID", OME_String, NULL, BETAFLIGHT_IDENTIFIER, 0 },
|
||||
{ "FWVER", OME_String, NULL, FC_VERSION_STRING, 0 },
|
||||
|
@ -100,7 +100,7 @@ static CMS_Menu menuInfo = {
|
|||
|
||||
// Features
|
||||
|
||||
static OSD_Entry menuFeaturesEntries[] =
|
||||
static const OSD_Entry menuFeaturesEntries[] =
|
||||
{
|
||||
{"--- FEATURES ---", OME_Label, NULL, NULL, 0},
|
||||
|
||||
|
@ -141,7 +141,7 @@ static CMS_Menu menuFeatures = {
|
|||
|
||||
// Main
|
||||
|
||||
static OSD_Entry menuMainEntries[] =
|
||||
static const OSD_Entry menuMainEntries[] =
|
||||
{
|
||||
{"-- MAIN --", OME_Label, NULL, NULL, 0},
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ static long cmsx_Failsafe_onExit(const OSD_Entry *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_Entry cmsx_menuFailsafeEntries[] =
|
||||
static const OSD_Entry cmsx_menuFailsafeEntries[] =
|
||||
{
|
||||
{ "-- FAILSAFE --", OME_Label, NULL, NULL, 0},
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ static long cmsx_PidWriteback(const OSD_Entry *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_Entry cmsx_menuPidEntries[] =
|
||||
static const OSD_Entry cmsx_menuPidEntries[] =
|
||||
{
|
||||
{ "-- PID --", OME_Label, NULL, pidProfileIndexString, 0},
|
||||
|
||||
|
@ -223,7 +223,7 @@ static long cmsx_RateProfileOnEnter(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_Entry cmsx_menuRateProfileEntries[] =
|
||||
static const OSD_Entry cmsx_menuRateProfileEntries[] =
|
||||
{
|
||||
{ "-- RATE --", OME_Label, NULL, rateProfileIndexString, 0 },
|
||||
|
||||
|
@ -296,7 +296,7 @@ static long cmsx_launchControlOnExit(const OSD_Entry *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_Entry cmsx_menuLaunchControlEntries[] = {
|
||||
static const OSD_Entry cmsx_menuLaunchControlEntries[] = {
|
||||
{ "-- LAUNCH CONTROL --", OME_Label, NULL, pidProfileIndexString, 0 },
|
||||
|
||||
{ "MODE", OME_TAB, NULL, &(OSD_TAB_t) { &cmsx_launchControlMode, LAUNCH_CONTROL_MODE_COUNT - 1, osdLaunchControlModeNames}, 0 },
|
||||
|
@ -388,7 +388,7 @@ static long cmsx_profileOtherOnExit(const OSD_Entry *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_Entry cmsx_menuProfileOtherEntries[] = {
|
||||
static const OSD_Entry cmsx_menuProfileOtherEntries[] = {
|
||||
{ "-- OTHER PP --", OME_Label, NULL, pidProfileIndexString, 0 },
|
||||
|
||||
{ "FF TRANS", OME_FLOAT, NULL, &(OSD_FLOAT_t) { &cmsx_feedForwardTransition, 0, 100, 1, 10 }, 0 },
|
||||
|
@ -461,7 +461,7 @@ static long cmsx_menuGyro_onExit(const OSD_Entry *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_Entry cmsx_menuFilterGlobalEntries[] =
|
||||
static const OSD_Entry cmsx_menuFilterGlobalEntries[] =
|
||||
{
|
||||
{ "-- FILTER GLB --", OME_Label, NULL, NULL, 0 },
|
||||
|
||||
|
@ -543,7 +543,7 @@ static long cmsx_menuDynFilt_onExit(const OSD_Entry *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_Entry cmsx_menuDynFiltEntries[] =
|
||||
static const OSD_Entry cmsx_menuDynFiltEntries[] =
|
||||
{
|
||||
{ "-- DYN FILT --", OME_Label, NULL, NULL, 0 },
|
||||
|
||||
|
@ -611,7 +611,7 @@ static long cmsx_FilterPerProfileWriteback(const OSD_Entry *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_Entry cmsx_menuFilterPerProfileEntries[] =
|
||||
static const OSD_Entry cmsx_menuFilterPerProfileEntries[] =
|
||||
{
|
||||
{ "-- FILTER PP --", OME_Label, NULL, NULL, 0 },
|
||||
|
||||
|
@ -681,7 +681,7 @@ static long cmsx_CopyControlRateProfile(displayPort_t *pDisplay, const void *ptr
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_Entry cmsx_menuCopyProfileEntries[] =
|
||||
static const OSD_Entry cmsx_menuCopyProfileEntries[] =
|
||||
{
|
||||
{ "-- COPY PROFILE --", OME_Label, NULL, NULL, 0},
|
||||
|
||||
|
@ -706,7 +706,7 @@ CMS_Menu cmsx_menuCopyProfile = {
|
|||
|
||||
#endif
|
||||
|
||||
static OSD_Entry cmsx_menuImuEntries[] =
|
||||
static const OSD_Entry cmsx_menuImuEntries[] =
|
||||
{
|
||||
{ "-- PROFILE --", OME_Label, NULL, NULL, 0},
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ static long cmsx_Ledstrip_OnExit(const OSD_Entry *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_Entry cmsx_menuLedstripEntries[] =
|
||||
static const OSD_Entry cmsx_menuLedstripEntries[] =
|
||||
{
|
||||
{ "-- LED STRIP --", OME_Label, NULL, NULL, 0 },
|
||||
{ "ENABLED", OME_Bool, NULL, &cmsx_FeatureLedstrip, 0 },
|
||||
|
|
|
@ -67,7 +67,7 @@ static long cmsx_menuRcConfirmBack(const OSD_Entry *self)
|
|||
//
|
||||
// RC preview
|
||||
//
|
||||
static OSD_Entry cmsx_menuRcEntries[] =
|
||||
static const OSD_Entry cmsx_menuRcEntries[] =
|
||||
{
|
||||
{ "-- RC PREV --", OME_Label, NULL, NULL, 0},
|
||||
|
||||
|
@ -119,7 +119,7 @@ static long cmsx_menuMiscOnExit(const OSD_Entry *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_Entry menuMiscEntries[]=
|
||||
static const OSD_Entry menuMiscEntries[]=
|
||||
{
|
||||
{ "-- MISC --", OME_Label, NULL, NULL, 0 },
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ static long menuOsdActiveElemsOnExit(const OSD_Entry *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
OSD_Entry menuOsdActiveElemsEntries[] =
|
||||
const OSD_Entry menuOsdActiveElemsEntries[] =
|
||||
{
|
||||
{"--- ACTIV ELEM ---", OME_Label, NULL, NULL, 0},
|
||||
{"RSSI", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_RSSI_VALUE], DYNAMIC},
|
||||
|
@ -171,7 +171,7 @@ static long menuAlarmsOnExit(const OSD_Entry *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
OSD_Entry menuAlarmsEntries[] =
|
||||
const OSD_Entry menuAlarmsEntries[] =
|
||||
{
|
||||
{"--- ALARMS ---", OME_Label, NULL, NULL, 0},
|
||||
{"RSSI", OME_UINT8, NULL, &(OSD_UINT8_t){&osdConfig_rssi_alarm, 5, 90, 5}, 0},
|
||||
|
@ -220,7 +220,7 @@ static long menuTimersOnExit(const OSD_Entry *self)
|
|||
|
||||
static const char * osdTimerPrecisionNames[] = {"SCND", "HDTH"};
|
||||
|
||||
OSD_Entry menuTimersEntries[] =
|
||||
const OSD_Entry menuTimersEntries[] =
|
||||
{
|
||||
{"--- TIMERS ---", OME_Label, NULL, NULL, 0},
|
||||
{"1 SRC", OME_TAB, NULL, &(OSD_TAB_t){&timerSource[OSD_TIMER_1], OSD_TIMER_SRC_COUNT - 1, osdTimerSourceNames}, 0 },
|
||||
|
@ -287,7 +287,7 @@ static long cmsx_menuOsdOnExit(const OSD_Entry *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
OSD_Entry cmsx_menuOsdEntries[] =
|
||||
const OSD_Entry cmsx_menuOsdEntries[] =
|
||||
{
|
||||
{"---OSD---", OME_Label, NULL, NULL, 0},
|
||||
#ifdef USE_OSD_PROFILES
|
||||
|
|
|
@ -96,7 +96,7 @@ static long cmsx_Power_onExit(const OSD_Entry *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_Entry cmsx_menuPowerEntries[] =
|
||||
static const OSD_Entry cmsx_menuPowerEntries[] =
|
||||
{
|
||||
{ "-- POWER --", OME_Label, NULL, NULL, 0},
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include "fc/config.h"
|
||||
|
||||
static OSD_Entry cmsx_menuSaveExitEntries[] =
|
||||
static const OSD_Entry cmsx_menuSaveExitEntries[] =
|
||||
{
|
||||
{ "-- SAVE/EXIT --", OME_Label, NULL, NULL, 0},
|
||||
{"EXIT", OME_OSD_Exit, cmsMenuExit, (void *)CMS_EXIT, 0},
|
||||
|
|
|
@ -98,7 +98,7 @@ static long cmsx_Vtx_onExit(const OSD_Entry *self)
|
|||
}
|
||||
|
||||
|
||||
static OSD_Entry cmsx_menuVtxEntries[] =
|
||||
static const OSD_Entry cmsx_menuVtxEntries[] =
|
||||
{
|
||||
{"--- VTX ---", OME_Label, NULL, NULL, 0},
|
||||
{"BAND", OME_TAB, NULL, &entryVtxBand, 0},
|
||||
|
|
|
@ -339,7 +339,7 @@ static const char * const saCmsDeviceStatusNames[] = {
|
|||
|
||||
static OSD_TAB_t saCmsEntOnline = { &saCmsDeviceStatus, 2, saCmsDeviceStatusNames };
|
||||
|
||||
static OSD_Entry saCmsMenuStatsEntries[] = {
|
||||
static const OSD_Entry saCmsMenuStatsEntries[] = {
|
||||
{ "- SA STATS -", OME_Label, NULL, NULL, 0 },
|
||||
{ "STATUS", OME_TAB, NULL, &saCmsEntOnline, DYNAMIC },
|
||||
{ "BAUDRATE", OME_UINT16, NULL, &(OSD_UINT16_t){ &sa_smartbaud, 0, 0, 0 }, DYNAMIC },
|
||||
|
@ -536,7 +536,7 @@ static long saCmsConfigUserFreq(displayPort_t *pDisp, const void *self)
|
|||
return MENU_CHAIN_BACK;
|
||||
}
|
||||
|
||||
static OSD_Entry saCmsMenuPORFreqEntries[] = {
|
||||
static const OSD_Entry saCmsMenuPORFreqEntries[] = {
|
||||
{ "- POR FREQ -", OME_Label, NULL, NULL, 0 },
|
||||
|
||||
{ "CUR FREQ", OME_UINT16, NULL, &(OSD_UINT16_t){ &saCmsORFreq, 5000, 5999, 0 }, DYNAMIC },
|
||||
|
@ -558,7 +558,7 @@ static CMS_Menu saCmsMenuPORFreq =
|
|||
.entries = saCmsMenuPORFreqEntries,
|
||||
};
|
||||
|
||||
static OSD_Entry saCmsMenuUserFreqEntries[] = {
|
||||
static const OSD_Entry saCmsMenuUserFreqEntries[] = {
|
||||
{ "- USER FREQ -", OME_Label, NULL, NULL, 0 },
|
||||
|
||||
{ "CUR FREQ", OME_UINT16, NULL, &(OSD_UINT16_t){ &saCmsUserFreq, 5000, 5999, 0 }, DYNAMIC },
|
||||
|
@ -582,7 +582,7 @@ static CMS_Menu saCmsMenuUserFreq =
|
|||
|
||||
static OSD_TAB_t saCmsEntFselMode = { &saCmsFselModeNew, 1, saCmsFselModeNames };
|
||||
|
||||
static OSD_Entry saCmsMenuConfigEntries[] = {
|
||||
static const OSD_Entry saCmsMenuConfigEntries[] = {
|
||||
{ "- SA CONFIG -", OME_Label, NULL, NULL, 0 },
|
||||
|
||||
{ "OP MODEL", OME_TAB, saCmsConfigOpmodelByGvar, &(OSD_TAB_t){ &saCmsOpmodel, 2, saCmsOpmodelNames }, DYNAMIC },
|
||||
|
@ -607,7 +607,7 @@ static CMS_Menu saCmsMenuConfig = {
|
|||
.entries = saCmsMenuConfigEntries
|
||||
};
|
||||
|
||||
static OSD_Entry saCmsMenuCommenceEntries[] = {
|
||||
static const OSD_Entry saCmsMenuCommenceEntries[] = {
|
||||
{ "CONFIRM", OME_Label, NULL, NULL, 0 },
|
||||
|
||||
{ "YES", OME_Funcall, saCmsCommence, NULL, 0 },
|
||||
|
@ -626,7 +626,7 @@ static CMS_Menu saCmsMenuCommence = {
|
|||
.entries = saCmsMenuCommenceEntries,
|
||||
};
|
||||
|
||||
static OSD_Entry saCmsMenuFreqModeEntries[] = {
|
||||
static const OSD_Entry saCmsMenuFreqModeEntries[] = {
|
||||
{ "- SMARTAUDIO -", OME_Label, NULL, NULL, 0 },
|
||||
|
||||
{ "", OME_Label, NULL, saCmsStatusString, DYNAMIC },
|
||||
|
@ -639,7 +639,7 @@ static OSD_Entry saCmsMenuFreqModeEntries[] = {
|
|||
{ NULL, OME_END, NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
static OSD_Entry saCmsMenuChanModeEntries[] =
|
||||
static const OSD_Entry saCmsMenuChanModeEntries[] =
|
||||
{
|
||||
{ "- SMARTAUDIO -", OME_Label, NULL, NULL, 0 },
|
||||
|
||||
|
@ -655,7 +655,7 @@ static OSD_Entry saCmsMenuChanModeEntries[] =
|
|||
{ NULL, OME_END, NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
static OSD_Entry saCmsMenuOfflineEntries[] =
|
||||
static const OSD_Entry saCmsMenuOfflineEntries[] =
|
||||
{
|
||||
{ "- VTX SMARTAUDIO -", OME_Label, NULL, NULL, 0 },
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ static long trampCmsOnEnter(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static OSD_Entry trampCmsMenuCommenceEntries[] = {
|
||||
static const OSD_Entry trampCmsMenuCommenceEntries[] = {
|
||||
{ "CONFIRM", OME_Label, NULL, NULL, 0 },
|
||||
{ "YES", OME_Funcall, trampCmsCommence, NULL, 0 },
|
||||
{ "BACK", OME_Back, NULL, NULL, 0 },
|
||||
|
@ -224,7 +224,7 @@ static CMS_Menu trampCmsMenuCommence = {
|
|||
.entries = trampCmsMenuCommenceEntries,
|
||||
};
|
||||
|
||||
static OSD_Entry trampMenuEntries[] =
|
||||
static const OSD_Entry trampMenuEntries[] =
|
||||
{
|
||||
{ "- TRAMP -", OME_Label, NULL, NULL, 0 },
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ typedef struct
|
|||
const OSD_MenuElement type;
|
||||
const CMSEntryFuncPtr func;
|
||||
void *data;
|
||||
uint8_t flags;
|
||||
const uint8_t flags;
|
||||
} OSD_Entry;
|
||||
|
||||
// Bits in flags
|
||||
|
@ -71,13 +71,13 @@ typedef struct
|
|||
#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; }
|
||||
#define CLR_PRINTVALUE(p) { (p)->flags &= ~PRINT_VALUE; }
|
||||
#define IS_PRINTVALUE(x) ((x) & PRINT_VALUE)
|
||||
#define SET_PRINTVALUE(x) { (x) |= PRINT_VALUE; }
|
||||
#define CLR_PRINTVALUE(x) { (x) &= ~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_PRINTLABEL(x) ((x) & PRINT_LABEL)
|
||||
#define SET_PRINTLABEL(x) { (x) |= PRINT_LABEL; }
|
||||
#define CLR_PRINTLABEL(x) { (x) &= ~PRINT_LABEL; }
|
||||
|
||||
#define IS_DYNAMIC(p) ((p)->flags & DYNAMIC)
|
||||
|
||||
|
@ -104,7 +104,7 @@ typedef struct
|
|||
#endif
|
||||
const CMSMenuFuncPtr onEnter;
|
||||
const CMSMenuOnExitPtr onExit;
|
||||
OSD_Entry *entries;
|
||||
const OSD_Entry *entries;
|
||||
} CMS_Menu;
|
||||
|
||||
typedef struct
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue