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