Touch-ups after rebase

Led strip’s color manipulation was dropped due to the drastically
change in the config structure; led strip menu now only has feature
on/off.
This commit is contained in:
jflyper 2016-11-06 04:34:19 +09:00
parent e9a2f2b2c1
commit a6b03a9473
8 changed files with 72 additions and 122 deletions

View File

@ -542,12 +542,18 @@ static void cmsTraverseGlobalExit(CMS_Menu *pMenu)
{
OSD_Entry *p;
for (p = pMenu->entries; p->type != OME_END ; p++)
if (p->type == OME_Submenu)
cmsTraverseGlobalExit(p->data);
debug[0]++;
if (pMenu->onGlobalExit)
for (p = pMenu->entries; p->type != OME_END ; p++) {
if (p->type == OME_Submenu) {
cmsTraverseGlobalExit(p->data);
}
}
if (pMenu->onGlobalExit) {
debug[1]++;
pMenu->onGlobalExit();
}
}
long cmsMenuExit(displayPort_t *pDisplay, void *ptr)
@ -566,6 +572,8 @@ long cmsMenuExit(displayPort_t *pDisplay, void *ptr)
if (currentMenu->onExit)
currentMenu->onExit((OSD_Entry *)NULL); // Forced exit
saveConfigAndNotify();
}
cmsInMenu = false;
@ -834,7 +842,7 @@ void cmsHandler(uint32_t currentTime)
}
}
// Will initializing with menuMain be better?
// Is initializing with menuMain better?
// Can it be done with the current main()?
void cmsInit(void)
{

View File

@ -26,7 +26,7 @@
#include "io/flashfs.h"
#ifdef USE_FLASHFS
long cmsx_EraseFlash(displayPort_t *pDisplay, void *ptr)
static long cmsx_EraseFlash(displayPort_t *pDisplay, void *ptr)
{
UNUSED(ptr);
@ -46,16 +46,20 @@ long cmsx_EraseFlash(displayPort_t *pDisplay, void *ptr)
}
#endif // USE_FLASHFS
uint8_t cmsx_FeatureBlackbox;
static bool featureRead = false;
static uint8_t cmsx_FeatureBlackbox;
long cmsx_Blackbox_FeatureRead(void)
static long cmsx_Blackbox_FeatureRead(void)
{
cmsx_FeatureBlackbox = feature(FEATURE_BLACKBOX) ? 1 : 0;
if (!featureRead) {
cmsx_FeatureBlackbox = feature(FEATURE_BLACKBOX) ? 1 : 0;
featureRead = true;
}
return 0;
}
long cmsx_Blackbox_FeatureWriteback(void)
static long cmsx_Blackbox_FeatureWriteback(void)
{
if (cmsx_FeatureBlackbox)
featureSet(FEATURE_BLACKBOX);
@ -65,9 +69,9 @@ long cmsx_Blackbox_FeatureWriteback(void)
return 0;
}
OSD_UINT8_t entryBlackboxRateDenom = {&masterConfig.blackbox_rate_denom,1,32,1};
static OSD_UINT8_t entryBlackboxRateDenom = {&masterConfig.blackbox_rate_denom,1,32,1};
OSD_Entry cmsx_menuBlackboxEntries[] =
static OSD_Entry cmsx_menuBlackboxEntries[] =
{
{"--- BLACKBOX ---", OME_Label, NULL, NULL, 0},
{"ENABLED", OME_Bool, NULL, &cmsx_FeatureBlackbox, 0},

View File

@ -121,5 +121,4 @@ CMS_Menu menuMain = {
NULL,
menuMainEntries,
};
#endif

View File

@ -31,9 +31,9 @@
#include "config/config_master.h"
#include "config/feature.h"
OSD_UINT8_t entryPidProfile = {&masterConfig.current_profile_index, 0, MAX_PROFILE_COUNT, 1};
static OSD_UINT8_t entryPidProfile = {&masterConfig.current_profile_index, 0, MAX_PROFILE_COUNT, 1};
uint8_t tempPid[4][3];
static uint8_t tempPid[4][3];
static OSD_UINT8_t entryRollP = {&tempPid[PIDROLL][0], 10, 150, 1};
static OSD_UINT8_t entryRollI = {&tempPid[PIDROLL][1], 1, 150, 1};
@ -47,7 +47,7 @@ static OSD_UINT8_t entryYawP = {&tempPid[PIDYAW][0], 10, 150, 1};
static OSD_UINT8_t entryYawI = {&tempPid[PIDYAW][1], 1, 150, 1};
static OSD_UINT8_t entryYawD = {&tempPid[PIDYAW][2], 0, 150, 1};
long cmsx_PidRead(void)
static long cmsx_PidRead(void)
{
uint8_t i;
@ -63,7 +63,7 @@ long cmsx_PidRead(void)
return 0;
}
long cmsx_PidWriteback(OSD_Entry *self)
static long cmsx_PidWriteback(OSD_Entry *self)
{
UNUSED(self);
@ -82,7 +82,7 @@ long cmsx_PidWriteback(OSD_Entry *self)
return 0;
}
OSD_Entry cmsx_menuPidEntries[] =
static OSD_Entry cmsx_menuPidEntries[] =
{
{"--- PID ---", OME_Label, NULL, NULL, 0},
{"ROLL P", OME_UINT8, NULL, &entryRollP, 0},
@ -101,7 +101,7 @@ OSD_Entry cmsx_menuPidEntries[] =
{NULL, OME_END, NULL, NULL, 0}
};
CMS_Menu cmsx_menuPid = {
static CMS_Menu cmsx_menuPid = {
"MENUPID",
OME_MENU,
cmsx_PidRead,
@ -113,7 +113,7 @@ CMS_Menu cmsx_menuPid = {
//
// Rate & Expo
//
controlRateConfig_t rateProfile;
static controlRateConfig_t rateProfile;
static OSD_FLOAT_t entryRollRate = {&rateProfile.rates[0], 0, 250, 1, 10};
static OSD_FLOAT_t entryPitchRate = {&rateProfile.rates[1], 0, 250, 1, 10};
@ -127,14 +127,14 @@ static OSD_UINT16_t entryTpaBreak = {&rateProfile.tpa_breakpoint, 1100, 1800, 10
static OSD_FLOAT_t entryPSetpoint = {&masterConfig.profile[0].pidProfile.setpointRelaxRatio, 0, 100, 1, 10};
static OSD_FLOAT_t entryDSetpoint = {&masterConfig.profile[0].pidProfile.dtermSetpointWeight, 0, 255, 1, 10};
long cmsx_RateExpoRead(void)
static long cmsx_RateExpoRead(void)
{
memcpy(&rateProfile, &masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile], sizeof(controlRateConfig_t));
return 0;
}
long cmsx_RateExpoWriteback(OSD_Entry *self)
static long cmsx_RateExpoWriteback(OSD_Entry *self)
{
UNUSED(self);
@ -143,7 +143,7 @@ long cmsx_RateExpoWriteback(OSD_Entry *self)
return 0;
}
long cmsx_menuRcConfirmBack(OSD_Entry *self)
static long cmsx_menuRcConfirmBack(OSD_Entry *self)
{
if (self && self->type == OME_Back)
return 0;
@ -151,7 +151,7 @@ long cmsx_menuRcConfirmBack(OSD_Entry *self)
return -1;
}
OSD_Entry cmsx_menuRateExpoEntries[] =
static OSD_Entry cmsx_menuRateExpoEntries[] =
{
{"--- RATE&EXPO ---", OME_Label, NULL, NULL, 0},
{"RC RATE", OME_FLOAT, NULL, &entryRcYawRate, 0},
@ -191,7 +191,7 @@ static OSD_INT16_t entryRcAux2 = {&rcData[AUX2], 1, 2500, 0};
static OSD_INT16_t entryRcAux3 = {&rcData[AUX3], 1, 2500, 0};
static OSD_INT16_t entryRcAux4 = {&rcData[AUX4], 1, 2500, 0};
OSD_Entry cmsx_menuRcEntries[] =
static OSD_Entry cmsx_menuRcEntries[] =
{
{"--- RC PREV ---", OME_Label, NULL, NULL, 0},
{"ROLL", OME_INT16, NULL, &entryRcRoll, DYNAMIC},
@ -219,15 +219,15 @@ CMS_Menu cmsx_menuRc = {
//
// Misc
//
OSD_UINT16_t entryMinThrottle = {&masterConfig.motorConfig.minthrottle, 1020, 1300, 10};
OSD_UINT8_t entryGyroSoftLpfHz = {&masterConfig.gyro_soft_lpf_hz, 0, 255, 1};
OSD_UINT16_t entryDtermLpf = {&masterConfig.profile[0].pidProfile.dterm_lpf_hz, 0, 500, 5};
OSD_UINT16_t entryYawLpf = {&masterConfig.profile[0].pidProfile.yaw_lpf_hz, 0, 500, 5};
OSD_UINT16_t entryYawPLimit = {&masterConfig.profile[0].pidProfile.yaw_p_limit, 100, 500, 5};
OSD_UINT8_t entryVbatScale = {&masterConfig.batteryConfig.vbatscale, 1, 250, 1};
OSD_UINT8_t entryVbatMaxCell = {&masterConfig.batteryConfig.vbatmaxcellvoltage, 10, 50, 1};
static OSD_UINT16_t entryMinThrottle = {&masterConfig.motorConfig.minthrottle, 1020, 1300, 10};
static OSD_UINT8_t entryGyroSoftLpfHz = {&masterConfig.gyro_soft_lpf_hz, 0, 255, 1};
static OSD_UINT16_t entryDtermLpf = {&masterConfig.profile[0].pidProfile.dterm_lpf_hz, 0, 500, 5};
static OSD_UINT16_t entryYawLpf = {&masterConfig.profile[0].pidProfile.yaw_lpf_hz, 0, 500, 5};
static OSD_UINT16_t entryYawPLimit = {&masterConfig.profile[0].pidProfile.yaw_p_limit, 100, 500, 5};
static OSD_UINT8_t entryVbatScale = {&masterConfig.batteryConfig.vbatscale, 1, 250, 1};
static OSD_UINT8_t entryVbatMaxCell = {&masterConfig.batteryConfig.vbatmaxcellvoltage, 10, 50, 1};
OSD_Entry menuImuMiscEntries[]=
static OSD_Entry menuImuMiscEntries[]=
{
{"--- MISC ---", OME_Label, NULL, NULL, 0},
{"GYRO LPF", OME_UINT8, NULL, &entryGyroSoftLpfHz, 0},
@ -250,7 +250,7 @@ CMS_Menu menuImuMisc = {
menuImuMiscEntries,
};
OSD_Entry cmsx_menuImuEntries[] =
static OSD_Entry cmsx_menuImuEntries[] =
{
{"--- CFG.IMU ---", OME_Label, NULL, NULL, 0},
{"PID PROF", OME_UINT8, NULL, &entryPidProfile, 0},

View File

@ -21,69 +21,20 @@
#ifdef LED_STRIP
//local variable to keep color value
uint8_t ledColor;
static bool featureRead = false;
static uint8_t cmsx_FeatureLedstrip;
static const char * const LED_COLOR_NAMES[] = {
"BLACK ",
"WHITE ",
"RED ",
"ORANGE ",
"YELLOW ",
"LIME GRN",
"GREEN ",
"MINT GRN",
"CYAN ",
"LT BLUE ",
"BLUE ",
"DK VIOLT",
"MAGENTA ",
"DEEP PNK"
};
//find first led with color flag and restore color index
//after saving all leds with flags color will have color set in OSD
void cmsx_GetLedColor(void)
static long cmsx_Ledstrip_FeatureRead(void)
{
for (int ledIndex = 0; ledIndex < LED_MAX_STRIP_LENGTH; ledIndex++) {
const ledConfig_t *ledConfig = &masterConfig.ledConfigs[ledIndex];
int fn = ledGetFunction(ledConfig);
if (fn == LED_FUNCTION_COLOR) {
ledColor = ledGetColor(ledConfig);
break;
}
}
}
//udate all leds with flag color
static long applyLedColor(displayPort_t *pDisplay, void *ptr)
{
UNUSED(ptr);
UNUSED(pDisplay); // Arrgh
for (int ledIndex = 0; ledIndex < LED_MAX_STRIP_LENGTH; ledIndex++) {
ledConfig_t *ledConfig = &masterConfig.ledConfigs[ledIndex];
if (ledGetFunction(ledConfig) == LED_FUNCTION_COLOR)
*ledConfig = DEFINE_LED(ledGetX(ledConfig), ledGetY(ledConfig), ledColor, ledGetDirection(ledConfig), ledGetFunction(ledConfig), ledGetOverlay(ledConfig), 0);
if (!featureRead) {
cmsx_FeatureLedstrip = feature(FEATURE_LED_STRIP) ? 1 : 0;
featureRead = true;
}
return 0;
}
uint8_t cmsx_FeatureLedstrip;
OSD_TAB_t entryLed = {&ledColor, 13, &LED_COLOR_NAMES[0]};
long cmsx_Ledstrip_FeatureRead(void)
{
cmsx_FeatureLedstrip = feature(FEATURE_LED_STRIP) ? 1 : 0;
return 0;
}
long cmsx_Ledstrip_FeatureWriteback(void)
static long cmsx_Ledstrip_FeatureWriteback(void)
{
if (cmsx_FeatureLedstrip)
featureSet(FEATURE_LED_STRIP);
@ -93,26 +44,10 @@ long cmsx_Ledstrip_FeatureWriteback(void)
return 0;
}
long cmsx_Ledstrip_ConfigRead(void)
{
cmsx_GetLedColor();
return 0;
}
long cmsx_Ledstrip_onEnter(void)
{
cmsx_Ledstrip_FeatureRead();
cmsx_Ledstrip_ConfigRead();
return 0;
}
OSD_Entry cmsx_menuLedstripEntries[] =
static OSD_Entry cmsx_menuLedstripEntries[] =
{
{"--- LED STRIP ---", OME_Label, NULL, NULL, 0},
{"ENABLED", OME_Bool, NULL, &cmsx_FeatureLedstrip, 0},
{"LED COLOR", OME_TAB, applyLedColor, &entryLed, 0},
{"BACK", OME_Back, NULL, NULL, 0},
{NULL, OME_END, NULL, NULL, 0}
};
@ -120,7 +55,7 @@ OSD_Entry cmsx_menuLedstripEntries[] =
CMS_Menu cmsx_menuLedstrip = {
"MENULED",
OME_MENU,
cmsx_Ledstrip_onEnter,
cmsx_Ledstrip_FeatureRead,
NULL,
cmsx_Ledstrip_FeatureWriteback,
cmsx_menuLedstripEntries,

View File

@ -18,14 +18,18 @@
#if defined(VTX) || defined(USE_RTC6705)
uint8_t cmsx_featureVtx = 0, cmsx_vtxBand, cmsx_vtxChannel;
static bool featureRead = false;
static uint8_t cmsx_featureVtx = 0, cmsx_vtxBand, cmsx_vtxChannel;
void cmsx_Vtx_FeatureRead(void)
static void cmsx_Vtx_FeatureRead(void)
{
cmsx_featureVtx = feature(FEATURE_VTX) ? 1 : 0;
if (!featureRead) {
cmsx_featureVtx = feature(FEATURE_VTX) ? 1 : 0;
featureRead = true;
}
}
void cmsx_Vtx_FeatureWriteback(void)
static void cmsx_Vtx_FeatureWriteback(void)
{
if (cmsx_featureVtx)
featureSet(FEATURE_VTX);
@ -41,10 +45,10 @@ static const char * const vtxBandNames[] = {
"RACEBAND",
};
OSD_TAB_t entryVtxBand = {&cmsx_vtxBand,4,&vtxBandNames[0]};
OSD_UINT8_t entryVtxChannel = {&cmsx_vtxChannel, 1, 8, 1};
static OSD_TAB_t entryVtxBand = {&cmsx_vtxBand,4,&vtxBandNames[0]};
static OSD_UINT8_t entryVtxChannel = {&cmsx_vtxChannel, 1, 8, 1};
void cmsx_Vtx_ConfigRead(void)
static void cmsx_Vtx_ConfigRead(void)
{
#ifdef VTX
cmsx_vtxBand = masterConfig.vtxBand;
@ -57,7 +61,7 @@ void cmsx_Vtx_ConfigRead(void)
#endif // USE_RTC6705
}
void cmsx_Vtx_ConfigWriteback(void)
static void cmsx_Vtx_ConfigWriteback(void)
{
#ifdef VTX
masterConfig.vtxBand = cmsx_vtxBand;
@ -70,11 +74,11 @@ void cmsx_Vtx_ConfigWriteback(void)
}
#ifdef VTX
OSD_UINT8_t entryVtxMode = {&masterConfig.vtx_mode, 0, 2, 1};
OSD_UINT16_t entryVtxMhz = {&masterConfig.vtx_mhz, 5600, 5950, 1};
static OSD_UINT8_t entryVtxMode = {&masterConfig.vtx_mode, 0, 2, 1};
static OSD_UINT16_t entryVtxMhz = {&masterConfig.vtx_mhz, 5600, 5950, 1};
#endif // VTX
OSD_Entry cmsx_menuVtxEntries[] =
static OSD_Entry cmsx_menuVtxEntries[] =
{
{"--- VTX ---", OME_Label, NULL, NULL, 0},
{"ENABLED", OME_Bool, NULL, &cmsx_featureVtx, 0},

View File

@ -68,6 +68,7 @@ typedef struct {
void updateOsd(uint32_t currentTime);
void osdInit(void);
void resetOsdConfig(osd_profile_t *osdProfile);
void osdResetAlarms(void);
#ifdef CMS
void osdCmsInit(displayPort_t *);

View File

@ -12,10 +12,9 @@
#include "drivers/display.h"
#include "drivers/max7456.h"
displayPort_t osd7456DisplayPort;
displayPort_t osd7456DisplayPort; // Referenced from osd.c
extern uint16_t refreshTimeout;
void osdResetAlarms(void);
static int osdMenuBegin(displayPort_t *displayPort)
{
@ -71,7 +70,7 @@ static uint32_t osdTxBytesFree(displayPort_t *displayPort)
return UINT32_MAX;
}
displayPortVTable_t osdVTable = {
static displayPortVTable_t osdVTable = {
osdMenuBegin,
osdMenuEnd,
osdClearScreen,