mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
Improved CMS const correctness. Added CMS and USE_MSP_DISPLAYPORT to common.h
This commit is contained in:
parent
c9b7ac21c1
commit
f68e6a4d2f
10 changed files with 110 additions and 110 deletions
|
@ -125,11 +125,11 @@ static displayPort_t *cmsDisplayPortSelectNext(void)
|
|||
|
||||
static bool cmsInMenu = false;
|
||||
|
||||
STATIC_UNIT_TESTED CMS_Menu *currentMenu; // Points to top entry of the current page
|
||||
STATIC_UNIT_TESTED const CMS_Menu *currentMenu; // Points to top entry of the current page
|
||||
|
||||
// XXX Does menu backing support backing into second page???
|
||||
|
||||
static CMS_Menu *menuStack[10]; // Stack to save menu transition
|
||||
static const CMS_Menu *menuStack[10]; // Stack to save menu transition
|
||||
static uint8_t menuStackHistory[10];// cursorRow in a stacked menu
|
||||
static uint8_t menuStackIdx = 0;
|
||||
|
||||
|
@ -179,14 +179,15 @@ static CMS_Menu menuErr = {
|
|||
|
||||
static void cmsUpdateMaxRow(displayPort_t *instance)
|
||||
{
|
||||
OSD_Entry *ptr;
|
||||
|
||||
maxRow = 0;
|
||||
for (ptr = pageTop; ptr->type != OME_END; ptr++)
|
||||
maxRow++;
|
||||
|
||||
if (maxRow > MAX_MENU_ITEMS(instance))
|
||||
for (const OSD_Entry *ptr = pageTop; ptr->type != OME_END; ptr++) {
|
||||
maxRow++;
|
||||
}
|
||||
|
||||
if (maxRow > MAX_MENU_ITEMS(instance)) {
|
||||
maxRow = MAX_MENU_ITEMS(instance);
|
||||
}
|
||||
|
||||
maxRow--;
|
||||
}
|
||||
|
@ -446,7 +447,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
|
|||
}
|
||||
}
|
||||
|
||||
long cmsMenuChange(displayPort_t *pDisplay, void *ptr)
|
||||
long cmsMenuChange(displayPort_t *pDisplay, const void *ptr)
|
||||
{
|
||||
CMS_Menu *pMenu = (CMS_Menu *)ptr;
|
||||
|
||||
|
@ -544,13 +545,11 @@ STATIC_UNIT_TESTED void cmsMenuOpen(void)
|
|||
cmsMenuChange(pCurrentDisplay, currentMenu);
|
||||
}
|
||||
|
||||
static void cmsTraverseGlobalExit(CMS_Menu *pMenu)
|
||||
static void cmsTraverseGlobalExit(const CMS_Menu *pMenu)
|
||||
{
|
||||
OSD_Entry *p;
|
||||
|
||||
debug[0]++;
|
||||
|
||||
for (p = pMenu->entries; p->type != OME_END ; p++) {
|
||||
for (const OSD_Entry *p = pMenu->entries; p->type != OME_END ; p++) {
|
||||
if (p->type == OME_Submenu) {
|
||||
cmsTraverseGlobalExit(p->data);
|
||||
}
|
||||
|
@ -562,7 +561,7 @@ static void cmsTraverseGlobalExit(CMS_Menu *pMenu)
|
|||
}
|
||||
}
|
||||
|
||||
long cmsMenuExit(displayPort_t *pDisplay, void *ptr)
|
||||
long cmsMenuExit(displayPort_t *pDisplay, const void *ptr)
|
||||
{
|
||||
if (ptr) {
|
||||
displayClear(pDisplay);
|
||||
|
|
|
@ -9,8 +9,8 @@ bool cmsDisplayPortRegister(displayPort_t *pDisplay);
|
|||
void cmsInit(void);
|
||||
void cmsHandler(uint32_t currentTime);
|
||||
|
||||
long cmsMenuChange(displayPort_t *pPort, void *ptr);
|
||||
long cmsMenuExit(displayPort_t *pPort, void *ptr);
|
||||
long cmsMenuChange(displayPort_t *pPort, const void *ptr);
|
||||
long cmsMenuExit(displayPort_t *pPort, const void *ptr);
|
||||
|
||||
#define CMS_STARTUP_HELP_TEXT1 "MENU: THR MID"
|
||||
#define CMS_STARTUP_HELP_TEXT2 "+ YAW LEFT"
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include "io/flashfs.h"
|
||||
|
||||
#ifdef USE_FLASHFS
|
||||
static long cmsx_EraseFlash(displayPort_t *pDisplay, void *ptr)
|
||||
static long cmsx_EraseFlash(displayPort_t *pDisplay, const void *ptr)
|
||||
{
|
||||
UNUSED(ptr);
|
||||
|
||||
|
@ -101,11 +101,11 @@ static OSD_Entry cmsx_menuBlackboxEntries[] =
|
|||
};
|
||||
|
||||
CMS_Menu cmsx_menuBlackbox = {
|
||||
"MENUBB",
|
||||
OME_MENU,
|
||||
cmsx_Blackbox_FeatureRead,
|
||||
NULL,
|
||||
cmsx_Blackbox_FeatureWriteback,
|
||||
cmsx_menuBlackboxEntries,
|
||||
.GUARD_text = "MENUBB",
|
||||
.GUARD_type = OME_MENU,
|
||||
.onEnter = cmsx_Blackbox_FeatureRead,
|
||||
.onExit = NULL,
|
||||
.onGlobalExit = cmsx_Blackbox_FeatureWriteback,
|
||||
.entries = cmsx_menuBlackboxEntries
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -75,12 +75,12 @@ static OSD_Entry menuInfoEntries[] = {
|
|||
};
|
||||
|
||||
static CMS_Menu menuInfo = {
|
||||
"MENUINFO",
|
||||
OME_MENU,
|
||||
cmsx_InfoInit,
|
||||
NULL,
|
||||
NULL,
|
||||
menuInfoEntries,
|
||||
.GUARD_text = "MENUINFO",
|
||||
.GUARD_type = OME_MENU,
|
||||
.onEnter = cmsx_InfoInit,
|
||||
.onExit = NULL,
|
||||
.onGlobalExit = NULL,
|
||||
.entries = menuInfoEntries
|
||||
};
|
||||
|
||||
// Features
|
||||
|
@ -100,12 +100,12 @@ static OSD_Entry menuFeaturesEntries[] =
|
|||
};
|
||||
|
||||
static CMS_Menu menuFeatures = {
|
||||
"MENUFEATURES",
|
||||
OME_MENU,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
menuFeaturesEntries,
|
||||
.GUARD_text = "MENUFEATURES",
|
||||
.GUARD_type = OME_MENU,
|
||||
.onEnter = NULL,
|
||||
.onExit = NULL,
|
||||
.onGlobalExit = NULL,
|
||||
.entries = menuFeaturesEntries,
|
||||
};
|
||||
|
||||
// Main
|
||||
|
@ -129,11 +129,11 @@ static OSD_Entry menuMainEntries[] =
|
|||
};
|
||||
|
||||
CMS_Menu menuMain = {
|
||||
"MENUMAIN",
|
||||
OME_MENU,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
menuMainEntries,
|
||||
.GUARD_text = "MENUMAIN",
|
||||
.GUARD_type = OME_MENU,
|
||||
.onEnter = NULL,
|
||||
.onExit = NULL,
|
||||
.onGlobalExit = NULL,
|
||||
.entries = menuMainEntries,
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -64,7 +64,7 @@ static long cmsx_menuImu_onEnter(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static long cmsx_menuImu_onExit(OSD_Entry *self)
|
||||
static long cmsx_menuImu_onExit(const OSD_Entry *self)
|
||||
{
|
||||
UNUSED(self);
|
||||
|
||||
|
@ -97,7 +97,7 @@ static long cmsx_PidOnEnter(void)
|
|||
}
|
||||
|
||||
|
||||
static long cmsx_PidWriteback(OSD_Entry *self)
|
||||
static long cmsx_PidWriteback(const OSD_Entry *self)
|
||||
{
|
||||
UNUSED(self);
|
||||
|
||||
|
@ -135,12 +135,12 @@ static OSD_Entry cmsx_menuPidEntries[] =
|
|||
};
|
||||
|
||||
static CMS_Menu cmsx_menuPid = {
|
||||
"XPID",
|
||||
OME_MENU,
|
||||
cmsx_PidOnEnter,
|
||||
cmsx_PidWriteback,
|
||||
NULL,
|
||||
cmsx_menuPidEntries,
|
||||
.GUARD_text = "XPID",
|
||||
.GUARD_type = OME_MENU,
|
||||
.onEnter = cmsx_PidOnEnter,
|
||||
.onExit = cmsx_PidWriteback,
|
||||
.onGlobalExit = NULL,
|
||||
.entries = cmsx_menuPidEntries
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -155,7 +155,7 @@ static long cmsx_RateExpoRead(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static long cmsx_RateExpoWriteback(OSD_Entry *self)
|
||||
static long cmsx_RateExpoWriteback(const OSD_Entry *self)
|
||||
{
|
||||
UNUSED(self);
|
||||
|
||||
|
@ -164,7 +164,7 @@ static long cmsx_RateExpoWriteback(OSD_Entry *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static long cmsx_menuRcConfirmBack(OSD_Entry *self)
|
||||
static long cmsx_menuRcConfirmBack(const OSD_Entry *self)
|
||||
{
|
||||
if (self && self->type == OME_Back)
|
||||
return 0;
|
||||
|
@ -196,12 +196,12 @@ static OSD_Entry cmsx_menuRateExpoEntries[] =
|
|||
};
|
||||
|
||||
CMS_Menu cmsx_menuRateExpo = {
|
||||
"MENURATE",
|
||||
OME_MENU,
|
||||
cmsx_RateExpoRead,
|
||||
cmsx_RateExpoWriteback,
|
||||
NULL,
|
||||
cmsx_menuRateExpoEntries,
|
||||
.GUARD_text = "MENURATE",
|
||||
.GUARD_type = OME_MENU,
|
||||
.onEnter = cmsx_RateExpoRead,
|
||||
.onExit = cmsx_RateExpoWriteback,
|
||||
.onGlobalExit = NULL,
|
||||
.entries = cmsx_menuRateExpoEntries
|
||||
};
|
||||
|
||||
|
||||
|
@ -227,12 +227,12 @@ static OSD_Entry cmsx_menuRcEntries[] =
|
|||
};
|
||||
|
||||
CMS_Menu cmsx_menuRcPreview = {
|
||||
"XRCPREV",
|
||||
OME_MENU,
|
||||
NULL,
|
||||
cmsx_menuRcConfirmBack,
|
||||
NULL,
|
||||
cmsx_menuRcEntries,
|
||||
.GUARD_text = "XRCPREV",
|
||||
.GUARD_type = OME_MENU,
|
||||
.onEnter = NULL,
|
||||
.onExit = cmsx_menuRcConfirmBack,
|
||||
.onGlobalExit = NULL,
|
||||
.entries = cmsx_menuRcEntries
|
||||
};
|
||||
|
||||
|
||||
|
@ -256,15 +256,15 @@ static OSD_Entry menuImuMiscEntries[]=
|
|||
};
|
||||
|
||||
CMS_Menu menuImuMisc = {
|
||||
"XIMUMISC",
|
||||
OME_MENU,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
menuImuMiscEntries,
|
||||
.GUARD_text = "XIMUMISC",
|
||||
.GUARD_type = OME_MENU,
|
||||
.onEnter = NULL,
|
||||
.onExit = NULL,
|
||||
.onGlobalExit = NULL,
|
||||
.entries = menuImuMiscEntries
|
||||
};
|
||||
|
||||
static long onProfileChange(displayPort_t *pDisplay, void *ptr)
|
||||
static long onProfileChange(displayPort_t *pDisplay, const void *ptr)
|
||||
{
|
||||
UNUSED(pDisplay);
|
||||
UNUSED(ptr);
|
||||
|
|
|
@ -71,12 +71,12 @@ static OSD_Entry cmsx_menuLedstripEntries[] =
|
|||
};
|
||||
|
||||
CMS_Menu cmsx_menuLedstrip = {
|
||||
"MENULED",
|
||||
OME_MENU,
|
||||
cmsx_Ledstrip_FeatureRead,
|
||||
NULL,
|
||||
cmsx_Ledstrip_FeatureWriteback,
|
||||
cmsx_menuLedstripEntries,
|
||||
.GUARD_text = "MENULED",
|
||||
.GUARD_type = OME_MENU,
|
||||
.onEnter = cmsx_Ledstrip_FeatureRead,
|
||||
.onExit = NULL,
|
||||
.onGlobalExit = cmsx_Ledstrip_FeatureWriteback,
|
||||
.entries = cmsx_menuLedstripEntries
|
||||
};
|
||||
#endif // LED_STRIP
|
||||
#endif // CMS
|
||||
|
|
|
@ -50,12 +50,12 @@ OSD_Entry cmsx_menuAlarmsEntries[] =
|
|||
};
|
||||
|
||||
CMS_Menu cmsx_menuAlarms = {
|
||||
"MENUALARMS",
|
||||
OME_MENU,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
cmsx_menuAlarmsEntries,
|
||||
.GUARD_text = "MENUALARMS",
|
||||
.GUARD_type = OME_MENU,
|
||||
.onEnter = NULL,
|
||||
.onExit = NULL,
|
||||
.onGlobalExit = NULL,
|
||||
.entries = cmsx_menuAlarmsEntries,
|
||||
};
|
||||
|
||||
OSD_Entry menuOsdActiveElemsEntries[] =
|
||||
|
@ -85,12 +85,12 @@ OSD_Entry menuOsdActiveElemsEntries[] =
|
|||
};
|
||||
|
||||
CMS_Menu menuOsdActiveElems = {
|
||||
"MENUOSDACT",
|
||||
OME_MENU,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
menuOsdActiveElemsEntries,
|
||||
.GUARD_text = "MENUOSDACT",
|
||||
.GUARD_type = OME_MENU,
|
||||
.onEnter = NULL,
|
||||
.onExit = NULL,
|
||||
.onGlobalExit = NULL,
|
||||
.entries = menuOsdActiveElemsEntries
|
||||
};
|
||||
|
||||
OSD_Entry cmsx_menuOsdLayoutEntries[] =
|
||||
|
@ -102,12 +102,11 @@ OSD_Entry cmsx_menuOsdLayoutEntries[] =
|
|||
};
|
||||
|
||||
CMS_Menu cmsx_menuOsdLayout = {
|
||||
"MENULAYOUT",
|
||||
OME_MENU,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
cmsx_menuOsdLayoutEntries,
|
||||
.GUARD_text = "MENULAYOUT",
|
||||
.GUARD_type = OME_MENU,
|
||||
.onEnter = NULL,
|
||||
.onExit = NULL,
|
||||
.onGlobalExit = NULL,
|
||||
.entries = cmsx_menuOsdLayoutEntries
|
||||
};
|
||||
|
||||
#endif // CMS
|
||||
|
|
|
@ -102,7 +102,7 @@ static long cmsx_Vtx_onEnter(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static long cmsx_Vtx_onExit(OSD_Entry *self)
|
||||
static long cmsx_Vtx_onExit(const OSD_Entry *self)
|
||||
{
|
||||
UNUSED(self);
|
||||
|
||||
|
@ -134,12 +134,12 @@ static OSD_Entry cmsx_menuVtxEntries[] =
|
|||
};
|
||||
|
||||
CMS_Menu cmsx_menuVtx = {
|
||||
"MENUVTX",
|
||||
OME_MENU,
|
||||
cmsx_Vtx_onEnter,
|
||||
cmsx_Vtx_onExit,
|
||||
cmsx_Vtx_FeatureWriteback,
|
||||
cmsx_menuVtxEntries,
|
||||
.GUARD_text = "MENUVTX",
|
||||
.GUARD_type = OME_MENU,
|
||||
.onEnter = cmsx_Vtx_onEnter,
|
||||
.onExit= cmsx_Vtx_onExit,
|
||||
.onGlobalExit = cmsx_Vtx_FeatureWriteback,
|
||||
.entries = cmsx_menuVtxEntries
|
||||
};
|
||||
|
||||
#endif // VTX || USE_RTC6705
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
typedef long (*CMSEntryFuncPtr)(displayPort_t *, void *);
|
||||
|
||||
//type of elements
|
||||
|
||||
typedef enum
|
||||
|
@ -53,11 +51,13 @@ typedef enum
|
|||
OME_MAX = OME_MENU
|
||||
} OSD_MenuElement;
|
||||
|
||||
typedef long (*CMSEntryFuncPtr)(displayPort_t *displayPort, const void *ptr);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *text;
|
||||
OSD_MenuElement type;
|
||||
CMSEntryFuncPtr func;
|
||||
const OSD_MenuElement type;
|
||||
const CMSEntryFuncPtr func;
|
||||
void *data;
|
||||
uint8_t flags;
|
||||
} OSD_Entry;
|
||||
|
@ -87,17 +87,17 @@ onExit function is called with self:
|
|||
(2) NULL if called from menu exit (forced exit at top level).
|
||||
*/
|
||||
|
||||
typedef long (*CMSMenuOnExitPtr)(OSD_Entry *self);
|
||||
typedef long (*CMSMenuOnExitPtr)(const OSD_Entry *self);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// These two are debug aids for menu content creators.
|
||||
const char *GUARD_text;
|
||||
OSD_MenuElement GUARD_type;
|
||||
const OSD_MenuElement GUARD_type;
|
||||
|
||||
CMSMenuFuncPtr onEnter;
|
||||
CMSMenuOnExitPtr onExit;
|
||||
CMSMenuFuncPtr onGlobalExit;
|
||||
const CMSMenuFuncPtr onEnter;
|
||||
const CMSMenuOnExitPtr onExit;
|
||||
const CMSMenuFuncPtr onGlobalExit;
|
||||
OSD_Entry *entries;
|
||||
} CMS_Menu;
|
||||
|
||||
|
|
|
@ -55,7 +55,9 @@
|
|||
#endif
|
||||
|
||||
#if (FLASH_SIZE > 128)
|
||||
#define CMS
|
||||
#define USE_DASHBOARD
|
||||
#define USE_MSP_DISPLAYPORT
|
||||
#define TELEMETRY_MAVLINK
|
||||
#else
|
||||
#define SKIP_CLI_COMMAND_HELP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue