mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 22:05:17 +03:00
Menu contents separation
This commit is contained in:
parent
cc69964d6b
commit
f8c48f569a
16 changed files with 646 additions and 475 deletions
|
@ -57,6 +57,20 @@
|
||||||
|
|
||||||
#include "build/debug.h"
|
#include "build/debug.h"
|
||||||
|
|
||||||
|
// External menu contents
|
||||||
|
#include "io/cms_imu.h"
|
||||||
|
#include "io/cms_blackbox.h"
|
||||||
|
#include "io/cms_vtx.h"
|
||||||
|
#ifdef OSD
|
||||||
|
#include "io/cms_osd.h"
|
||||||
|
#endif // OSD
|
||||||
|
#include "io/cms_ledstrip.h"
|
||||||
|
|
||||||
|
// Forwards
|
||||||
|
void cmsx_InfoInit(void);
|
||||||
|
void cmsx_FeatureRead(void);
|
||||||
|
void cmsx_FeatureWriteback(void);
|
||||||
|
|
||||||
// Device management
|
// Device management
|
||||||
|
|
||||||
#define CMS_MAX_DEVICE 4
|
#define CMS_MAX_DEVICE 4
|
||||||
|
@ -164,9 +178,11 @@ void cmsScreenInit(displayPort_t *pDisp, cmsDeviceInitFuncPtr cmsDeviceInitFunc)
|
||||||
//
|
//
|
||||||
|
|
||||||
#define LEFT_MENU_COLUMN 1
|
#define LEFT_MENU_COLUMN 1
|
||||||
#define RIGHT_MENU_COLUMN(p) ((p)->cols - 7)
|
#define RIGHT_MENU_COLUMN(p) ((p)->cols - 10)
|
||||||
#define MAX_MENU_ITEMS(p) ((p)->rows - 2)
|
#define MAX_MENU_ITEMS(p) ((p)->rows - 2)
|
||||||
|
|
||||||
|
displayPort_t currentDisplay;
|
||||||
|
|
||||||
bool cmsInMenu = false;
|
bool cmsInMenu = false;
|
||||||
|
|
||||||
OSD_Entry *menuStack[10]; //tab to save menu stack
|
OSD_Entry *menuStack[10]; //tab to save menu stack
|
||||||
|
@ -210,7 +226,7 @@ void cmsUpdateMaxRows(displayPort_t *instance)
|
||||||
currentMenuIdx--;
|
currentMenuIdx--;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmsFtoa(int32_t value, char *floatString)
|
static void cmsFormatFloat(int32_t value, char *floatString)
|
||||||
{
|
{
|
||||||
uint8_t k;
|
uint8_t k;
|
||||||
// np. 3450
|
// np. 3450
|
||||||
|
@ -225,7 +241,8 @@ static void cmsFtoa(int32_t value, char *floatString)
|
||||||
|
|
||||||
// 03.450
|
// 03.450
|
||||||
// usuwam koncowe zera i kropke
|
// usuwam koncowe zera i kropke
|
||||||
for (k = 5; k > 1; k--)
|
// Keep the first decimal place
|
||||||
|
for (k = 5; k > 3; k--)
|
||||||
if (floatString[k] == '0' || floatString[k] == '.')
|
if (floatString[k] == '0' || floatString[k] == '.')
|
||||||
floatString[k] = 0;
|
floatString[k] = 0;
|
||||||
else
|
else
|
||||||
|
@ -355,7 +372,7 @@ int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row, bool dr
|
||||||
case OME_FLOAT:
|
case OME_FLOAT:
|
||||||
if (IS_PRINTVALUE(p) && p->data) {
|
if (IS_PRINTVALUE(p) && p->data) {
|
||||||
OSD_FLOAT_t *ptr = p->data;
|
OSD_FLOAT_t *ptr = p->data;
|
||||||
cmsFtoa(*ptr->val * ptr->multipler, buff);
|
cmsFormatFloat(*ptr->val * ptr->multipler, buff);
|
||||||
cmsPad(buff, 5);
|
cmsPad(buff, 5);
|
||||||
cnt = cmsScreenWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay) - 1, row, buff); // XXX One char left ???
|
cnt = cmsScreenWrite(pDisplay, RIGHT_MENU_COLUMN(pDisplay) - 1, row, buff); // XXX One char left ???
|
||||||
CLR_PRINTVALUE(p);
|
CLR_PRINTVALUE(p);
|
||||||
|
@ -447,22 +464,14 @@ void cmsDrawMenu(displayPort_t *pDisplay)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX Needs separation
|
|
||||||
OSD_Entry menuPid[];
|
|
||||||
void cmsx_PidRead(void);
|
|
||||||
void cmsx_PidWriteback(void);
|
|
||||||
OSD_Entry menuRateExpo[];
|
|
||||||
void cmsx_RateExpoRead(void);
|
|
||||||
void cmsx_RateExpoWriteback(void);
|
|
||||||
|
|
||||||
long cmsMenuChange(displayPort_t *pDisplay, void *ptr)
|
long cmsMenuChange(displayPort_t *pDisplay, void *ptr)
|
||||||
{
|
{
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
// XXX (jflyper): This can be avoided by adding pre- and post-
|
// XXX (jflyper): This can be avoided by adding pre- and post-
|
||||||
// XXX (or onEnter and onExit) functions?
|
// XXX (or onEnter and onExit) functions?
|
||||||
if (ptr == &menuPid[0])
|
if (ptr == cmsx_menuPid)
|
||||||
cmsx_PidRead();
|
cmsx_PidRead();
|
||||||
if (ptr == &menuRateExpo[0])
|
if (ptr == cmsx_menuRateExpo)
|
||||||
cmsx_RateExpoRead();
|
cmsx_RateExpoRead();
|
||||||
|
|
||||||
if ((OSD_Entry *)ptr != currentMenu) {
|
if ((OSD_Entry *)ptr != currentMenu) {
|
||||||
|
@ -485,11 +494,11 @@ long cmsMenuBack(displayPort_t *pDisplay)
|
||||||
{
|
{
|
||||||
// becasue pids and rates may be stored in profiles we need some thicks to manipulate it
|
// becasue pids and rates may be stored in profiles we need some thicks to manipulate it
|
||||||
// hack to save pid profile
|
// hack to save pid profile
|
||||||
if (currentMenu == &menuPid[0])
|
if (currentMenu == cmsx_menuPid)
|
||||||
cmsx_PidWriteback();
|
cmsx_PidWriteback();
|
||||||
|
|
||||||
// hack - save rate config for current profile
|
// hack - save rate config for current profile
|
||||||
if (currentMenu == &menuRateExpo[0])
|
if (currentMenu == cmsx_menuRateExpo)
|
||||||
cmsx_RateExpoWriteback();
|
cmsx_RateExpoWriteback();
|
||||||
|
|
||||||
if (menuStackIdx) {
|
if (menuStackIdx) {
|
||||||
|
@ -505,13 +514,6 @@ long cmsMenuBack(displayPort_t *pDisplay)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX Separation
|
|
||||||
void cmsx_FeatureRead(void);
|
|
||||||
void cmsx_FeatureWriteback(void);
|
|
||||||
void cmsx_InfoInit(void);
|
|
||||||
|
|
||||||
displayPort_t currentDisplay;
|
|
||||||
|
|
||||||
void cmsMenuOpen(void)
|
void cmsMenuOpen(void)
|
||||||
{
|
{
|
||||||
cmsDeviceInitFuncPtr initfunc;
|
cmsDeviceInitFuncPtr initfunc;
|
||||||
|
@ -744,8 +746,6 @@ uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
OSD_Entry menuRc[];
|
|
||||||
|
|
||||||
void cmsUpdate(displayPort_t *pDisplay, uint32_t currentTime)
|
void cmsUpdate(displayPort_t *pDisplay, uint32_t currentTime)
|
||||||
{
|
{
|
||||||
static int16_t rcDelay = BUTTON_TIME;
|
static int16_t rcDelay = BUTTON_TIME;
|
||||||
|
@ -785,7 +785,7 @@ void cmsUpdate(displayPort_t *pDisplay, uint32_t currentTime)
|
||||||
key = KEY_RIGHT;
|
key = KEY_RIGHT;
|
||||||
rcDelay = BUTTON_TIME;
|
rcDelay = BUTTON_TIME;
|
||||||
}
|
}
|
||||||
else if ((IS_HI(YAW) || IS_LO(YAW)) && currentMenu != menuRc) // this menu is used to check transmitter signals so can't exit using YAW
|
else if ((IS_HI(YAW) || IS_LO(YAW)) && currentMenu != cmsx_menuRc) // this menu is used to check transmitter signals so can't exit using YAW
|
||||||
{
|
{
|
||||||
key = KEY_ESC;
|
key = KEY_ESC;
|
||||||
rcDelay = BUTTON_TIME;
|
rcDelay = BUTTON_TIME;
|
||||||
|
@ -830,401 +830,11 @@ void cmsInit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Menu tables, should eventually be all GONE!?
|
// Menu contents
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
|
||||||
// IMU
|
|
||||||
//
|
|
||||||
|
|
||||||
OSD_UINT8_t entryPidProfile = {&masterConfig.current_profile_index, 0, MAX_PROFILE_COUNT, 1};
|
|
||||||
|
|
||||||
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};
|
|
||||||
static OSD_UINT8_t entryRollD = {&tempPid[PIDROLL][2], 0, 150, 1};
|
|
||||||
|
|
||||||
static OSD_UINT8_t entryPitchP = {&tempPid[PIDPITCH][0], 10, 150, 1};
|
|
||||||
static OSD_UINT8_t entryPitchI = {&tempPid[PIDPITCH][1], 1, 150, 1};
|
|
||||||
static OSD_UINT8_t entryPitchD = {&tempPid[PIDPITCH][2], 0, 150, 1};
|
|
||||||
|
|
||||||
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};
|
|
||||||
|
|
||||||
void cmsx_PidRead(void)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
|
||||||
tempPid[i][0] = masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[i];
|
|
||||||
tempPid[i][1] = masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[i];
|
|
||||||
tempPid[i][2] = masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[i];
|
|
||||||
}
|
|
||||||
tempPid[3][0] = masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDLEVEL];
|
|
||||||
tempPid[3][1] = masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDLEVEL];
|
|
||||||
tempPid[3][2] = masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDLEVEL];
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmsx_PidWriteback(void)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
|
||||||
masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[i] = tempPid[i][0];
|
|
||||||
masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[i] = tempPid[i][1];
|
|
||||||
masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[i] = tempPid[i][2];
|
|
||||||
}
|
|
||||||
|
|
||||||
masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDLEVEL] = tempPid[3][0];
|
|
||||||
masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDLEVEL] = tempPid[3][1];
|
|
||||||
masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDLEVEL] = tempPid[3][2];
|
|
||||||
}
|
|
||||||
|
|
||||||
OSD_Entry menuPid[] =
|
|
||||||
{
|
|
||||||
{"--- PID ---", OME_Label, NULL, NULL, 0},
|
|
||||||
{"ROLL P", OME_UINT8, NULL, &entryRollP, 0},
|
|
||||||
{"ROLL I", OME_UINT8, NULL, &entryRollI, 0},
|
|
||||||
{"ROLL D", OME_UINT8, NULL, &entryRollD, 0},
|
|
||||||
|
|
||||||
{"PITCH P", OME_UINT8, NULL, &entryPitchP, 0},
|
|
||||||
{"PITCH I", OME_UINT8, NULL, &entryPitchI, 0},
|
|
||||||
{"PITCH D", OME_UINT8, NULL, &entryPitchD, 0},
|
|
||||||
|
|
||||||
{"YAW P", OME_UINT8, NULL, &entryYawP, 0},
|
|
||||||
{"YAW I", OME_UINT8, NULL, &entryYawI, 0},
|
|
||||||
{"YAW D", OME_UINT8, NULL, &entryYawD, 0},
|
|
||||||
|
|
||||||
{"BACK", OME_Back, NULL, NULL, 0},
|
|
||||||
{NULL, OME_END, NULL, NULL, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Rate & Expo
|
|
||||||
//
|
|
||||||
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};
|
|
||||||
static OSD_FLOAT_t entryYawRate = {&rateProfile.rates[2], 0, 250, 1, 10};
|
|
||||||
static OSD_FLOAT_t entryRcRate = {&rateProfile.rcRate8, 0, 200, 1, 10};
|
|
||||||
static OSD_FLOAT_t entryRcYawRate = {&rateProfile.rcYawRate8, 0, 200, 1, 10};
|
|
||||||
static OSD_FLOAT_t entryRcExpo = {&rateProfile.rcExpo8, 0, 100, 1, 10};
|
|
||||||
static OSD_FLOAT_t entryRcExpoYaw = {&rateProfile.rcYawExpo8, 0, 100, 1, 10};
|
|
||||||
static OSD_FLOAT_t extryTpaEntry = {&rateProfile.dynThrPID, 0, 70, 1, 10};
|
|
||||||
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};
|
|
||||||
|
|
||||||
void cmsx_RateExpoRead()
|
|
||||||
{
|
|
||||||
memcpy(&rateProfile, &masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile], sizeof(controlRateConfig_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmsx_RateExpoWriteback()
|
|
||||||
{
|
|
||||||
memcpy(&masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile], &rateProfile, sizeof(controlRateConfig_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
OSD_Entry menuRateExpo[] =
|
|
||||||
{
|
|
||||||
{"--- RATE&EXPO ---", OME_Label, NULL, NULL, 0},
|
|
||||||
{"RC RATE", OME_FLOAT, NULL, &entryRcYawRate, 0},
|
|
||||||
{"RC YAW RATE", OME_FLOAT, NULL, &entryRcRate, 0},
|
|
||||||
{"ROLL SUPER", OME_FLOAT, NULL, &entryRollRate, 0},
|
|
||||||
{"PITCH SUPER", OME_FLOAT, NULL, &entryPitchRate, 0},
|
|
||||||
{"YAW SUPER", OME_FLOAT, NULL, &entryYawRate, 0},
|
|
||||||
{"RC EXPO", OME_FLOAT, NULL, &entryRcExpo, 0},
|
|
||||||
{"RC YAW EXPO", OME_FLOAT, NULL, &entryRcExpoYaw, 0},
|
|
||||||
{"THR PID ATT", OME_FLOAT, NULL, &extryTpaEntry, 0},
|
|
||||||
{"TPA BRKPT", OME_UINT16, NULL, &entryTpaBreak, 0},
|
|
||||||
{"D SETPT", OME_FLOAT, NULL, &entryDSetpoint, 0},
|
|
||||||
{"D SETPT TRN", OME_FLOAT, NULL, &entryPSetpoint, 0},
|
|
||||||
{"BACK", OME_Back, NULL, NULL, 0},
|
|
||||||
{NULL, OME_END, NULL, NULL, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// RC preview
|
|
||||||
//
|
|
||||||
static OSD_INT16_t entryRcRoll = {&rcData[ROLL], 1, 2500, 0};
|
|
||||||
static OSD_INT16_t entryRcPitch = {&rcData[PITCH], 1, 2500, 0};
|
|
||||||
static OSD_INT16_t entryRcThr = {&rcData[THROTTLE], 1, 2500, 0};
|
|
||||||
static OSD_INT16_t entryRcYaw = {&rcData[YAW], 1, 2500, 0};
|
|
||||||
static OSD_INT16_t entryRcAux1 = {&rcData[AUX1], 1, 2500, 0};
|
|
||||||
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 menuRc[] =
|
|
||||||
{
|
|
||||||
{"--- RC PREV ---", OME_Label, NULL, NULL, 0},
|
|
||||||
{"ROLL", OME_Poll_INT16, NULL, &entryRcRoll, 0},
|
|
||||||
{"PITCH", OME_Poll_INT16, NULL, &entryRcPitch, 0},
|
|
||||||
{"THR", OME_Poll_INT16, NULL, &entryRcThr, 0},
|
|
||||||
{"YAW", OME_Poll_INT16, NULL, &entryRcYaw, 0},
|
|
||||||
{"AUX1", OME_Poll_INT16, NULL, &entryRcAux1, 0},
|
|
||||||
{"AUX2", OME_Poll_INT16, NULL, &entryRcAux2, 0},
|
|
||||||
{"AUX3", OME_Poll_INT16, NULL, &entryRcAux3, 0},
|
|
||||||
{"AUX4", OME_Poll_INT16, NULL, &entryRcAux4, 0},
|
|
||||||
{"BACK", OME_Back, NULL, NULL, 0},
|
|
||||||
{NULL, OME_END, NULL, NULL, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// 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};
|
|
||||||
|
|
||||||
OSD_Entry menuImuMisc[]=
|
|
||||||
{
|
|
||||||
{"--- MISC ---", OME_Label, NULL, NULL, 0},
|
|
||||||
{"GYRO LPF", OME_UINT8, NULL, &entryGyroSoftLpfHz, 0},
|
|
||||||
{"DTERM LPF", OME_UINT16, NULL, &entryDtermLpf, 0},
|
|
||||||
{"YAW LPF", OME_UINT16, NULL, &entryYawLpf, 0},
|
|
||||||
{"YAW P LIM", OME_UINT16, NULL, &entryYawPLimit, 0},
|
|
||||||
{"MIN THR", OME_UINT16, NULL, &entryMinThrottle, 0},
|
|
||||||
{"VBAT SCALE", OME_UINT8, NULL, &entryVbatScale, 0},
|
|
||||||
{"VBAT CLMAX", OME_UINT8, NULL, &entryVbatMaxCell, 0},
|
|
||||||
{"BACK", OME_Back, NULL, NULL, 0},
|
|
||||||
{NULL, OME_END, NULL, NULL, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
OSD_Entry menuImu[] =
|
|
||||||
{
|
|
||||||
{"--- CFG.IMU ---", OME_Label, NULL, NULL, 0},
|
|
||||||
{"PID PROF", OME_UINT8, NULL, &entryPidProfile, 0},
|
|
||||||
{"PID", OME_Submenu, cmsMenuChange, &menuPid[0], 0},
|
|
||||||
{"RATE&RXPO", OME_Submenu, cmsMenuChange, &menuRateExpo[0], 0},
|
|
||||||
{"RC PREV", OME_Submenu, cmsMenuChange, &menuRc[0], 0},
|
|
||||||
{"MISC", OME_Submenu, cmsMenuChange, &menuImuMisc[0], 0},
|
|
||||||
{"BACK", OME_Back, NULL, NULL, 0},
|
|
||||||
{NULL, OME_END, NULL, NULL, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Black box
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Should goto flashfs eventually.
|
|
||||||
//
|
|
||||||
#ifdef USE_FLASHFS
|
|
||||||
long cmsx_EraseFlash(displayPort_t *pDisplay, void *ptr)
|
|
||||||
{
|
|
||||||
UNUSED(ptr);
|
|
||||||
|
|
||||||
cmsScreenClear(pDisplay);
|
|
||||||
cmsScreenWrite(pDisplay, 5, 3, "ERASING FLASH...");
|
|
||||||
cmsScreenResync(pDisplay); // Was max7456RefreshAll(); Why at this timing?
|
|
||||||
|
|
||||||
flashfsEraseCompletely();
|
|
||||||
while (!flashfsIsReady()) {
|
|
||||||
delay(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmsScreenClear(pDisplay);
|
|
||||||
cmsScreenResync(pDisplay); // Was max7456RefreshAll(); wedges during heavy SPI?
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif // USE_FLASHFS
|
|
||||||
|
|
||||||
uint8_t featureBlackbox = 0;
|
|
||||||
|
|
||||||
OSD_UINT8_t entryBlackboxRateDenom = {&masterConfig.blackbox_rate_denom,1,32,1};
|
|
||||||
|
|
||||||
OSD_Entry menuBlackbox[] =
|
|
||||||
{
|
|
||||||
{"--- BLACKBOX ---", OME_Label, NULL, NULL, 0},
|
|
||||||
{"ENABLED", OME_Bool, NULL, &featureBlackbox, 0},
|
|
||||||
{"RATE DENOM", OME_UINT8, NULL, &entryBlackboxRateDenom, 0},
|
|
||||||
#ifdef USE_FLASHFS
|
|
||||||
{"ERASE FLASH", OME_Submenu, cmsx_EraseFlash, NULL, 0},
|
|
||||||
#endif // USE_FLASHFS
|
|
||||||
{"BACK", OME_Back, NULL, NULL, 0},
|
|
||||||
{NULL, OME_END, NULL, NULL, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// VTX
|
|
||||||
//
|
|
||||||
#if defined(VTX) || defined(USE_RTC6705)
|
|
||||||
|
|
||||||
uint8_t featureVtx = 0, vtxBand, vtxChannel;
|
|
||||||
|
|
||||||
static const char * const vtxBandNames[] = {
|
|
||||||
"BOSCAM A",
|
|
||||||
"BOSCAM B",
|
|
||||||
"BOSCAM E",
|
|
||||||
"FATSHARK",
|
|
||||||
"RACEBAND",
|
|
||||||
};
|
|
||||||
|
|
||||||
OSD_TAB_t entryVtxBand = {&vtxBand,4,&vtxBandNames[0]};
|
|
||||||
OSD_UINT8_t entryVtxChannel = {&vtxChannel, 1, 8, 1};
|
|
||||||
|
|
||||||
#ifdef VTX
|
|
||||||
OSD_UINT8_t entryVtxMode = {&masterConfig.vtx_mode, 0, 2, 1};
|
|
||||||
OSD_UINT16_t entryVtxMhz = {&masterConfig.vtx_mhz, 5600, 5950, 1};
|
|
||||||
#endif // VTX
|
|
||||||
|
|
||||||
OSD_Entry menu_vtx[] =
|
|
||||||
{
|
|
||||||
{"--- VTX ---", OME_Label, NULL, NULL, 0},
|
|
||||||
{"ENABLED", OME_Bool, NULL, &featureVtx, 0},
|
|
||||||
#ifdef VTX
|
|
||||||
{"VTX MODE", OME_UINT8, NULL, &entryVtxMode, 0},
|
|
||||||
{"VTX MHZ", OME_UINT16, NULL, &entryVtxMhz, 0},
|
|
||||||
#endif // VTX
|
|
||||||
{"BAND", OME_TAB, NULL, &entryVtxBand, 0},
|
|
||||||
{"CHANNEL", OME_UINT8, NULL, &entryVtxChannel, 0},
|
|
||||||
#ifdef USE_RTC6705
|
|
||||||
{"LOW POWER", OME_Bool, NULL, &masterConfig.vtx_power, 0},
|
|
||||||
#endif // USE_RTC6705
|
|
||||||
{"BACK", OME_Back, NULL, NULL, 0},
|
|
||||||
{NULL, OME_END, NULL, NULL, 0}
|
|
||||||
};
|
|
||||||
#endif // VTX || USE_RTC6705
|
|
||||||
|
|
||||||
//
|
|
||||||
// LED_STRIP
|
|
||||||
//
|
|
||||||
#ifdef LED_STRIP
|
|
||||||
|
|
||||||
//local variable to keep color value
|
|
||||||
uint8_t ledColor;
|
|
||||||
|
|
||||||
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
|
|
||||||
static void getLedColor(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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t featureLedstrip;
|
|
||||||
|
|
||||||
OSD_TAB_t entryLed = {&ledColor, 13, &LED_COLOR_NAMES[0]};
|
|
||||||
|
|
||||||
OSD_Entry menuLedstrip[] =
|
|
||||||
{
|
|
||||||
{"--- LED STRIP ---", OME_Label, NULL, NULL, 0},
|
|
||||||
{"ENABLED", OME_Bool, NULL, &featureLedstrip, 0},
|
|
||||||
{"LED COLOR", OME_TAB, applyLedColor, &entryLed, 0},
|
|
||||||
{"BACK", OME_Back, NULL, NULL, 0},
|
|
||||||
{NULL, OME_END, NULL, NULL, 0}
|
|
||||||
};
|
|
||||||
#endif // LED_STRIP
|
|
||||||
|
|
||||||
#ifdef OSD
|
|
||||||
//
|
|
||||||
// OSD specific menu pages and items
|
|
||||||
// XXX Should be part of the osd.c, or new osd_cms.c.
|
|
||||||
//
|
|
||||||
|
|
||||||
OSD_UINT8_t entryAlarmRssi = {&masterConfig.osdProfile.rssi_alarm, 5, 90, 5};
|
|
||||||
OSD_UINT16_t entryAlarmCapacity = {&masterConfig.osdProfile.cap_alarm, 50, 30000, 50};
|
|
||||||
OSD_UINT16_t enryAlarmFlyTime = {&masterConfig.osdProfile.time_alarm, 1, 200, 1};
|
|
||||||
OSD_UINT16_t entryAlarmAltitude = {&masterConfig.osdProfile.alt_alarm, 1, 200, 1};
|
|
||||||
|
|
||||||
OSD_Entry menuAlarms[] =
|
|
||||||
{
|
|
||||||
{"--- ALARMS ---", OME_Label, NULL, NULL, 0},
|
|
||||||
{"RSSI", OME_UINT8, NULL, &entryAlarmRssi, 0},
|
|
||||||
{"MAIN BAT", OME_UINT16, NULL, &entryAlarmCapacity, 0},
|
|
||||||
{"FLY TIME", OME_UINT16, NULL, &enryAlarmFlyTime, 0},
|
|
||||||
{"MAX ALT", OME_UINT16, NULL, &entryAlarmAltitude, 0},
|
|
||||||
{"BACK", OME_Back, NULL, NULL, 0},
|
|
||||||
{NULL, OME_END, NULL, NULL, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
OSD_Entry menuOsdActiveElems[] =
|
|
||||||
{
|
|
||||||
{"--- ACTIV ELEM ---", OME_Label, NULL, NULL, 0},
|
|
||||||
{"RSSI", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_RSSI_VALUE], 0},
|
|
||||||
{"MAIN BATTERY", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_MAIN_BATT_VOLTAGE], 0},
|
|
||||||
{"HORIZON", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_ARTIFICIAL_HORIZON], 0},
|
|
||||||
{"HORIZON SIDEBARS", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_HORIZON_SIDEBARS], 0},
|
|
||||||
{"UPTIME", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_ONTIME], 0},
|
|
||||||
{"FLY TIME", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_FLYTIME], 0},
|
|
||||||
{"FLY MODE", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_FLYMODE], 0},
|
|
||||||
{"NAME", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_CRAFT_NAME], 0},
|
|
||||||
{"THROTTLE", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_THROTTLE_POS], 0},
|
|
||||||
#ifdef VTX
|
|
||||||
{"VTX CHAN", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_VTX_CHANNEL]},
|
|
||||||
#endif // VTX
|
|
||||||
{"CURRENT (A)", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_CURRENT_DRAW], 0},
|
|
||||||
{"USED MAH", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_MAH_DRAWN], 0},
|
|
||||||
#ifdef GPS
|
|
||||||
{"GPS SPEED", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_GPS_SPEED], 0},
|
|
||||||
{"GPS SATS.", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_GPS_SATS], 0},
|
|
||||||
#endif // GPS
|
|
||||||
{"ALTITUDE", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_ALTITUDE], 0},
|
|
||||||
{"BACK", OME_Back, NULL, NULL, 0},
|
|
||||||
{NULL, OME_END, NULL, NULL, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
OSD_Entry menuOsdLayout[] =
|
|
||||||
{
|
|
||||||
{"---SCREEN LAYOUT---", OME_Label, NULL, NULL, 0},
|
|
||||||
{"ACTIVE ELEM.", OME_Submenu, cmsMenuChange, &menuOsdActiveElems[0], 0},
|
|
||||||
{"BACK", OME_Back, NULL, NULL, 0},
|
|
||||||
{NULL, OME_END, NULL, NULL, 0}
|
|
||||||
};
|
|
||||||
#endif // OSD
|
|
||||||
|
|
||||||
//
|
|
||||||
// Info
|
// Info
|
||||||
//
|
|
||||||
static char infoGitRev[GIT_SHORT_REVISION_LENGTH];
|
static char infoGitRev[GIT_SHORT_REVISION_LENGTH];
|
||||||
static char infoTargetName[] = __TARGET__;
|
static char infoTargetName[] = __TARGET__;
|
||||||
|
|
||||||
|
@ -1236,13 +846,6 @@ OSD_Entry menuInfo[] = {
|
||||||
{ "FWVER", OME_String, NULL, FC_VERSION_STRING, 0 },
|
{ "FWVER", OME_String, NULL, FC_VERSION_STRING, 0 },
|
||||||
{ "GITREV", OME_String, NULL, infoGitRev, 0 },
|
{ "GITREV", OME_String, NULL, infoGitRev, 0 },
|
||||||
{ "TARGET", OME_String, NULL, infoTargetName, 0 },
|
{ "TARGET", OME_String, NULL, infoTargetName, 0 },
|
||||||
|
|
||||||
#if 0
|
|
||||||
{ BETAFLIGHT_IDENTIFIER, OME_Label, NULL, NULL, 0 },
|
|
||||||
{ FC_VERSION_STRING, OME_Label, NULL, NULL, 0 },
|
|
||||||
{ infoGitRev, OME_Label, NULL, NULL, 0 },
|
|
||||||
{ infoTargetName, OME_Label, NULL, NULL, 0 },
|
|
||||||
#endif
|
|
||||||
{ "BACK", OME_Back, NULL, NULL, 0 },
|
{ "BACK", OME_Back, NULL, NULL, 0 },
|
||||||
{ NULL, OME_END, NULL, NULL, 0 }
|
{ NULL, OME_END, NULL, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
@ -1257,30 +860,34 @@ void cmsx_InfoInit(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Features
|
||||||
|
|
||||||
OSD_Entry menuFeatures[] =
|
OSD_Entry menuFeatures[] =
|
||||||
{
|
{
|
||||||
{"--- FEATURES ---", OME_Label, NULL, NULL, 0},
|
{"--- FEATURES ---", OME_Label, NULL, NULL, 0},
|
||||||
{"BLACKBOX", OME_Submenu, cmsMenuChange, &menuBlackbox[0], 0},
|
{"BLACKBOX", OME_Submenu, cmsMenuChange, cmsx_menuBlackbox, 0},
|
||||||
#if defined(VTX) || defined(USE_RTC6705)
|
#if defined(VTX) || defined(USE_RTC6705)
|
||||||
{"VTX", OME_Submenu, cmsMenuChange, &menu_vtx[0], 0},
|
{"VTX", OME_Submenu, cmsMenuChange, cmsx_menuVtx, 0},
|
||||||
#endif // VTX || USE_RTC6705
|
#endif // VTX || USE_RTC6705
|
||||||
#ifdef LED_STRIP
|
#ifdef LED_STRIP
|
||||||
{"LED STRIP", OME_Submenu, cmsMenuChange, &menuLedstrip[0], 0},
|
{"LED STRIP", OME_Submenu, cmsMenuChange, &cmsx_menuLedstrip, 0},
|
||||||
#endif // LED_STRIP
|
#endif // LED_STRIP
|
||||||
{"BACK", OME_Back, NULL, NULL, 0},
|
{"BACK", OME_Back, NULL, NULL, 0},
|
||||||
{NULL, OME_END, NULL, NULL, 0}
|
{NULL, OME_END, NULL, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Main
|
||||||
|
|
||||||
OSD_Entry menuMain[] =
|
OSD_Entry menuMain[] =
|
||||||
{
|
{
|
||||||
{"--- MAIN MENU ---", OME_Label, NULL, NULL, 0},
|
{"--- MAIN MENU ---", OME_Label, NULL, NULL, 0},
|
||||||
{"CFG&IMU", OME_Submenu, cmsMenuChange, &menuImu[0], 0},
|
{"CFG&IMU", OME_Submenu, cmsMenuChange, cmsx_menuImu, 0},
|
||||||
{"FEATURES", OME_Submenu, cmsMenuChange, &menuFeatures[0], 0},
|
{"FEATURES", OME_Submenu, cmsMenuChange, menuFeatures, 0},
|
||||||
#ifdef OSD
|
#ifdef OSD
|
||||||
{"SCR LAYOUT", OME_Submenu, cmsMenuChange, &menuOsdLayout[0], 0},
|
{"SCR LAYOUT", OME_Submenu, cmsMenuChange, cmsx_menuOsdLayout, 0},
|
||||||
{"ALARMS", OME_Submenu, cmsMenuChange, &menuAlarms[0], 0},
|
{"ALARMS", OME_Submenu, cmsMenuChange, cmsx_menuAlarms, 0},
|
||||||
#endif
|
#endif
|
||||||
{"INFO", OME_Submenu, cmsMenuChange, &menuInfo[0], 0},
|
{"FC&FW INFO", OME_Submenu, cmsMenuChange, menuInfo, 0},
|
||||||
{"SAVE&REBOOT", OME_OSD_Exit, cmsMenuExit, (void*)1, 0},
|
{"SAVE&REBOOT", OME_OSD_Exit, cmsMenuExit, (void*)1, 0},
|
||||||
{"EXIT", OME_OSD_Exit, cmsMenuExit, (void*)0, 0},
|
{"EXIT", OME_OSD_Exit, cmsMenuExit, (void*)0, 0},
|
||||||
{NULL,OME_END, NULL, NULL, 0}
|
{NULL,OME_END, NULL, NULL, 0}
|
||||||
|
@ -1288,60 +895,33 @@ OSD_Entry menuMain[] =
|
||||||
|
|
||||||
void cmsx_FeatureRead(void)
|
void cmsx_FeatureRead(void)
|
||||||
{
|
{
|
||||||
featureBlackbox = feature(FEATURE_BLACKBOX) ? 1 : 0;
|
cmsx_Blackbox_FeatureRead();
|
||||||
|
|
||||||
#ifdef LED_STRIP
|
#ifdef LED_STRIP
|
||||||
featureLedstrip = feature(FEATURE_LED_STRIP) ? 1 : 0;
|
cmsx_Ledstrip_FeatureRead();
|
||||||
getLedColor();
|
cmsx_Ledstrip_ConfigRead();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(VTX) || defined(USE_RTC6705)
|
#if defined(VTX) || defined(USE_RTC6705)
|
||||||
featureVtx = feature(FEATURE_VTX) ? 1 : 0;
|
cmsx_Vtx_FeatureRead();
|
||||||
|
cmsx_Vtx_ConfigRead();
|
||||||
#endif // VTX || USE_RTC6705
|
#endif // VTX || USE_RTC6705
|
||||||
|
|
||||||
#ifdef VTX
|
|
||||||
vtxBand = masterConfig.vtxBand;
|
|
||||||
vtxChannel = masterConfig.vtx_channel + 1;
|
|
||||||
#endif // VTX
|
|
||||||
|
|
||||||
#ifdef USE_RTC6705
|
|
||||||
vtxBand = masterConfig.vtx_channel / 8;
|
|
||||||
vtxChannel = masterConfig.vtx_channel % 8 + 1;
|
|
||||||
#endif // USE_RTC6705
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmsx_FeatureWriteback(void)
|
void cmsx_FeatureWriteback(void)
|
||||||
{
|
{
|
||||||
if (featureBlackbox)
|
cmsx_Blackbox_FeatureWriteback();
|
||||||
featureSet(FEATURE_BLACKBOX);
|
|
||||||
else
|
|
||||||
featureClear(FEATURE_BLACKBOX);
|
|
||||||
|
|
||||||
#ifdef LED_STRIP
|
#ifdef LED_STRIP
|
||||||
if (featureLedstrip)
|
cmsx_Ledstrip_FeatureWriteback();
|
||||||
featureSet(FEATURE_LED_STRIP);
|
|
||||||
else
|
|
||||||
featureClear(FEATURE_LED_STRIP);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(VTX) || defined(USE_RTC6705)
|
#if defined(VTX) || defined(USE_RTC6705)
|
||||||
if (featureVtx)
|
cmsx_Vtx_FeatureWriteback();
|
||||||
featureSet(FEATURE_VTX);
|
cmsx_Vtx_ConfigWriteback();
|
||||||
else
|
|
||||||
featureClear(FEATURE_VTX);
|
|
||||||
#endif // VTX || USE_RTC6705
|
#endif // VTX || USE_RTC6705
|
||||||
|
|
||||||
#ifdef VTX
|
|
||||||
masterConfig.vtxBand = vtxBand;
|
|
||||||
masterConfig.vtx_channel = vtxChannel - 1;
|
|
||||||
#endif // VTX
|
|
||||||
|
|
||||||
#ifdef USE_RTC6705
|
|
||||||
masterConfig.vtx_channel = vtxBand * 8 + vtxChannel - 1;
|
|
||||||
#endif // USE_RTC6705
|
|
||||||
|
|
||||||
saveConfigAndNotify();
|
saveConfigAndNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // CMS
|
#endif // CMS
|
||||||
|
|
|
@ -32,9 +32,12 @@ void cmsInit(void);
|
||||||
void cmsHandler(uint32_t currentTime);
|
void cmsHandler(uint32_t currentTime);
|
||||||
|
|
||||||
// Required for external CMS tables
|
// Required for external CMS tables
|
||||||
|
void cmsScreenClear(displayPort_t *pPort);
|
||||||
|
void cmsScreenResync(displayPort_t *pPort);
|
||||||
|
int cmsScreenWrite(displayPort_t *pPort, uint8_t x, uint8_t y, char *s);
|
||||||
|
|
||||||
long cmsChangeScreen(displayPort_t *pPort, void *ptr);
|
long cmsMenuChange(displayPort_t *pPort, void *ptr);
|
||||||
long cmsExitMenu(displayPort_t *pPort, void *ptr);
|
long cmsMenuExit(displayPort_t *pPort, 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"
|
||||||
|
|
77
src/main/io/cms_blackbox.c
Normal file
77
src/main/io/cms_blackbox.c
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
//
|
||||||
|
// CMS things for blackbox and flashfs.
|
||||||
|
// Should be part of blackbox.c (or new blackbox/blackbox_cms.c) and io/flashfs.c
|
||||||
|
//
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#include "build/version.h"
|
||||||
|
|
||||||
|
#ifdef CMS
|
||||||
|
|
||||||
|
#include "drivers/system.h"
|
||||||
|
|
||||||
|
#include "config/config_profile.h"
|
||||||
|
#include "config/config_master.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
|
#include "io/cms.h"
|
||||||
|
#include "io/cms_types.h"
|
||||||
|
#include "io/cms_blackbox.h"
|
||||||
|
|
||||||
|
#include "io/flashfs.h"
|
||||||
|
|
||||||
|
#ifdef USE_FLASHFS
|
||||||
|
long cmsx_EraseFlash(displayPort_t *pDisplay, void *ptr)
|
||||||
|
{
|
||||||
|
UNUSED(ptr);
|
||||||
|
|
||||||
|
cmsScreenClear(pDisplay);
|
||||||
|
cmsScreenWrite(pDisplay, 5, 3, "ERASING FLASH...");
|
||||||
|
cmsScreenResync(pDisplay); // Was max7456RefreshAll(); Why at this timing?
|
||||||
|
|
||||||
|
flashfsEraseCompletely();
|
||||||
|
while (!flashfsIsReady()) {
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmsScreenClear(pDisplay);
|
||||||
|
cmsScreenResync(pDisplay); // Was max7456RefreshAll(); wedges during heavy SPI?
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif // USE_FLASHFS
|
||||||
|
|
||||||
|
uint8_t cmsx_FeatureBlackbox;
|
||||||
|
|
||||||
|
OSD_UINT8_t entryBlackboxRateDenom = {&masterConfig.blackbox_rate_denom,1,32,1};
|
||||||
|
|
||||||
|
OSD_Entry cmsx_menuBlackbox[] =
|
||||||
|
{
|
||||||
|
{"--- BLACKBOX ---", OME_Label, NULL, NULL, 0},
|
||||||
|
{"ENABLED", OME_Bool, NULL, &cmsx_FeatureBlackbox, 0},
|
||||||
|
{"RATE DENOM", OME_UINT8, NULL, &entryBlackboxRateDenom, 0},
|
||||||
|
#ifdef USE_FLASHFS
|
||||||
|
{"ERASE FLASH", OME_Submenu, cmsx_EraseFlash, NULL, 0},
|
||||||
|
#endif // USE_FLASHFS
|
||||||
|
{"BACK", OME_Back, NULL, NULL, 0},
|
||||||
|
{NULL, OME_END, NULL, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
void cmsx_Blackbox_FeatureRead(void)
|
||||||
|
{
|
||||||
|
cmsx_FeatureBlackbox = feature(FEATURE_BLACKBOX) ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmsx_Blackbox_FeatureWriteback(void)
|
||||||
|
{
|
||||||
|
if (cmsx_FeatureBlackbox)
|
||||||
|
featureSet(FEATURE_BLACKBOX);
|
||||||
|
else
|
||||||
|
featureClear(FEATURE_BLACKBOX);
|
||||||
|
}
|
||||||
|
#endif
|
4
src/main/io/cms_blackbox.h
Normal file
4
src/main/io/cms_blackbox.h
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
extern OSD_Entry cmsx_menuBlackbox[];
|
||||||
|
|
||||||
|
void cmsx_Blackbox_FeatureRead(void);
|
||||||
|
void cmsx_Blackbox_FeatureWriteback(void);
|
206
src/main/io/cms_imu.c
Normal file
206
src/main/io/cms_imu.c
Normal file
|
@ -0,0 +1,206 @@
|
||||||
|
|
||||||
|
// Menu contents for PID, RATES, RC preview, misc
|
||||||
|
// Should be part of the relevant .c file.
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#include "build/version.h"
|
||||||
|
|
||||||
|
#ifdef CMS
|
||||||
|
|
||||||
|
#include "drivers/system.h"
|
||||||
|
|
||||||
|
//#include "common/typeconversion.h"
|
||||||
|
|
||||||
|
#include "io/cms.h"
|
||||||
|
#include "io/cms_types.h"
|
||||||
|
#include "io/cms_imu.h"
|
||||||
|
|
||||||
|
#include "fc/config.h"
|
||||||
|
#include "fc/rc_controls.h"
|
||||||
|
#include "fc/runtime_config.h"
|
||||||
|
|
||||||
|
#include "flight/pid.h"
|
||||||
|
|
||||||
|
#include "config/config_profile.h"
|
||||||
|
#include "config/config_master.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
|
OSD_UINT8_t entryPidProfile = {&masterConfig.current_profile_index, 0, MAX_PROFILE_COUNT, 1};
|
||||||
|
|
||||||
|
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};
|
||||||
|
static OSD_UINT8_t entryRollD = {&tempPid[PIDROLL][2], 0, 150, 1};
|
||||||
|
|
||||||
|
static OSD_UINT8_t entryPitchP = {&tempPid[PIDPITCH][0], 10, 150, 1};
|
||||||
|
static OSD_UINT8_t entryPitchI = {&tempPid[PIDPITCH][1], 1, 150, 1};
|
||||||
|
static OSD_UINT8_t entryPitchD = {&tempPid[PIDPITCH][2], 0, 150, 1};
|
||||||
|
|
||||||
|
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};
|
||||||
|
|
||||||
|
void cmsx_PidRead(void)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
tempPid[i][0] = masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[i];
|
||||||
|
tempPid[i][1] = masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[i];
|
||||||
|
tempPid[i][2] = masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[i];
|
||||||
|
}
|
||||||
|
tempPid[3][0] = masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDLEVEL];
|
||||||
|
tempPid[3][1] = masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDLEVEL];
|
||||||
|
tempPid[3][2] = masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDLEVEL];
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmsx_PidWriteback(void)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[i] = tempPid[i][0];
|
||||||
|
masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[i] = tempPid[i][1];
|
||||||
|
masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[i] = tempPid[i][2];
|
||||||
|
}
|
||||||
|
|
||||||
|
masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDLEVEL] = tempPid[3][0];
|
||||||
|
masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDLEVEL] = tempPid[3][1];
|
||||||
|
masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDLEVEL] = tempPid[3][2];
|
||||||
|
}
|
||||||
|
|
||||||
|
OSD_Entry cmsx_menuPid[] =
|
||||||
|
{
|
||||||
|
{"--- PID ---", OME_Label, NULL, NULL, 0},
|
||||||
|
{"ROLL P", OME_UINT8, NULL, &entryRollP, 0},
|
||||||
|
{"ROLL I", OME_UINT8, NULL, &entryRollI, 0},
|
||||||
|
{"ROLL D", OME_UINT8, NULL, &entryRollD, 0},
|
||||||
|
|
||||||
|
{"PITCH P", OME_UINT8, NULL, &entryPitchP, 0},
|
||||||
|
{"PITCH I", OME_UINT8, NULL, &entryPitchI, 0},
|
||||||
|
{"PITCH D", OME_UINT8, NULL, &entryPitchD, 0},
|
||||||
|
|
||||||
|
{"YAW P", OME_UINT8, NULL, &entryYawP, 0},
|
||||||
|
{"YAW I", OME_UINT8, NULL, &entryYawI, 0},
|
||||||
|
{"YAW D", OME_UINT8, NULL, &entryYawD, 0},
|
||||||
|
|
||||||
|
{"BACK", OME_Back, NULL, NULL, 0},
|
||||||
|
{NULL, OME_END, NULL, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Rate & Expo
|
||||||
|
//
|
||||||
|
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};
|
||||||
|
static OSD_FLOAT_t entryYawRate = {&rateProfile.rates[2], 0, 250, 1, 10};
|
||||||
|
static OSD_FLOAT_t entryRcRate = {&rateProfile.rcRate8, 0, 200, 1, 10};
|
||||||
|
static OSD_FLOAT_t entryRcYawRate = {&rateProfile.rcYawRate8, 0, 200, 1, 10};
|
||||||
|
static OSD_FLOAT_t entryRcExpo = {&rateProfile.rcExpo8, 0, 100, 1, 10};
|
||||||
|
static OSD_FLOAT_t entryRcExpoYaw = {&rateProfile.rcYawExpo8, 0, 100, 1, 10};
|
||||||
|
static OSD_FLOAT_t extryTpaEntry = {&rateProfile.dynThrPID, 0, 70, 1, 10};
|
||||||
|
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};
|
||||||
|
|
||||||
|
void cmsx_RateExpoRead()
|
||||||
|
{
|
||||||
|
memcpy(&rateProfile, &masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile], sizeof(controlRateConfig_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmsx_RateExpoWriteback()
|
||||||
|
{
|
||||||
|
memcpy(&masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile], &rateProfile, sizeof(controlRateConfig_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
OSD_Entry cmsx_menuRateExpo[] =
|
||||||
|
{
|
||||||
|
{"--- RATE&EXPO ---", OME_Label, NULL, NULL, 0},
|
||||||
|
{"RC RATE", OME_FLOAT, NULL, &entryRcYawRate, 0},
|
||||||
|
{"RC YAW RATE", OME_FLOAT, NULL, &entryRcRate, 0},
|
||||||
|
{"ROLL SUPER", OME_FLOAT, NULL, &entryRollRate, 0},
|
||||||
|
{"PITCH SUPER", OME_FLOAT, NULL, &entryPitchRate, 0},
|
||||||
|
{"YAW SUPER", OME_FLOAT, NULL, &entryYawRate, 0},
|
||||||
|
{"RC EXPO", OME_FLOAT, NULL, &entryRcExpo, 0},
|
||||||
|
{"RC YAW EXPO", OME_FLOAT, NULL, &entryRcExpoYaw, 0},
|
||||||
|
{"THR PID ATT", OME_FLOAT, NULL, &extryTpaEntry, 0},
|
||||||
|
{"TPA BRKPT", OME_UINT16, NULL, &entryTpaBreak, 0},
|
||||||
|
{"D SETPT", OME_FLOAT, NULL, &entryDSetpoint, 0},
|
||||||
|
{"D SETPT TRN", OME_FLOAT, NULL, &entryPSetpoint, 0},
|
||||||
|
{"BACK", OME_Back, NULL, NULL, 0},
|
||||||
|
{NULL, OME_END, NULL, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// RC preview
|
||||||
|
//
|
||||||
|
static OSD_INT16_t entryRcRoll = {&rcData[ROLL], 1, 2500, 0};
|
||||||
|
static OSD_INT16_t entryRcPitch = {&rcData[PITCH], 1, 2500, 0};
|
||||||
|
static OSD_INT16_t entryRcThr = {&rcData[THROTTLE], 1, 2500, 0};
|
||||||
|
static OSD_INT16_t entryRcYaw = {&rcData[YAW], 1, 2500, 0};
|
||||||
|
static OSD_INT16_t entryRcAux1 = {&rcData[AUX1], 1, 2500, 0};
|
||||||
|
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_menuRc[] =
|
||||||
|
{
|
||||||
|
{"--- RC PREV ---", OME_Label, NULL, NULL, 0},
|
||||||
|
{"ROLL", OME_Poll_INT16, NULL, &entryRcRoll, 0},
|
||||||
|
{"PITCH", OME_Poll_INT16, NULL, &entryRcPitch, 0},
|
||||||
|
{"THR", OME_Poll_INT16, NULL, &entryRcThr, 0},
|
||||||
|
{"YAW", OME_Poll_INT16, NULL, &entryRcYaw, 0},
|
||||||
|
{"AUX1", OME_Poll_INT16, NULL, &entryRcAux1, 0},
|
||||||
|
{"AUX2", OME_Poll_INT16, NULL, &entryRcAux2, 0},
|
||||||
|
{"AUX3", OME_Poll_INT16, NULL, &entryRcAux3, 0},
|
||||||
|
{"AUX4", OME_Poll_INT16, NULL, &entryRcAux4, 0},
|
||||||
|
{"BACK", OME_Back, NULL, NULL, 0},
|
||||||
|
{NULL, OME_END, NULL, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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};
|
||||||
|
|
||||||
|
OSD_Entry menuImuMisc[]=
|
||||||
|
{
|
||||||
|
{"--- MISC ---", OME_Label, NULL, NULL, 0},
|
||||||
|
{"GYRO LPF", OME_UINT8, NULL, &entryGyroSoftLpfHz, 0},
|
||||||
|
{"DTERM LPF", OME_UINT16, NULL, &entryDtermLpf, 0},
|
||||||
|
{"YAW LPF", OME_UINT16, NULL, &entryYawLpf, 0},
|
||||||
|
{"YAW P LIM", OME_UINT16, NULL, &entryYawPLimit, 0},
|
||||||
|
{"MIN THR", OME_UINT16, NULL, &entryMinThrottle, 0},
|
||||||
|
{"VBAT SCALE", OME_UINT8, NULL, &entryVbatScale, 0},
|
||||||
|
{"VBAT CLMAX", OME_UINT8, NULL, &entryVbatMaxCell, 0},
|
||||||
|
{"BACK", OME_Back, NULL, NULL, 0},
|
||||||
|
{NULL, OME_END, NULL, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
OSD_Entry cmsx_menuImu[] =
|
||||||
|
{
|
||||||
|
{"--- CFG.IMU ---", OME_Label, NULL, NULL, 0},
|
||||||
|
{"PID PROF", OME_UINT8, NULL, &entryPidProfile, 0},
|
||||||
|
{"PID", OME_Submenu, cmsMenuChange, cmsx_menuPid, 0},
|
||||||
|
{"RATE&RXPO", OME_Submenu, cmsMenuChange, cmsx_menuRateExpo, 0},
|
||||||
|
{"RC PREV", OME_Submenu, cmsMenuChange, cmsx_menuRc, 0},
|
||||||
|
{"MISC", OME_Submenu, cmsMenuChange, menuImuMisc, 0},
|
||||||
|
{"BACK", OME_Back, NULL, NULL, 0},
|
||||||
|
{NULL, OME_END, NULL, NULL, 0}
|
||||||
|
};
|
||||||
|
#endif // CMS
|
13
src/main/io/cms_imu.h
Normal file
13
src/main/io/cms_imu.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
extern OSD_Entry cmsx_menuImu[];
|
||||||
|
|
||||||
|
// All of below should be gone.
|
||||||
|
|
||||||
|
extern OSD_Entry cmsx_menuPid[];
|
||||||
|
extern OSD_Entry cmsx_menuRc[];
|
||||||
|
extern OSD_Entry cmsx_menuRateExpo[];
|
||||||
|
|
||||||
|
void cmsx_PidRead(void);
|
||||||
|
void cmsx_PidWriteback(void);
|
||||||
|
void cmsx_RateExpoRead(void);
|
||||||
|
void cmsx_RateExpoWriteback(void);
|
||||||
|
|
107
src/main/io/cms_ledstrip.c
Normal file
107
src/main/io/cms_ledstrip.c
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#include "build/version.h"
|
||||||
|
|
||||||
|
#ifdef CMS
|
||||||
|
|
||||||
|
#include "drivers/system.h"
|
||||||
|
|
||||||
|
#include "config/config_profile.h"
|
||||||
|
#include "config/config_master.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
|
#include "io/cms.h"
|
||||||
|
#include "io/cms_types.h"
|
||||||
|
#include "io/cms_blackbox.h"
|
||||||
|
|
||||||
|
#ifdef LED_STRIP
|
||||||
|
|
||||||
|
//local variable to keep color value
|
||||||
|
uint8_t ledColor;
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t cmsx_FeatureLedstrip;
|
||||||
|
|
||||||
|
OSD_TAB_t entryLed = {&ledColor, 13, &LED_COLOR_NAMES[0]};
|
||||||
|
|
||||||
|
OSD_Entry cmsx_menuLedstrip[] =
|
||||||
|
{
|
||||||
|
{"--- 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}
|
||||||
|
};
|
||||||
|
|
||||||
|
void cmsx_Ledstrip_FeatureRead(void)
|
||||||
|
{
|
||||||
|
cmsx_FeatureLedstrip = feature(FEATURE_LED_STRIP) ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmsx_Ledstrip_FeatureWriteback(void)
|
||||||
|
{
|
||||||
|
if (cmsx_FeatureLedstrip)
|
||||||
|
featureSet(FEATURE_LED_STRIP);
|
||||||
|
else
|
||||||
|
featureClear(FEATURE_LED_STRIP);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmsx_Ledstrip_ConfigRead(void)
|
||||||
|
{
|
||||||
|
cmsx_GetLedColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // LED_STRIP
|
||||||
|
#endif // CMS
|
6
src/main/io/cms_ledstrip.h
Normal file
6
src/main/io/cms_ledstrip.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
extern OSD_Entry cmsx_menuLedstrip[];
|
||||||
|
|
||||||
|
void cmsx_Ledstrip_FeatureRead(void);
|
||||||
|
void cmsx_Ledstrip_FeatureWriteback(void);
|
||||||
|
|
||||||
|
void cmsx_Ledstrip_ConfigRead(void);
|
2
src/main/io/cms_osd.h
Normal file
2
src/main/io/cms_osd.h
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
extern OSD_Entry cmsx_menuAlarms[];
|
||||||
|
extern OSD_Entry cmsx_menuOsdLayout[];
|
96
src/main/io/cms_vtx.c
Normal file
96
src/main/io/cms_vtx.c
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#include "build/version.h"
|
||||||
|
|
||||||
|
#include "io/cms.h"
|
||||||
|
#include "io/cms_types.h"
|
||||||
|
#include "io/cms_vtx.h"
|
||||||
|
|
||||||
|
#include "config/config_profile.h"
|
||||||
|
#include "config/config_master.h"
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
|
#ifdef CMS
|
||||||
|
|
||||||
|
#if defined(VTX) || defined(USE_RTC6705)
|
||||||
|
|
||||||
|
uint8_t cmsx_featureVtx = 0, cmsx_vtxBand, cmsx_vtxChannel;
|
||||||
|
|
||||||
|
static const char * const vtxBandNames[] = {
|
||||||
|
"BOSCAM A",
|
||||||
|
"BOSCAM B",
|
||||||
|
"BOSCAM E",
|
||||||
|
"FATSHARK",
|
||||||
|
"RACEBAND",
|
||||||
|
};
|
||||||
|
|
||||||
|
OSD_TAB_t entryVtxBand = {&cmsx_vtxBand,4,&vtxBandNames[0]};
|
||||||
|
OSD_UINT8_t entryVtxChannel = {&cmsx_vtxChannel, 1, 8, 1};
|
||||||
|
|
||||||
|
#ifdef VTX
|
||||||
|
OSD_UINT8_t entryVtxMode = {&masterConfig.vtx_mode, 0, 2, 1};
|
||||||
|
OSD_UINT16_t entryVtxMhz = {&masterConfig.vtx_mhz, 5600, 5950, 1};
|
||||||
|
#endif // VTX
|
||||||
|
|
||||||
|
OSD_Entry cmsx_menuVtx[] =
|
||||||
|
{
|
||||||
|
{"--- VTX ---", OME_Label, NULL, NULL, 0},
|
||||||
|
{"ENABLED", OME_Bool, NULL, &featureVtx, 0},
|
||||||
|
#ifdef VTX
|
||||||
|
{"VTX MODE", OME_UINT8, NULL, &entryVtxMode, 0},
|
||||||
|
{"VTX MHZ", OME_UINT16, NULL, &entryVtxMhz, 0},
|
||||||
|
#endif // VTX
|
||||||
|
{"BAND", OME_TAB, NULL, &entryVtxBand, 0},
|
||||||
|
{"CHANNEL", OME_UINT8, NULL, &entryVtxChannel, 0},
|
||||||
|
#ifdef USE_RTC6705
|
||||||
|
{"LOW POWER", OME_Bool, NULL, &masterConfig.vtx_power, 0},
|
||||||
|
#endif // USE_RTC6705
|
||||||
|
{"BACK", OME_Back, NULL, NULL, 0},
|
||||||
|
{NULL, OME_END, NULL, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
void cmsx_Vtx_FeatureRead(void)
|
||||||
|
{
|
||||||
|
cmsx_featureVtx = feature(FEATURE_VTX) ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmsx_Vtx_FeatureWriteback(void)
|
||||||
|
{
|
||||||
|
if (cmsx_featureVtx)
|
||||||
|
featureSet(FEATURE_VTX);
|
||||||
|
else
|
||||||
|
featureClear(FEATURE_VTX);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmsx_Vtx_ConfigRead(void)
|
||||||
|
{
|
||||||
|
#ifdef VTX
|
||||||
|
cmsx_vtxBand = masterConfig.vtxBand;
|
||||||
|
cmsx_vtxChannel = masterConfig.vtx_channel + 1;
|
||||||
|
#endif // VTX
|
||||||
|
|
||||||
|
#ifdef USE_RTC6705
|
||||||
|
cmsx_vtxBand = masterConfig.vtx_channel / 8;
|
||||||
|
cmsx_vtxChannel = masterConfig.vtx_channel % 8 + 1;
|
||||||
|
#endif // USE_RTC6705
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmsx_Vtx_ConfigRead(void)
|
||||||
|
{
|
||||||
|
#ifdef VTX
|
||||||
|
masterConfig.vtxBand = cmsx_vtxBand;
|
||||||
|
masterConfig.vtx_channel = cmsx_vtxChannel - 1;
|
||||||
|
#endif // VTX
|
||||||
|
|
||||||
|
#ifdef USE_RTC6705
|
||||||
|
masterConfig.vtx_channel = cmsx_vtxBand * 8 + cmsx_vtxChannel - 1;
|
||||||
|
#endif // USE_RTC6705
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // VTX || USE_RTC6705
|
||||||
|
|
||||||
|
#endif // CMS
|
7
src/main/io/cms_vtx.h
Normal file
7
src/main/io/cms_vtx.h
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
extern OSD_Entry cmsx_menuVtx[];
|
||||||
|
|
||||||
|
void cmsx_Vtx_FeatureRead(void);
|
||||||
|
void cmsx_Vtx_FeatureWriteback(void);
|
||||||
|
|
||||||
|
void cmsx_Vtx_ConfigRead(void);
|
||||||
|
void cmsx_Vtx_ConfigWriteback(void);
|
|
@ -636,6 +636,7 @@ void osdUpdate(uint32_t currentTime)
|
||||||
//
|
//
|
||||||
// OSD specific CMS functions
|
// OSD specific CMS functions
|
||||||
//
|
//
|
||||||
|
#include "io/cms_osd.h"
|
||||||
|
|
||||||
uint8_t shiftdown;
|
uint8_t shiftdown;
|
||||||
|
|
||||||
|
@ -727,4 +728,55 @@ void osdCmsInit(displayPort_t *pPort)
|
||||||
osdResync(pPort);
|
osdResync(pPort);
|
||||||
pPort->vTable = &osdVTable;
|
pPort->vTable = &osdVTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSD_UINT8_t entryAlarmRssi = {&masterConfig.osdProfile.rssi_alarm, 5, 90, 5};
|
||||||
|
OSD_UINT16_t entryAlarmCapacity = {&masterConfig.osdProfile.cap_alarm, 50, 30000, 50};
|
||||||
|
OSD_UINT16_t enryAlarmFlyTime = {&masterConfig.osdProfile.time_alarm, 1, 200, 1};
|
||||||
|
OSD_UINT16_t entryAlarmAltitude = {&masterConfig.osdProfile.alt_alarm, 1, 200, 1};
|
||||||
|
|
||||||
|
OSD_Entry cmsx_menuAlarms[] =
|
||||||
|
{
|
||||||
|
{"--- ALARMS ---", OME_Label, NULL, NULL, 0},
|
||||||
|
{"RSSI", OME_UINT8, NULL, &entryAlarmRssi, 0},
|
||||||
|
{"MAIN BAT", OME_UINT16, NULL, &entryAlarmCapacity, 0},
|
||||||
|
{"FLY TIME", OME_UINT16, NULL, &enryAlarmFlyTime, 0},
|
||||||
|
{"MAX ALT", OME_UINT16, NULL, &entryAlarmAltitude, 0},
|
||||||
|
{"BACK", OME_Back, NULL, NULL, 0},
|
||||||
|
{NULL, OME_END, NULL, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
OSD_Entry menuOsdActiveElems[] =
|
||||||
|
{
|
||||||
|
{"--- ACTIV ELEM ---", OME_Label, NULL, NULL, 0},
|
||||||
|
{"RSSI", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_RSSI_VALUE], 0},
|
||||||
|
{"MAIN BATTERY", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_MAIN_BATT_VOLTAGE], 0},
|
||||||
|
{"HORIZON", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_ARTIFICIAL_HORIZON], 0},
|
||||||
|
{"HORIZON SIDEBARS", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_HORIZON_SIDEBARS], 0},
|
||||||
|
{"UPTIME", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_ONTIME], 0},
|
||||||
|
{"FLY TIME", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_FLYTIME], 0},
|
||||||
|
{"FLY MODE", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_FLYMODE], 0},
|
||||||
|
{"NAME", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_CRAFT_NAME], 0},
|
||||||
|
{"THROTTLE", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_THROTTLE_POS], 0},
|
||||||
|
#ifdef VTX
|
||||||
|
{"VTX CHAN", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_VTX_CHANNEL]},
|
||||||
|
#endif // VTX
|
||||||
|
{"CURRENT (A)", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_CURRENT_DRAW], 0},
|
||||||
|
{"USED MAH", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_MAH_DRAWN], 0},
|
||||||
|
#ifdef GPS
|
||||||
|
{"GPS SPEED", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_GPS_SPEED], 0},
|
||||||
|
{"GPS SATS.", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_GPS_SATS], 0},
|
||||||
|
#endif // GPS
|
||||||
|
{"ALTITUDE", OME_VISIBLE, NULL, &masterConfig.osdProfile.item_pos[OSD_ALTITUDE], 0},
|
||||||
|
{"BACK", OME_Back, NULL, NULL, 0},
|
||||||
|
{NULL, OME_END, NULL, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
OSD_Entry cmsx_menuOsdLayout[] =
|
||||||
|
{
|
||||||
|
{"---SCREEN LAYOUT---", OME_Label, NULL, NULL, 0},
|
||||||
|
{"ACTIVE ELEM.", OME_Submenu, cmsMenuChange, &menuOsdActiveElems[0], 0},
|
||||||
|
{"BACK", OME_Back, NULL, NULL, 0},
|
||||||
|
{NULL, OME_END, NULL, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
#endif // OSD
|
#endif // OSD
|
||||||
|
|
|
@ -15,5 +15,9 @@ TARGET_SRC = \
|
||||||
io/transponder_ir.c \
|
io/transponder_ir.c \
|
||||||
drivers/max7456.c \
|
drivers/max7456.c \
|
||||||
io/osd.c \
|
io/osd.c \
|
||||||
|
io/canvas.c \
|
||||||
io/cms.c \
|
io/cms.c \
|
||||||
io/canvas.c
|
io/cms_imu.c \
|
||||||
|
io/cms_blackbox.c \
|
||||||
|
io/cms_vtx.c \
|
||||||
|
io/cms_ledstrip.c
|
||||||
|
|
|
@ -13,5 +13,9 @@ TARGET_SRC = \
|
||||||
drivers/vtx_soft_spi_rtc6705.c \
|
drivers/vtx_soft_spi_rtc6705.c \
|
||||||
drivers/max7456.c \
|
drivers/max7456.c \
|
||||||
io/osd.c \
|
io/osd.c \
|
||||||
|
io/canvas.c \
|
||||||
io/cms.c \
|
io/cms.c \
|
||||||
io/canvas.c
|
io/cms_imu.c \
|
||||||
|
io/cms_blackbox.c \
|
||||||
|
io/cms_vtx.c \
|
||||||
|
io/cms_ledstrip.c
|
||||||
|
|
|
@ -9,6 +9,10 @@ TARGET_SRC = \
|
||||||
drivers/barometer_bmp280.c \
|
drivers/barometer_bmp280.c \
|
||||||
drivers/compass_ak8975.c \
|
drivers/compass_ak8975.c \
|
||||||
drivers/compass_hmc5883l.c \
|
drivers/compass_hmc5883l.c \
|
||||||
|
io/canvas.c \
|
||||||
io/cms.c \
|
io/cms.c \
|
||||||
io/canvas.c
|
io/cms_imu.c \
|
||||||
|
io/cms_blackbox.c \
|
||||||
|
io/cms_vtx.c \
|
||||||
|
io/cms_ledstrip.c
|
||||||
|
|
||||||
|
|
|
@ -27,4 +27,10 @@ TARGET_SRC = \
|
||||||
drivers/flash_m25p16.c \
|
drivers/flash_m25p16.c \
|
||||||
drivers/max7456.c \
|
drivers/max7456.c \
|
||||||
io/osd.c \
|
io/osd.c \
|
||||||
io/cms.c
|
io/canvas.c \
|
||||||
|
io/cms.c \
|
||||||
|
io/cms_imu.c \
|
||||||
|
io/cms_blackbox.c \
|
||||||
|
io/cms_vtx.c \
|
||||||
|
io/cms_ledstrip.c
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue