feat(radio): refactor of switch handling to better support customisable switches (#6095)

Co-authored-by: philmoz <phil.a.mitchell@gmail.com>
Co-authored-by: 3djc <3djc@gh.com>
Co-authored-by: elecpower <elecpower@users.noreply.github.com>
This commit is contained in:
philmoz
2025-07-28 12:59:22 +10:00
committed by GitHub
co-authored by philmoz 3djc elecpower
parent 28833f42e6
commit 0c8c39b134
155 changed files with 4538 additions and 2306 deletions
+1
View File
@@ -411,6 +411,7 @@ endif()
set(SRC
${SRC}
edgetx.cpp
datastructs_private.cpp
functions.cpp
strhelpers.cpp
switches.cpp
@@ -40,13 +40,7 @@ static timer_handle_t _refresh_timer = TIMER_INITIALIZER;
void rgbSetLedColor(uint8_t led, uint8_t r, uint8_t g, uint8_t b)
{
#if defined(SIXPOS_SWITCH_INDEX)
ws2812_set_color(led + 6, r, g, b);
#elif defined(RGB_LED_OFFSET)
ws2812_set_color(led + RGB_LED_OFFSET, r, g, b);
#else
ws2812_set_color(led, r, g, b);
#endif
}
uint32_t rgbGetLedColor(uint8_t led)
+17 -12
View File
@@ -20,10 +20,11 @@
*/
#include "hal/switch_driver.h"
#include "bsp_io.h"
#include "stm32_switch_driver.h"
#include "stm32_gpio_driver.h"
#include "drivers/pca95xx.h"
#include "definitions.h"
#include "myeeprom.h"
@@ -37,30 +38,33 @@ __weak void boardInitSwitches()
_init_switches();
}
__weak SwitchHwPos boardSwitchGetPosition(SwitchCategory cat, uint8_t idx)
__weak SwitchHwPos boardSwitchGetPosition(uint8_t idx)
{
const stm32_switch_t* sw = &_switch_offsets[cat][idx];
if(sw->type != SWITCH_HW_ADC && sw->GPIOx_high == nullptr)
return bsp_get_switch_position(sw, cat, idx);
const stm32_switch_t* sw = &_switch_defs[idx];
return stm32_switch_get_position(sw);
}
__weak const char* boardSwitchGetName(SwitchCategory cat, uint8_t idx)
__weak const char* boardSwitchGetName(uint8_t idx)
{
return _switch_offsets[cat][idx].name;
return _switch_defs[idx].name;
}
__weak SwitchHwType boardSwitchGetType(SwitchCategory cat, uint8_t idx)
__weak SwitchHwType boardSwitchGetType(uint8_t idx)
{
return _switch_offsets[cat][idx].type;
return _switch_defs[idx].type;
}
const stm32_switch_t* boardGetSwitchDef(uint8_t idx) { return &_switch_defs[idx]; }
uint8_t boardGetMaxSwitches() { return n_switches; }
uint8_t boardGetMaxFctSwitches() { return n_fct_switches; }
#if defined(FUNCTION_SWITCHES)
bool boardIsCustomSwitch(uint8_t idx) { return _switch_defs[idx].isCustomSwitch; }
uint8_t boardGetCustomSwitchIdx(uint8_t idx) { return _switch_defs[idx].customSwitchIdx; }
#endif
swconfig_t boardSwitchGetDefaultConfig() { return _switch_default_config; }
SwitchConfig boardSwitchGetDefaultConfig(uint8_t idx) { return _switch_defs[idx].defaultType; }
#if !defined(COLORLCD)
switch_display_pos_t switchGetDisplayPosition(uint8_t idx)
{
// TODO: find a solution for FLEX switches so they can be displayed on main view
@@ -68,3 +72,4 @@ switch_display_pos_t switchGetDisplayPosition(uint8_t idx)
return _switch_display[idx];
}
#endif
+2 -2
View File
@@ -1452,11 +1452,11 @@ int cliDisplay(const char ** argv)
cliSerialPrint("[Trim %s] = %s", getTrimLabel(i),
keysGetTrimState(i) ? "on" : "off");
}
for (int i = 0; i < switchGetMaxSwitches(); i++) {
for (int i = 0; i < switchGetMaxAllSwitches(); i++) {
if (SWITCH_EXISTS(i)) {
static const char * const SWITCH_POSITIONS[] = { "up", "mid", "down" };
auto pos = switchGetPosition(i);
cliSerialPrint("[%s] = %s", switchGetName(i), SWITCH_POSITIONS[pos]);
cliSerialPrint("[%s] = %s", switchGetDefaultName(i), SWITCH_POSITIONS[pos]);
}
}
}
+1 -1
View File
@@ -560,7 +560,7 @@ enum MixSources {
#define INPUTSRC_LAST MIXSRC_LAST_TELEM
#if defined(FUNCTION_SWITCHES)
#define MIXSRC_LAST_REGULAR_SWITCH (MIXSRC_FIRST_SWITCH + switchGetMaxSwitches() - 1)
#define MIXSRC_LAST_REGULAR_SWITCH (MIXSRC_FIRST_SWITCH + switchGetMaxAllSwitches() - 1)
#define MIXSRC_FIRST_FS_SWITCH (MIXSRC_LAST_REGULAR_SWITCH + 1)
#endif
+14 -8
View File
@@ -83,21 +83,27 @@ static inline void check_struct()
#endif
#if defined(PCBXLITES)
CHKSIZE(RadioData, 873);
CHKSIZE(RadioData, 945);
#elif defined(RADIO_ST16)
CHKSIZE(RadioData, 1159);
#elif defined(COLORLCD)
CHKSIZE(RadioData, 967);
CHKSIZE(RadioData, 1039);
#elif defined(RADIO_GX12)
CHKSIZE(RadioData, 1063);
#elif defined(RADIO_GX12)
CHKSIZE(RadioData, 1062);
#else
CHKSIZE(RadioData, 871);
CHKSIZE(RadioData, 943);
#endif
#if defined(RADIO_TPRO) || defined(RADIO_TPROV2) || defined(RADIO_BUMBLEBEE)
CHKSIZE(ModelData, 6354);
CHKSIZE(ModelData, 6355);
#elif defined(RADIO_T14) || defined(RADIO_T12MAX)
CHKSIZE(ModelData, 6329);
#elif defined(RADIO_FAMILY_T20)
CHKSIZE(ModelData, 6390);
CHKSIZE(ModelData, 6391);
#elif defined(RADIO_GX12)
CHKSIZE(ModelData, 6390);
CHKSIZE(ModelData, 6419);
#elif defined(PCBX9E)
CHKSIZE(ModelData, 6771);
#elif defined(PCBX9D) || defined(PCBX9DP)
@@ -113,9 +119,9 @@ static inline void check_struct()
#elif defined(PCBNV14)
CHKSIZE(ModelData, 27295);
#elif defined(PCBST16)
CHKSIZE(ModelData, 27754);
CHKSIZE(ModelData, 27761);
#elif defined(RADIO_T15)
CHKSIZE(ModelData, 27682);
CHKSIZE(ModelData, 27683);
#elif defined(PCBHORUS)
CHKSIZE(ModelData, 27657);
#else
+254
View File
@@ -0,0 +1,254 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "edgetx.h"
#include "hal/switch_driver.h"
SwitchConfig ModelData::getSwitchType(uint8_t n)
{
#if defined(FUNCTION_SWITCHES)
if (switchIsCustomSwitch(n) && cfsType(n) != SWITCH_GLOBAL)
return cfsType(n);
#endif
return g_eeGeneral.switchType(n);
}
void ModelData::setSwitchType(uint8_t n, SwitchConfig v) {
#if defined(FUNCTION_SWITCHES)
if (switchIsCustomSwitch(n) && cfsType(n) != SWITCH_GLOBAL)
cfsSetType(n,v);
#endif
g_eeGeneral.switchSetType(n, v);
}
char* ModelData::getSwitchCustomName(uint8_t n)
{
#if defined(FUNCTION_SWITCHES)
if (switchIsCustomSwitch(n) && cfsType(n) != SWITCH_GLOBAL)
return g_model.cfsName(n);
#endif
return g_eeGeneral.getSwitchCustomName(n);
}
bool ModelData::switchHasCustomName(uint8_t n)
{
#if defined(FUNCTION_SWITCHES)
if (switchIsCustomSwitch(n) && cfsType(n) != SWITCH_GLOBAL)
return g_model.cfsName(n)[0] != 0;
#endif
return g_eeGeneral.switchHasCustomName(n);
}
uint8_t ModelData::getSwitchStateForWarning(uint8_t n)
{
#if defined(FUNCTION_SWITCHES)
if (switchIsCustomSwitch(n)) {
return cfsState(n) ? 3 : 1;
}
#endif
extern swarnstate_t switches_states;
return (switches_states >> (n * 2)) & 3;
}
char* RadioData::getSwitchCustomName(uint8_t n)
{
return switchConfig[n].name;
}
bool RadioData::switchHasCustomName(uint8_t n)
{
return switchConfig[n].name[0] != 0;
}
SwitchConfig RadioData::switchType(uint8_t n) {
return (SwitchConfig)switchConfig[n].type;
}
void RadioData::switchSetType(uint8_t n, SwitchConfig v) {
switchConfig[n].type = v;
storageDirty(EE_GENERAL);
}
char* RadioData::switchName(uint8_t n) {
return switchConfig[n].name;
}
#if defined(FUNCTION_SWITCHES)
uint8_t ModelData::getSwitchGroup(uint8_t n) {
if (switchIsCustomSwitch(n) && cfsType(n) != SWITCH_GLOBAL)
return cfsGroup(n);
return g_eeGeneral.switchGroup(n);
}
fsStartPositionType ModelData::getSwitchStart(uint8_t n) {
if (switchIsCustomSwitch(n) && cfsType(n) != SWITCH_GLOBAL)
return cfsStart(n);
return g_eeGeneral.switchStart(n);
}
void ModelData::setSwitchStart(uint8_t n, fsStartPositionType v) {
if (switchIsCustomSwitch(n) && cfsType(n) != SWITCH_GLOBAL)
cfsSetStart(n, v);
g_eeGeneral.switchSetStart(n, v);
}
SwitchConfig ModelData::cfsType(uint8_t n) {
return (SwitchConfig)customSwitches[switchGetCustomSwitchIdx(n)].type;
}
void ModelData::cfsSetType(uint8_t n, SwitchConfig v) {
customSwitches[switchGetCustomSwitchIdx(n)].type = v;
storageDirty(EE_MODEL);
}
char* ModelData::cfsName(uint8_t n) {
return customSwitches[switchGetCustomSwitchIdx(n)].name;
}
uint8_t ModelData::cfsGroup(uint8_t n) {
return customSwitches[switchGetCustomSwitchIdx(n)].group;
}
void ModelData::cfsSetGroup(uint8_t n, uint8_t v) {
customSwitches[switchGetCustomSwitchIdx(n)].group = v;
storageDirty(EE_MODEL);
}
fsStartPositionType ModelData::cfsStart(uint8_t n) {
return (fsStartPositionType)customSwitches[switchGetCustomSwitchIdx(n)].start;
}
void ModelData::cfsSetStart(uint8_t n, fsStartPositionType v) {
customSwitches[switchGetCustomSwitchIdx(n)].start = v;
storageDirty(EE_MODEL);
}
bool ModelData::cfsState(uint8_t n) {
return customSwitches[switchGetCustomSwitchIdx(n)].state;
}
void ModelData::cfsSetState(uint8_t n, bool v) {
customSwitches[switchGetCustomSwitchIdx(n)].state = v;
storageDirty(EE_MODEL);
}
bool ModelData::cfsSFState(uint8_t n) {
return bfGet<uint8_t>(sfPushState, switchGetCustomSwitchIdx(n), 1);
}
void ModelData::cfsSetSFState(uint8_t n, bool v) {
// Note: n = cfs index, not switch index
sfPushState = bfSet<uint8_t>(sfPushState, v, n, 1);
}
void ModelData::cfsResetSFState() {
sfPushState = 0;
}
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
RGBLedColor& ModelData::getSwitchOnColor(uint8_t n) {
if (switchIsCustomSwitch(n) && cfsType(n) != SWITCH_GLOBAL)
return cfsOnColor(n);
return g_eeGeneral.switchOnColor(n);
}
RGBLedColor& ModelData::getSwitchOffColor(uint8_t n) {
if (switchIsCustomSwitch(n) && cfsType(n) != SWITCH_GLOBAL)
return cfsOffColor(n);
return g_eeGeneral.switchOffColor(n);
}
bool ModelData::getSwitchOnColorLuaOverride(uint8_t n) {
if (switchIsCustomSwitch(n) && cfsType(n) != SWITCH_GLOBAL)
return cfsOnColorLuaOverride(n);
return g_eeGeneral.cfsOnColorLuaOverride(n);
}
bool ModelData::getSwitchOffColorLuaOverride(uint8_t n) {
if (switchIsCustomSwitch(n) && cfsType(n) != SWITCH_GLOBAL)
return cfsOffColorLuaOverride(n);
return g_eeGeneral.cfsOffColorLuaOverride(n);
}
RGBLedColor& ModelData::cfsOnColor(uint8_t n) {
return customSwitches[switchGetCustomSwitchIdx(n)].onColor;
}
RGBLedColor& ModelData::cfsOffColor(uint8_t n) {
return customSwitches[switchGetCustomSwitchIdx(n)].offColor;
}
bool ModelData::cfsOnColorLuaOverride(uint8_t n) {
return customSwitches[switchGetCustomSwitchIdx(n)].onColorLuaOverride;
}
bool ModelData::cfsOffColorLuaOverride(uint8_t n) {
return customSwitches[switchGetCustomSwitchIdx(n)].offColorLuaOverride;
}
void ModelData::cfsSetOnColorLuaOverride(uint8_t n, bool v) {
customSwitches[switchGetCustomSwitchIdx(n)].onColorLuaOverride = v;
storageDirty(EE_MODEL);
}
void ModelData::cfsSetOffColorLuaOverride(uint8_t n, bool v) {
customSwitches[switchGetCustomSwitchIdx(n)].offColorLuaOverride = v;
storageDirty(EE_MODEL);
}
#endif
fsStartPositionType RadioData::switchStart(uint8_t n) {
return (fsStartPositionType)switchConfig[n].start;
}
void RadioData::switchSetStart(uint8_t n, fsStartPositionType v) {
switchConfig[n].start = v;
storageDirty(EE_GENERAL);
}
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
RGBLedColor& RadioData::switchOnColor(uint8_t n) {
return switchConfig[n].onColor;
}
RGBLedColor& RadioData::switchOffColor(uint8_t n) {
return switchConfig[n].offColor;
}
bool RadioData::cfsOnColorLuaOverride(uint8_t n) {
return switchConfig[n].onColorLuaOverride;
}
bool RadioData::cfsOffColorLuaOverride(uint8_t n) {
return switchConfig[n].offColorLuaOverride;
}
void RadioData::cfsSetOnColorLuaOverride(uint8_t n, bool v) {
switchConfig[n].onColorLuaOverride = v;
storageDirty(EE_GENERAL);
}
void RadioData::cfsSetOffColorLuaOverride(uint8_t n, bool v) {
switchConfig[n].offColorLuaOverride = v;
storageDirty(EE_GENERAL);
}
#endif
#endif
+125 -11
View File
@@ -32,6 +32,7 @@
#include "usb_joystick.h"
#include "input_mapping.h"
#include "debug.h"
#include "bitfield.h"
#if defined(PCBTARANIS)
#define N_TARANIS_FIELD(x)
@@ -643,21 +644,54 @@ struct RGBLedColor {
}
};
#if defined(FUNCTION_SWITCHES)
PACK(struct customSwitch {
CUST_IDX(sw, cfs_idx_read, cfs_idx_write);
NOBACKUP(char name[LEN_SWITCH_NAME]);
uint8_t type:3 ENUM(SwitchConfig);
#if NUM_FUNCTIONS_GROUPS > 3
uint8_t group:3;
#else
uint8_t group:2;
#endif
uint8_t start:2 ENUM(fsStartPositionType);
uint8_t state:1;
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
NOBACKUP(uint8_t onColorLuaOverride:1 ENUM(booleanEnum));
NOBACKUP(uint8_t offColorLuaOverride:1 ENUM(booleanEnum));
#if NUM_FUNCTIONS_GROUPS > 3
NOBACKUP(uint8_t spare:5) SKIP;
#else
NOBACKUP(uint8_t spare:6) SKIP;
#endif
NOBACKUP(RGBLedColor onColor) FUNC(isAlwaysActive);
NOBACKUP(RGBLedColor offColor) FUNC(isAlwaysActive);
#else
#if NUM_FUNCTIONS_GROUPS > 3
NOBACKUP(uint8_t spare:7) SKIP;
#endif
#endif
});
#endif
#if defined(FUNCTION_SWITCHES)
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
#define FUNCTION_SWITCHS_RGB_LEDS_FIELDS \
RGBLedColor functionSwitchLedONColor[NUM_FUNCTIONS_SWITCHES]; \
RGBLedColor functionSwitchLedOFFColor[NUM_FUNCTIONS_SWITCHES];
CUST_ARRAY(functionSwitchLedONColor, struct_cfsOnColorConfig, NUM_FUNCTIONS_SWITCHES, nullptr); \
CUST_ARRAY(functionSwitchLedOFFColor, struct_cfsOffColorConfig, NUM_FUNCTIONS_SWITCHES, nullptr);
#else
#define FUNCTION_SWITCHS_RGB_LEDS_FIELDS
#endif
#if defined(FUNCTION_SWITCHES)
#define FUNCTION_SWITCHS_FIELDS \
uint16_t functionSwitchConfig; \
uint16_t functionSwitchGroup; \
uint16_t functionSwitchStartConfig; \
uint8_t functionSwitchLogicalState; \
char switchNames[NUM_FUNCTIONS_SWITCHES][LEN_SWITCH_NAME]; \
FUNCTION_SWITCHS_RGB_LEDS_FIELDS
CUST_ATTR(functionSwitchConfig, r_functionSwitchConfig, nullptr); \
CUST_ATTR(functionSwitchGroup, r_functionSwitchGroup, nullptr); \
CUST_ATTR(functionSwitchStartConfig, r_functionSwitchStartConfig, nullptr); \
CUST_ATTR(functionSwitchLogicalState, r_functionSwitchLogicalState, nullptr); \
CUST_ARRAY(switchNames, struct_cfsNameConfig, NUM_FUNCTIONS_SWITCHES, nullptr); \
FUNCTION_SWITCHS_RGB_LEDS_FIELDS \
customSwitch customSwitches[NUM_FUNCTIONS_SWITCHES] FUNC(isAlwaysActive) NO_IDX; \
uint8_t cfsGroupOn ARRAY(1, struct_cfsGroupOn, cfsGroupIsActive); \
NOBACKUP(uint8_t sfPushState) SKIP;
#else
#define FUNCTION_SWITCHS_FIELDS
#endif
@@ -744,7 +778,7 @@ PACK(struct ModelData {
NOBACKUP(uint8_t thrTraceSrc CUST(r_thrSrc,w_thrSrc));
CUST_ATTR(switchWarningState, r_swtchWarn, nullptr);
NOBACKUP(swarnstate_t switchWarning ARRAY(3, struct_swtchWarn, nullptr));
NOBACKUP(swarnstate_t switchWarning ARRAY(2, struct_swtchWarn, nullptr));
GVarData gvars[MAX_GVARS];
@@ -828,6 +862,47 @@ PACK(struct ModelData {
uint8_t modelSFDisabled:2 ENUM(ModelOverridableEnable);
uint8_t modelCustomScriptsDisabled:2 ENUM(ModelOverridableEnable);
uint8_t modelTelemetryDisabled:2 ENUM(ModelOverridableEnable);
SwitchConfig getSwitchType(uint8_t n);
void setSwitchType(uint8_t n, SwitchConfig v);
char* getSwitchCustomName(uint8_t n);
bool switchHasCustomName(uint8_t n);
uint8_t getSwitchStateForWarning(uint8_t n);
NOBACKUP(uint8_t getSwitchWarning(uint8_t n) { return bfGet<swarnstate_t>(switchWarning, n * 2, 2); })
NOBACKUP(void setSwitchWarning(uint8_t n, uint8_t v) { switchWarning = bfSet<swarnstate_t>(switchWarning, v, n * 2, 2); })
#if defined(FUNCTION_SWITCHES)
uint8_t getSwitchGroup(uint8_t n);
fsStartPositionType getSwitchStart(uint8_t n);
void setSwitchStart(uint8_t n, fsStartPositionType v);
SwitchConfig cfsType(uint8_t n);
void cfsSetType(uint8_t n, SwitchConfig v);
char* cfsName(uint8_t n);
uint8_t cfsGroup(uint8_t n);
void cfsSetGroup(uint8_t n, uint8_t v);
fsStartPositionType cfsStart(uint8_t n);
void cfsSetStart(uint8_t n, fsStartPositionType v);
bool cfsState(uint8_t n);
void cfsSetState(uint8_t n, bool v);
bool cfsSFState(uint8_t n);
void cfsSetSFState(uint8_t n, bool v);
void cfsResetSFState();
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
RGBLedColor& getSwitchOnColor(uint8_t n);
RGBLedColor& getSwitchOffColor(uint8_t n);
bool getSwitchOnColorLuaOverride(uint8_t n);
bool getSwitchOffColorLuaOverride(uint8_t n);
RGBLedColor& cfsOnColor(uint8_t n);
RGBLedColor& cfsOffColor(uint8_t n);
bool cfsOnColorLuaOverride(uint8_t n);
bool cfsOffColorLuaOverride(uint8_t n);
void cfsSetOnColorLuaOverride(uint8_t n, bool v);
void cfsSetOffColorLuaOverride(uint8_t n, bool v);
#endif
bool cfsGroupAlwaysOn(uint8_t n) { return bfGet<uint8_t>(cfsGroupOn, n, 1); }
void cfsSetGroupAlwaysOn(uint8_t n, bool v) { cfsGroupOn = bfSet<uint8_t>(cfsGroupOn, v, n, 1); }
#endif
});
/*
@@ -877,6 +952,26 @@ PACK(struct TrainerData {
#define BUZZER_FIELD int8_t spare2:2 SKIP
#endif
PACK(struct switchDef {
CUST_IDX(sw, sw_idx_read, sw_idx_write);
NOBACKUP(char name[LEN_SWITCH_NAME]);
uint8_t type:3 ENUM(SwitchConfig);
#if defined(FUNCTION_SWITCHES)
uint8_t start:2 ENUM(fsStartPositionType) FUNC(switch_is_cfs);
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
NOBACKUP(uint8_t onColorLuaOverride:1 ENUM(booleanEnum)) FUNC(switch_is_cfs);
NOBACKUP(uint8_t offColorLuaOverride:1 ENUM(booleanEnum)) FUNC(switch_is_cfs);
NOBACKUP(uint8_t spare:1) SKIP;
NOBACKUP(RGBLedColor onColor) FUNC(switch_is_cfs);
NOBACKUP(RGBLedColor offColor) FUNC(switch_is_cfs);
#else
NOBACKUP(uint8_t spare:3) SKIP;
#endif
#else
NOBACKUP(uint8_t spare:5) SKIP;
#endif
});
PACK(struct RadioData {
// Real attributes
@@ -967,7 +1062,7 @@ PACK(struct RadioData {
CUST_ARRAY(slidersConfig, struct_sliderConfig, MAX_POTS, nullptr);
uint8_t stickInvert SKIP;
potconfig_t potsConfig ARRAY(4,struct_potConfig,nullptr);
swconfig_t switchConfig ARRAY(2,struct_switchConfig,nullptr);
switchDef switchConfig[MAX_SWITCHES] FUNC(switchIsActive) NO_IDX; \
CUST_ARRAY(flexSwitches, struct_flexSwitch, MAX_FLEX_SWITCHES, flex_sw_valid);
EXTRA_GENERAL_FIELDS
@@ -1035,6 +1130,25 @@ PACK(struct RadioData {
return backlightBright;
#endif
});
char* getSwitchCustomName(uint8_t n);
bool switchHasCustomName(uint8_t n);
SwitchConfig switchType(uint8_t n);
void switchSetType(uint8_t n, SwitchConfig v);
char* switchName(uint8_t n);
#if defined(FUNCTION_SWITCHES)
uint8_t switchGroup(uint8_t n) { return 0; }
fsStartPositionType switchStart(uint8_t n);
void switchSetStart(uint8_t n, fsStartPositionType v);
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
RGBLedColor& switchOnColor(uint8_t n);
RGBLedColor& switchOffColor(uint8_t n);
bool cfsOnColorLuaOverride(uint8_t n);
bool cfsOffColorLuaOverride(uint8_t n);
void cfsSetOnColorLuaOverride(uint8_t n, bool v);
void cfsSetOffColorLuaOverride(uint8_t n, bool v);
#endif
#endif
});
#undef SWITCHES_WARNING_DATA
+17 -1
View File
@@ -293,6 +293,22 @@ void setDefaultOwnerId()
}
#endif
void generalDefaultSwitches()
{
for (uint8_t sw = 0; sw < switchGetMaxSwitches(); sw += 1) {
g_eeGeneral.switchConfig[sw].type = switchGetDefaultConfig(sw);
g_eeGeneral.switchConfig[sw].name[0] = 0;
#if defined(FUNCTION_SWITCHES)
if (switchIsCustomSwitch(sw))
g_eeGeneral.switchConfig[sw].start = FS_START_PREVIOUS;
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
g_eeGeneral.switchConfig[sw].onColor.setColor(0xFFFFFF);
g_eeGeneral.switchConfig[sw].offColor.setColor(0);
#endif
#endif
}
}
void generalDefault()
{
memclear(&g_eeGeneral, sizeof(g_eeGeneral));
@@ -318,7 +334,7 @@ void generalDefault()
adcCalibDefaults();
g_eeGeneral.potsConfig = adcGetDefaultPotsConfig();
g_eeGeneral.switchConfig = switchGetDefaultConfig();
generalDefaultSwitches();
#if defined(STICK_DEAD_ZONE)
g_eeGeneral.stickDeadZone = DEFAULT_STICK_DEADZONE;
+1
View File
@@ -353,6 +353,7 @@ uint16_t isqrt32(uint32_t n);
void setDefaultOwnerId();
void generalDefault();
void generalDefaultSwitches();
uint32_t hash(const void * ptr, uint32_t size);
+13 -1
View File
@@ -26,6 +26,13 @@ enum SwitchConfig {
SWITCH_TOGGLE,
SWITCH_2POS,
SWITCH_3POS,
#if defined(FUNCTION_SWITCHES)
SWITCH_GLOBAL,
#endif
SWITCH_none = SWITCH_NONE,
SWITCH_toggle = SWITCH_TOGGLE,
SWITCH_2pos = SWITCH_2POS,
SWITCH_3pos = SWITCH_3POS,
};
enum FlexAnalogConfig {
@@ -40,11 +47,16 @@ enum FlexAnalogConfig {
};
enum fsStartPositionType {
FS_START_ON,
FS_START_OFF,
FS_START_ON,
FS_START_PREVIOUS
};
enum booleanEnum {
BOOL_OFF,
BOOL_ON
};
enum CalibrationState {
CALIB_START,
CALIB_SET_MIDPOINT,
+7 -8
View File
@@ -154,7 +154,7 @@ void evalFunctions(CustomFunctionData * functions, CustomFunctionsContext & func
MASK_FUNC_TYPE newActiveFunctions = 0;
MASK_CFN_TYPE newActiveSwitches = 0;
#if defined(FUNCTION_SWITCHES)
functionSwitchFunctionState = 0;
g_model.cfsResetSFState();
#endif
uint8_t playFirstIndex = (functions == g_model.customFn ? 1 : 1+MAX_SPECIAL_FUNCTIONS);
@@ -386,14 +386,13 @@ void evalFunctions(CustomFunctionData * functions, CustomFunctionsContext & func
if (CFN_PARAM(cfn)) { // Duration is set
if (! CFN_VAL2(cfn) ) { // Duration not started yet
CFN_VAL2(cfn) = timersGetMsTick() + CFN_PARAM(cfn) * 100;
functionSwitchFunctionState |= 1 << CFN_CS_INDEX(cfn);
}
else if (timersGetMsTick() < (uint32_t)CFN_VAL2(cfn) ) { // Still within push duration
functionSwitchFunctionState |= 1 << CFN_CS_INDEX(cfn);
g_model.cfsSetSFState(CFN_CS_INDEX(cfn), 1);
} else if (timersGetMsTick() < (uint32_t)CFN_VAL2(cfn) ) { // Still within push duration
g_model.cfsSetSFState(CFN_CS_INDEX(cfn), 1);
}
} else { // No duration set
g_model.cfsSetSFState(CFN_CS_INDEX(cfn), 1);
}
else // No duration set
functionSwitchFunctionState |= 1 << CFN_CS_INDEX(cfn);
break;
#endif
@@ -473,7 +472,7 @@ void evalFunctions(CustomFunctionData * functions, CustomFunctionsContext & func
if (CFN_FUNC(cfn) == FUNC_PUSH_CUST_SWITCH) {
// Handling duration after function is active
if (timersGetMsTick() < (uint32_t)CFN_VAL2(cfn)) {
functionSwitchFunctionState |= 1 << CFN_CS_INDEX(cfn);
g_model.cfsSetSFState(CFN_CS_INDEX(cfn), 1);
}
else {
CFN_VAL2(cfn) = 0;
+169 -108
View File
@@ -43,7 +43,7 @@ uint8_t g_moduleIdx;
uint8_t getSwitchWarningsCount()
{
uint8_t count = 0;
for (int i = 0; i < switchGetMaxSwitches(); ++i) {
for (int i = 0; i < switchGetMaxAllSwitches(); ++i) {
if (SWITCH_WARNING_ALLOWED(i)) {
++count;
}
@@ -79,6 +79,20 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_SW4,
ITEM_MODEL_SETUP_SW5,
ITEM_MODEL_SETUP_SW6,
ITEM_MODEL_SETUP_SW7,
ITEM_MODEL_SETUP_SW8,
ITEM_MODEL_SETUP_SW9,
ITEM_MODEL_SETUP_SW10,
ITEM_MODEL_SETUP_SW11,
ITEM_MODEL_SETUP_SW12,
ITEM_MODEL_SETUP_SW13,
ITEM_MODEL_SETUP_SW14,
ITEM_MODEL_SETUP_SW15,
ITEM_MODEL_SETUP_SW16,
ITEM_MODEL_SETUP_SW17,
ITEM_MODEL_SETUP_SW18,
ITEM_MODEL_SETUP_SW19,
ITEM_MODEL_SETUP_SW20,
ITEM_MODEL_SETUP_GROUP1_LABEL,
ITEM_MODEL_SETUP_GROUP1_ALWAYS_ON,
ITEM_MODEL_SETUP_GROUP1_START,
@@ -88,6 +102,9 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_GROUP3_LABEL,
ITEM_MODEL_SETUP_GROUP3_ALWAYS_ON,
ITEM_MODEL_SETUP_GROUP3_START,
ITEM_MODEL_SETUP_GROUP4_LABEL,
ITEM_MODEL_SETUP_GROUP4_ALWAYS_ON,
ITEM_MODEL_SETUP_GROUP4_START,
#endif
ITEM_MODEL_SETUP_EXTENDED_LIMITS,
ITEM_MODEL_SETUP_EXTENDED_TRIMS,
@@ -107,6 +124,7 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_SWITCHES_WARNING1,
#if defined(PCBTARANIS)
ITEM_MODEL_SETUP_SWITCHES_WARNING2,
ITEM_MODEL_SETUP_SWITCHES_WARNING3,
ITEM_MODEL_SETUP_POTS_WARNING,
#endif
ITEM_MODEL_SETUP_BEEP_CENTER,
@@ -259,6 +277,7 @@ static uint8_t FS_ROW(uint8_t value) { return expandState.functionSwitches ? val
uint8_t G1_ROW(int8_t value) { return (firstSwitchInGroup(1) >= 0) ? value : HIDDEN_ROW; }
uint8_t G2_ROW(int8_t value) { return (firstSwitchInGroup(2) >= 0) ? value : HIDDEN_ROW; }
uint8_t G3_ROW(int8_t value) { return (firstSwitchInGroup(3) >= 0) ? value : HIDDEN_ROW; }
uint8_t G4_ROW(int8_t value) { return (firstSwitchInGroup(4) >= 0) ? value : HIDDEN_ROW; }
#endif
static uint8_t VIEWOPT_ROW(uint8_t value) { return expandState.viewOpt ? value : HIDDEN_ROW; }
@@ -304,17 +323,18 @@ static uint8_t VIEWOPT_ROW(uint8_t value) { return expandState.viewOpt ? value :
#define CURRENT_RECEIVER_EDITED(k) (k - ITEM_MODEL_SETUP_EXTERNAL_MODULE_PXX2_RECEIVER_1)
#endif
#define MAX_SWITCH_PER_LINE (getSwitchWarningsCount() > 5 ? 4 : 5)
#define MAX_SWITCH_PER_LINE 5
#if defined(PCBXLITE)
// X-Lite needs an additional column for full line selection (<])
#define SW_WARN_ROWS \
PREFLIGHT_ROW(uint8_t(NAVIGATION_LINE_BY_LINE|getSwitchWarningsCount())), \
PREFLIGHT_ROW(uint8_t(getSwitchWarningsCount() > 4 ? TITLE_ROW : HIDDEN_ROW))
PREFLIGHT_ROW(uint8_t(getSwitchWarningsCount() > MAX_SWITCH_PER_LINE ? TITLE_ROW : HIDDEN_ROW))
#else
// Handle special case when there is only one switch that can trigger a warning (MT12)
#define SW_WARN_ROWS \
PREFLIGHT_ROW(uint8_t(NAVIGATION_LINE_BY_LINE|((getSwitchWarningsCount() == 1) ? 1 : getSwitchWarningsCount()-1))), \
PREFLIGHT_ROW(uint8_t(getSwitchWarningsCount() > MAX_SWITCH_PER_LINE ? TITLE_ROW : HIDDEN_ROW))
PREFLIGHT_ROW(uint8_t(getSwitchWarningsCount() > MAX_SWITCH_PER_LINE ? TITLE_ROW : HIDDEN_ROW)), \
PREFLIGHT_ROW(uint8_t(getSwitchWarningsCount() > (MAX_SWITCH_PER_LINE * 2) ? TITLE_ROW : HIDDEN_ROW))
#endif
inline uint8_t MODULE_TYPE_ROWS(int moduleIdx)
@@ -356,22 +376,23 @@ inline uint8_t TIMER_ROW(uint8_t timer, uint8_t value)
#define EXTRA_MODULE_ROWS
#if defined(FUNCTION_SWITCHES)
#define FUNCTION_SWITCHES_ROWS 0, \
FS_ROW(0), \
FS_ROW(0), \
FS_ROW(0), \
FS_ROW(0), \
FS_ROW(0), \
FS_ROW(0), \
FS_ROW(G1_ROW(LABEL())), \
FS_ROW(G1_ROW(0)), \
FS_ROW(G1_ROW(0)), \
FS_ROW(G2_ROW(LABEL())), \
FS_ROW(G2_ROW(0)), \
FS_ROW(G2_ROW(0)), \
FS_ROW(G3_ROW(LABEL())), \
FS_ROW(G3_ROW(0)), \
FS_ROW(G3_ROW(0)),
#define FUNCTION_SWITCHES_ROWS 0, \
FS_ROW(0), FS_ROW(0), FS_ROW(0), FS_ROW(0), FS_ROW(0), \
FS_ROW(0), FS_ROW(0), FS_ROW(0), FS_ROW(0), FS_ROW(0), \
FS_ROW(0), FS_ROW(0), FS_ROW(0), FS_ROW(0), FS_ROW(0), \
FS_ROW(0), FS_ROW(0), FS_ROW(0), FS_ROW(0), FS_ROW(0), \
FS_ROW(G1_ROW(LABEL())), \
FS_ROW(G1_ROW(0)), \
FS_ROW(G1_ROW(0)), \
FS_ROW(G2_ROW(LABEL())), \
FS_ROW(G2_ROW(0)), \
FS_ROW(G2_ROW(0)), \
FS_ROW(G3_ROW(LABEL())), \
FS_ROW(G3_ROW(0)), \
FS_ROW(G3_ROW(0)), \
FS_ROW(G4_ROW(LABEL())), \
FS_ROW(G4_ROW(0)), \
FS_ROW(G4_ROW(0)),
#else
#define FUNCTION_SWITCHES_ROWS
#endif
@@ -561,10 +582,6 @@ inline uint8_t USB_JOYSTICK_APPLYROW()
#define USB_JOYSTICK_ROWS
#endif
#if defined(FUNCTION_SWITCHES)
static const char* _fct_sw_start[] = { STR_CHAR_DOWN, STR_CHAR_UP, "=" };
#endif
uint8_t viewOptChoice(coord_t y, const char* title, uint8_t value, uint8_t attr, event_t event)
{
lcdDrawText(INDENT_WIDTH-1, y, title);
@@ -572,93 +589,99 @@ uint8_t viewOptChoice(coord_t y, const char* title, uint8_t value, uint8_t attr,
}
#if defined(FUNCTION_SWITCHES)
static int cfsIndex;
const char* _fct_sw_start[] = { STR_CHAR_UP, STR_CHAR_DOWN, "=" };
static int swIndex;
static uint8_t cfsGroup;
bool checkCFSTypeAvailable(int val)
{
int group = FSWITCH_GROUP(cfsIndex);
if (group > 0 && IS_FSWITCH_GROUP_ON(group) && val == SWITCH_TOGGLE)
if (val == SWITCH_3POS) return false;
int group = g_model.cfsGroup(swIndex);
if (group > 0 && g_model.cfsGroupAlwaysOn(group) && val == SWITCH_TOGGLE)
return false;
return true;
}
bool checkCFSGroupAvailable(int group)
static bool checkCFSGroupAvailable(int group)
{
if (FSWITCH_CONFIG(cfsIndex) == SWITCH_TOGGLE && group && IS_FSWITCH_GROUP_ON(group))
if (g_model.cfsType(swIndex) == SWITCH_TOGGLE && group && g_model.cfsGroupAlwaysOn(group))
return false;
return true;
}
bool checkCFSSwitchAvailable(int sw)
static bool checkCFSSwitchAvailable(int sw)
{
return (sw == 0) || (sw == NUM_FUNCTIONS_SWITCHES + 1) || (FSWITCH_GROUP(sw - 1) == cfsGroup);
return (sw == -1) || (sw == switchGetMaxSwitches()) || (switchIsCustomSwitch(sw) && (g_model.cfsGroup(sw) == cfsGroup));
}
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
bool checkCFSColorAvailable(int col)
static bool checkCFSColorAvailable(int col)
{
return col > 0;
}
#endif
enum CFSFields {
CFS_FIELD_NAME,
CFS_FIELD_TYPE,
CFS_FIELD_NAME,
CFS_FIELD_GROUP,
CFS_FIELD_START,
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
CFS_FIELD_COLOR_LABEL,
CFS_FIELD_ON_COLOR,
CFS_FIELD_ON_LUA_OVERRIDE,
CFS_FIELD_OFF_COLOR,
CFS_FIELD_OFF_LUA_OVERRIDE,
#endif
CFS_FIELD_COUNT
};
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
static void menuCFSColor(coord_t y, RGBLedColor& color, const char* title, LcdFlags attr, event_t event)
void menuCFSColor(coord_t y, RGBLedColor& color, const char* title, LcdFlags attr, event_t event)
{
uint8_t selectedColor = getRGBColorIndex(color.getColor());
selectedColor = editChoice(30, y, title, \
STR_FS_COLOR_LIST, selectedColor, 0, DIM(colorTable), menuHorizontalPosition == 0 ? attr : 0, event, INDENT_WIDTH, checkCFSColorAvailable);
if (attr && menuHorizontalPosition == 0 && checkIncDec_Ret) {
color.setColor(colorTable[selectedColor - 1]);
storageDirty(EE_MODEL);
storageDirty((isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL);
}
lcdDrawNumber(LCD_W - 6 * FW, y, color.r, (menuHorizontalPosition == 1 ? attr : 0) | RIGHT);
if (attr && menuHorizontalPosition == 1)
color.r = checkIncDecModel(event, color.r, 0, 255);
color.r = checkIncDec(event, color.r, 0, 255, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL);
lcdDrawNumber(LCD_W - 3 * FW, y, color.g, (menuHorizontalPosition == 2 ? attr : 0) | RIGHT);
if (attr && menuHorizontalPosition == 2)
color.g = checkIncDecModel(event, color.g, 0, 255);
color.g = checkIncDec(event, color.g, 0, 255, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL);
lcdDrawNumber(LCD_W, y, color.b, (menuHorizontalPosition == 3 ? attr : 0) | RIGHT);
if (attr && menuHorizontalPosition == 3)
color.b = checkIncDecModel(event, color.b, 0, 255);
color.b = checkIncDec(event, color.b, 0, 255, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL);
}
#endif
void menuModelCFSOne(event_t event)
static void menuModelCFSOne(event_t event)
{
std::string s(STR_CHAR_SWITCH);
s += switchGetName(cfsIndex + switchGetMaxSwitches());
s += switchGetDefaultName(swIndex);
int config = FSWITCH_CONFIG(cfsIndex);
uint8_t group = FSWITCH_GROUP(cfsIndex);
int startPos = FSWITCH_STARTUP(cfsIndex);
int config = g_model.cfsType(swIndex);
uint8_t group = g_model.cfsGroup(swIndex);
int startPos = g_model.cfsStart(swIndex);
SUBMENU(s.c_str(), CFS_FIELD_COUNT,
{
0,
0,
(uint8_t)((config != SWITCH_NONE) ? 0 : HIDDEN_ROW),
(uint8_t)((config != SWITCH_NONE && config != SWITCH_TOGGLE && group == 0) ? 0 : HIDDEN_ROW),
(uint8_t)((config != SWITCH_NONE && config != SWITCH_GLOBAL) ? 0 : HIDDEN_ROW),
(uint8_t)((config != SWITCH_NONE && config != SWITCH_GLOBAL) ? 0 : HIDDEN_ROW),
(uint8_t)((config != SWITCH_NONE && config != SWITCH_TOGGLE && config != SWITCH_GLOBAL && group == 0) ? 0 : HIDDEN_ROW),
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
LABEL(),
3,
3,
(uint8_t)((config != SWITCH_NONE && config != SWITCH_GLOBAL) ? LABEL() : HIDDEN_ROW),
(uint8_t)((config != SWITCH_NONE && config != SWITCH_GLOBAL) ? 3 : HIDDEN_ROW),
(uint8_t)((config != SWITCH_NONE && config != SWITCH_GLOBAL) ? 0 : HIDDEN_ROW),
(uint8_t)((config != SWITCH_NONE && config != SWITCH_GLOBAL) ? 3 : HIDDEN_ROW),
(uint8_t)((config != SWITCH_NONE && config != SWITCH_GLOBAL) ? 0 : HIDDEN_ROW),
#endif
});
@@ -677,40 +700,42 @@ void menuModelCFSOne(event_t event)
LcdFlags attr = (sub == i ? (editMode > 0 ? BLINK | INVERS : INVERS) : 0);
switch(i) {
case CFS_FIELD_TYPE:
config = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_SWITCH_TYPE, STR_SWTYPES, config, SWITCH_NONE, SWITCH_GLOBAL, attr, event, 0, checkCFSTypeAvailable);
if (attr && checkIncDec_Ret) {
g_model.cfsSetType(swIndex, (SwitchConfig)config);
if (config == SWITCH_NONE) {
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
fsLedRGB(switchGetCustomSwitchIdx(swIndex), 0);
#endif
} else if (config == SWITCH_TOGGLE) {
g_model.cfsSetStart(swIndex, FS_START_PREVIOUS); // Toggle switches do not have startup position
}
}
break;
case CFS_FIELD_NAME:
editSingleName(MODEL_SETUP_2ND_COLUMN, y, STR_NAME, g_model.switchNames[cfsIndex],
editSingleName(MODEL_SETUP_2ND_COLUMN, y, STR_NAME, g_model.cfsName(swIndex),
LEN_SWITCH_NAME, event, (attr != 0),
editMode);
break;
case CFS_FIELD_TYPE:
config = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_SWITCH_TYPE, STR_SWTYPES, config, SWITCH_NONE, SWITCH_2POS, attr, event, 0, checkCFSTypeAvailable);
if (attr && checkIncDec_Ret) {
FSWITCH_SET_CONFIG(cfsIndex, config);
if (config == SWITCH_TOGGLE) {
FSWITCH_SET_STARTUP(cfsIndex, FS_START_PREVIOUS); // Toggle switches do not have startup position
}
storageDirty(EE_MODEL);
}
break;
case CFS_FIELD_GROUP:
group = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_SWITCH_GROUP, STR_FSGROUPS, group, 0, 3, attr, event, 0, checkCFSGroupAvailable);
group = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_SWITCH_GROUP, STR_FSGROUPS, group, 0, NUM_FUNCTIONS_GROUPS, attr, event, 0, checkCFSGroupAvailable);
if (attr && checkIncDec_Ret) {
int oldGroup = FSWITCH_GROUP(cfsIndex);
int oldGroup = g_model.cfsGroup(swIndex);
if (groupHasSwitchOn(group))
setFSLogicalState(cfsIndex, 0);
FSWITCH_SET_GROUP(cfsIndex, group);
setFSLogicalState(swIndex, 0);
g_model.cfsSetGroup(swIndex, group);
if (group > 0) {
FSWITCH_SET_STARTUP(cfsIndex, groupDefaultSwitch(group) == -1 ? FS_START_PREVIOUS : FS_START_OFF);
if (config == SWITCH_TOGGLE && IS_FSWITCH_GROUP_ON(group))
FSWITCH_SET_CONFIG(cfsIndex, SWITCH_2POS);
setGroupSwitchState(group, cfsIndex);
g_model.cfsSetStart(swIndex, groupDefaultSwitch(group) == -1 ? FS_START_PREVIOUS : FS_START_OFF);
if (config == SWITCH_TOGGLE && g_model.cfsGroupAlwaysOn(group))
g_model.cfsSetType(swIndex, SWITCH_2POS);
setGroupSwitchState(group);
} else {
FSWITCH_SET_STARTUP(cfsIndex, FS_START_PREVIOUS);
g_model.cfsSetStart(swIndex, FS_START_PREVIOUS);
}
setGroupSwitchState(oldGroup);
storageDirty(EE_MODEL);
}
break;
@@ -718,9 +743,8 @@ void menuModelCFSOne(event_t event)
lcdDrawText(0, y, STR_SWITCH_STARTUP);
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, _fct_sw_start[startPos], attr ? (s_editMode ? INVERS + BLINK : INVERS) : 0);
if (attr) {
startPos = checkIncDec(event, startPos, FS_START_ON, FS_START_PREVIOUS, EE_MODEL);
FSWITCH_SET_STARTUP(cfsIndex, startPos);
storageDirty(EE_MODEL);
startPos = checkIncDec(event, startPos, FS_START_OFF, FS_START_PREVIOUS, EE_MODEL);
g_model.cfsSetStart(swIndex, (fsStartPositionType)startPos);
}
break;
@@ -733,11 +757,19 @@ void menuModelCFSOne(event_t event)
break;
case CFS_FIELD_ON_COLOR:
menuCFSColor(y, g_model.functionSwitchLedONColor[cfsIndex], STR_OFFON[1], attr, event);
menuCFSColor(y, g_model.cfsOnColor(swIndex), STR_OFFON[1], attr, event);
break;
case CFS_FIELD_ON_LUA_OVERRIDE:
g_model.cfsSetOnColorLuaOverride(swIndex, editCheckBox(g_model.cfsOnColorLuaOverride(swIndex), LCD_W - 2 * FW, y, STR_LUA_OVERRIDE, attr, event, INDENT_WIDTH));
break;
case CFS_FIELD_OFF_COLOR:
menuCFSColor(y, g_model.functionSwitchLedOFFColor[cfsIndex], STR_OFFON[0], attr, event);
menuCFSColor(y, g_model.cfsOffColor(swIndex), STR_OFFON[0], attr, event);
break;
case CFS_FIELD_OFF_LUA_OVERRIDE:
g_model.cfsSetOffColorLuaOverride(swIndex, editCheckBox(g_model.cfsOffColorLuaOverride(swIndex), LCD_W - 2 * FW, y, STR_LUA_OVERRIDE, attr, event, INDENT_WIDTH));
break;
#endif
}
@@ -812,6 +844,15 @@ void menuModelSetup(event_t event)
USB_JOYSTICK_ROWS
});
#if defined(FUNCTION_SWITCHES)
int swCnt = switchGetMaxSwitches();
uint8_t* p = (uint8_t*)mstate_tab;
for (int i = 0; i < MAX_SWITCHES; i += 1) {
if (i >= swCnt || !switchIsCustomSwitch(i))
p[i + ITEM_MODEL_SETUP_SW1] = HIDDEN_ROW;
}
#endif
MENU_CHECK(menuTabModel, MENU_MODEL_SETUP, HEADER_LINE + ITEM_MODEL_SETUP_LINES_COUNT);
title(STR_MENU_MODEL_SETUP);
@@ -988,33 +1029,48 @@ void menuModelSetup(event_t event)
case ITEM_MODEL_SETUP_SW4:
case ITEM_MODEL_SETUP_SW5:
case ITEM_MODEL_SETUP_SW6:
case ITEM_MODEL_SETUP_SW7:
case ITEM_MODEL_SETUP_SW8:
case ITEM_MODEL_SETUP_SW9:
case ITEM_MODEL_SETUP_SW10:
case ITEM_MODEL_SETUP_SW11:
case ITEM_MODEL_SETUP_SW12:
case ITEM_MODEL_SETUP_SW13:
case ITEM_MODEL_SETUP_SW14:
case ITEM_MODEL_SETUP_SW15:
case ITEM_MODEL_SETUP_SW16:
case ITEM_MODEL_SETUP_SW17:
case ITEM_MODEL_SETUP_SW18:
case ITEM_MODEL_SETUP_SW19:
case ITEM_MODEL_SETUP_SW20:
{
int index = (k - ITEM_MODEL_SETUP_SW1);
lcdDrawSizedText(INDENT_WIDTH, y, STR_CHAR_SWITCH, 2, attr);
lcdDrawText(lcdNextPos, y, switchGetName(index+switchGetMaxSwitches()), attr);
lcdDrawText(lcdNextPos, y, switchGetDefaultName(index), attr);
if (attr && event == EVT_KEY_BREAK(KEY_ENTER)) {
cfsIndex = index;
swIndex = index;
pushMenu(menuModelCFSOne);
}
if (ZEXIST(g_model.switchNames[index])) {
char s[LEN_SWITCH_NAME + 1];
strAppend(s, g_model.switchNames[index], LEN_SWITCH_NAME);
lcdDrawText(35, y, s);
} else {
lcdDrawMMM(35, y, 0);
}
int config = FSWITCH_CONFIG(index);
int config = g_model.cfsType(index);
lcdDrawText(30 + 5 * FW, y, STR_SWTYPES[config]);
if (config != SWITCH_NONE) {
uint8_t group = FSWITCH_GROUP(index);
if (config != SWITCH_NONE && config != SWITCH_GLOBAL) {
if (g_model.cfsName(index)[0]) {
char s[LEN_SWITCH_NAME + 1];
strAppend(s, g_model.cfsName(index), LEN_SWITCH_NAME);
lcdDrawText(35, y, s);
} else {
lcdDrawMMM(35, y, 0);
}
uint8_t group = g_model.cfsGroup(index);
lcdDrawText(30 + 13 * FW, y, STR_FSGROUPS[group]);
if (config != SWITCH_TOGGLE && group == 0) {
int startPos = FSWITCH_STARTUP(index);
int startPos = g_model.cfsStart(index);
lcdDrawText(30 + 15 * FW, y, _fct_sw_start[startPos]);
}
}
@@ -1024,6 +1080,7 @@ void menuModelSetup(event_t event)
case ITEM_MODEL_SETUP_GROUP1_LABEL:
case ITEM_MODEL_SETUP_GROUP2_LABEL:
case ITEM_MODEL_SETUP_GROUP3_LABEL:
case ITEM_MODEL_SETUP_GROUP4_LABEL:
{
int group = (k - ITEM_MODEL_SETUP_GROUP1_LABEL) / 3 + 1;
lcdDrawText(INDENT_WIDTH, y, STR_GROUP);
@@ -1034,13 +1091,14 @@ void menuModelSetup(event_t event)
case ITEM_MODEL_SETUP_GROUP1_ALWAYS_ON:
case ITEM_MODEL_SETUP_GROUP2_ALWAYS_ON:
case ITEM_MODEL_SETUP_GROUP3_ALWAYS_ON:
case ITEM_MODEL_SETUP_GROUP4_ALWAYS_ON:
{
uint8_t group = (k - ITEM_MODEL_SETUP_GROUP1_ALWAYS_ON) / 3 + 1;
lcdDrawText(INDENT_WIDTH * 2, y, STR_GROUP_ALWAYS_ON);
int groupAlwaysOn = IS_FSWITCH_GROUP_ON(group);
int groupAlwaysOn = g_model.cfsGroupAlwaysOn(group);
groupAlwaysOn = editCheckBox(groupAlwaysOn, MODEL_SETUP_2ND_COLUMN, y, nullptr, attr, event);
if (attr && checkIncDec_Ret) {
SET_FSWITCH_GROUP_ON(group, groupAlwaysOn);
g_model.cfsSetGroupAlwaysOn(group, groupAlwaysOn);
setGroupSwitchState(group);
}
}
@@ -1049,20 +1107,27 @@ void menuModelSetup(event_t event)
case ITEM_MODEL_SETUP_GROUP1_START:
case ITEM_MODEL_SETUP_GROUP2_START:
case ITEM_MODEL_SETUP_GROUP3_START:
case ITEM_MODEL_SETUP_GROUP4_START:
{
uint8_t group = (k - ITEM_MODEL_SETUP_GROUP1_START) / 3 + 1;
lcdDrawText(INDENT_WIDTH * 2, y, STR_START);
int sw = groupDefaultSwitch(group) + 1;
int sw = groupDefaultSwitch(group);
cfsGroup = group;
sw = editChoice(MODEL_SETUP_2ND_COLUMN + 1, y, nullptr, STR_FSSWITCHES, sw, 0, IS_FSWITCH_GROUP_ON(group) ? NUM_FUNCTIONS_SWITCHES : NUM_FUNCTIONS_SWITCHES + 1, attr, event, 0, checkCFSSwitchAvailable);
if (sw == -1)
lcdDrawText(MODEL_SETUP_2ND_COLUMN + 1, y, "=", attr);
else if (sw == switchGetMaxSwitches())
lcdDrawText(MODEL_SETUP_2ND_COLUMN + 1, y, STR_OFF, attr);
else
lcdDrawText(MODEL_SETUP_2ND_COLUMN + 1, y, switchGetDefaultName(sw), attr);
sw = checkIncDec(event, sw, -1, switchGetMaxSwitches() - (g_model.cfsGroupAlwaysOn(group) ? 1 : 0), EE_MODEL, checkCFSSwitchAvailable);
if (attr && checkIncDec_Ret) {
for (int i = 0; i < NUM_FUNCTIONS_SWITCHES; i += 1) {
if (FSWITCH_GROUP(i) == group) {
FSWITCH_SET_STARTUP(i, sw ? FS_START_OFF : FS_START_PREVIOUS);
for (int i = 0; i < switchGetMaxSwitches(); i += 1) {
if (switchIsCustomSwitch(i) && g_model.cfsGroup(i) == group) {
g_model.cfsSetStart(i, (sw >= 0) ? FS_START_OFF : FS_START_PREVIOUS);
}
}
if (sw > 0 && sw <= NUM_FUNCTIONS_SWITCHES) {
FSWITCH_SET_STARTUP(sw - 1, FS_START_ON);
if (sw >= 0 && sw < switchGetMaxSwitches()) {
g_model.cfsSetStart(sw, FS_START_ON);
}
}
}
@@ -1162,6 +1227,7 @@ void menuModelSetup(event_t event)
break;
case ITEM_MODEL_SETUP_SWITCHES_WARNING2:
case ITEM_MODEL_SETUP_SWITCHES_WARNING3:
if (i==0) {
if (IS_PREVIOUS_EVENT(event))
menuVerticalOffset--;
@@ -1186,8 +1252,6 @@ void menuModelSetup(event_t event)
break;
}
swarnstate_t states = g_model.switchWarning;
lcdDrawTextIndented(y, STR_SWITCHWARNING);
#if defined(PCBXLITE)
lcdDrawText(LCD_W, y, "<]", RIGHT);
@@ -1213,17 +1277,15 @@ void menuModelSetup(event_t event)
}
int current = 0;
for (int i = 0; i < switchGetMaxSwitches(); i++) {
for (int i = 0; i < switchGetMaxAllSwitches(); i++) {
if (SWITCH_WARNING_ALLOWED(i)) {
div_t qr = div(current, MAX_SWITCH_PER_LINE);
if (event == EVT_KEY_BREAK(KEY_ENTER) && attr &&
l_posHorz == current && old_posHorz >= 0) {
uint8_t curr_state = (states & 0x07);
// remove old setting
g_model.switchWarning &= ~(0x07 << (3 * i));
uint8_t curr_state = g_model.getSwitchWarning(i);
// add the new one (if switch UP and 2POS, jump directly to DOWN)
curr_state += (curr_state != 1 || IS_CONFIG_3POS(i) ? 1 : 2);
g_model.switchWarning |= (curr_state & 0x03) << (3 * i);
g_model.setSwitchWarning(i, curr_state);
storageDirty(EE_MODEL);
#if defined(PCBXLITE)
s_editMode = 0;
@@ -1235,10 +1297,9 @@ void menuModelSetup(event_t event)
y + FH * qr.quot, switchGetLetter(i),
attr && (menuHorizontalPosition == current) ? INVERS : 0);
lcdDrawText(lcdNextPos, y + FH * qr.quot,
getSwitchWarnSymbol(states & 0x03));
getSwitchWarnSymbol(g_model.getSwitchWarning(i)));
++current;
}
states >>= 3;
}
if (attr && ((menuHorizontalPosition < 0) ||
menuHorizontalPosition >= switchWarningsCount)) {
@@ -257,13 +257,13 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
lcdDrawText(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, STR_CHANS, attr);
else
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, MIXSRC_FIRST_STICK + param - 1, attr);
if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_CH_INDEX(cfn), maxParam);
}
#if defined(GVARS)
else if (func == FUNC_ADJUST_GVAR) {
maxParam = MAX_GVARS - 1;
drawStringWithIndex(lcdNextPos + 2, y, STR_GV, CFN_GVAR_INDEX(cfn)+1, attr);
if (active) CFN_GVAR_INDEX(cfn) = checkIncDec(event, CFN_GVAR_INDEX(cfn), 0, maxParam, eeFlags);
break;
}
#endif // GVARS
else if (func == FUNC_SET_TIMER) {
@@ -276,18 +276,17 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
if (attr)
repeatLastCursorHorMove(event);
}
break;
}
#if defined(FUNCTION_SWITCHES)
else if (func == FUNC_PUSH_CUST_SWITCH) {
maxParam = NUM_FUNCTIONS_SWITCHES - 1;
drawStringWithIndex(lcdNextPos +5, y, "SW", CFN_CS_INDEX(cfn) + 1, attr);
uint8_t sw = switchGetSwitchFromCustomIdx(CFN_CS_INDEX(cfn));
lcdDrawText(lcdNextPos + 5, y, switchGetDefaultName(sw), attr);
if (active) CFN_CS_INDEX(cfn) = switchGetCustomSwitchIdx(checkIncDec(event, sw, 0, switchGetMaxSwitches() - 1, eeFlags, switchIsCustomSwitch));
}
#endif
else if (attr) {
repeatLastCursorHorMove(event);
}
if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_CH_INDEX(cfn), maxParam);
break;
}
+39 -12
View File
@@ -65,21 +65,41 @@ void menuRadioDiagFS(event_t event)
constexpr coord_t FS_3RD_COLUMN = 100;
#endif
SIMPLE_SUBMENU(STR_MENU_FSWITCH, 1);
lcdDrawText(FS_1ST_COLUMN, MENU_HEADER_HEIGHT + 1, "Phys");
lcdDrawText(FS_2ND_COLUMN, MENU_HEADER_HEIGHT + 1, "Log");
lcdDrawText(FS_3RD_COLUMN, MENU_HEADER_HEIGHT + 1, "Led");
for(uint8_t i=0; i < NUM_FUNCTIONS_SWITCHES; i++) {
coord_t y = 2*FH + i*FH + 1;
lcdDrawTextIndented(y, STR_CHAR_SWITCH);
lcdDrawText(lcdNextPos, y, switchGetName(i+switchGetMaxSwitches()), 0);
lcdDrawText(FS_1ST_COLUMN + 7, y, getFSPhysicalState(i) ? STR_CHAR_DOWN : STR_CHAR_UP);
lcdDrawText(FS_2ND_COLUMN + 5, y, getFSLogicalState(i) ? STR_CHAR_DOWN : STR_CHAR_UP);
static uint8_t nxtSw = 0;
static uint8_t ofst = 0;
if (event == EVT_ENTRY)
ofst = 0;
for(uint8_t i=ofst, r=0; i < switchGetMaxSwitches(); i++) {
if (switchIsCustomSwitch(i)) {
if (r < 6) {
uint8_t sw = switchGetCustomSwitchIdx(i);
coord_t y = 2*FH + r*FH + 1;
lcdDrawTextIndented(y, STR_CHAR_SWITCH);
lcdDrawText(lcdNextPos, y, switchGetDefaultName(i));
lcdDrawText(FS_1ST_COLUMN + 7, y, getFSPhysicalState(i) ? STR_CHAR_DOWN : STR_CHAR_UP);
lcdDrawText(FS_2ND_COLUMN + 5, y, g_model.cfsState(i) ? STR_CHAR_DOWN : STR_CHAR_UP);
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
lcdDrawText(FS_3RD_COLUMN, y, STR_FS_COLOR_LIST[getRGBColorIndex(fsGetLedRGB(i))], 0);
lcdDrawText(FS_3RD_COLUMN, y, STR_FS_COLOR_LIST[getRGBColorIndex(rgbGetLedColor(sw))], 0);
#else
lcdDrawText(FS_3RD_COLUMN, y, STR_OFFON[fsLedState(i)]);
lcdDrawText(FS_3RD_COLUMN, y, STR_OFFON[fsLedState(sw)]);
#endif
r += 1;
} else {
nxtSw = i;
break;
}
}
}
if (nxtSw > 6 && event == EVT_KEY_BREAK(KEY_PAGEDN)) {
if (ofst == 0) ofst = nxtSw; else ofst = 0;
}
}
#endif
@@ -93,6 +113,8 @@ void menuRadioDiagKeys(event_t event)
lcdDrawText(14*FW, 1, STR_VTRIM, INVERS);
trim_yo = MENU_HEADER_HEIGHT + 1;
}
uint8_t sw_y = MENU_HEADER_HEIGHT + 1;
uint8_t sw_x = 8 * FW - 9;
for (uint8_t i = 0; i < 16; i++) {
coord_t y;
@@ -131,13 +153,18 @@ void menuRadioDiagKeys(event_t event)
}
}
if (i < switchGetMaxSwitches()) {
if (SWITCH_EXISTS(i)) {
y = (i > 4) ? FH * (i - 4) + 1 : MENU_HEADER_HEIGHT + FH * i + 1;
if (i < switchGetMaxAllSwitches()) {
if (SWITCH_EXISTS(i) && !switchIsCustomSwitch(i)) {
getvalue_t val = getValue(MIXSRC_FIRST_SWITCH + i);
getvalue_t sw =
((val < 0) ? 3 * i + 1 : ((val == 0) ? 3 * i + 2 : 3 * i + 3));
drawSwitch(i > 4 ? 11 * FW - 5 : 8 * FW - 9, y, sw, 0, false);
drawSwitch(sw_x, sw_y, sw, 0, false);
if (i == 5) {
sw_x = 11 * FW - 5;
sw_y = MENU_HEADER_HEIGHT + 1;
} else {
sw_y += FH;
}
}
}
}
+24 -8
View File
@@ -351,7 +351,7 @@ void drawSmallSwitch(coord_t x, coord_t y, int width, unsigned int index)
}
}
lcdDrawChar(width == 5 ? x + 1 : x, y, 'A' + index, SMLSIZE);
lcdDrawChar(width == 5 ? x + 1 : x, y, switchGetDefaultName(index)[1], SMLSIZE);
y += 7;
if (val <= 0) {
@@ -520,14 +520,25 @@ void menuMainView(event_t event)
// -> 2 columns: one for each side
// -> 4 slots on each side
uint8_t maxSwitch = 0;
uint8_t leftMaxRow = 0;
uint8_t rightMaxRow = 0;
for (uint8_t n = 0; n < switchGetMaxSwitches(); n += 1)
if (SWITCH_EXISTS(n) && !switchIsFlex(n))
if (SWITCH_EXISTS(n) && !switchIsFlex(n) && !switchIsCustomSwitch(n)) {
auto switch_display = switchGetDisplayPosition(n);
if (switch_display.col) {
if (switch_display.row > rightMaxRow)
rightMaxRow = switch_display.row;
} else {
if (switch_display.row > leftMaxRow)
leftMaxRow = switch_display.row;
}
maxSwitch = n + 1;
}
for (int i = 0; i < maxSwitch; ++i) {
if (SWITCH_EXISTS(i) && !switchIsFlex(i)) {
auto switch_display = switchGetDisplayPosition(i);
if (maxSwitch < 7) {
if (leftMaxRow < 3 && rightMaxRow < 3) {
for (int i = 0; i < maxSwitch; ++i) {
if (SWITCH_EXISTS(i) && !switchIsFlex(i) && !switchIsCustomSwitch(i)) {
auto switch_display = switchGetDisplayPosition(i);
coord_t x = switch_display.col == 0 ? 3 * FW + 3 : 18 * FW + 1;
coord_t y = 33 + switch_display.row * FH;
getvalue_t val = getValue(MIXSRC_FIRST_SWITCH + i);
@@ -537,9 +548,14 @@ void menuMainView(event_t event)
: ((val == 0) ? 3 * i + 2 : 3 * i + 3));
drawSwitch(x, y, sw, CENTERED, false);
}
else {
}
}
else {
for (int i = 0; i < maxSwitch; ++i) {
if (SWITCH_EXISTS(i) && !switchIsFlex(i) && !switchIsCustomSwitch(i)) {
auto switch_display = switchGetDisplayPosition(i);
coord_t x = (switch_display.col == 0 ? 8 : 96) + switch_display.row * 5;
if (maxSwitch < 9) x += (switch_display.col == 0 ? 2 : 3);
if (maxSwitch < 9) x += 3;
drawSmallSwitch(x, 5 * FH + 1, 4, i);
}
}
+5 -9
View File
@@ -41,7 +41,7 @@ uint8_t g_moduleIdx;
uint8_t getSwitchWarningsCount()
{
uint8_t count = 0;
for (int i = 0; i < switchGetMaxSwitches(); ++i) {
for (int i = 0; i < switchGetMaxAllSwitches(); ++i) {
if (SWITCH_WARNING_ALLOWED(i)) {
++count;
}
@@ -870,7 +870,6 @@ void menuModelSetup(event_t event)
}
#endif
lcdDrawTextIndented(y, STR_SWITCHWARNING);
swarnstate_t states = g_model.switchWarning;
if (attr) {
s_editMode = 0;
@@ -888,17 +887,15 @@ void menuModelSetup(event_t event)
LcdFlags line = attr;
int current = 0;
for (int i = 0; i < switchGetMaxSwitches(); i++) {
for (int i = 0; i < switchGetMaxAllSwitches(); i++) {
if (SWITCH_WARNING_ALLOWED(i)) {
div_t qr = div(current, 8);
if (event == EVT_KEY_BREAK(KEY_ENTER) && line &&
l_posHorz == current) {
uint8_t curr_state = (states & 0x07);
// remove old setting
g_model.switchWarning &= ~(0x07 << (3 * i));
uint8_t curr_state = g_model.getSwitchWarning(i);
// add the new one (if switch UP and 2POS, jump directly to DOWN)
curr_state += (curr_state != 1 || IS_CONFIG_3POS(i) ? 1 : 2);
g_model.switchWarning |= (curr_state & 0x03) << (3 * i);
g_model.setSwitchWarning(i, curr_state);
storageDirty(EE_MODEL);
}
lcdDrawChar(
@@ -906,10 +903,9 @@ void menuModelSetup(event_t event)
y + FH * qr.quot, 'A' + i,
line && (menuHorizontalPosition == current) ? INVERS : 0);
lcdDrawText(lcdNextPos, y + FH * qr.quot,
getSwitchWarnSymbol(states & 0x03));
getSwitchWarnSymbol(g_model.getSwitchWarning(i)));
++current;
}
states >>= 3;
}
if (attr && menuHorizontalPosition < 0) {
#if defined(PCBX9E)
+1
View File
@@ -123,6 +123,7 @@ endif()
if(FUNCTION_SWITCHES)
add_gui_src(model/function_switches.cpp)
add_gui_src(radio/radio_cfs.cpp)
add_gui_src(radio/radio_diagcustswitches.cpp)
endif()
@@ -59,15 +59,14 @@ void SwitchWarnDialog::checkEvents()
FullScreenDialog::checkEvents();
std::string warn_txt;
swarnstate_t states = g_model.switchWarning;
for (int i = 0; i < MAX_SWITCHES; ++i) {
for (int i = 0; i < switchGetMaxAllSwitches(); ++i) {
if (SWITCH_WARNING_ALLOWED(i)) {
swarnstate_t mask = ((swarnstate_t)0x07 << (i * 3));
if (states & mask) {
if ((switches_states & mask) != (states & mask)) {
swarnstate_t state = (states >> (i * 3)) & 0x07;
uint8_t warnState = g_model.getSwitchWarning(i);
if (warnState) {
swarnstate_t swState = g_model.getSwitchStateForWarning(i);
if (warnState != swState) {
warn_txt +=
getSwitchPositionName(SWSRC_FIRST_SWITCH + i * 3 + state - 1);
getSwitchPositionName(SWSRC_FIRST_SWITCH + i * 3 + warnState - 1);
warn_txt += " ";
}
}
@@ -24,15 +24,16 @@
#include "function_switches.h"
#include "edgetx.h"
#include "hal/rgbleds.h"
#include "strhelpers.h"
#include "switches.h"
#include "color_picker.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
static const char* _fct_sw_start[] = {STR_CHAR_DOWN, STR_CHAR_UP, STR_LAST};
const char* _fct_sw_start[] = {STR_CHAR_UP, STR_CHAR_DOWN, STR_LAST};
const std::string edgetx_fs_manual_url =
const char* edgetx_fs_manual_url =
"https://edgetx.gitbook.io/edgetx-user-manual/b-and-w-radios/model-select/"
"setup#function-switches";
@@ -45,65 +46,70 @@ class FunctionSwitch : public Window
padAll(PAD_TINY);
std::string s(STR_CHAR_SWITCH);
s += switchGetName(switchIndex + switchGetMaxSwitches());
s += switchGetDefaultName(switchIndex);
new StaticText(this, {PAD_LARGE, PAD_MEDIUM, SW_W, EdgeTxStyles::STD_FONT_HEIGHT}, s);
new ModelTextEdit(this, {NM_X, 0, NM_W, 0},
g_model.switchNames[switchIndex], LEN_SWITCH_NAME);
g_model.cfsName(switchIndex), LEN_SWITCH_NAME);
typeChoice = new Choice(
this, {TP_X, 0, TP_W, 0}, STR_SWTYPES, SWITCH_NONE, SWITCH_2POS,
[=]() { return FSWITCH_CONFIG(switchIndex); },
this, {TP_X, 0, TP_W, 0}, STR_SWTYPES, SWITCH_NONE, SWITCH_GLOBAL,
[=]() { return g_model.cfsType(switchIndex); },
[=](int val) {
FSWITCH_SET_CONFIG(switchIndex, val);
if (val == SWITCH_TOGGLE) {
FSWITCH_SET_STARTUP(switchIndex, FS_START_PREVIOUS);
g_model.cfsSetType(switchIndex, (SwitchConfig)val);
if (val == SWITCH_NONE) {
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
fsLedRGB(switchGetCustomSwitchIdx(switchIndex), 0);
#endif
} else if (val == SWITCH_TOGGLE) {
g_model.cfsSetStart(switchIndex, FS_START_PREVIOUS);
setFSLogicalState(switchIndex, 0);
startChoice->setValue(startChoice->getIntValue());
}
SET_DIRTY();
});
typeChoice->setAvailableHandler([=](int typ) -> bool {
int group = FSWITCH_GROUP(switchIndex);
if (group > 0 && IS_FSWITCH_GROUP_ON(group) && typ == SWITCH_TOGGLE)
if (typ == SWITCH_3POS) return false;
int group = g_model.cfsGroup(switchIndex);
if (group > 0 && g_model.cfsGroupAlwaysOn(group) && typ == SWITCH_TOGGLE)
return false;
return true;
});
groupChoice = new Choice(
this, {GR_X, 0, GR_W, 0}, STR_FUNCTION_SWITCH_GROUPS, 0, 3,
[=]() { return FSWITCH_GROUP(switchIndex); },
[=]() { return g_model.cfsGroup(switchIndex); },
[=](int group) {
int oldGroup = FSWITCH_GROUP(switchIndex);
int oldGroup = g_model.cfsGroup(switchIndex);
if (groupHasSwitchOn(group)) setFSLogicalState(switchIndex, 0);
FSWITCH_SET_GROUP(switchIndex, group);
g_model.cfsSetGroup(switchIndex, group);
if (group > 0) {
FSWITCH_SET_STARTUP(switchIndex, groupDefaultSwitch(group) == -1
g_model.cfsSetStart(switchIndex, groupDefaultSwitch(group) == -1
? FS_START_PREVIOUS
: FS_START_OFF);
if (FSWITCH_CONFIG(switchIndex) == SWITCH_TOGGLE &&
IS_FSWITCH_GROUP_ON(group))
FSWITCH_SET_CONFIG(switchIndex, SWITCH_2POS);
setGroupSwitchState(group, switchIndex);
if (g_model.cfsType(switchIndex) == SWITCH_TOGGLE &&
g_model.cfsGroupAlwaysOn(group))
g_model.cfsSetType(switchIndex, SWITCH_2POS);
setGroupSwitchState(group);
} else {
FSWITCH_SET_STARTUP(switchIndex, FS_START_PREVIOUS);
g_model.cfsSetStart(switchIndex, FS_START_PREVIOUS);
}
setGroupSwitchState(oldGroup);
SET_DIRTY();
});
groupChoice->setAvailableHandler([=](int group) -> bool {
if (FSWITCH_CONFIG(switchIndex) == SWITCH_TOGGLE && group &&
IS_FSWITCH_GROUP_ON(group))
if (g_model.cfsType(switchIndex) == SWITCH_TOGGLE && group &&
g_model.cfsGroupAlwaysOn(group))
return false;
return true;
});
startChoice = new Choice(
this, {ST_X, 0, ST_W, 0}, _fct_sw_start, 0, 2,
[=]() { return FSWITCH_STARTUP(switchIndex); },
[=]() { return g_model.cfsStart(switchIndex); },
[=](int val) {
FSWITCH_SET_STARTUP(switchIndex, val);
g_model.cfsSetStart(switchIndex, (fsStartPositionType)val);
SET_DIRTY();
});
@@ -113,23 +119,23 @@ class FunctionSwitch : public Window
new StaticText(this, rect_t{C2_X - C2_W - PAD_TINY, C2_Y + PAD_SMALL, C2_W, 0}, STR_ON_ONE_SWITCHES[0], COLOR_THEME_PRIMARY1_INDEX, FONT(XS) | RIGHT);
#endif
offValue = g_model.functionSwitchLedOFFColor[switchIndex];
onValue = g_model.functionSwitchLedONColor[switchIndex];
offValue = g_model.cfsOffColor(switchIndex);
onValue = g_model.cfsOnColor(switchIndex);
offColor = new ColorPicker(
this, {C1_X, C1_Y, C1_W, 0},
[=]() -> int { // getValue
return g_model.functionSwitchLedOFFColor[switchIndex].getColor() | RGB888_FLAG;
return g_model.cfsOffColor(switchIndex).getColor() | RGB888_FLAG;
},
[=](int newValue) { // setValue
g_model.functionSwitchLedOFFColor[switchIndex] = offValue;
g_model.functionSwitchLedONColor[switchIndex] = onValue;
g_model.cfsOffColor(switchIndex) = offValue;
g_model.cfsOnColor(switchIndex) = onValue;
// Convert color index to RGB
newValue = color32ToRGB(newValue);
g_model.functionSwitchLedOFFColor[switchIndex].setColor(newValue);
g_model.cfsOffColor(switchIndex).setColor(newValue);
offValue = g_model.functionSwitchLedOFFColor[switchIndex];
offValue = g_model.cfsOffColor(switchIndex);
SET_DIRTY();
},
[=](int newValue) { previewColor(newValue); }, ETX_RGB888);
@@ -137,20 +143,29 @@ class FunctionSwitch : public Window
onColor = new ColorPicker(
this, {C2_X, C2_Y, C2_W, 0},
[=]() -> int { // getValue
return g_model.functionSwitchLedONColor[switchIndex].getColor() | RGB888_FLAG;
return g_model.cfsOnColor(switchIndex).getColor() | RGB888_FLAG;
},
[=](int newValue) { // setValue
g_model.functionSwitchLedOFFColor[switchIndex] = offValue;
g_model.functionSwitchLedONColor[switchIndex] = onValue;
g_model.cfsOffColor(switchIndex) = offValue;
g_model.cfsOnColor(switchIndex) = onValue;
// Convert color index to RGB
newValue = color32ToRGB(newValue);
g_model.functionSwitchLedONColor[switchIndex].setColor(newValue);
g_model.cfsOnColor(switchIndex).setColor(newValue);
onValue = g_model.functionSwitchLedONColor[switchIndex];
onValue = g_model.cfsOnColor(switchIndex);
SET_DIRTY();
},
[=](int newValue) { previewColor(newValue); }, ETX_RGB888);
overrideLabel = new StaticText(this, {GR_X, C1_Y + EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_LARGE, GR_W + ST_W - PAD_LARGE, 0},
STR_LUA_OVERRIDE, COLOR_THEME_PRIMARY1_INDEX, FONT(XS) | RIGHT);
offOverride = new ToggleSwitch(this, {C1_X - PAD_MEDIUM * 2, C1_Y + EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_OUTLINE, 0, 0},
[=]() { return g_model.cfsOffColorLuaOverride(switchIndex); },
[=](bool v) { g_model.cfsSetOffColorLuaOverride(switchIndex, v); });
onOverride = new ToggleSwitch(this, {C2_X, C1_Y + EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_OUTLINE, 0, 0},
[=]() { return g_model.cfsOnColorLuaOverride(switchIndex); },
[=](bool v) { g_model.cfsSetOnColorLuaOverride(switchIndex, v); });
#endif //FUNCTION_SWITCHES_RGB_LEDS
setState();
@@ -167,7 +182,7 @@ class FunctionSwitch : public Window
static constexpr coord_t ST_X = GR_X + GR_W + PAD_SMALL;
static LAYOUT_VAL_SCALED(ST_W, 60)
#if NARROW_LAYOUT
static constexpr coord_t ROW_H = EdgeTxStyles::UI_ELEMENT_HEIGHT * 2 + PAD_OUTLINE * 3;
static constexpr coord_t ROW_H = EdgeTxStyles::UI_ELEMENT_HEIGHT * 3 + PAD_OUTLINE * 4;
static constexpr coord_t C1_X = TP_X;
static constexpr coord_t C1_Y = EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_OUTLINE;
static LAYOUT_VAL_SCALED(C1_W, 40)
@@ -175,7 +190,7 @@ class FunctionSwitch : public Window
static constexpr coord_t C2_Y = EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_OUTLINE;
static LAYOUT_VAL_SCALED(C2_W, 40)
#else
static constexpr coord_t ROW_H = EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_OUTLINE * 2;
static constexpr coord_t ROW_H = EdgeTxStyles::UI_ELEMENT_HEIGHT * 2 + PAD_OUTLINE * 3;
static constexpr coord_t C1_X = ST_X + ST_W + PAD_SMALL;
static constexpr coord_t C1_Y = 0;
static LAYOUT_VAL_SCALED(C1_W, 40)
@@ -206,6 +221,9 @@ class FunctionSwitch : public Window
ColorPicker* onColor = nullptr;
RGBLedColor offValue;
RGBLedColor onValue;
StaticText* overrideLabel = nullptr;
ToggleSwitch* onOverride = nullptr;
ToggleSwitch* offOverride = nullptr;
#endif
int lastType = -1;
@@ -214,29 +232,37 @@ class FunctionSwitch : public Window
{
// Convert color index to RGB
newValue = color32ToRGB(newValue);
if (getFSLogicalState(switchIndex)) {
g_model.functionSwitchLedONColor[switchIndex].setColor(newValue);
if (g_model.cfsState(switchIndex)) {
g_model.cfsOnColor(switchIndex).setColor(newValue);
} else {
g_model.functionSwitchLedOFFColor[switchIndex].setColor(newValue);
g_model.cfsOffColor(switchIndex).setColor(newValue);
}
}
#endif
void setState()
{
startChoice->show(FSWITCH_CONFIG(switchIndex) == SWITCH_2POS && FSWITCH_GROUP(switchIndex) == 0);
groupChoice->show(FSWITCH_CONFIG(switchIndex) != SWITCH_NONE);
uint8_t typ = g_model.cfsType(switchIndex);
startChoice->show(typ == SWITCH_2POS && g_model.cfsGroup(switchIndex) == 0);
groupChoice->show(typ != SWITCH_NONE && typ != SWITCH_GLOBAL);
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
offColor->show(FSWITCH_CONFIG(switchIndex) != SWITCH_NONE);
onColor->show(FSWITCH_CONFIG(switchIndex) != SWITCH_NONE);
offColor->show(typ != SWITCH_NONE && typ != SWITCH_GLOBAL);
onColor->show(typ != SWITCH_NONE && typ != SWITCH_GLOBAL);
overrideLabel->show(typ != SWITCH_NONE && typ != SWITCH_GLOBAL);
onOverride->show(typ != SWITCH_NONE && typ != SWITCH_GLOBAL);
offOverride->show(typ != SWITCH_NONE && typ != SWITCH_GLOBAL);
if (typ != SWITCH_NONE && typ != SWITCH_GLOBAL)
setHeight(ROW_H);
else
setHeight(ROW_H - EdgeTxStyles::UI_ELEMENT_HEIGHT - PAD_OUTLINE);
#endif
}
void checkEvents() override
{
setState();
if (lastType != (int)FSWITCH_CONFIG(switchIndex)) {
lastType = FSWITCH_CONFIG(switchIndex);
if (lastType != (int)g_model.cfsType(switchIndex)) {
lastType = g_model.cfsType(switchIndex);
typeChoice->setValue(lastType);
}
Window::checkEvents();
@@ -256,38 +282,43 @@ class SwitchGroup : public Window
auto btn = new TextButton(
this, {AO_X, 0, AO_W, 0}, STR_GROUP_ALWAYS_ON, [=]() -> int8_t {
int groupAlwaysOn = IS_FSWITCH_GROUP_ON(groupIndex);
int groupAlwaysOn = g_model.cfsGroupAlwaysOn(groupIndex);
groupAlwaysOn ^= 1;
SET_FSWITCH_GROUP_ON(groupIndex, groupAlwaysOn);
g_model.cfsSetGroupAlwaysOn(groupIndex, groupAlwaysOn);
setGroupSwitchState(groupIndex);
startChoice->setValue(startChoice->getIntValue());
SET_DIRTY();
return groupAlwaysOn;
});
btn->check(IS_FSWITCH_GROUP_ON(groupIndex));
btn->check(g_model.cfsGroupAlwaysOn(groupIndex));
new StaticText(this, {SL_X, PAD_MEDIUM, SL_W, EdgeTxStyles::STD_FONT_HEIGHT}, STR_SWITCH_STARTUP);
startChoice = new Choice(
this, {ST_X, 0, ST_W, 0}, STR_FSSWITCHES, 0,
NUM_FUNCTIONS_SWITCHES + 1,
this, {ST_X, 0, ST_W, 0}, 0, switchGetMaxSwitches() + 1,
[=]() { return groupDefaultSwitch(groupIndex) + 1; },
[=](int sw) {
for (int i = 0; i < NUM_FUNCTIONS_SWITCHES; i += 1) {
if (FSWITCH_GROUP(i) == groupIndex) {
FSWITCH_SET_STARTUP(i, sw ? FS_START_OFF : FS_START_PREVIOUS);
for (int i = 0; i < switchGetMaxSwitches(); i += 1) {
if (switchIsCustomSwitch(i) && g_model.cfsGroup(i) == groupIndex) {
g_model.cfsSetStart(i, (sw > 0) ? FS_START_OFF : FS_START_PREVIOUS);
}
}
if (sw > 0 && sw <= NUM_FUNCTIONS_SWITCHES) {
FSWITCH_SET_STARTUP(sw - 1, FS_START_ON);
if (sw > 0 && sw <= switchGetMaxSwitches()) {
g_model.cfsSetStart(sw - 1, FS_START_ON);
}
SET_DIRTY();
});
startChoice->setTextHandler([=](int sw) -> std::string {
if (sw == 0)
return "=";
if (sw == switchGetMaxSwitches() + 1)
return STR_OFF;
return switchGetDefaultName(sw - 1);
});
startChoice->setAvailableHandler([=](int sw) -> bool {
return (sw == 0) ||
(sw == NUM_FUNCTIONS_SWITCHES + 1 &&
!IS_FSWITCH_GROUP_ON(groupIndex)) ||
(FSWITCH_GROUP(sw - 1) == groupIndex);
(sw == switchGetMaxSwitches() + 1 && !g_model.cfsGroupAlwaysOn(groupIndex)) ||
(switchIsCustomSwitch(sw - 1) && g_model.cfsGroup(sw - 1) == groupIndex);
});
}
@@ -331,8 +362,9 @@ ModelFunctionSwitches::ModelFunctionSwitches() : Page(ICON_MODEL_SETUP)
new StaticText(box, rect_t{FunctionSwitch::C2_X + PAD_OUTLINE, 0, FunctionSwitch::C2_W, 0}, STR_ON_ONE_SWITCHES[0], COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
#endif
for (uint8_t i = 0; i < NUM_FUNCTIONS_SWITCHES; i += 1) {
new FunctionSwitch(body, i);
for (uint8_t i = 0; i < switchGetMaxSwitches(); i += 1) {
if (switchIsCustomSwitch(i))
new FunctionSwitch(body, i);
}
for (uint8_t i = 1; i <= 3; i += 1) {
@@ -349,8 +381,7 @@ ModelFunctionSwitches::ModelFunctionSwitches() : Page(ICON_MODEL_SETUP)
auto qr = lv_qrcode_create(box->getLvObj(), 150,
makeLvColor(COLOR_THEME_SECONDARY1),
makeLvColor(COLOR_THEME_SECONDARY3));
lv_qrcode_update(qr, edgetx_fs_manual_url.c_str(),
edgetx_fs_manual_url.length());
lv_qrcode_update(qr, edgetx_fs_manual_url, strlen(edgetx_fs_manual_url));
lv_obj_set_pos(qr, (LCD_W - 150) / 2, EdgeTxStyles::STD_FONT_HEIGHT);
#endif
@@ -38,7 +38,7 @@ class SwitchWarnMatrix : public ButtonMatrix
{
// Setup button layout & texts
uint8_t btn_cnt = 0;
for (uint8_t i = 0; i < MAX_SWITCHES; i++) {
for (uint8_t i = 0; i < switchGetMaxAllSwitches(); i++) {
if (SWITCH_WARNING_ALLOWED(i)) {
sw_idx[btn_cnt] = i;
btn_cnt++;
@@ -66,17 +66,16 @@ class SwitchWarnMatrix : public ButtonMatrix
return;
}
if (btn_id >= MAX_SWITCHES) return;
if (btn_id >= switchGetMaxAllSwitches()) return;
auto sw = sw_idx[btn_id];
swarnstate_t newstate = bfGet(g_model.switchWarning, 3 * sw, 3);
if (newstate == 1 && SWITCH_CONFIG(sw) != SWITCH_3POS)
uint8_t newstate = g_model.getSwitchWarning(sw);
if (newstate == 1 && g_model.getSwitchType(sw) != SWITCH_3POS)
newstate = 3;
else
newstate = (newstate + 1) % 4;
newstate = (newstate + 1) & 3;
g_model.switchWarning =
bfSet(g_model.switchWarning, newstate, 3 * sw, 3);
g_model.setSwitchWarning(sw, newstate);
SET_DIRTY();
setTextAndState(btn_id);
@@ -84,15 +83,15 @@ class SwitchWarnMatrix : public ButtonMatrix
bool isActive(uint8_t btn_id) override
{
if (btn_id >= MAX_SWITCHES) return false;
return bfGet(g_model.switchWarning, 3 * sw_idx[btn_id], 3) != 0;
if (btn_id >= switchGetMaxAllSwitches()) return false;
return g_model.getSwitchWarning(sw_idx[btn_id]) != 0;
}
void setTextAndState(uint8_t btn_id)
{
swsrc_t index = sw_idx[btn_id];
auto warn_pos = g_model.switchWarning >> (3 * index) & 0x07;
std::string s = std::string(switchGetName(index)) +
auto warn_pos = g_model.getSwitchWarning(index);
std::string s = std::string(switchGetDefaultName(index)) +
std::string(getSwitchWarnSymbol(warn_pos));
setText(btn_id, s.c_str());
setChecked(btn_id);
@@ -109,7 +108,7 @@ class SwitchWarnMatrix : public ButtonMatrix
void setAllState()
{
uint8_t btn_id = 0;
for (uint8_t i = 0; i < MAX_SWITCHES; i++) {
for (uint8_t i = 0; i < switchGetMaxAllSwitches(); i++) {
if (SWITCH_WARNING_ALLOWED(i)) {
setTextAndState(btn_id);
btn_id++;
@@ -220,7 +220,7 @@ void FunctionLineButton::refresh()
#if defined(FUNCTION_SWITCHES)
case FUNC_PUSH_CUST_SWITCH:
sprintf(s + strlen(s), "%s%d", STR_SWITCH, CFN_CS_INDEX(cfn) + 1);
strAppend(s + strlen(s), switchGetDefaultName(switchGetSwitchFromCustomIdx(CFN_CS_INDEX(cfn))));
break;
#endif
@@ -505,10 +505,15 @@ void FunctionEditPage::updateSpecialFunctionOneWindow()
#if defined(FUNCTION_SWITCHES)
case FUNC_PUSH_CUST_SWITCH: {
new StaticText(line, rect_t{}, STR_SWITCH);
auto choice = new Choice(line, rect_t{}, 0, NUM_FUNCTIONS_SWITCHES - 1, GET_SET_DEFAULT(CFN_CS_INDEX(cfn)), STR_SWITCH);
auto choice = new Choice(line, rect_t{}, 0, switchGetMaxSwitches() - 1,
[=]() { return switchGetSwitchFromCustomIdx(CFN_CS_INDEX(cfn)); },
[=](int n) { CFN_CS_INDEX(cfn) = switchGetCustomSwitchIdx(n); },
STR_SWITCH);
choice->setTextHandler([=](int n) {
return std::string(STR_SWITCH) + std::to_string(n + 1);
return std::string(switchGetDefaultName(n));
});
choice->setAvailableHandler(switchIsCustomSwitch);
line = specialFunctionOneWindow->newLine(grid);
auto edit = addNumberEdit(line, STR_INTERVAL, cfn, PUSH_CS_DURATION_MIN,
+7 -9
View File
@@ -171,7 +171,7 @@ class SwitchDynamicLabel : public StaticText
std::string label()
{
std::string str(switchGetCanonicalName(index));
std::string str(switchGetDefaultName(index));
return str + getSwitchPositionSymbol(lastpos);
}
@@ -206,7 +206,7 @@ class HWSwitch
HWSwitch(Window* parent, int swnum, coord_t y)
{
new SwitchDynamicLabel(parent, swnum, PAD_TINY, y + PAD_SMALL, HWSwitches::SW_CTRL_W);
new HWInputEdit(parent, (char*)switchGetCustomName(swnum), LEN_SWITCH_NAME,
new HWInputEdit(parent, g_eeGeneral.getSwitchCustomName(swnum), LEN_SWITCH_NAME,
HWSwitches::SW_CTRL_W + PAD_SMALL, y);
coord_t x = HWSwitches::SW_CTRL_W * 2 + PAD_SMALL * 2;
@@ -233,12 +233,9 @@ class HWSwitch
sw_cfg = new Choice(
parent, {x, y, HWSwitches::SW_CTRL_W, 0},
STR_SWTYPES, SWITCH_NONE, switchGetMaxType(swnum),
[=]() -> int { return SWITCH_CONFIG(swnum); },
[=]() -> int { return g_eeGeneral.switchType(swnum); },
[=](int newValue) {
swconfig_t mask = (swconfig_t)SWITCH_CONFIG_MASK(swnum);
g_eeGeneral.switchConfig =
(g_eeGeneral.switchConfig & ~mask) |
((swconfig_t(newValue) & SW_CFG_MASK) << (SW_CFG_BITS * swnum));
g_eeGeneral.switchSetType(swnum, (SwitchConfig)newValue);
SET_DIRTY();
});
@@ -266,9 +263,10 @@ HWSwitches::HWSwitches(Window* parent) :
{
padAll(PAD_TINY);
auto max_switches = switchGetMaxSwitches();
auto max_switches = switchGetMaxAllSwitches();
for (int i = 0; i < max_switches; i++) {
new HWSwitch(this, i, i * HWSwitch::SW_CTRL_H + PAD_OUTLINE);
if (!switchIsCustomSwitch(i))
new HWSwitch(this, i, i * HWSwitch::SW_CTRL_H + PAD_OUTLINE);
}
}
+318
View File
@@ -0,0 +1,318 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#if defined(FUNCTION_SWITCHES)
#include "radio_cfs.h"
#include "edgetx.h"
#include "hal/rgbleds.h"
#include "strhelpers.h"
#include "switches.h"
#include "color_picker.h"
#define SET_DIRTY() storageDirty(EE_GENERAL)
static const lv_coord_t cfs_line_col_dsc1[] = {LV_GRID_CONTENT,
LV_GRID_TEMPLATE_LAST};
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
static const lv_coord_t cfs_line_col_dsc2[] = {
LV_GRID_FR(13), LV_GRID_FR(11), LV_GRID_FR(11),
LV_GRID_FR(12), LV_GRID_FR(10), LV_GRID_FR(7), LV_GRID_FR(7),
LV_GRID_TEMPLATE_LAST};
#else
static const lv_coord_t cfs_line_col_dsc2[] = {
LV_GRID_FR(10), LV_GRID_FR(10), LV_GRID_FR(10),
LV_GRID_FR(12), LV_GRID_FR(8), LV_GRID_TEMPLATE_LAST};
#endif
static const lv_coord_t cfs_line_row_dsc[] = {LV_GRID_CONTENT,
LV_GRID_TEMPLATE_LAST};
extern const char* _fct_sw_start[];
extern const char* edgetx_fs_manual_url;
class RadioFunctionSwitch : public Window
{
public:
RadioFunctionSwitch(Window* parent, uint8_t sw) :
Window(parent, {0, 0, LCD_W - PAD_SMALL * 2, ROW_H}), switchIndex(sw)
{
padAll(PAD_TINY);
std::string s(STR_CHAR_SWITCH);
s += switchGetDefaultName(switchIndex);
new StaticText(this, {PAD_LARGE, PAD_MEDIUM, SW_W, EdgeTxStyles::STD_FONT_HEIGHT}, s);
new ModelTextEdit(this, {NM_X, 0, NM_W, 0},
g_eeGeneral.switchName(switchIndex), LEN_SWITCH_NAME);
typeChoice = new Choice(
this, {TP_X, 0, TP_W, 0}, STR_SWTYPES, SWITCH_NONE, SWITCH_GLOBAL,
[=]() { return g_eeGeneral.switchType(switchIndex); },
[=](int val) {
g_eeGeneral.switchSetType(switchIndex, (SwitchConfig)val);
if (val == SWITCH_NONE) {
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
if (g_model.getSwitchType(switchIndex) == SWITCH_NONE)
fsLedRGB(switchGetCustomSwitchIdx(switchIndex), 0);
#endif
} else if (val == SWITCH_TOGGLE) {
g_eeGeneral.switchSetStart(switchIndex, FS_START_PREVIOUS);
setFSLogicalState(switchIndex, 0);
startChoice->setValue(startChoice->getIntValue());
}
SET_DIRTY();
});
typeChoice->setAvailableHandler([=](int typ) -> bool {
if (typ == SWITCH_3POS || typ == SWITCH_GLOBAL) return false;
int group = g_eeGeneral.switchGroup(switchIndex);
if (group > 0 && g_model.cfsGroupAlwaysOn(group) && typ == SWITCH_TOGGLE)
return false;
return true;
});
startChoice = new Choice(
this, {ST_X, 0, ST_W, 0}, _fct_sw_start, 0, 2,
[=]() { return g_eeGeneral.switchStart(switchIndex); },
[=](int val) {
g_eeGeneral.switchSetStart(switchIndex, (fsStartPositionType)val);
SET_DIRTY();
});
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
#if NARROW_LAYOUT
new StaticText(this, rect_t{C1_X - C1_W - PAD_TINY, C1_Y + PAD_SMALL, C1_W, 0}, STR_OFF, COLOR_THEME_PRIMARY1_INDEX, FONT(XS) | RIGHT);
new StaticText(this, rect_t{C2_X - C2_W - PAD_TINY, C2_Y + PAD_SMALL, C2_W, 0}, STR_ON_ONE_SWITCHES[0], COLOR_THEME_PRIMARY1_INDEX, FONT(XS) | RIGHT);
#endif
offValue = g_eeGeneral.switchOffColor(switchIndex);
onValue = g_eeGeneral.switchOnColor(switchIndex);
offColor = new ColorPicker(
this, {C1_X, 0, C1_W, 0},
[=]() -> int { // getValue
return g_eeGeneral.switchOffColor(switchIndex).getColor() | RGB888_FLAG;
},
[=](int newValue) { // setValue
g_eeGeneral.switchOffColor(switchIndex) = offValue;
g_eeGeneral.switchOnColor(switchIndex) = onValue;
// Convert color index to RGB
newValue = color32ToRGB(newValue);
g_eeGeneral.switchOffColor(switchIndex).setColor(newValue);
offValue = g_eeGeneral.switchOffColor(switchIndex);
SET_DIRTY();
},
[=](int newValue) { previewColor(newValue); }, ETX_RGB888);
onColor = new ColorPicker(
this, {C2_X, 0, C2_W, 0},
[=]() -> int { // getValue
return g_eeGeneral.switchOnColor(switchIndex).getColor() | RGB888_FLAG;
},
[=](int newValue) { // setValue
g_eeGeneral.switchOffColor(switchIndex) = offValue;
g_eeGeneral.switchOnColor(switchIndex) = onValue;
// Convert color index to RGB
newValue = color32ToRGB(newValue);
g_eeGeneral.switchOnColor(switchIndex).setColor(newValue);
onValue = g_eeGeneral.switchOnColor(switchIndex);
SET_DIRTY();
},
[=](int newValue) { previewColor(newValue); }, ETX_RGB888);
overrideLabel = new StaticText(this, {GR_X, C1_Y + EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_LARGE, GR_W + ST_W - PAD_LARGE, 0},
STR_LUA_OVERRIDE, COLOR_THEME_PRIMARY1_INDEX, FONT(XS) | RIGHT);
offOverride = new ToggleSwitch(this, {C1_X - PAD_MEDIUM * 2, C1_Y + EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_OUTLINE, 0, 0},
[=]() { return g_model.cfsOffColorLuaOverride(switchIndex); },
[=](bool v) { g_model.cfsSetOffColorLuaOverride(switchIndex, v); });
onOverride = new ToggleSwitch(this, {C2_X, C1_Y + EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_OUTLINE, 0, 0},
[=]() { return g_model.cfsOnColorLuaOverride(switchIndex); },
[=](bool v) { g_model.cfsSetOnColorLuaOverride(switchIndex, v); });
#endif //FUNCTION_SWITCHES_RGB_LEDS
setState();
}
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
static LAYOUT_VAL_SCALED(SW_W, 70)
static constexpr coord_t NM_X = SW_W + PAD_SMALL;
static LAYOUT_VAL_SCALED(NM_W, 60)
static constexpr coord_t TP_X = NM_X + NM_W + PAD_SMALL;
static LAYOUT_VAL_SCALED(TP_W, 78)
static constexpr coord_t GR_X = TP_X + TP_W + PAD_SMALL;
static LAYOUT_VAL_SCALED(GR_W, 84)
static constexpr coord_t ST_X = GR_X + GR_W + PAD_SMALL;
static LAYOUT_VAL_SCALED(ST_W, 60)
#if NARROW_LAYOUT
static constexpr coord_t ROW_H = EdgeTxStyles::UI_ELEMENT_HEIGHT * 3 + PAD_OUTLINE * 4;
static constexpr coord_t C1_X = TP_X;
static constexpr coord_t C1_Y = EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_OUTLINE;
static LAYOUT_VAL_SCALED(C1_W, 40)
static constexpr coord_t C2_X = GR_X;
static constexpr coord_t C2_Y = EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_OUTLINE;
static LAYOUT_VAL_SCALED(C2_W, 40)
#else
static constexpr coord_t ROW_H = EdgeTxStyles::UI_ELEMENT_HEIGHT * 2 + PAD_OUTLINE * 3;
static constexpr coord_t C1_X = ST_X + ST_W + PAD_SMALL;
static constexpr coord_t C1_Y = 0;
static LAYOUT_VAL_SCALED(C1_W, 40)
static constexpr coord_t C2_X = C1_X + C1_W + PAD_SMALL;
static constexpr coord_t C2_Y = 0;
static LAYOUT_VAL_SCALED(C2_W, 40)
#endif
#else
static constexpr coord_t ROW_H = EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_OUTLINE * 2;
static constexpr coord_t SW_W = (LCD_W - PAD_SMALL * 2 - PAD_TINY * 4) / 5;
static constexpr coord_t NM_X = SW_W + PAD_TINY;
static LAYOUT_VAL_SCALED(NM_W, 80)
static constexpr coord_t TP_X = NM_X + SW_W + PAD_TINY;
static LAYOUT_VAL_SCALED(TP_W, 86)
static constexpr coord_t GR_X = TP_X + SW_W + PAD_TINY;
static LAYOUT_VAL_SCALED(GR_W, 94)
static constexpr coord_t ST_X = GR_X + SW_W + PAD_LARGE * 2 + PAD_SMALL;
static LAYOUT_VAL_SCALED(ST_W, 70)
#endif
protected:
uint8_t switchIndex;
Choice* typeChoice = nullptr;
Choice* startChoice = nullptr;
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
ColorPicker* offColor = nullptr;
ColorPicker* onColor = nullptr;
RGBLedColor offValue;
RGBLedColor onValue;
StaticText* overrideLabel = nullptr;
ToggleSwitch* onOverride = nullptr;
ToggleSwitch* offOverride = nullptr;
#endif
int lastType = -1;
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
void previewColor(int newValue)
{
// Convert color index to RGB
newValue = color32ToRGB(newValue);
if (g_model.cfsState(switchIndex)) {
g_eeGeneral.switchOnColor(switchIndex).setColor(newValue);
} else {
g_eeGeneral.switchOffColor(switchIndex).setColor(newValue);
}
}
#endif
void setState()
{
uint8_t typ = g_eeGeneral.switchType(switchIndex);
startChoice->show(typ == SWITCH_2POS && g_eeGeneral.switchGroup(switchIndex) == 0);
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
offColor->show(typ != SWITCH_NONE && typ != SWITCH_GLOBAL);
onColor->show(typ != SWITCH_NONE && typ != SWITCH_GLOBAL);
overrideLabel->show(typ != SWITCH_NONE && typ != SWITCH_GLOBAL);
onOverride->show(typ != SWITCH_NONE && typ != SWITCH_GLOBAL);
offOverride->show(typ != SWITCH_NONE && typ != SWITCH_GLOBAL);
if (typ != SWITCH_NONE && typ != SWITCH_GLOBAL)
setHeight(ROW_H);
else
setHeight(ROW_H - EdgeTxStyles::UI_ELEMENT_HEIGHT - PAD_OUTLINE);
#endif
}
void checkEvents() override
{
setState();
if (lastType != (int)g_eeGeneral.switchType(switchIndex)) {
lastType = g_eeGeneral.switchType(switchIndex);
typeChoice->setValue(lastType);
}
Window::checkEvents();
}
};
RadioFunctionSwitches::RadioFunctionSwitches() : Page(ICON_RADIO_HARDWARE)
{
header->setTitle(STR_HARDWARE);
header->setTitle2(STR_MENU_FSWITCH);
body->padAll(PAD_TINY);
body->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO);
FlexGridLayout grid1(cfs_line_col_dsc1, cfs_line_row_dsc, PAD_TINY);
FlexGridLayout grid2(cfs_line_col_dsc2, cfs_line_row_dsc, PAD_TINY);
auto line = body->newLine(grid2);
new StaticText(line, rect_t{}, STR_SWITCHES);
new StaticText(line, rect_t{}, STR_NAME, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
new StaticText(line, rect_t{}, STR_SWITCH_TYPE,
COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
grid2.nextColumn();
// new StaticText(line, rect_t{}, STR_GROUP, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
startupHeader = new StaticText(line, rect_t{}, STR_SWITCH_STARTUP,
COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
new StaticText(line, rect_t{}, STR_OFF, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
new StaticText(line, rect_t{}, STR_ON_ONE_SWITCHES[0], COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
#endif
for (uint8_t i = 0; i < switchGetMaxSwitches(); i += 1) {
if (switchIsCustomSwitch(i))
new RadioFunctionSwitch(body, i);
}
setState();
line = body->newLine(grid1);
new StaticText(line, rect_t{}, STR_MORE_INFO);
line = body->newLine(grid1);
line->padBottom(PAD_LARGE);
line->padLeft((width() - 150) / 2);
auto qr = lv_qrcode_create(line->getLvObj(), 150,
makeLvColor(COLOR_THEME_SECONDARY1),
makeLvColor(COLOR_THEME_SECONDARY3));
lv_qrcode_update(qr, edgetx_fs_manual_url, strlen(edgetx_fs_manual_url));
}
void RadioFunctionSwitches::setState()
{
// int cnt = 0;
// for (int i = 1; i <= 3; i += 1) {
// cnt += getSwitchCountInFSGroup(i);
// }
// startupHeader->show(cnt != NUM_FUNCTIONS_SWITCHES);
}
void RadioFunctionSwitches::checkEvents()
{
setState();
Page::checkEvents();
}
#endif
@@ -1,6 +1,12 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
@@ -13,9 +19,24 @@
* GNU General Public License for more details.
*/
#pragma once
#pragma once
#include "hal/switch_driver.h"
#include "stm32_switch_driver.h"
SwitchHwPos bsp_get_switch_position(const stm32_switch_t *sw, SwitchCategory cat, uint8_t idx) {return SWITCH_HW_MID;}
#if defined(FUNCTION_SWITCHES)
#include "page.h"
class RadioFunctionSwitches : public Page
{
public:
RadioFunctionSwitches();
protected:
BitmapBuffer* qrcode = nullptr;
StaticText* startupHeader = nullptr;
void setState();
void checkEvents() override;
};
#endif
@@ -65,36 +65,40 @@ class RadioCustSwitchesDiagsWindow : public Window
"Log");
new StaticText(this, {FS_3RD_COLUMN, PAD_SMALL, FS_LBL_WIDTH, LV_SIZE_CONTENT},
"Led");
for (uint8_t i = 0; i < NUM_FUNCTIONS_SWITCHES; i += 1) {
coord_t y = (i + 2) * EdgeTxStyles::STD_FONT_HEIGHT;
std::string s(STR_CHAR_SWITCH);
s += switchGetName(i + switchGetMaxSwitches());
new StaticText(this, {PAD_LARGE, y, FS_LBL_WIDTH, LV_SIZE_CONTENT}, s);
new DynamicText(
this, {FS_1ST_COLUMN + PAD_LARGE, y, FS_LBL_WIDTH, LV_SIZE_CONTENT},
[=]() {
return getFSPhysicalState(i) ? STR_CHAR_DOWN : STR_CHAR_UP;
});
new DynamicText(
this, {FS_2ND_COLUMN + PAD_LARGE, y, FS_LBL_WIDTH, LV_SIZE_CONTENT},
[=]() { return getFSLogicalState(i) ? STR_CHAR_DOWN : STR_CHAR_UP; });
for (uint8_t i = 0, r = 0; i < switchGetMaxSwitches(); i += 1) {
if (switchIsCustomSwitch(i)) {
coord_t y = (r + 2) * EdgeTxStyles::STD_FONT_HEIGHT;
std::string s(STR_CHAR_SWITCH);
s += switchGetDefaultName(i);
new StaticText(this, {PAD_LARGE, y, FS_LBL_WIDTH, LV_SIZE_CONTENT}, s);
new DynamicText(
this, {FS_1ST_COLUMN + PAD_LARGE, y, FS_LBL_WIDTH, LV_SIZE_CONTENT},
[=]() {
return getFSPhysicalState(i) ? STR_CHAR_DOWN : STR_CHAR_UP;
});
new DynamicText(
this, {FS_2ND_COLUMN + 10, y, FS_LBL_WIDTH, LV_SIZE_CONTENT},
[=]() { return g_model.cfsState(i) ? STR_CHAR_DOWN : STR_CHAR_UP; });
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
colorBox[i] = new ColorSwatch(this, {FS_3RD_COLUMN, y, FS_COLOR_WIDTH,
FS_COLOR_HEIGHT}, getLedColor(i));
colorBox[r] = new ColorSwatch(this, {FS_3RD_COLUMN, y, FS_COLOR_WIDTH,
FS_COLOR_HEIGHT}, getLedColor(r));
#else
new DynamicText(this,
{FS_3RD_COLUMN, y, FS_LBL_WIDTH, LV_SIZE_CONTENT},
[=]() { return STR_OFFON[getFSLedState(i)]; });
new DynamicText(this,
{FS_3RD_COLUMN, y, FS_LBL_WIDTH, LV_SIZE_CONTENT},
[=]() { return STR_OFFON[getFSLedState(i)]; });
#endif
r += 1;
}
}
}
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
void checkEvents() override {
Window::checkEvents();
for (uint8_t i = 0; i < NUM_FUNCTIONS_SWITCHES; i += 1) {
colorBox[i]->setColor(getLedColor(i));
if (colorBox[i])
colorBox[i]->setColor(getLedColor(i));
}
}
#endif
@@ -125,14 +125,14 @@ class RadioKeyDiagsWindow : public Window
void addSwitches(Window *form)
{
switchValues = new lv_obj_t *[switchGetMaxSwitches()];
switchValues = new lv_obj_t *[switchGetMaxAllSwitches()];
lv_obj_t *obj = form->getLvObj();
uint8_t i;
uint8_t row = 0;
// SWITCHES
for (i = 0; i < switchGetMaxSwitches(); i++) {
if (SWITCH_EXISTS(i)) {
for (i = 0; i < switchGetMaxAllSwitches(); i++) {
if (SWITCH_EXISTS(i) && !switchIsCustomSwitch(i)) {
auto lbl = lv_label_create(obj);
lv_label_set_text(lbl, "");
lv_obj_set_pos(lbl, 0, row * EdgeTxStyles::STD_FONT_HEIGHT);
@@ -197,8 +197,8 @@ class RadioKeyDiagsWindow : public Window
{
uint8_t i;
for (i = 0; i < switchGetMaxSwitches(); i++) {
if (SWITCH_EXISTS(i)) {
for (i = 0; i < switchGetMaxAllSwitches(); i++) {
if (SWITCH_EXISTS(i) && !switchIsCustomSwitch(i)) {
getvalue_t val = getValue(MIXSRC_FIRST_SWITCH + i);
getvalue_t sw =
((val < 0) ? 3 * i + 1 : ((val == 0) ? 3 * i + 2 : 3 * i + 3));
@@ -34,6 +34,7 @@
#include "radio_setup.h"
#if defined(FUNCTION_SWITCHES)
#include "radio_cfs.h"
#include "radio_diagcustswitches.h"
#endif
@@ -191,6 +192,9 @@ void RadioHardwarePage::build(Window* window)
{STR_STICKS, []() { new HWInputDialog<HWSticks>(STR_STICKS); }},
{STR_POTS, []() { new HWInputDialog<HWPots>(STR_POTS, HWPots::POTS_WINDOW_WIDTH); }},
{STR_SWITCHES, []() { new HWInputDialog<HWSwitches>(STR_SWITCHES, HWSwitches::SW_WINDOW_WIDTH); }},
#if defined(FUNCTION_SWITCHES)
{STR_FUNCTION_SWITCHES, []() { new RadioFunctionSwitches(); }},
#endif
});
// Debugs
@@ -32,7 +32,11 @@ class RadioHardwarePage : public PageTab
void build(Window* window) override;
#if defined(FUNCTION_SWITCHES)
static LAYOUT_SIZE(BTN_COLS, 2, 2)
#else
static LAYOUT_SIZE(BTN_COLS, 4, 3)
#endif
static LAYOUT_SIZE(FS_BTN_COLS, 2, 2)
protected:
+196 -22
View File
@@ -24,6 +24,7 @@
#include "hal/adc_driver.h"
#include "hal/switch_driver.h"
#include "hal/module_port.h"
#include "hal/rgbleds.h"
#include "analogs.h"
#include "switches.h"
@@ -62,6 +63,11 @@ enum {
ITEM_RADIO_HARDWARE_LABEL_SWITCHES,
ITEM_RADIO_HARDWARE_SWITCH,
ITEM_RADIO_HARDWARE_SWITCH_END = ITEM_RADIO_HARDWARE_SWITCH + MAX_SWITCHES - 1,
#if defined(FUNCTION_SWITCHES)
ITEM_RADIO_HARDWARE_LABEL_CFS,
ITEM_RADIO_HARDWARE_CFS,
ITEM_RADIO_HARDWARE_CFS_END = ITEM_RADIO_HARDWARE_CFS + MAX_SWITCHES - 1,
#endif
CASE_BATTGRAPH(ITEM_RADIO_HARDWARE_BATT_RANGE)
ITEM_RADIO_HARDWARE_BATTERY_CALIB,
ITEM_RADIO_HARDWARE_RTC_BATTERY,
@@ -114,6 +120,130 @@ static void onHardwareAntennaSwitchConfirm(const char * result)
}
#endif
#if defined(FUNCTION_SWITCHES)
#define RADIO_SETUP_2ND_COLUMN (LCD_W-11*FW)
extern char* _fct_sw_start[];
static int swIndex;
extern bool checkCFSTypeAvailable(int val);
enum CFSFields {
CFS_FIELD_TYPE,
CFS_FIELD_NAME,
CFS_FIELD_START,
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
CFS_FIELD_COLOR_LABEL,
CFS_FIELD_ON_COLOR,
CFS_FIELD_ON_LUA_OVERRIDE,
CFS_FIELD_OFF_COLOR,
CFS_FIELD_OFF_LUA_OVERRIDE,
#endif
CFS_FIELD_COUNT
};
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
extern void menuCFSColor(coord_t y, RGBLedColor& color, const char* title, LcdFlags attr, event_t event);
#endif
static void menuRadioCFSOne(event_t event)
{
std::string s(STR_CHAR_SWITCH);
s += switchGetDefaultName(swIndex);
int config = g_eeGeneral.switchType(swIndex);
uint8_t group = g_eeGeneral.switchGroup(swIndex);
int startPos = g_eeGeneral.switchStart(swIndex);
SUBMENU(s.c_str(), CFS_FIELD_COUNT,
{
0,
(uint8_t)((config != SWITCH_NONE && config != SWITCH_GLOBAL) ? 0 : HIDDEN_ROW),
(uint8_t)((config != SWITCH_NONE && config != SWITCH_TOGGLE && config != SWITCH_GLOBAL && group == 0) ? 0 : HIDDEN_ROW),
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
(uint8_t)((config != SWITCH_NONE && config != SWITCH_GLOBAL) ? LABEL() : HIDDEN_ROW),
(uint8_t)((config != SWITCH_NONE && config != SWITCH_GLOBAL) ? 3 : HIDDEN_ROW),
(uint8_t)((config != SWITCH_NONE && config != SWITCH_GLOBAL) ? 0 : HIDDEN_ROW),
(uint8_t)((config != SWITCH_NONE && config != SWITCH_GLOBAL) ? 3 : HIDDEN_ROW),
(uint8_t)((config != SWITCH_NONE && config != SWITCH_GLOBAL) ? 0 : HIDDEN_ROW),
#endif
});
int8_t sub = menuVerticalPosition;
int8_t editMode = s_editMode;
coord_t y = MENU_HEADER_HEIGHT + 1;
for (int k = 0; k < NUM_BODY_LINES; k += 1) {
int i = k + menuVerticalOffset;
for (int j = 0; j <= i; j += 1) {
if (j < (int)DIM(mstate_tab) && mstate_tab[j] == HIDDEN_ROW) {
i += 1;
}
}
LcdFlags attr = (sub == i ? (editMode > 0 ? BLINK | INVERS : INVERS) : 0);
switch(i) {
case CFS_FIELD_TYPE:
config = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_SWITCH_TYPE, STR_SWTYPES, config, SWITCH_NONE, SWITCH_3POS, attr, event, 0, checkCFSTypeAvailable);
if (attr && checkIncDec_Ret) {
g_eeGeneral.switchSetType(swIndex, (SwitchConfig)config);
if (config == SWITCH_NONE) {
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
if (g_model.getSwitchType(swIndex) == SWITCH_NONE)
fsLedRGB(switchGetCustomSwitchIdx(swIndex), 0);
#endif
} else if (config == SWITCH_TOGGLE) {
g_eeGeneral.switchSetStart(swIndex, FS_START_PREVIOUS); // Toggle switches do not have startup position
}
}
break;
case CFS_FIELD_NAME:
editSingleName(RADIO_SETUP_2ND_COLUMN, y, STR_NAME, g_eeGeneral.switchName(swIndex),
LEN_SWITCH_NAME, event, (attr != 0),
editMode);
break;
case CFS_FIELD_START:
lcdDrawText(0, y, STR_SWITCH_STARTUP);
lcdDrawText(RADIO_SETUP_2ND_COLUMN, y, _fct_sw_start[startPos], attr ? (s_editMode ? INVERS + BLINK : INVERS) : 0);
if (attr) {
startPos = checkIncDec(event, startPos, FS_START_OFF, FS_START_PREVIOUS, EE_MODEL);
g_eeGeneral.switchSetStart(swIndex, (fsStartPositionType)startPos);
}
break;
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
case CFS_FIELD_COLOR_LABEL:
lcdDrawText(0, y, STR_BLCOLOR);
lcdDrawText(LCD_W - 6 * FW, y, "R", RIGHT | SMLSIZE);
lcdDrawText(LCD_W - 3 * FW, y, "G", RIGHT | SMLSIZE);
lcdDrawText(LCD_W, y, "B", RIGHT | SMLSIZE);
break;
case CFS_FIELD_ON_COLOR:
menuCFSColor(y, g_eeGeneral.switchOnColor(swIndex), STR_OFFON[1], attr, event);
break;
case CFS_FIELD_ON_LUA_OVERRIDE:
g_eeGeneral.cfsSetOnColorLuaOverride(swIndex, editCheckBox(g_eeGeneral.cfsOnColorLuaOverride(swIndex), LCD_W - 2 * FW, y, STR_LUA_OVERRIDE, attr, event, INDENT_WIDTH));
break;
case CFS_FIELD_OFF_COLOR:
menuCFSColor(y, g_eeGeneral.switchOffColor(swIndex), STR_OFFON[0], attr, event);
break;
case CFS_FIELD_OFF_LUA_OVERRIDE:
g_eeGeneral.cfsSetOffColorLuaOverride(swIndex, editCheckBox(g_eeGeneral.cfsOffColorLuaOverride(swIndex), LCD_W - 2 * FW, y, STR_LUA_OVERRIDE, attr, event, INDENT_WIDTH));
break;
#endif
}
y += FH;
}
}
#endif
static uint8_t _dispSerialPort(uint8_t port_nr)
{
auto port = serialGetPort(port_nr);
@@ -147,11 +277,25 @@ static void _init_menu_tab_array(uint8_t* tab, size_t len)
tab[i] = idx < max_pots ? (IS_POT_MULTIPOS(idx) ? 1 : 2) : HIDDEN_ROW;
}
auto max_switches = switchGetMaxSwitches();
int max_switches = switchGetMaxAllSwitches();
for (int i = ITEM_RADIO_HARDWARE_SWITCH; i <= ITEM_RADIO_HARDWARE_SWITCH_END; i++) {
uint8_t idx = i - ITEM_RADIO_HARDWARE_SWITCH;
tab[i] = switchIsFlex(idx) ? 2 : idx < max_switches ? 1 : HIDDEN_ROW;
if (idx < max_switches && !switchIsCustomSwitch(idx)) {
tab[i] = switchIsFlex(idx) ? 2 : 1;
} else {
tab[i] = HIDDEN_ROW;
}
}
#if defined (FUNCTION_SWITCHES)
for (int i = ITEM_RADIO_HARDWARE_CFS; i <= ITEM_RADIO_HARDWARE_CFS_END; i++) {
uint8_t idx = i - ITEM_RADIO_HARDWARE_CFS;
if (idx < max_switches && switchIsCustomSwitch(idx)) {
tab[i] = 0;
} else {
tab[i] = HIDDEN_ROW;
}
}
#endif
#if defined(BATTGRAPH)
tab[ITEM_RADIO_HARDWARE_BATT_RANGE] = 1;
@@ -280,6 +424,12 @@ void menuRadioHardware(event_t event)
lcdDrawTextAlignedLeft(y, STR_SWITCHES);
break;
#if defined(FUNCTION_SWITCHES)
case ITEM_RADIO_HARDWARE_LABEL_CFS:
lcdDrawTextAlignedLeft(y, STR_FUNCTION_SWITCHES);
break;
#endif
#if defined(BATTGRAPH)
case ITEM_RADIO_HARDWARE_BATT_RANGE:
lcdDrawTextAlignedLeft(y, STR_BATTERY_RANGE);
@@ -530,15 +680,14 @@ void menuRadioHardware(event_t event)
setPotInversion(idx, 0);
storageDirty(EE_GENERAL);
}
}
else if (k <= ITEM_RADIO_HARDWARE_SWITCH_END) {
} else if (k <= ITEM_RADIO_HARDWARE_SWITCH_END) {
// Switches
int index = k - ITEM_RADIO_HARDWARE_SWITCH;
int config = SWITCH_CONFIG(index);
int config = g_eeGeneral.switchType(index);
LcdFlags flags = menuHorizontalPosition < 0 ? attr : 0;
lcdDrawText(INDENT_WIDTH, y, STR_CHAR_SWITCH, flags);
lcdDrawText(lcdNextPos, y, switchGetName(index), flags);
lcdDrawText(lcdNextPos, y, switchGetDefaultName(index), flags);
if (switchIsFlex(index)) {
// flexSwitch source
@@ -550,10 +699,10 @@ void menuRadioHardware(event_t event)
//Name
flags = menuHorizontalPosition == 1 ? attr : 0;
if (switchHasCustomName(index) ||
if (g_eeGeneral.switchHasCustomName(index) ||
(attr && s_editMode > 0 && menuHorizontalPosition == 1)) {
editName(HW_SETTINGS_COLUMN2, y,
(char*)switchGetCustomName(index), LEN_SWITCH_NAME,
g_eeGeneral.getSwitchCustomName(index), LEN_SWITCH_NAME,
event, flags, 0, old_editMode);
} else {
lcdDrawMMM(HW_SETTINGS_COLUMN2, y, flags);
@@ -565,19 +714,14 @@ void menuRadioHardware(event_t event)
SWITCH_NONE, switchGetMaxType(index), flags, event);
if (attr && checkIncDec_Ret) {
swconfig_t mask = SWITCH_CONFIG_MASK(index);
g_eeGeneral.switchConfig =
(g_eeGeneral.switchConfig & ~mask) |
((swconfig_t(config) & SW_CFG_MASK) << (SW_CFG_BITS * index));
storageDirty(EE_GENERAL);
g_eeGeneral.switchSetType(index, (SwitchConfig)config);
}
}
else {
} else {
flags = menuHorizontalPosition == 0 ? attr : 0;
if (switchHasCustomName(index) ||
if (g_eeGeneral.switchHasCustomName(index) ||
(attr && s_editMode > 0 && menuHorizontalPosition == 0)) {
editName(HW_SETTINGS_COLUMN1, y,
(char*)switchGetCustomName(index), LEN_SWITCH_NAME,
g_eeGeneral.getSwitchCustomName(index), LEN_SWITCH_NAME,
event, flags, 0, old_editMode);
} else {
lcdDrawMMM(HW_SETTINGS_COLUMN1, y, flags);
@@ -589,13 +733,43 @@ void menuRadioHardware(event_t event)
SWITCH_NONE, switchGetMaxType(index), flags, event);
if (attr && checkIncDec_Ret) {
swconfig_t mask = SWITCH_CONFIG_MASK(index);
g_eeGeneral.switchConfig =
(g_eeGeneral.switchConfig & ~mask) |
((swconfig_t(config) & SW_CFG_MASK) << (SW_CFG_BITS * index));
storageDirty(EE_GENERAL);
g_eeGeneral.switchSetType(index, (SwitchConfig)config);
}
}
#if defined(FUNCTION_SWITCHES)
} else if (k <= ITEM_RADIO_HARDWARE_CFS_END) {
// Customisable Switches
int index = k - ITEM_RADIO_HARDWARE_CFS;
int config = g_eeGeneral.switchType(index);
lcdDrawText(INDENT_WIDTH, y, STR_CHAR_SWITCH, attr);
lcdDrawText(lcdNextPos, y, switchGetDefaultName(index), attr);
lcdDrawText(HW_SETTINGS_COLUMN2, y, STR_SWTYPES[config]);
if (attr && event == EVT_KEY_BREAK(KEY_ENTER)) {
swIndex = index;
pushMenu(menuRadioCFSOne);
}
if (config != SWITCH_NONE) {
if (g_eeGeneral.switchName(index)[0]) {
char s[LEN_SWITCH_NAME + 1];
strAppend(s, g_eeGeneral.switchName(index), LEN_SWITCH_NAME);
lcdDrawText(HW_SETTINGS_COLUMN1, y, s);
} else {
lcdDrawMMM(HW_SETTINGS_COLUMN1, y, 0);
}
uint8_t group = g_eeGeneral.switchGroup(index);
// lcdDrawText(30 + 13 * FW, y, STR_FSGROUPS[group]);
if (config != SWITCH_TOGGLE && group == 0) {
int startPos = g_eeGeneral.switchStart(index);
lcdDrawText(30 + 15 * FW, y, _fct_sw_start[startPos]);
}
}
#endif
} else if (k <= ITEM_RADIO_HARDWARE_SERIAL_PORT_END) {
auto port_nr = k - ITEM_RADIO_HARDWARE_SERIAL_PORT;
auto port = serialGetPort(port_nr);
+4 -7
View File
@@ -362,7 +362,7 @@ bool isSwitchAvailable(int swtch, SwitchContext context)
if (swtch >= SWSRC_FIRST_SWITCH && swtch <= SWSRC_LAST_SWITCH) {
div_t swinfo = switchInfo(swtch);
if (swinfo.quot >= switchGetMaxSwitches() + switchGetMaxFctSwitches()) {
if (swinfo.quot >= switchGetMaxAllSwitches()) {
return false;
}
@@ -370,7 +370,7 @@ bool isSwitchAvailable(int swtch, SwitchContext context)
return false;
}
if (IS_SWITCH_FS(swinfo.quot) && context == GeneralCustomFunctionsContext) {
if (switchIsCustomSwitch(swinfo.quot) && context == GeneralCustomFunctionsContext) {
return false; // FS are defined at model level, and cannot be in global functions
}
@@ -439,7 +439,7 @@ static bool isSwitchSwitchAvailable(int swtch, bool invert) {
// Check normal switch
if (swtch < MAX_SWITCHES * 3) {
div_t swinfo = switchInfo(swtch + SWSRC_FIRST_SWITCH);
if (swinfo.quot >= switchGetMaxSwitches() + switchGetMaxFctSwitches()) {
if (swinfo.quot >= switchGetMaxAllSwitches()) {
return false;
}
@@ -670,12 +670,9 @@ bool isAssignableFunctionAvailable(int function, bool modelFunctions)
case FUNC_DISABLE_AUDIO_AMP:
return false;
#endif
#if !defined(LED_STRIP_GPIO)
#if !defined(LED_STRIP_LENGTH)
case FUNC_RGB_LED:
return false;
#elif defined(RGB_LED_OFFSET)
case FUNC_RGB_LED:
return (LED_STRIP_LENGTH > RGB_LED_OFFSET);
#endif
#if !defined(DEBUG)
case FUNC_TEST:
+31 -4
View File
@@ -25,32 +25,59 @@
#include "dataconstants.h"
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
static bool hasLedOverride[NUM_FUNCTIONS_SWITCHES] = { false };
static RGBLedColor ledOverride[NUM_FUNCTIONS_SWITCHES];
void setFSLedOverride(uint8_t index, bool state, uint8_t r, uint8_t g, uint8_t b)
{
hasLedOverride[index] = state;
ledOverride[index].r = r;
ledOverride[index].g = g;
ledOverride[index].b = b;
}
void setFSLedOFF(uint8_t index) {
fsLedRGB(index, g_model.functionSwitchLedOFFColor[index].getColor());
if (g_model.getSwitchType(index) != SWITCH_NONE) {
uint8_t cfsIdx = switchGetCustomSwitchIdx(index);
if (hasLedOverride[cfsIdx] && g_model.getSwitchOffColorLuaOverride(index))
fsLedRGB(cfsIdx, ledOverride[cfsIdx].getColor());
else
fsLedRGB(cfsIdx, g_model.getSwitchOffColor(index).getColor());
}
}
void setFSLedON(uint8_t index) {
fsLedRGB(index, g_model.functionSwitchLedONColor[index].getColor());
if (g_model.getSwitchType(index) != SWITCH_NONE) {
uint8_t cfsIdx = switchGetCustomSwitchIdx(index);
if (hasLedOverride[cfsIdx] && g_model.getSwitchOnColorLuaOverride(index))
fsLedRGB(cfsIdx, ledOverride[cfsIdx].getColor());
else
fsLedRGB(cfsIdx, g_model.getSwitchOnColor(index).getColor());
}
}
bool getFSLedState(uint8_t index) {
return fsGetLedRGB(index) == g_model.functionSwitchLedONColor[index].getColor();
uint8_t cfsIdx = switchGetCustomSwitchIdx(index);
return rgbGetLedColor(cfsIdx) == g_model.getSwitchOnColor(index).getColor();
}
uint32_t getFSLedRGBColor(uint8_t index)
{
return fsGetLedRGB(index);
return fsGetLedRGB(index);
}
#else
void setFSLedOFF(uint8_t index) {
index = switchGetCustomSwitchIdx(index);
fsLedOff(index);
}
void setFSLedON(uint8_t index) {
index = switchGetCustomSwitchIdx(index);
fsLedOn(index);
}
bool getFSLedState(uint8_t index) {
index = switchGetCustomSwitchIdx(index);
return fsLedState(index);
}
#endif
+1
View File
@@ -25,6 +25,7 @@
// "Off", "White", "Red", "Green", "Yellow", "Orange", "Blue", "Pink"
constexpr uint32_t colorTable[] = {0x000000, 0xFFFFFF, 0xFF0000, 0x00FF00, 0xFFFF00, 0xFF4000, 0x0000FF, 0xFF00FF};
void setFSLedOverride(uint8_t index, bool state, uint8_t r, uint8_t g, uint8_t b);
void setFSLedOFF(uint8_t index);
void setFSLedON(uint8_t index);
bool getFSLedState(uint8_t index);
+60 -34
View File
@@ -31,15 +31,18 @@
// Board API
void boardInitSwitches();
SwitchHwPos boardSwitchGetPosition(SwitchCategory cat, uint8_t idx);
SwitchHwPos boardSwitchGetPosition(uint8_t idx);
const char* boardSwitchGetName(SwitchCategory cat, uint8_t idx);
SwitchHwType boardSwitchGetType(SwitchCategory cat, uint8_t idx);
const char* boardSwitchGetName(uint8_t idx);
SwitchHwType boardSwitchGetType(uint8_t idx);
#if defined(FUNCTION_SWITCHES)
bool boardIsCustomSwitch(uint8_t idx);
uint8_t boardGetCustomSwitchIdx(uint8_t idx);
#endif
uint8_t boardGetMaxSwitches();
uint8_t boardGetMaxFctSwitches();
swconfig_t boardSwitchGetDefaultConfig();
SwitchConfig boardSwitchGetDefaultConfig(uint8_t n);
constexpr uint8_t _INVALID_ADC_CH = 0xFF;
@@ -51,14 +54,39 @@ void switchInit()
boardInitSwitches();
}
swconfig_t switchGetDefaultConfig() { return boardSwitchGetDefaultConfig(); }
SwitchConfig switchGetDefaultConfig(uint8_t n) { return boardSwitchGetDefaultConfig(n); }
#if defined(FUNCTION_SWITCHES)
bool switchIsCustomSwitch(int sw)
{
return boardIsCustomSwitch(sw);
}
uint8_t switchGetCustomSwitchIdx(uint8_t sw)
{
return boardGetCustomSwitchIdx(sw);
}
uint8_t switchGetSwitchFromCustomIdx(uint8_t idx)
{
for (uint8_t i = 0; i < switchGetMaxSwitches(); i += 1)
if (switchIsCustomSwitch(i) && switchGetCustomSwitchIdx(i) == idx)
return i;
return switchGetMaxSwitches();
}
#else
bool switchIsCustomSwitch(int sw) { return false; }
#endif
uint8_t switchGetMaxSwitches()
{
return boardGetMaxSwitches() + MAX_FLEX_SWITCHES;
return boardGetMaxSwitches();
}
uint8_t switchGetMaxFctSwitches() { return boardGetMaxFctSwitches(); }
uint8_t switchGetMaxAllSwitches()
{
return boardGetMaxSwitches() + MAX_FLEX_SWITCHES;
}
uint32_t switchState(uint8_t pos_idx)
{
@@ -72,9 +100,9 @@ uint32_t switchState(uint8_t pos_idx)
SwitchHwPos switchGetPosition(uint8_t sw_idx)
{
auto idx = (int)sw_idx;
auto max_switches = boardGetMaxSwitches();
auto max_switches = switchGetMaxSwitches();
if (idx < max_switches) {
return boardSwitchGetPosition(SWITCH_PHYSICAL, idx);
return boardSwitchGetPosition(idx);
}
idx -= max_switches;
@@ -95,12 +123,6 @@ SwitchHwPos switchGetPosition(uint8_t sw_idx)
return ret;
}
idx -= MAX_FLEX_SWITCHES;
}
if (idx < boardGetMaxFctSwitches()) {
return boardSwitchGetPosition(SWITCH_FUNCTION, idx);
}
return SWITCH_HW_UP;
@@ -113,12 +135,12 @@ static const char * const _flex_sw_canon_names[] = {
static_assert(DIM(_flex_sw_canon_names) >= MAX_FLEX_SWITCHES,
"Missing canonical name for flex switches");
const char* switchGetName(uint8_t sw_idx)
const char* switchGetDefaultName(uint8_t sw_idx)
{
auto idx = (int)sw_idx;
auto max_switches = boardGetMaxSwitches();
auto max_switches = switchGetMaxSwitches();
if (idx < max_switches) {
return boardSwitchGetName(SWITCH_PHYSICAL, idx);
return boardSwitchGetName(idx);
}
idx -= max_switches;
@@ -129,20 +151,25 @@ const char* switchGetName(uint8_t sw_idx)
idx -= MAX_FLEX_SWITCHES;
}
if (idx < boardGetMaxFctSwitches()) {
return boardSwitchGetName(SWITCH_FUNCTION, idx);
}
return nullptr;
}
int8_t switchGetIndexFromName(const char* name)
{
for (uint8_t i = 0; i < switchGetMaxSwitches(); i += 1)
if (strcmp(name, boardSwitchGetName(i)) == 0)
return i;
return -1;
}
SwitchHwType switchGetHwType(uint8_t sw_idx)
{
auto idx = (int)sw_idx;
auto max_switches = boardGetMaxSwitches();
auto max_switches = switchGetMaxSwitches();
if (idx < max_switches) {
return boardSwitchGetType(SWITCH_PHYSICAL, idx);
return boardSwitchGetType(idx);
}
idx -= max_switches;
@@ -155,8 +182,8 @@ SwitchHwType switchGetHwType(uint8_t sw_idx)
bool switchIsFlex(uint8_t idx)
{
auto max_switches = boardGetMaxSwitches();
return idx >= max_switches && idx < max_switches + MAX_FLEX_SWITCHES;
auto max_switches = switchGetMaxSwitches();
return idx >= max_switches && idx < switchGetMaxAllSwitches();
}
void switchConfigFlex_raw(uint8_t idx, int8_t channel)
@@ -179,7 +206,7 @@ uint8_t switchGetFlexChannel(uint8_t idx)
void switchConfigFlex(uint8_t idx, int8_t channel)
{
auto max_switches = boardGetMaxSwitches();
auto max_switches = switchGetMaxSwitches();
if (idx < max_switches) return;
idx -= max_switches;
switchConfigFlex_raw(idx, channel);
@@ -193,7 +220,7 @@ int8_t switchGetFlexConfig_raw(uint8_t idx)
int8_t switchGetFlexConfig(uint8_t idx)
{
auto max_switches = boardGetMaxSwitches();
auto max_switches = switchGetMaxSwitches();
if (idx < max_switches) return _INVALID_ADC_CH;
idx -= max_switches;
return switchGetFlexConfig_raw(idx);
@@ -208,7 +235,7 @@ bool switchIsFlexValid_raw(uint8_t sw_idx)
bool switchIsFlexValid(uint8_t idx)
{
auto max_switches = boardGetMaxSwitches();
auto max_switches = switchGetMaxSwitches();
if (idx < max_switches) return false;
idx -= max_switches;
return switchIsFlexValid_raw(idx);
@@ -229,7 +256,7 @@ bool switchIsFlexInputAvailable(uint8_t idx, uint8_t channel)
if (MAX_FLEX_SWITCHES == 0) return false;
if (POT_CONFIG(channel) != FLEX_SWITCH) return false;
auto phy_switches = boardGetMaxSwitches();
auto phy_switches = switchGetMaxSwitches();
if (idx < phy_switches) return false;
return is_flex_input_available(idx - phy_switches, channel);
@@ -237,9 +264,8 @@ bool switchIsFlexInputAvailable(uint8_t idx, uint8_t channel)
static void invalidate_flex_config(uint8_t flex_idx)
{
auto sw_idx = flex_idx + boardGetMaxSwitches();
swconfig_t mask = (swconfig_t)SWITCH_CONFIG_MASK(sw_idx);
g_eeGeneral.switchConfig &= ~mask;
auto sw_idx = flex_idx + switchGetMaxSwitches();
g_eeGeneral.switchSetType(sw_idx, SWITCH_NONE);
_flex_switches[flex_idx] = _INVALID_ADC_CH;
}
+11 -20
View File
@@ -23,6 +23,7 @@
#include <stdint.h>
#include "edgetx_types.h"
#include "edgetx_constants.h"
enum SwitchHwType {
SWITCH_HW_2POS = 0,
@@ -36,21 +37,22 @@ enum SwitchHwPos {
SWITCH_HW_DOWN,
};
enum SwitchCategory {
SWITCH_PHYSICAL=0,
SWITCH_FUNCTION,
};
#define SWITCH_HW_INVERTED 1
// init hardware for switches
void switchInit();
// returns the factory configuration for all switches
swconfig_t switchGetDefaultConfig();
SwitchConfig switchGetDefaultConfig(uint8_t n);
// returns the maximum number of regular switches supported in hardware (customizable switches NOT included)
bool switchIsCustomSwitch(int sw);
uint8_t switchGetCustomSwitchIdx(uint8_t sw);
uint8_t switchGetSwitchFromCustomIdx(uint8_t sw);
// returns the maximum number of physical + custom switches supported in hardware
uint8_t switchGetMaxSwitches();
// returns the maximum number of physical + custom + flex switches supported in hardware
uint8_t switchGetMaxAllSwitches();
// returns the number of configured switches
uint8_t getSwitchCount();
@@ -58,9 +60,6 @@ uint8_t getSwitchCount();
// returns the highest row for a specified column
uint8_t switchGetMaxRow(uint8_t col);
// returns the maximum number of customizable switches supported in hardware
uint8_t switchGetMaxFctSwitches();
struct switch_display_pos_t {
uint8_t col;
uint8_t row;
@@ -83,20 +82,12 @@ void switchConfigFlex_raw(uint8_t idx, int8_t channel);
int8_t switchGetFlexConfig_raw(uint8_t idx);
bool switchIsFlexValid_raw(uint8_t idx);
// The functions bellow support regular as well as customizable switches.
//
// Regular switches are indexed from `0` to `switchGetMaxSwitches() - 1`
// Customizable switches are indexed above the previous range.
//
// The total number of switches (and max index + 1) is:
// switchGetMaxSwitches() + switchGetMaxFctSwitches()
//
// returns state (0 / 1) of a specific switch position
uint32_t switchState(uint8_t pos_idx);
// returns a position for a switch index
SwitchHwPos switchGetPosition(uint8_t idx);
const char* switchGetName(uint8_t idx);
const char* switchGetDefaultName(uint8_t idx);
SwitchHwType switchGetHwType(uint8_t idx);
int8_t switchGetIndexFromName(const char* name);
+2 -2
View File
@@ -198,7 +198,7 @@ void writeHeader()
f_puts(",", &g_oLogFile);
}
for (uint8_t i = 0; i < switchGetMaxSwitches(); i++) {
for (uint8_t i = 0; i < switchGetMaxAllSwitches(); i++) {
if (SWITCH_EXISTS(i)) {
char s[LEN_SWITCH_NAME + 2];
char * temp;
@@ -341,7 +341,7 @@ void logsWrite()
f_printf(&g_oLogFile, "%d,", calibratedAnalogs[offset + i]);
}
for (uint8_t i = 0; i < switchGetMaxSwitches(); i++) {
for (uint8_t i = 0; i < switchGetMaxAllSwitches(); i++) {
if (SWITCH_EXISTS(i)) {
f_printf(&g_oLogFile, "%d,", getSwitchState(i));
}
+1 -1
View File
@@ -377,7 +377,7 @@ LROT_BEGIN(lvgllib, NULL, 0)
LROT_FUNCENTRY(box, [](lua_State* L) { return luaLvglObjEx(L, []() { return new LvglWidgetBox(); }); })
LROT_FUNCENTRY(setting, [](lua_State* L) { return luaLvglObjEx(L, []() { return new LvglWidgetSetting(); }, true); })
LROT_FUNCENTRY(page, [](lua_State* L) { return luaLvglObj(L, []() { return new LvglWidgetPage(); }, true); })
LROT_FUNCENTRY(dialog, [](lua_State* L) { return luaLvglObjEx(L, []() { return new LvglWidgetDialog(); }, true); })
LROT_FUNCENTRY(dialog, [](lua_State* L) { return luaLvglObj(L, []() { return new LvglWidgetDialog(); }, true); })
// Dialogs
LROT_FUNCENTRY(confirm, [](lua_State* L) { return luaLvglPopup(L, []() { return new LvglWidgetConfirmDialog(); }); })
LROT_FUNCENTRY(message, [](lua_State* L) { return luaLvglPopup(L, []() { return new LvglWidgetMessageDialog(); }); })
+96 -22
View File
@@ -34,6 +34,7 @@
#include "input_mapping.h"
#if defined(LED_STRIP_GPIO)
#include "boards/generic_stm32/rgb_leds.h"
#include "hal/rgbleds.h"
#endif
@@ -2843,7 +2844,15 @@ static int luaGetTrainerStatus(lua_State * L)
return 1;
}
#if defined(LED_STRIP_GPIO)
// To simplify code below
#if !defined(BLING_LED_STRIP_LENGTH)
#define BLING_LED_STRIP_LENGTH 0
#endif
#if !defined(CFS_LED_STRIP_LENGTH)
#define CFS_LED_STRIP_LENGTH 0
#endif
#if (BLING_LED_STRIP_LENGTH > 0) || (CFS_LED_STRIP_LENGTH > 0)
/*luadoc
@function setRGBLedColor(id, rvalue, bvalue, cvalue)
@@ -2855,28 +2864,101 @@ static int luaGetTrainerStatus(lua_State * L)
@param bvalue: interger, value of blue channel
@retval: true if LED index is valid, false otherwise
@status current Introduced in 2.10
*/
static int luaSetRgbLedColor(lua_State * L)
{
uint8_t id = luaL_checkunsigned(L, 1);
if (id >= (BLING_LED_STRIP_LENGTH + CFS_LED_STRIP_LENGTH)) {
lua_pushboolean(L, false);
return 1;
}
uint8_t r = luaL_checkunsigned(L, 2);
uint8_t g = luaL_checkunsigned(L, 3);
uint8_t b = luaL_checkunsigned(L, 4);
#if defined(LED_STRIP_RESERVED_AT_END)
if (id >= LED_STRIP_LENGTH - LED_STRIP_RESERVED_AT_END) {
#if CFS_LED_STRIP_LENGTH > 0
if (id >= BLING_LED_STRIP_LENGTH) {
id -= BLING_LED_STRIP_LENGTH;
uint8_t swIdx = switchGetSwitchFromCustomIdx(id / CFS_LEDS_PER_SWITCH);
if (g_model.getSwitchType(swIdx) == SWITCH_NONE) {
rgbSetLedColor(id + CFS_LED_STRIP_START, r, g, b);
} else {
lua_pushboolean(L, false);
return 1;
}
#endif
rgbSetLedColor(id, r, g, b);
} else {
rgbSetLedColor(id + BLING_LED_STRIP_START, r, g, b);
}
#else
rgbSetLedColor(id + BLING_LED_STRIP_START, r, g, b);
#endif
lua_pushboolean(L, true);
return 1;
}
#endif
#if (CFS_LED_STRIP_LENGTH > 0)
/*luadoc
@function setCFSLedColor(id, rvalue, bvalue, cvalue)
Overrides the LED color for a custom function switch
- if passed 4 arguments (id, r, g, b) then sets override color
- if passed 1 argument (id) then cancels override color
@param id: string identifying a custom function switch name
@param rvalue: interger, value of red channel
@param gvalue: interger, value of green channel
@param bvalue: interger, value of blue channel
@retval: true if LED index is valid, false otherwise
@status current Introduced in ???
*/
static int luaSetCFSLedColor(lua_State * L)
{
uint8_t r = 0, g = 0, b = 0;
int n = lua_gettop(L);
const char* nm = luaL_checkstring(L, 1);
int8_t id = switchGetIndexFromName(nm);
if (id < 0) {
lua_pushboolean(L, false);
return 1;
}
uint8_t cfsIdx = switchGetCustomSwitchIdx(id);
if (cfsIdx >= CFS_LED_STRIP_LENGTH / CFS_LEDS_PER_SWITCH) {
lua_pushboolean(L, false);
return 1;
}
if (n > 1) {
r = luaL_checkunsigned(L, 2);
g = luaL_checkunsigned(L, 3);
b = luaL_checkunsigned(L, 4);
}
setFSLedOverride(cfsIdx, n > 1, r, g, b);
lua_pushboolean(L, true);
return 1;
}
#endif
#if defined(LED_STRIP_LENGTH)
/*luadoc
@function applyRGBLedColors()
@@ -2892,7 +2974,6 @@ static int luaApplyRGBLedColors(lua_State * L)
return 1;
}
#endif
@@ -2997,9 +3078,12 @@ LROT_BEGIN(etxlib, NULL, 0)
LROT_FUNCENTRY( getSourceIndex, luaGetSourceIndex )
LROT_FUNCENTRY( getSourceName, luaGetSourceName )
LROT_FUNCENTRY( sources, luaSources )
#if defined(LED_STRIP_GPIO)
LROT_FUNCENTRY(setRGBLedColor, luaSetRgbLedColor )
LROT_FUNCENTRY(applyRGBLedColors, luaApplyRGBLedColors )
#if (BLING_LED_STRIP_LENGTH > 0) || (CFS_LED_STRIP_LENGTH > 0)
LROT_FUNCENTRY( setRGBLedColor, luaSetRgbLedColor )
LROT_FUNCENTRY( applyRGBLedColors, luaApplyRGBLedColors )
#endif
#if (CFS_LED_STRIP_LENGTH > 0)
LROT_FUNCENTRY( setCFSLedColor, luaSetCFSLedColor )
#endif
LROT_FUNCENTRY( getStickMode, luaGetStickMode )
LROT_END(etxlib, NULL, 0)
@@ -3144,18 +3228,8 @@ LROT_BEGIN(etxcst, NULL, 0)
LROT_NUMENTRY( PLAY_NOW, PLAY_NOW )
LROT_NUMENTRY( PLAY_BACKGROUND, PLAY_BACKGROUND )
LROT_NUMENTRY( TIMEHOUR, TIMEHOUR )
#if defined(LED_STRIP_GPIO)
#if defined(RADIO_V16)
LROT_NUMENTRY( LED_STRIP_LENGTH, LED_STRIP_LENGTH - 6 )
#elif defined(RGB_LED_OFFSET)
// Exclude function switch LEDs
LROT_NUMENTRY( LED_STRIP_LENGTH, LED_STRIP_LENGTH - RGB_LED_OFFSET )
#elif defined(LED_STRIP_RESERVED_AT_END)
// Exclude leds at the end of the strip
LROT_NUMENTRY( LED_STRIP_LENGTH, LED_STRIP_LENGTH - LED_STRIP_RESERVED_AT_END )
#else
LROT_NUMENTRY( LED_STRIP_LENGTH, LED_STRIP_LENGTH )
#endif
#if (BLING_LED_STRIP_LENGTH > 0) || (CFS_LED_STRIP_LENGTH > 0)
LROT_NUMENTRY( LED_STRIP_LENGTH, BLING_LED_STRIP_LENGTH + CFS_LED_STRIP_LENGTH )
#endif
LROT_NUMENTRY( UNIT_RAW, UNIT_RAW )
LROT_NUMENTRY( UNIT_VOLTS, UNIT_VOLTS )
+14 -16
View File
@@ -424,18 +424,14 @@ getvalue_t _getValue(mixsrc_t i, bool* valid)
else if (i >= MIXSRC_FIRST_SWITCH && i <= MIXSRC_LAST_SWITCH) {
auto sw_idx = (uint8_t)(i - MIXSRC_FIRST_SWITCH);
#if defined(FUNCTION_SWITCHES)
auto max_reg_switches = switchGetMaxSwitches();
if (sw_idx >= max_reg_switches) {
auto fct_idx = sw_idx - max_reg_switches;
auto max_fct_switches = switchGetMaxFctSwitches();
if (fct_idx < max_fct_switches) {
return _switch_2pos_lookup[getFSLogicalState(fct_idx)];
}
auto max_switches = switchGetMaxSwitches();
if (sw_idx < max_switches && switchIsCustomSwitch(sw_idx)) {
return _switch_2pos_lookup[g_model.cfsState(sw_idx)];
}
#endif
auto sw_cfg = (SwitchConfig)SWITCH_CONFIG(sw_idx);
auto sw_cfg = g_model.getSwitchType(sw_idx);
switch(sw_cfg) {
case SWITCH_NONE:
default:
if (valid != nullptr) *valid = false;
return 0;
case SWITCH_TOGGLE:
@@ -452,18 +448,20 @@ getvalue_t _getValue(mixsrc_t i, bool* valid)
if (stepcount == 0)
return 0;
if (IS_FSWITCH_GROUP_ON(group_idx))
if (g_model.cfsGroupAlwaysOn(group_idx))
stepcount--;
int stepsize = (2 * RESX) / stepcount;
int value = -RESX;
for (uint8_t i = 0; i < switchGetMaxFctSwitches(); i++) {
if(FSWITCH_GROUP(i) == group_idx) {
if (getFSLogicalState(i) == 1)
return value + (IS_FSWITCH_GROUP_ON(group_idx) ? 0 : stepsize);
else
value += stepsize;
for (uint8_t i = 0; i < switchGetMaxSwitches(); i++) {
if (switchIsCustomSwitch(i)) {
if (g_model.getSwitchGroup(i) == group_idx) {
if (g_model.cfsState(i) == 1)
return value + (g_model.cfsGroupAlwaysOn(group_idx) ? 0 : stepsize);
else
value += stepsize;
}
}
}
return -RESX;
+3 -3
View File
@@ -58,7 +58,7 @@ bool getSwitchAudioFile(char* path, swsrc_t index)
if (index <= SWSRC_LAST_SWITCH) {
div_t swinfo = switchInfo(index);
auto sw_name = switchGetName(swinfo.quot);
auto sw_name = switchGetDefaultName(swinfo.quot);
if (!sw_name) return false;
str = strAppend(str, sw_name);
str = strAppend(str, _sw_positions[swinfo.rem]);
@@ -116,9 +116,9 @@ bool matchModeAudioFile(const char* filename, int& index, int& event)
bool matchSwitchAudioFile(const char* filename, int& sw_pos)
{
// Switches Audio Files <switchname>-[up|mid|down].wav
for (int i = 0; i < switchGetMaxSwitches(); i++) {
for (int i = 0; i < switchGetMaxAllSwitches(); i++) {
auto* c = filename;
auto sw_name = switchGetName(i);
auto sw_name = switchGetDefaultName(i);
auto sw_name_len = strlen(sw_name);
if (strncasecmp(c, sw_name, sw_name_len) != 0) continue;
c += sw_name_len;
+24 -28
View File
@@ -100,6 +100,26 @@ void setVendorSpecificModelDefaults(uint8_t id)
#endif
}
#if defined(FUNCTION_SWITCHES)
void initCustomSwitches()
{
for (int i = 0; i < switchGetMaxSwitches(); i += 1) {
if (switchIsCustomSwitch(i)) {
uint8_t idx = switchGetCustomSwitchIdx(i);
g_model.customSwitches[idx].type = SWITCH_GLOBAL;
g_model.customSwitches[idx].group = 0;
g_model.customSwitches[idx].start = FS_START_PREVIOUS;
g_model.customSwitches[idx].state = 0;
g_model.customSwitches[idx].name[0] = 0;
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
g_model.customSwitches[idx].offColor.setColor(0);
g_model.customSwitches[idx].onColor.setColor(0xFFFFFF);
#endif
}
}
}
#endif
void applyDefaultTemplate()
{
setDefaultInputs();
@@ -110,42 +130,18 @@ void applyDefaultTemplate()
setDefaultModelRegistrationID();
#if defined(FUNCTION_SWITCHES)
g_model.functionSwitchConfig = DEFAULT_FS_CONFIG;
g_model.functionSwitchGroup = DEFAULT_FS_GROUPS;
g_model.functionSwitchStartConfig = DEFAULT_FS_STARTUP_CONFIG;
g_model.functionSwitchLogicalState = 0;
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
for (uint8_t i = 0; i < NUM_FUNCTIONS_SWITCHES; i++) {
g_model.functionSwitchLedOFFColor[i].setColor(0);
g_model.functionSwitchLedONColor[i].setColor(0xFFFFFF);
}
#endif
#endif
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
for (uint8_t i = 0; i < NUM_FUNCTIONS_SWITCHES; i++) {
g_model.functionSwitchLedOFFColor[i].setColor(0);
g_model.functionSwitchLedONColor[i].setColor(0xFFFFFF);
}
initCustomSwitches();
#endif
#if defined(COLORLCD)
LayoutFactory::loadDefaultLayout();
#endif
// enable switch warnings
for (uint64_t i = 0; i < MAX_SWITCHES; i++) {
if (SWITCH_EXISTS(i)) {
g_model.switchWarning |= (1ull << (3ull * i));
}
}
#else
// enable switch warnings
for (uint64_t i = 0; i < MAX_SWITCHES; i++) {
for (uint64_t i = 0; i < switchGetMaxAllSwitches(); i++) {
if (SWITCH_WARNING_ALLOWED(i))
g_model.switchWarning |= (1ull << (3ull * i));
g_model.setSwitchWarning(i, 1);
}
#endif
#if defined(USE_HATS_AS_KEYS)
g_model.hatsMode = HATSMODE_GLOBAL;
+5 -23
View File
@@ -85,28 +85,10 @@
#define SW_CFG_MASK ((1 << SW_CFG_BITS) - 1)
#define SWITCH_CONFIG_MASK(x) ((swconfig_t)SW_CFG_MASK << (SW_CFG_BITS * (x)))
#define SWITCH_CONFIG(x) (bfGet<swconfig_t>(g_eeGeneral.switchConfig, SW_CFG_BITS * (x), SW_CFG_BITS))
#if defined(FUNCTION_SWITCHES)
#define FSW_CFG_BITS 2
#define FSWITCH_CONFIG(x) (bfGet<swconfig_t>(g_model.functionSwitchConfig, FSW_CFG_BITS * (x), FSW_CFG_BITS))
#define FSWITCH_SET_CONFIG(x,v) g_model.functionSwitchConfig = bfSet<swconfig_t>(g_model.functionSwitchConfig, v, FSW_CFG_BITS * (x), FSW_CFG_BITS)
#define FSWITCH_GROUP(x) (bfGet<swconfig_t>(g_model.functionSwitchGroup, FSW_CFG_BITS * (x), FSW_CFG_BITS))
#define FSWITCH_SET_GROUP(x,v) g_model.functionSwitchGroup = bfSet<swconfig_t>(g_model.functionSwitchGroup, v, FSW_CFG_BITS * (x), FSW_CFG_BITS)
#define FSWITCH_STARTUP(x) (bfGet<swconfig_t>(g_model.functionSwitchStartConfig, FSW_CFG_BITS * (x), FSW_CFG_BITS))
#define FSWITCH_SET_STARTUP(x,v) g_model.functionSwitchStartConfig = bfSet<swconfig_t>(g_model.functionSwitchStartConfig, v, FSW_CFG_BITS * (x), FSW_CFG_BITS)
#define IS_FSWITCH_GROUP_ON(x) (bfGet<swconfig_t>(g_model.functionSwitchGroup, FSW_CFG_BITS * NUM_FUNCTIONS_SWITCHES + x, 1))
#define SET_FSWITCH_GROUP_ON(x,v) g_model.functionSwitchGroup = bfSet<swconfig_t>(g_model.functionSwitchGroup, v, FSW_CFG_BITS * NUM_FUNCTIONS_SWITCHES + x, 1)
#define IS_SWITCH_FS(x) (x >= switchGetMaxSwitches() && x < (switchGetMaxSwitches() + switchGetMaxFctSwitches()))
#define SWITCH_EXISTS(x) (IS_SWITCH_FS(x) ? true : (SWITCH_CONFIG(x) != SWITCH_NONE))
#define IS_CONFIG_3POS(x) (IS_SWITCH_FS(x) ? (FSWITCH_CONFIG(x - switchGetMaxSwitches()) == SWITCH_3POS) : (SWITCH_CONFIG(x) == SWITCH_3POS))
#define IS_CONFIG_TOGGLE(x) (IS_SWITCH_FS(x) ? (FSWITCH_CONFIG(x - switchGetMaxSwitches()) == SWITCH_TOGGLE) : (SWITCH_CONFIG(x) == SWITCH_TOGGLE))
#else
#define SWITCH_EXISTS(x) (SWITCH_CONFIG(x) != SWITCH_NONE)
#define IS_CONFIG_3POS(x) (SWITCH_CONFIG(x) == SWITCH_3POS)
#define IS_CONFIG_TOGGLE(x) (SWITCH_CONFIG(x) == SWITCH_TOGGLE)
#define IS_SWITCH_FS(x) (false)
#endif
#define SWITCH_WARNING_ALLOWED(x) (SWITCH_EXISTS(x) && !(IS_CONFIG_TOGGLE(x) || IS_SWITCH_FS(x)))
#define SWITCH_EXISTS(x) (g_model.getSwitchType(x) != SWITCH_NONE)
#define IS_CONFIG_3POS(x) (g_model.getSwitchType(x) == SWITCH_3POS)
#define IS_CONFIG_TOGGLE(x) (g_model.getSwitchType(x) == SWITCH_TOGGLE)
#define SWITCH_WARNING_ALLOWED(x) (SWITCH_EXISTS(x) && !IS_CONFIG_TOGGLE(x))
#define ALTERNATE_VIEW 0x10
@@ -267,4 +249,4 @@ constexpr uint8_t EE_GENERAL = 0x01;
constexpr uint8_t EE_MODEL = 0x02;
constexpr uint8_t EE_LABELS = 0x04;
#endif // _MYEEPROM_H_
#endif // _MYEEPROM_H_
+5 -2
View File
@@ -181,6 +181,7 @@ const char * loadRadioSettings()
#endif
adcCalibDefaults();
generalDefaultSwitches();
const char* error = loadRadioSettingsYaml(true);
if (!error) {
@@ -191,8 +192,6 @@ const char * loadRadioSettings()
return error;
}
struct yaml_checksummer_ctx {
FRESULT result;
uint16_t checksum;
@@ -341,6 +340,10 @@ const char * readModelYaml(const char * filename, uint8_t * buffer, uint32_t siz
memset(buffer,0,size);
if (init_model) {
#if defined(FUNCTION_SWITCHES)
extern void initCustomSwitches();
initCustomSwitches();
#endif
auto md = reinterpret_cast<ModelData*>(buffer);
#if defined(FLIGHT_MODES) && defined(GVARS)
// reset GVars to default values
@@ -88,6 +88,17 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -221,7 +232,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -255,13 +266,20 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_PADDING( 5 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
@@ -275,12 +293,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "contrast", 8 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -313,7 +331,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -340,7 +358,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 8, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 32, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_UNSIGNED( "backlightColor", 8 ),
YAML_STRING("bluetoothName", 10),
@@ -381,7 +399,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -402,7 +420,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -462,7 +480,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -475,7 +493,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -633,7 +651,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -683,7 +701,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -727,7 +745,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -776,7 +794,7 @@ static const struct YamlNode struct_TelemetryScreenData[] = {
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -816,16 +834,15 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 320, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -840,19 +857,19 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
+49 -32
View File
@@ -90,6 +90,17 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -240,7 +251,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -274,13 +285,20 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_PADDING( 5 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
@@ -292,12 +310,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 16 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -330,7 +348,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -357,7 +375,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 16, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 32, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_STRING("currModelFilename", 17),
YAML_UNSIGNED( "modelQuickSelect", 1 ),
@@ -409,7 +427,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -430,7 +448,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -490,7 +508,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -503,7 +521,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -661,7 +679,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -711,7 +729,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -755,7 +773,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -779,7 +797,7 @@ static const struct YamlNode union_ZoneOptionValue_elmts[] = {
};
static const struct YamlNode struct_ZoneOptionValueTyped[] = {
YAML_IDX,
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum),
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum, NULL),
YAML_UNION("value", 96, union_ZoneOptionValue_elmts, select_zov),
YAML_END
};
@@ -811,7 +829,7 @@ static const struct YamlNode struct_TopBarPersistentData[] = {
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -851,16 +869,15 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 352, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -876,20 +893,20 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
+180 -50
View File
@@ -359,7 +359,7 @@ static bool w_mixSrcRaw(const YamlNode* node, uint32_t val, yaml_writer_func wf,
}
else if (val >= MIXSRC_FIRST_SWITCH
&& val <= MIXSRC_LAST_SWITCH) {
str = switchGetCanonicalName(val - MIXSRC_FIRST_SWITCH);
str = switchGetDefaultName(val - MIXSRC_FIRST_SWITCH);
}
#if defined(FUNCTION_SWITCHES)
else if (val >= MIXSRC_FIRST_CUSTOMSWITCH_GROUP
@@ -847,60 +847,30 @@ static const struct YamlNode struct_sliderConfig[] = {
YAML_END
};
static uint32_t sw_read(void* user, const char* val, uint8_t val_len)
static uint32_t sw_idx_read(void* user, const char* val, uint8_t val_len)
{
(void)user;
return switchLookupIdx(val, val_len);
}
bool sw_write(void* user, yaml_writer_func wf, void* opaque)
static bool currentSwitchIsCFS = false;
bool sw_idx_write(void* user, yaml_writer_func wf, void* opaque)
{
auto tw = reinterpret_cast<YamlTreeWalker*>(user);
uint16_t idx = tw->getElmts();
const char* str = switchGetCanonicalName(idx);
currentSwitchIsCFS = switchIsCustomSwitch(idx);
const char* str = switchGetDefaultName(idx);
return str ? wf(opaque, str, strlen(str)) : true;
}
static void sw_name_read(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
bool switch_is_cfs(void* user, uint8_t* data, uint32_t bitoffs)
{
auto tw = reinterpret_cast<YamlTreeWalker*>(user);
uint16_t idx = tw->getElmts(1);
switchSetCustomName(idx, val, val_len);
return currentSwitchIsCFS;
}
static bool sw_name_write(void* user, uint8_t* data, uint32_t bitoffs,
yaml_writer_func wf, void* opaque)
{
auto tw = reinterpret_cast<YamlTreeWalker*>(user);
uint16_t idx = tw->getElmts(1);
const char* str = switchGetCustomName(idx);
if (!wf(opaque, "\"", 1)) return false;
if (!wf(opaque, str, strnlen(str, LEN_SWITCH_NAME)))
return false;
return wf(opaque, "\"", 1);
}
static const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "none" },
{ SWITCH_TOGGLE, "toggle" },
{ SWITCH_2POS, "2pos" },
{ SWITCH_3POS, "3pos" },
{ 0, NULL }
};
static const struct YamlNode struct_switchConfig[] = {
YAML_IDX_CUST( "sw", sw_read, sw_write),
YAML_ENUM( "type", 2, enum_SwitchConfig),
YAML_CUSTOM( "name", sw_name_read, sw_name_write),
YAML_END
};
static bool flex_sw_valid(void* user, uint8_t* data, uint32_t bitoffs)
{
auto tw = reinterpret_cast<YamlTreeWalker*>(user);
@@ -908,13 +878,11 @@ static bool flex_sw_valid(void* user, uint8_t* data, uint32_t bitoffs)
return switchIsFlexValid_raw(idx);
}
uint8_t boardGetMaxSwitches();
static uint32_t flex_sw_read(void* user, const char* val, uint8_t val_len)
{
(void)user;
auto idx = switchLookupIdx(val, val_len);
return idx - boardGetMaxSwitches();
return idx - switchGetMaxSwitches();
}
bool flex_sw_write(void* user, yaml_writer_func wf, void* opaque)
@@ -922,8 +890,8 @@ bool flex_sw_write(void* user, yaml_writer_func wf, void* opaque)
auto tw = reinterpret_cast<YamlTreeWalker*>(user);
uint16_t idx = tw->getElmts();
auto sw_offset = boardGetMaxSwitches();
const char* str = switchGetCanonicalName(idx + sw_offset);
auto sw_offset = switchGetMaxSwitches();
const char* str = switchGetDefaultName(idx + sw_offset);
return str ? wf(opaque, str, strlen(str)) : true;
}
@@ -1002,7 +970,7 @@ static const struct YamlIdStr enum_PotConfig[] = {
static const struct YamlNode struct_potConfig[] = {
YAML_IDX_CUST("pot", pot_read, pot_write ),
YAML_ENUM("type", POT_CFG_TYPE_BITS, enum_PotConfig),
YAML_ENUM("type", POT_CFG_TYPE_BITS, enum_PotConfig, NULL),
YAML_UNSIGNED("inv", POT_CFG_INV_BITS),
YAML_CUSTOM("name", pot_name_read, pot_name_write),
YAML_END
@@ -1121,7 +1089,7 @@ static bool w_swtchSrc_unquoted(const YamlNode* node, uint32_t val,
if (sval <= SWSRC_LAST_SWITCH) {
auto sw_info = switchInfo(sval);
str = switchGetCanonicalName(sw_info.quot);
str = switchGetDefaultName(sw_info.quot);
if (!str) return true;
wf(opaque, str, strlen(str));
str = yaml_unsigned2str(sw_info.rem);
@@ -1270,8 +1238,8 @@ static const struct YamlIdStr enum_SwitchWarnPos[] = {
};
static const struct YamlNode struct_swtchWarn[] {
YAML_IDX_CUST( "sw", sw_read, sw_write ),
YAML_ENUM( "pos", 2, enum_SwitchWarnPos ),
YAML_IDX_CUST( "sw", sw_idx_read, sw_idx_write ),
YAML_ENUM( "pos", 2, enum_SwitchWarnPos, NULL ),
YAML_END,
};
@@ -2340,7 +2308,7 @@ static bool port_write(void* user, yaml_writer_func wf, void* opaque)
static const struct YamlNode struct_serialConfig[] = {
YAML_IDX_CUST( "port", port_read, port_write),
YAML_ENUM( "mode", 4, enum_UartModes),
YAML_ENUM( "mode", 4, enum_UartModes, NULL),
YAML_PADDING( 3 ),
YAML_UNSIGNED( "power", 1 ),
YAML_END
@@ -2369,3 +2337,165 @@ static void r_serialMode(void* user, uint8_t* data, uint32_t bitoffs,
*serialPort = (*serialPort & ~(0xF << port_nr * SERIAL_CONF_BITS_PER_PORT)) |
(m << port_nr * SERIAL_CONF_BITS_PER_PORT);
}
#if defined(FUNCTION_SWITCHES)
static uint16_t getIdx(void *user)
{
auto tw = reinterpret_cast<YamlTreeWalker*>(user);
return tw->getElmts(1);
}
static void r_cfs_name(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
{
uint16_t idx = getIdx(user);
strAppend(g_model.customSwitches[idx].name, val, LEN_SWITCH_NAME);
}
static const struct YamlNode struct_cfsNameConfig[] = {
YAML_IDX,
YAML_CUSTOM( "val", r_cfs_name, nullptr),
YAML_END
};
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
static void r_cfs_on_color_r(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
{
uint16_t idx = getIdx(user);
g_model.customSwitches[idx].onColor.r = yaml_str2uint(val, val_len);
}
static void r_cfs_on_color_g(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
{
uint16_t idx = getIdx(user);
g_model.customSwitches[idx].onColor.g = yaml_str2uint(val, val_len);
}
static void r_cfs_on_color_b(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
{
uint16_t idx = getIdx(user);
g_model.customSwitches[idx].onColor.b = yaml_str2uint(val, val_len);
}
static const struct YamlNode struct_cfsOnColorConfig[] = {
YAML_IDX,
YAML_CUSTOM( "r", r_cfs_on_color_r, nullptr),
YAML_CUSTOM( "g", r_cfs_on_color_g, nullptr),
YAML_CUSTOM( "b", r_cfs_on_color_b, nullptr),
YAML_END
};
static void r_cfs_off_color_r(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
{
uint16_t idx = getIdx(user);
g_model.customSwitches[idx].offColor.r = yaml_str2uint(val, val_len);
}
static void r_cfs_off_color_g(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
{
uint16_t idx = getIdx(user);
g_model.customSwitches[idx].offColor.g = yaml_str2uint(val, val_len);
}
static void r_cfs_off_color_b(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
{
uint16_t idx = getIdx(user);
g_model.customSwitches[idx].offColor.b = yaml_str2uint(val, val_len);
}
static const struct YamlNode struct_cfsOffColorConfig[] = {
YAML_IDX,
YAML_CUSTOM( "r", r_cfs_off_color_r, nullptr),
YAML_CUSTOM( "g", r_cfs_off_color_g, nullptr),
YAML_CUSTOM( "b", r_cfs_off_color_b, nullptr),
YAML_END
};
#endif
static uint32_t cfs_idx_read(void* user, const char* val, uint8_t val_len)
{
return switchGetCustomSwitchIdx(switchLookupIdx(val, val_len));
}
static bool cfs_idx_write(void* user, yaml_writer_func wf, void* opaque)
{
auto tw = reinterpret_cast<YamlTreeWalker*>(user);
uint16_t idx = tw->getElmts();
const char* str = switchGetDefaultName(switchGetSwitchFromCustomIdx(idx));
return str ? wf(opaque, str, strlen(str)) : true;
}
static const struct YamlNode struct_cfsGroupOn[] {
YAML_IDX,
YAML_UNSIGNED( "v", 1 ),
YAML_END,
};
static void r_functionSwitchConfig(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
{
uint32_t v = yaml_str2uint(val, val_len);
for (int i = 0; i < 6; i += 1) {
g_model.customSwitches[i].type = (SwitchConfig)bfGet<uint16_t>(v, 2 * i, 2);
}
}
static void r_functionSwitchStartConfig(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
{
uint32_t v = yaml_str2uint(val, val_len);
for (int i = 0; i < 6; i += 1) {
uint8_t b = bfGet<uint16_t>(v, 2 * i, 2);
if (b < 2) b ^= 1; // Swap On & Off
g_model.customSwitches[i].start = (fsStartPositionType)b;
}
}
static void r_functionSwitchGroup(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
{
uint32_t v = yaml_str2uint(val, val_len);
for (int i = 0; i < 6; i += 1) {
g_model.customSwitches[i].group = bfGet<uint16_t>(v, 2 * i, 2);
}
for (int i = 0; i <= 3; i += 1) {
g_model.cfsSetGroupAlwaysOn(i, bfGet<uint16_t>(v, 2 * 6 + i, 1));
}
}
static void r_functionSwitchLogicalState(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
{
uint32_t v = yaml_str2uint(val, val_len);
for (int i = 0; i < 6; i += 1) {
g_model.customSwitches[i].state = bfGet<uint16_t>(v, 1 * i, 1);
}
}
bool cfsGroupIsActive(void* user, uint8_t* data, uint32_t bitoffs)
{
auto tw = reinterpret_cast<YamlTreeWalker*>(user);
uint16_t idx = tw->getElmts();
return idx > 0 && idx <= NUM_FUNCTIONS_GROUPS;
}
bool isAlwaysActive(void* user, uint8_t* data, uint32_t bitoffs)
{
return true;
}
#endif
bool switchIsActive(void* user, uint8_t* data, uint32_t bitoffs)
{
auto tw = reinterpret_cast<YamlTreeWalker*>(user);
uint16_t idx = tw->getElmts();
return idx < switchGetMaxSwitches();
}
@@ -89,6 +89,29 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_GLOBAL, "GLOBAL" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_fsStartPositionType[] = {
{ FS_START_OFF, "START_OFF" },
{ FS_START_ON, "START_ON" },
{ FS_START_PREVIOUS, "START_PREVIOUS" },
{ 0, NULL }
};
const struct YamlIdStr enum_booleanEnum[] = {
{ BOOL_OFF, "OFF" },
{ BOOL_ON, "ON" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -222,7 +245,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -256,13 +279,31 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_RGBLedColor[] = {
YAML_UNSIGNED( "r", 8 ),
YAML_UNSIGNED( "g", 8 ),
YAML_UNSIGNED( "b", 8 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_ENUM("start", 2, enum_fsStartPositionType, switch_is_cfs),
YAML_ENUM("onColorLuaOverride", 1, enum_booleanEnum, switch_is_cfs),
YAML_ENUM("offColorLuaOverride", 1, enum_booleanEnum, switch_is_cfs),
YAML_PADDING( 1 ),
YAML_STRUCT("onColor", 24, struct_RGBLedColor, switch_is_cfs),
YAML_STRUCT("offColor", 24, struct_RGBLedColor, switch_is_cfs),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
@@ -276,12 +317,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "contrast", 8 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -314,7 +355,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -341,7 +382,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 8, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 80, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_UNSIGNED( "backlightColor", 8 ),
YAML_STRING("bluetoothName", 10),
@@ -382,7 +423,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -403,7 +444,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -463,7 +504,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -476,7 +517,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -634,7 +675,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -684,7 +725,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -728,7 +769,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -775,16 +816,23 @@ static const struct YamlNode struct_TelemetryScreenData[] = {
YAML_UNION("u", 192, union_TelemetryScreenData_u_elmts, select_tele_screen_data),
YAML_END
};
static const struct YamlNode struct_RGBLedColor[] = {
YAML_IDX,
YAML_UNSIGNED( "r", 8 ),
YAML_UNSIGNED( "g", 8 ),
YAML_UNSIGNED( "b", 8 ),
static const struct YamlNode struct_customSwitch[] = {
YAML_IDX_CUST("sw",cfs_idx_read,cfs_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_UNSIGNED( "group", 3 ),
YAML_ENUM("start", 2, enum_fsStartPositionType, NULL),
YAML_UNSIGNED( "state", 1 ),
YAML_ENUM("onColorLuaOverride", 1, enum_booleanEnum, NULL),
YAML_ENUM("offColorLuaOverride", 1, enum_booleanEnum, NULL),
YAML_PADDING( 5 ),
YAML_STRUCT("onColor", 24, struct_RGBLedColor, isAlwaysActive),
YAML_STRUCT("offColor", 24, struct_RGBLedColor, isAlwaysActive),
YAML_END
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -824,16 +872,15 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 320, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -847,27 +894,30 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("screens", 192, 4, struct_TelemetryScreenData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "functionSwitchConfig", 16 ),
YAML_UNSIGNED( "functionSwitchGroup", 16 ),
YAML_UNSIGNED( "functionSwitchStartConfig", 16 ),
YAML_UNSIGNED( "functionSwitchLogicalState", 8 ),
YAML_ARRAY("switchNames", 24, 6, struct_string_24, NULL),
YAML_ARRAY("functionSwitchLedONColor", 24, 6, struct_RGBLedColor, NULL),
YAML_ARRAY("functionSwitchLedOFFColor", 24, 6, struct_RGBLedColor, NULL),
YAML_CUSTOM("functionSwitchConfig",r_functionSwitchConfig,nullptr),
YAML_CUSTOM("functionSwitchGroup",r_functionSwitchGroup,nullptr),
YAML_CUSTOM("functionSwitchStartConfig",r_functionSwitchStartConfig,nullptr),
YAML_CUSTOM("functionSwitchLogicalState",r_functionSwitchLogicalState,nullptr),
YAML_ARRAY("switchNames", 0, NUM_FUNCTIONS_SWITCHES, struct_cfsNameConfig, nullptr),
YAML_ARRAY("functionSwitchLedONColor", 0, NUM_FUNCTIONS_SWITCHES, struct_cfsOnColorConfig, nullptr),
YAML_ARRAY("functionSwitchLedOFFColor", 0, NUM_FUNCTIONS_SWITCHES, struct_cfsOffColorConfig, nullptr),
YAML_ARRAY("customSwitches", 88, 8, struct_customSwitch, isAlwaysActive),
YAML_ARRAY("cfsGroupOn", 1, 8, struct_cfsGroupOn, cfsGroupIsActive),
YAML_PADDING( 8 ),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
@@ -89,6 +89,17 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -231,7 +242,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -265,13 +276,20 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_PADDING( 5 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
@@ -285,12 +303,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "contrast", 8 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -323,7 +341,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -350,7 +368,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 16, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 32, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_STRING("currModelFilename", 17),
YAML_UNSIGNED( "modelQuickSelect", 1 ),
@@ -400,7 +418,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -421,7 +439,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -481,7 +499,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -494,7 +512,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -652,7 +670,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -702,7 +720,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -746,7 +764,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -770,7 +788,7 @@ static const struct YamlNode union_ZoneOptionValue_elmts[] = {
};
static const struct YamlNode struct_ZoneOptionValueTyped[] = {
YAML_IDX,
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum),
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum, NULL),
YAML_UNION("value", 96, union_ZoneOptionValue_elmts, select_zov),
YAML_END
};
@@ -802,7 +820,7 @@ static const struct YamlNode struct_TopBarPersistentData[] = {
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -842,16 +860,15 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 384, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -867,20 +884,20 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
@@ -96,6 +96,17 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -238,7 +249,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -272,18 +283,25 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_PADDING( 5 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
YAML_UNSIGNED( "ppmunit", 2 ),
YAML_ENUM("hatsMode", 2, enum_HatsMode),
YAML_ENUM("hatsMode", 2, enum_HatsMode, NULL),
YAML_CUSTOM("semver",nullptr,w_semver),
YAML_CUSTOM("board",nullptr,w_board),
YAML_ARRAY("calib", 48, 20, struct_CalibData, NULL),
@@ -292,12 +310,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "contrast", 8 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -330,7 +348,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -357,7 +375,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 16, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 32, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_STRING("currModelFilename", 17),
YAML_UNSIGNED( "modelQuickSelect", 1 ),
@@ -407,7 +425,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -428,7 +446,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -488,7 +506,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -501,7 +519,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -659,7 +677,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -709,7 +727,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -753,7 +771,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -777,7 +795,7 @@ static const struct YamlNode union_ZoneOptionValue_elmts[] = {
};
static const struct YamlNode struct_ZoneOptionValueTyped[] = {
YAML_IDX,
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum),
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum, NULL),
YAML_UNION("value", 96, union_ZoneOptionValue_elmts, select_zov),
YAML_END
};
@@ -809,7 +827,7 @@ static const struct YamlNode struct_TopBarPersistentData[] = {
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -835,7 +853,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "disableTelemetryWarning", 1 ),
YAML_UNSIGNED( "showInstanceIds", 1 ),
YAML_UNSIGNED( "checklistInteractive", 1 ),
YAML_ENUM("hatsMode", 2, enum_HatsMode),
YAML_ENUM("hatsMode", 2, enum_HatsMode, NULL),
YAML_PADDING( 2 ),
YAML_SIGNED( "customThrottleWarningPosition", 8 ),
YAML_UNSIGNED( "beepANACenter", 16 ),
@@ -850,16 +868,15 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 384, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -875,20 +892,20 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
@@ -96,6 +96,17 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -238,7 +249,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -272,18 +283,25 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_PADDING( 5 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
YAML_UNSIGNED( "ppmunit", 2 ),
YAML_ENUM("hatsMode", 2, enum_HatsMode),
YAML_ENUM("hatsMode", 2, enum_HatsMode, NULL),
YAML_CUSTOM("semver",nullptr,w_semver),
YAML_CUSTOM("board",nullptr,w_board),
YAML_ARRAY("calib", 48, 20, struct_CalibData, NULL),
@@ -292,12 +310,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "contrast", 8 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -330,7 +348,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -357,7 +375,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 16, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 32, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_STRING("currModelFilename", 17),
YAML_UNSIGNED( "modelQuickSelect", 1 ),
@@ -407,7 +425,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -428,7 +446,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -488,7 +506,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -501,7 +519,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -659,7 +677,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -709,7 +727,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -753,7 +771,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -777,7 +795,7 @@ static const struct YamlNode union_ZoneOptionValue_elmts[] = {
};
static const struct YamlNode struct_ZoneOptionValueTyped[] = {
YAML_IDX,
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum),
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum, NULL),
YAML_UNION("value", 96, union_ZoneOptionValue_elmts, select_zov),
YAML_END
};
@@ -809,7 +827,7 @@ static const struct YamlNode struct_TopBarPersistentData[] = {
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -835,7 +853,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "disableTelemetryWarning", 1 ),
YAML_UNSIGNED( "showInstanceIds", 1 ),
YAML_UNSIGNED( "checklistInteractive", 1 ),
YAML_ENUM("hatsMode", 2, enum_HatsMode),
YAML_ENUM("hatsMode", 2, enum_HatsMode, NULL),
YAML_PADDING( 2 ),
YAML_SIGNED( "customThrottleWarningPosition", 8 ),
YAML_UNSIGNED( "beepANACenter", 16 ),
@@ -850,16 +868,15 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 384, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -875,20 +892,20 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
@@ -89,6 +89,17 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -231,7 +242,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -265,13 +276,20 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_PADDING( 5 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
@@ -285,12 +303,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "contrast", 8 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -323,7 +341,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -350,7 +368,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 16, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 32, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_STRING("currModelFilename", 17),
YAML_UNSIGNED( "modelQuickSelect", 1 ),
@@ -400,7 +418,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -421,7 +439,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -481,7 +499,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -494,7 +512,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -652,7 +670,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -702,7 +720,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -746,7 +764,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -770,7 +788,7 @@ static const struct YamlNode union_ZoneOptionValue_elmts[] = {
};
static const struct YamlNode struct_ZoneOptionValueTyped[] = {
YAML_IDX,
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum),
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum, NULL),
YAML_UNION("value", 96, union_ZoneOptionValue_elmts, select_zov),
YAML_END
};
@@ -802,7 +820,7 @@ static const struct YamlNode struct_TopBarPersistentData[] = {
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -842,16 +860,15 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 384, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -867,20 +884,20 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
@@ -90,6 +90,29 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_GLOBAL, "GLOBAL" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_fsStartPositionType[] = {
{ FS_START_OFF, "START_OFF" },
{ FS_START_ON, "START_ON" },
{ FS_START_PREVIOUS, "START_PREVIOUS" },
{ 0, NULL }
};
const struct YamlIdStr enum_booleanEnum[] = {
{ BOOL_OFF, "OFF" },
{ BOOL_ON, "ON" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -240,7 +263,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -274,13 +297,31 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_RGBLedColor[] = {
YAML_UNSIGNED( "r", 8 ),
YAML_UNSIGNED( "g", 8 ),
YAML_UNSIGNED( "b", 8 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_ENUM("start", 2, enum_fsStartPositionType, switch_is_cfs),
YAML_ENUM("onColorLuaOverride", 1, enum_booleanEnum, switch_is_cfs),
YAML_ENUM("offColorLuaOverride", 1, enum_booleanEnum, switch_is_cfs),
YAML_PADDING( 1 ),
YAML_STRUCT("onColor", 24, struct_RGBLedColor, switch_is_cfs),
YAML_STRUCT("offColor", 24, struct_RGBLedColor, switch_is_cfs),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
@@ -292,12 +333,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 16 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -330,7 +371,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -357,7 +398,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 16, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 80, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_STRING("currModelFilename", 17),
YAML_UNSIGNED( "modelQuickSelect", 1 ),
@@ -409,7 +450,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -430,7 +471,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -490,7 +531,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -503,7 +544,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -661,7 +702,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -711,7 +752,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -755,7 +796,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -779,7 +820,7 @@ static const struct YamlNode union_ZoneOptionValue_elmts[] = {
};
static const struct YamlNode struct_ZoneOptionValueTyped[] = {
YAML_IDX,
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum),
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum, NULL),
YAML_UNION("value", 96, union_ZoneOptionValue_elmts, select_zov),
YAML_END
};
@@ -809,21 +850,23 @@ static const struct YamlNode struct_TopBarPersistentData[] = {
YAML_ARRAY("options", 128, 1, struct_ZoneOptionValueTyped, NULL),
YAML_END
};
static const struct YamlNode struct_string_24[] = {
YAML_IDX,
YAML_STRING("val", 3),
YAML_END
};
static const struct YamlNode struct_RGBLedColor[] = {
YAML_IDX,
YAML_UNSIGNED( "r", 8 ),
YAML_UNSIGNED( "g", 8 ),
YAML_UNSIGNED( "b", 8 ),
static const struct YamlNode struct_customSwitch[] = {
YAML_IDX_CUST("sw",cfs_idx_read,cfs_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_UNSIGNED( "group", 2 ),
YAML_ENUM("start", 2, enum_fsStartPositionType, NULL),
YAML_UNSIGNED( "state", 1 ),
YAML_ENUM("onColorLuaOverride", 1, enum_booleanEnum, NULL),
YAML_ENUM("offColorLuaOverride", 1, enum_booleanEnum, NULL),
YAML_PADDING( 6 ),
YAML_STRUCT("onColor", 24, struct_RGBLedColor, isAlwaysActive),
YAML_STRUCT("offColor", 24, struct_RGBLedColor, isAlwaysActive),
YAML_END
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -863,16 +906,15 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 384, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -887,28 +929,31 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("topbarWidgetWidth", 8, 6, struct_unsigned_8, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "functionSwitchConfig", 16 ),
YAML_UNSIGNED( "functionSwitchGroup", 16 ),
YAML_UNSIGNED( "functionSwitchStartConfig", 16 ),
YAML_UNSIGNED( "functionSwitchLogicalState", 8 ),
YAML_ARRAY("switchNames", 24, 6, struct_string_24, NULL),
YAML_ARRAY("functionSwitchLedONColor", 24, 6, struct_RGBLedColor, NULL),
YAML_ARRAY("functionSwitchLedOFFColor", 24, 6, struct_RGBLedColor, NULL),
YAML_CUSTOM("functionSwitchConfig",r_functionSwitchConfig,nullptr),
YAML_CUSTOM("functionSwitchGroup",r_functionSwitchGroup,nullptr),
YAML_CUSTOM("functionSwitchStartConfig",r_functionSwitchStartConfig,nullptr),
YAML_CUSTOM("functionSwitchLogicalState",r_functionSwitchLogicalState,nullptr),
YAML_ARRAY("switchNames", 0, NUM_FUNCTIONS_SWITCHES, struct_cfsNameConfig, nullptr),
YAML_ARRAY("functionSwitchLedONColor", 0, NUM_FUNCTIONS_SWITCHES, struct_cfsOnColorConfig, nullptr),
YAML_ARRAY("functionSwitchLedOFFColor", 0, NUM_FUNCTIONS_SWITCHES, struct_cfsOffColorConfig, nullptr),
YAML_ARRAY("customSwitches", 88, 6, struct_customSwitch, isAlwaysActive),
YAML_ARRAY("cfsGroupOn", 1, 8, struct_cfsGroupOn, cfsGroupIsActive),
YAML_PADDING( 8 ),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
+72 -40
View File
@@ -90,6 +90,24 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_GLOBAL, "GLOBAL" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_fsStartPositionType[] = {
{ FS_START_OFF, "START_OFF" },
{ FS_START_ON, "START_ON" },
{ FS_START_PREVIOUS, "START_PREVIOUS" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -240,7 +258,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -274,13 +292,21 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_ENUM("start", 2, enum_fsStartPositionType, switch_is_cfs),
YAML_PADDING( 3 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
@@ -292,12 +318,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 16 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -330,7 +356,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -357,7 +383,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 16, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 32, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_STRING("currModelFilename", 17),
YAML_UNSIGNED( "modelQuickSelect", 1 ),
@@ -409,7 +435,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -430,7 +456,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -490,7 +516,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -503,7 +529,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -661,7 +687,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -711,7 +737,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -755,7 +781,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -779,7 +805,7 @@ static const struct YamlNode union_ZoneOptionValue_elmts[] = {
};
static const struct YamlNode struct_ZoneOptionValueTyped[] = {
YAML_IDX,
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum),
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum, NULL),
YAML_UNION("value", 96, union_ZoneOptionValue_elmts, select_zov),
YAML_END
};
@@ -809,14 +835,18 @@ static const struct YamlNode struct_TopBarPersistentData[] = {
YAML_ARRAY("options", 128, 1, struct_ZoneOptionValueTyped, NULL),
YAML_END
};
static const struct YamlNode struct_string_24[] = {
YAML_IDX,
YAML_STRING("val", 3),
static const struct YamlNode struct_customSwitch[] = {
YAML_IDX_CUST("sw",cfs_idx_read,cfs_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_UNSIGNED( "group", 2 ),
YAML_ENUM("start", 2, enum_fsStartPositionType, NULL),
YAML_UNSIGNED( "state", 1 ),
YAML_END
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -856,16 +886,15 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 352, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -880,26 +909,29 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("topbarWidgetWidth", 8, 6, struct_unsigned_8, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "functionSwitchConfig", 16 ),
YAML_UNSIGNED( "functionSwitchGroup", 16 ),
YAML_UNSIGNED( "functionSwitchStartConfig", 16 ),
YAML_UNSIGNED( "functionSwitchLogicalState", 8 ),
YAML_ARRAY("switchNames", 24, 6, struct_string_24, NULL),
YAML_CUSTOM("functionSwitchConfig",r_functionSwitchConfig,nullptr),
YAML_CUSTOM("functionSwitchGroup",r_functionSwitchGroup,nullptr),
YAML_CUSTOM("functionSwitchStartConfig",r_functionSwitchStartConfig,nullptr),
YAML_CUSTOM("functionSwitchLogicalState",r_functionSwitchLogicalState,nullptr),
YAML_ARRAY("switchNames", 0, NUM_FUNCTIONS_SWITCHES, struct_cfsNameConfig, nullptr),
YAML_ARRAY("customSwitches", 32, 6, struct_customSwitch, isAlwaysActive),
YAML_ARRAY("cfsGroupOn", 1, 8, struct_cfsGroupOn, cfsGroupIsActive),
YAML_PADDING( 8 ),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
+72 -35
View File
@@ -89,6 +89,24 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_GLOBAL, "GLOBAL" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_fsStartPositionType[] = {
{ FS_START_OFF, "START_OFF" },
{ FS_START_ON, "START_ON" },
{ FS_START_PREVIOUS, "START_PREVIOUS" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -222,7 +240,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -256,13 +274,21 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_ENUM("start", 2, enum_fsStartPositionType, switch_is_cfs),
YAML_PADDING( 3 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
@@ -276,12 +302,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "contrast", 8 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -314,7 +340,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -341,7 +367,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 8, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 32, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_UNSIGNED( "backlightColor", 8 ),
YAML_STRING("bluetoothName", 10),
@@ -382,7 +408,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -403,7 +429,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -463,7 +489,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -476,7 +502,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -634,7 +660,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -684,7 +710,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -728,7 +754,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -775,9 +801,18 @@ static const struct YamlNode struct_TelemetryScreenData[] = {
YAML_UNION("u", 192, union_TelemetryScreenData_u_elmts, select_tele_screen_data),
YAML_END
};
static const struct YamlNode struct_customSwitch[] = {
YAML_IDX_CUST("sw",cfs_idx_read,cfs_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_UNSIGNED( "group", 2 ),
YAML_ENUM("start", 2, enum_fsStartPositionType, NULL),
YAML_UNSIGNED( "state", 1 ),
YAML_END
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -817,16 +852,15 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 352, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -840,25 +874,28 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("screens", 192, 4, struct_TelemetryScreenData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "functionSwitchConfig", 16 ),
YAML_UNSIGNED( "functionSwitchGroup", 16 ),
YAML_UNSIGNED( "functionSwitchStartConfig", 16 ),
YAML_UNSIGNED( "functionSwitchLogicalState", 8 ),
YAML_ARRAY("switchNames", 24, 6, struct_string_24, NULL),
YAML_CUSTOM("functionSwitchConfig",r_functionSwitchConfig,nullptr),
YAML_CUSTOM("functionSwitchGroup",r_functionSwitchGroup,nullptr),
YAML_CUSTOM("functionSwitchStartConfig",r_functionSwitchStartConfig,nullptr),
YAML_CUSTOM("functionSwitchLogicalState",r_functionSwitchLogicalState,nullptr),
YAML_ARRAY("switchNames", 0, NUM_FUNCTIONS_SWITCHES, struct_cfsNameConfig, nullptr),
YAML_ARRAY("customSwitches", 32, 6, struct_customSwitch, isAlwaysActive),
YAML_ARRAY("cfsGroupOn", 1, 8, struct_cfsGroupOn, cfsGroupIsActive),
YAML_PADDING( 8 ),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
@@ -89,6 +89,24 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_GLOBAL, "GLOBAL" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_fsStartPositionType[] = {
{ FS_START_OFF, "START_OFF" },
{ FS_START_ON, "START_ON" },
{ FS_START_PREVIOUS, "START_PREVIOUS" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -222,7 +240,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -256,13 +274,21 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_ENUM("start", 2, enum_fsStartPositionType, switch_is_cfs),
YAML_PADDING( 3 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
@@ -276,12 +302,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "contrast", 8 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -314,7 +340,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -341,7 +367,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 8, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 32, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_UNSIGNED( "backlightColor", 8 ),
YAML_STRING("bluetoothName", 10),
@@ -382,7 +408,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -403,7 +429,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -463,7 +489,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -476,7 +502,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -634,7 +660,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -684,7 +710,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -728,7 +754,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -775,9 +801,18 @@ static const struct YamlNode struct_TelemetryScreenData[] = {
YAML_UNION("u", 192, union_TelemetryScreenData_u_elmts, select_tele_screen_data),
YAML_END
};
static const struct YamlNode struct_customSwitch[] = {
YAML_IDX_CUST("sw",cfs_idx_read,cfs_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_UNSIGNED( "group", 2 ),
YAML_ENUM("start", 2, enum_fsStartPositionType, NULL),
YAML_UNSIGNED( "state", 1 ),
YAML_END
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -817,16 +852,15 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 320, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -840,25 +874,28 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("screens", 192, 4, struct_TelemetryScreenData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "functionSwitchConfig", 16 ),
YAML_UNSIGNED( "functionSwitchGroup", 16 ),
YAML_UNSIGNED( "functionSwitchStartConfig", 16 ),
YAML_UNSIGNED( "functionSwitchLogicalState", 8 ),
YAML_ARRAY("switchNames", 24, 6, struct_string_24, NULL),
YAML_CUSTOM("functionSwitchConfig",r_functionSwitchConfig,nullptr),
YAML_CUSTOM("functionSwitchGroup",r_functionSwitchGroup,nullptr),
YAML_CUSTOM("functionSwitchStartConfig",r_functionSwitchStartConfig,nullptr),
YAML_CUSTOM("functionSwitchLogicalState",r_functionSwitchLogicalState,nullptr),
YAML_ARRAY("switchNames", 0, NUM_FUNCTIONS_SWITCHES, struct_cfsNameConfig, nullptr),
YAML_ARRAY("customSwitches", 32, 6, struct_customSwitch, isAlwaysActive),
YAML_ARRAY("cfsGroupOn", 1, 8, struct_cfsGroupOn, cfsGroupIsActive),
YAML_PADDING( 8 ),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
+49 -32
View File
@@ -89,6 +89,17 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -239,7 +250,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -273,13 +284,20 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_PADDING( 5 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
@@ -291,12 +309,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_PADDING( 16 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -329,7 +347,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -356,7 +374,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 16, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 32, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_STRING("currModelFilename", 17),
YAML_UNSIGNED( "modelQuickSelect", 1 ),
@@ -408,7 +426,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -429,7 +447,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -489,7 +507,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -502,7 +520,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -660,7 +678,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -710,7 +728,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -754,7 +772,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -778,7 +796,7 @@ static const struct YamlNode union_ZoneOptionValue_elmts[] = {
};
static const struct YamlNode struct_ZoneOptionValueTyped[] = {
YAML_IDX,
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum),
YAML_ENUM("type", 32, enum_ZoneOptionValueEnum, NULL),
YAML_UNION("value", 96, union_ZoneOptionValue_elmts, select_zov),
YAML_END
};
@@ -810,7 +828,7 @@ static const struct YamlNode struct_TopBarPersistentData[] = {
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -850,16 +868,15 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 352, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -875,20 +892,20 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioThemesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
+47 -30
View File
@@ -88,6 +88,17 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -221,7 +232,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -255,13 +266,20 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_PADDING( 5 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
@@ -275,12 +293,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "contrast", 8 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -313,7 +331,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -340,7 +358,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 8, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 32, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_UNSIGNED( "backlightColor", 8 ),
YAML_STRING("bluetoothName", 10),
@@ -381,7 +399,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -402,7 +420,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -462,7 +480,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -475,7 +493,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -633,7 +651,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -683,7 +701,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -727,7 +745,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -776,7 +794,7 @@ static const struct YamlNode struct_TelemetryScreenData[] = {
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -816,8 +834,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 352, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
@@ -826,8 +843,8 @@ static const struct YamlNode struct_ModelData[] = {
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -842,19 +859,19 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
@@ -88,6 +88,17 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -221,7 +232,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -255,13 +266,20 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_PADDING( 5 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
@@ -275,12 +293,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "contrast", 8 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -313,7 +331,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -340,7 +358,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 8, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 32, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_UNSIGNED( "backlightColor", 8 ),
YAML_STRING("bluetoothName", 10),
@@ -381,7 +399,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -402,7 +420,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -462,7 +480,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -475,7 +493,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -633,7 +651,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -683,7 +701,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -727,7 +745,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -776,7 +794,7 @@ static const struct YamlNode struct_TelemetryScreenData[] = {
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -816,8 +834,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 352, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
@@ -826,8 +843,8 @@ static const struct YamlNode struct_ModelData[] = {
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -842,19 +859,19 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
+47 -30
View File
@@ -88,6 +88,17 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -221,7 +232,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -255,13 +266,20 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_PADDING( 5 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
@@ -275,12 +293,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "contrast", 8 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -313,7 +331,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -340,7 +358,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 8, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 32, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_UNSIGNED( "backlightColor", 8 ),
YAML_STRING("bluetoothName", 10),
@@ -381,7 +399,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -402,7 +420,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -462,7 +480,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -475,7 +493,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -633,7 +651,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -683,7 +701,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -727,7 +745,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -776,7 +794,7 @@ static const struct YamlNode struct_TelemetryScreenData[] = {
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -816,8 +834,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 352, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
@@ -826,8 +843,8 @@ static const struct YamlNode struct_ModelData[] = {
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -843,19 +860,19 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
@@ -88,6 +88,17 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -221,7 +232,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -255,13 +266,20 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_PADDING( 5 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
@@ -275,12 +293,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "contrast", 8 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -313,7 +331,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -340,7 +358,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 8, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 32, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_UNSIGNED( "backlightColor", 8 ),
YAML_STRING("bluetoothName", 10),
@@ -381,7 +399,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -402,7 +420,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -462,7 +480,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -475,7 +493,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -633,7 +651,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -683,7 +701,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -727,7 +745,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -776,7 +794,7 @@ static const struct YamlNode struct_TelemetryScreenData[] = {
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -816,16 +834,15 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 320, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -840,19 +857,19 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
@@ -88,6 +88,17 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_TEST, "TEST" },
{ 0, NULL }
};
const struct YamlIdStr enum_SwitchConfig[] = {
{ SWITCH_NONE, "NONE" },
{ SWITCH_TOGGLE, "TOGGLE" },
{ SWITCH_2POS, "2POS" },
{ SWITCH_3POS, "3POS" },
{ SWITCH_none, "none" },
{ SWITCH_toggle, "toggle" },
{ SWITCH_2pos, "2pos" },
{ SWITCH_3pos, "3pos" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
{ TMRMODE_OFF, "OFF" },
{ TMRMODE_ON, "ON" },
@@ -223,7 +234,7 @@ static const struct YamlNode struct_signed_16[] = {
static const struct YamlNode struct_TrainerMix[] = {
YAML_IDX,
YAML_UNSIGNED( "srcChn", 6 ),
YAML_ENUM("mode", 2, enum_TrainerMultiplex),
YAML_ENUM("mode", 2, enum_TrainerMultiplex, NULL),
YAML_SIGNED( "studWeight", 8 ),
YAML_END
};
@@ -257,13 +268,20 @@ static const struct YamlNode union_anonymous_0_elmts[] = {
static const struct YamlNode struct_CustomFunctionData[] = {
YAML_IDX,
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_ENUM("func", 6, enum_Functions),
YAML_ENUM("func", 6, enum_Functions, NULL),
YAML_CUSTOM("def",r_customFn,w_customFn),
YAML_PADDING( 64 ),
YAML_PADDING( 1 ),
YAML_PADDING( 7 ),
YAML_END
};
static const struct YamlNode struct_switchDef[] = {
YAML_IDX_CUST("sw",sw_idx_read,sw_idx_write),
YAML_STRING("name", 3),
YAML_ENUM("type", 3, enum_SwitchConfig, NULL),
YAML_PADDING( 5 ),
YAML_END
};
static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "manuallyEdited", 1 ),
YAML_SIGNED( "timezoneMinutes", 3 ),
@@ -277,12 +295,12 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "contrast", 8 ),
YAML_UNSIGNED( "vBatWarn", 8 ),
YAML_SIGNED( "txVoltageCalibration", 8 ),
YAML_ENUM("backlightMode", 3, enum_BacklightMode),
YAML_ENUM("antennaMode", 2, enum_AntennaModes),
YAML_ENUM("backlightMode", 3, enum_BacklightMode, NULL),
YAML_ENUM("antennaMode", 2, enum_AntennaModes, NULL),
YAML_UNSIGNED( "disableRtcWarning", 1 ),
YAML_UNSIGNED( "keysBacklight", 1 ),
YAML_UNSIGNED( "dontPlayHello", 1 ),
YAML_ENUM("internalModule", 8, enum_ModuleType),
YAML_ENUM("internalModule", 8, enum_ModuleType, NULL),
YAML_STRUCT("trainer", 128, struct_TrainerData, NULL),
YAML_UNSIGNED( "view", 8 ),
YAML_PADDING( 2 ),
@@ -315,7 +333,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_UNSIGNED( "backlightBright", 8 ),
YAML_UNSIGNED( "globalTimer", 32 ),
YAML_UNSIGNED( "bluetoothBaudrate", 4 ),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes),
YAML_ENUM("bluetoothMode", 4, enum_BluetoothModes, NULL),
YAML_UNSIGNED( "countryCode", 2 ),
YAML_SIGNED( "pwrOnSpeed", 3 ),
YAML_SIGNED( "pwrOffSpeed", 3 ),
@@ -342,7 +360,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("slidersConfig", 0, MAX_POTS, struct_sliderConfig, nullptr),
YAML_PADDING( 8 ),
YAML_ARRAY("potsConfig", 4, 8, struct_potConfig, nullptr),
YAML_ARRAY("switchConfig", 2, 32, struct_switchConfig, nullptr),
YAML_ARRAY("switchConfig", 32, 20, struct_switchDef, switchIsActive),
YAML_ARRAY("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
YAML_UNSIGNED( "backlightColor", 8 ),
YAML_STRING("bluetoothName", 10),
@@ -385,7 +403,7 @@ static const struct YamlNode struct_TimerData[] = {
YAML_UNSIGNED( "start", 22 ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_SIGNED( "value", 22 ),
YAML_ENUM("mode", 3, enum_TimerModes),
YAML_ENUM("mode", 3, enum_TimerModes, NULL),
YAML_UNSIGNED( "countdownBeep", 2 ),
YAML_UNSIGNED( "minuteBeep", 1 ),
YAML_UNSIGNED( "persistent", 2 ),
@@ -406,7 +424,7 @@ static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex, NULL),
YAML_UNSIGNED( "delayPrec", 1 ),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
@@ -466,7 +484,7 @@ static const struct YamlNode struct_signed_8[] = {
};
static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_IDX,
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions),
YAML_ENUM("func", 8, enum_LogicalSwitchesFunctions, NULL),
YAML_CUSTOM("def",r_logicSw,w_logicSw),
YAML_PADDING( 10 ),
YAML_PADDING( 10 ),
@@ -479,7 +497,7 @@ static const struct YamlNode struct_LogicalSwitchData[] = {
YAML_END
};
static const struct YamlNode struct_SwashRingData[] = {
YAML_ENUM("type", 8, enum_SwashType),
YAML_ENUM("type", 8, enum_SwashType, NULL),
YAML_UNSIGNED( "value", 8 ),
YAML_UNSIGNED_CUST( "collectiveSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
YAML_UNSIGNED_CUST( "aileronSource", 8, r_mixSrcRaw, w_mixSrcRaw ),
@@ -637,7 +655,7 @@ static const struct YamlNode struct_ModuleData[] = {
YAML_CUSTOM("subType",r_modSubtype,w_modSubtype),
YAML_UNSIGNED( "channelsStart", 8 ),
YAML_SIGNED_CUST( "channelsCount", 8, r_channelsCount, w_channelsCount ),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes),
YAML_ENUM("failsafeMode", 4, enum_FailsafeModes, NULL),
YAML_PADDING( 4 ),
YAML_UNION("mod", 200, union_anonymous_4_elmts, select_mod_type),
YAML_END
@@ -687,7 +705,7 @@ static const struct YamlNode struct_anonymous_16[] = {
static const struct YamlNode union_anonymous_15_elmts[] = {
YAML_STRUCT("frskyInstance", 8, struct_anonymous_16, NULL),
YAML_UNSIGNED( "instance", 8 ),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula),
YAML_ENUM("formula", 8, enum_TelemetrySensorFormula, NULL),
YAML_END
};
static const struct YamlNode struct_anonymous_18[] = {
@@ -731,7 +749,7 @@ static const struct YamlNode struct_TelemetrySensor[] = {
YAML_UNION("id2", 8, union_anonymous_15_elmts, select_id2),
YAML_STRING("label", 4),
YAML_UNSIGNED( "subId", 8 ),
YAML_ENUM("type", 1, enum_TelemetrySensorType),
YAML_ENUM("type", 1, enum_TelemetrySensorType, NULL),
YAML_PADDING( 1 ),
YAML_UNSIGNED( "unit", 6 ),
YAML_UNSIGNED( "prec", 2 ),
@@ -780,7 +798,7 @@ static const struct YamlNode struct_TelemetryScreenData[] = {
};
static const struct YamlNode struct_USBJoystickChData[] = {
YAML_IDX,
YAML_ENUM("mode", 3, enum_USBJoystickCh),
YAML_ENUM("mode", 3, enum_USBJoystickCh, NULL),
YAML_UNSIGNED( "inversion", 1 ),
YAML_UNSIGNED( "param", 4 ),
YAML_UNSIGNED( "btn_num", 5 ),
@@ -820,16 +838,15 @@ static const struct YamlNode struct_ModelData[] = {
YAML_ARRAY("flightModeData", 320, 9, struct_FlightModeData, fmd_is_active),
YAML_UNSIGNED_CUST( "thrTraceSrc", 8, r_thrSrc, w_thrSrc ),
YAML_CUSTOM("switchWarningState",r_swtchWarn,nullptr),
YAML_ARRAY("switchWarning", 3, 21, struct_swtchWarn, nullptr),
YAML_PADDING(1),
YAML_ARRAY("switchWarning", 2, 32, struct_swtchWarn, nullptr),
YAML_ARRAY("gvars", 56, 9, struct_GVarData, NULL),
YAML_STRUCT("varioData", 40, struct_VarioData, NULL),
YAML_UNSIGNED_CUST( "rssiSource", 8, r_tele_sensor, w_tele_sensor ),
YAML_STRUCT("rssiAlarms", 0, struct_RssiAlarmData, NULL),
YAML_STRUCT("rfAlarms", 16, struct_RFAlarmData, NULL),
YAML_UNSIGNED( "thrTrimSw", 3 ),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable),
YAML_ENUM("potsWarnMode", 2, enum_PotsWarnMode, NULL),
YAML_ENUM("jitterFilter", 2, enum_ModelOverridableEnable, NULL),
YAML_PADDING( 1 ),
YAML_ARRAY("moduleData", 232, 2, struct_ModuleData, NULL),
YAML_ARRAY("failsafeChannels", 16, 32, struct_signed_16, NULL),
@@ -844,19 +861,19 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "view", 8 ),
YAML_STRING("modelRegistrationID", 8),
YAML_UNSIGNED( "usbJoystickExtMode", 1 ),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode),
YAML_ENUM("usbJoystickIfMode", 3, enum_USBJoystickIfMode, NULL),
YAML_UNSIGNED( "usbJoystickCircularCut", 4 ),
YAML_ARRAY("usbJoystickCh", 16, 26, struct_USBJoystickChData, NULL),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable),
YAML_ENUM("radioGFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("radioTrainerDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelHeliDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelFMDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCurvesDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelGVDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelLSDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelSFDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelCustomScriptsDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_ENUM("modelTelemetryDisabled", 2, enum_ModelOverridableEnable, NULL),
YAML_END
};
static const struct YamlNode struct_PartialModel[] = {
+5 -4
View File
@@ -88,6 +88,7 @@ struct YamlNode
struct {
const YamlIdStr* choices;
is_active_func is_active;
} _enum;
struct {
@@ -141,8 +142,8 @@ struct YamlNode
#define YAML_ARRAY(tag, bits, max_elmts, nodes, f_is_active) \
{ .size=(bits), .type=YDT_ARRAY, .elmts=(max_elmts), YAML_TAG(tag), .u={._array={ .child=(nodes), .u={.is_active=(f_is_active)}}} }
#define YAML_ENUM(tag, bits, id_strs) \
{ .size=(bits), .type=YDT_ENUM, .elmts=0, YAML_TAG(tag), .u={._enum={ .choices=(id_strs) }} }
#define YAML_ENUM(tag, bits, id_strs, f_is_active) \
{ .size=(bits), .type=YDT_ENUM, .elmts=0, YAML_TAG(tag), .u={._enum={ .choices=(id_strs), .is_active=(f_is_active) }} }
#define YAML_UNION(tag, bits, nodes, f_sel_m) \
{ .size=(bits), .type=YDT_UNION, .elmts=0, YAML_TAG(tag), .u={._array={ .child=(nodes), .u={.select_member=(f_sel_m) }}} }
@@ -193,8 +194,8 @@ struct YamlNode
#define YAML_ARRAY(tag, bits, max_elmts, nodes, f_is_active) \
{ (bits), YDT_ARRAY, (max_elmts), YAML_TAG(tag), {{ (nodes), {{ (f_is_active) }}}} }
#define YAML_ENUM(tag, bits, id_strs) \
{ (bits), YDT_ENUM, .elmts=0, YAML_TAG(tag), {{ (const YamlNode*)(id_strs) }} }
#define YAML_ENUM(tag, bits, id_strs, f_is_active) \
{ (bits), YDT_ENUM, .elmts=0, YAML_TAG(tag), {{ (const YamlNode*)(id_strs, {{ (f_is_active) }}) }} }
#define YAML_UNION(tag, bits, nodes, f_sel_m) \
{ (bits), YDT_UNION, .elmts=0, YAML_TAG(tag), {{ (nodes), {{ (YamlNode::is_active_func)(f_sel_m) }}}} }
@@ -622,6 +622,13 @@ bool YamlTreeWalker::generate(yaml_writer_func wf, void* opaque)
}
else {
if (attr->type == YDT_ENUM && attr->u._enum.is_active) {
if (!attr->u._enum.is_active(this, data, getBitOffset())) {
toNextAttr();
continue;
}
}
// only for lists:
// - arrays have IDX upfront
// - structs are not marked as arrays
+5 -5
View File
@@ -420,19 +420,19 @@ char *getFlightModeString(char *dest, int8_t idx)
return dest;
}
char *getCustomSwitchesGroupName(char *dest, uint8_t idx)
char* getCustomSwitchesGroupName(char *dest, uint8_t idx)
{
dest = strAppendStringWithIndex(dest, "GR", idx + 1);
return dest;
}
char *getSwitchName(char *dest, uint8_t idx, bool defaultOnly)
char* getSwitchName(char *dest, uint8_t idx, bool defaultOnly)
{
if (!defaultOnly && switchHasCustomName(idx)) {
dest = strAppend(dest, switchGetCustomName(idx), LEN_SWITCH_NAME);
if (!defaultOnly && g_model.switchHasCustomName(idx)) {
dest = strAppend(dest, g_model.getSwitchCustomName(idx), LEN_SWITCH_NAME);
} else {
dest = strAppend(dest, switchGetName(idx), LEN_SWITCH_NAME);
dest = strAppend(dest, switchGetDefaultName(idx), LEN_SWITCH_NAME);
}
return dest;
+130 -188
View File
@@ -88,72 +88,59 @@ uint8_t potsPos[MAX_POTS];
// Non pushed : SWSRC_Sx0 = -1024 = Sx(up) = state 0
// Pushed : SWSRC_Sx2 = +1024 = Sx(down) = state 1
uint8_t fsPreviousState = 0;
uint8_t functionSwitchFunctionState = 0;
uint16_t fsPreviousState = 0;
void setFSStartupPosition()
{
for (uint8_t i = 0; i < NUM_FUNCTIONS_SWITCHES; i++) {
uint8_t startPos = (g_model.functionSwitchStartConfig >> 2 * i) & 0x03;
if (FSWITCH_CONFIG(i) == SWITCH_TOGGLE)
startPos = FS_START_OFF;
switch(startPos) {
case FS_START_OFF:
g_model.functionSwitchLogicalState &= ~(1 << i); // clear state
break;
for (uint8_t i = 0; i < switchGetMaxSwitches(); i++) {
if (switchIsCustomSwitch(i)) {
uint8_t startPos = g_model.getSwitchStart(i);
if (g_model.getSwitchType(i) == SWITCH_TOGGLE)
startPos = FS_START_OFF;
switch(startPos) {
case FS_START_OFF:
g_model.cfsSetState(i, 0);
break;
case FS_START_ON:
g_model.functionSwitchLogicalState |= 1 << i;
break;
case FS_START_ON:
g_model.cfsSetState(i, 1);
break;
case FS_START_PREVIOUS:
default:
// Do nothing, use existing g_model.functionSwitchLogicalState value
break;
case FS_START_PREVIOUS:
default:
// Do nothing, use existing value
break;
}
}
}
}
uint8_t getFSLogicalState()
{
return g_model.functionSwitchLogicalState;
}
uint8_t getFSLogicalState(uint8_t index)
{
return (uint8_t )(bfSingleBitGet(getFSLogicalState(), index) >> (index));
}
void setFSLogicalState(uint8_t index, uint8_t value)
{
if (value)
g_model.functionSwitchLogicalState |= 1 << index; // Set bit
else
g_model.functionSwitchLogicalState &= ~(1 << index); // clear state
g_model.cfsSetState(index, value ? 1 : 0);
}
uint8_t getFSPhysicalState(uint8_t index)
bool getFSPhysicalState(uint8_t index)
{
#if defined(FUNCTION_SWITCHES)
if (bfSingleBitGet(functionSwitchFunctionState, index))
if (switchIsCustomSwitch(index) && g_model.cfsSFState(index))
return true;
#endif
index += switchGetMaxSwitches();
return switchGetPosition(index) != SWITCH_HW_UP;
}
uint8_t getFSPreviousPhysicalState(uint8_t index)
static bool getFSPreviousPhysicalState(uint8_t index)
{
return (uint8_t )(bfSingleBitGet(fsPreviousState, index) >> (index));
return (uint8_t)(bfSingleBitGet(fsPreviousState, index) >> (index));
}
uint8_t getSwitchCountInFSGroup(uint8_t index)
{
uint8_t count = 0;
for (uint8_t i = 0; i < switchGetMaxFctSwitches(); i++) {
if (FSWITCH_GROUP(i) == index)
for (uint8_t i = 0; i < switchGetMaxSwitches(); i++) {
if (switchIsCustomSwitch(i) && g_model.getSwitchGroup(i) == index)
count++;
}
@@ -167,63 +154,63 @@ bool isFSGroupUsed(uint8_t index)
void evalFunctionSwitches()
{
uint8_t fct_switches = switchGetMaxFctSwitches();
for (uint8_t i = 0; i < fct_switches; i++) {
if (FSWITCH_CONFIG(i) == SWITCH_NONE) {
setFSLedOFF(i);
//fsLedRGB(i, 0);
continue;
}
uint8_t physicalState = getFSPhysicalState(i);
if (physicalState != getFSPreviousPhysicalState(i)) {
// FS was moved
inactivityTimerReset(ActivitySource::MainControls);
if ((FSWITCH_CONFIG(i) == SWITCH_2POS && physicalState == 1) ||
(FSWITCH_CONFIG(i) == SWITCH_TOGGLE)) {
if (IS_FSWITCH_GROUP_ON(FSWITCH_GROUP(i)) != 0) {
// In an always on group
g_model.functionSwitchLogicalState |= 1 << i; // Set bit
} else {
g_model.functionSwitchLogicalState ^= 1 << i; // Toggle bit
}
for (uint8_t i = 0; i < switchGetMaxSwitches(); i++) {
if (switchIsCustomSwitch(i)) {
if (g_model.getSwitchType(i) == SWITCH_NONE) {
continue;
}
if (FSWITCH_GROUP(i) && physicalState == 1) {
// switch is in a group, other in group need to be turned off
for (uint8_t j = 0; j < NUM_FUNCTIONS_SWITCHES; j++) {
if (i == j) continue;
if (FSWITCH_GROUP(j) == FSWITCH_GROUP(i)) {
g_model.functionSwitchLogicalState &= ~(1 << j); // clear state
bool physicalState = getFSPhysicalState(i);
if (physicalState != getFSPreviousPhysicalState(i)) {
// FS was moved
inactivityTimerReset(ActivitySource::MainControls);
if ((g_model.getSwitchType(i) == SWITCH_2POS && physicalState) ||
(g_model.getSwitchType(i) == SWITCH_TOGGLE)) {
if (g_model.cfsGroupAlwaysOn(g_model.getSwitchGroup(i)) != 0) {
// In an always on group
g_model.cfsSetState(i, 1);
} else {
g_model.cfsSetState(i, g_model.cfsState(i) ^ 1); // Toggle bit
}
}
if (g_model.getSwitchGroup(i) && physicalState) {
// switch is in a group, other in group need to be turned off
for (uint8_t j = 0; j < switchGetMaxSwitches(); j++) {
if ((i != j) && switchIsCustomSwitch(j)) {
if (g_model.getSwitchGroup(j) == g_model.getSwitchGroup(i)) {
g_model.cfsSetState(j, 0);
}
}
}
}
fsPreviousState ^= 1 << i; // Toggle state
storageDirty(EE_MODEL);
}
fsPreviousState ^= 1 << i; // Toggle state
storageDirty(EE_MODEL);
}
if (!pwrPressed()) {
if (getFSLogicalState(i))
setFSLedON(i);
else
setFSLedOFF(i);
if (!pwrPressed()) {
if (g_model.cfsState(i))
setFSLedON(i);
else
setFSLedOFF(i);
}
}
}
}
bool groupHasSwitchOn(uint8_t group)
{
for (int j = 0; j < NUM_FUNCTIONS_SWITCHES; j += 1)
if (FSWITCH_GROUP(j) == group && getFSLogicalState(j))
for (int j = 0; j < switchGetMaxSwitches(); j += 1)
if (switchIsCustomSwitch(j) && g_model.getSwitchGroup(j) == group && g_model.cfsState(j))
return true;
return false;
}
int firstSwitchInGroup(uint8_t group)
{
for (int j = 0; j < NUM_FUNCTIONS_SWITCHES; j += 1)
if (FSWITCH_GROUP(j) == group)
for (int j = 0; j < switchGetMaxSwitches(); j += 1)
if (switchIsCustomSwitch(j) && g_model.getSwitchGroup(j) == group)
return j;
return -1;
}
@@ -231,28 +218,30 @@ int firstSwitchInGroup(uint8_t group)
int groupDefaultSwitch(uint8_t group)
{
bool allOff = true;
for (int j = 0; j < NUM_FUNCTIONS_SWITCHES; j += 1) {
if (FSWITCH_GROUP(j) == group) {
if (FSWITCH_STARTUP(j) == FS_START_ON)
return j;
if (FSWITCH_STARTUP(j) != FS_START_OFF)
allOff = false;
for (int j = 0; j < switchGetMaxSwitches(); j += 1) {
if (switchIsCustomSwitch(j)) {
if (g_model.getSwitchGroup(j) == group) {
if (g_model.getSwitchStart(j) == FS_START_ON)
return j;
if (g_model.getSwitchStart(j) != FS_START_OFF)
allOff = false;
}
}
}
if (allOff)
return NUM_FUNCTIONS_SWITCHES;
return switchGetMaxSwitches();
return -1;
}
void setGroupSwitchState(uint8_t group, int defaultSwitch)
void setGroupSwitchState(uint8_t group)
{
// Check rules for always on group
// - Toggle switch type not valid, change all switches to 2POS
// - One switch must be turned on, turn on first switch if needed
if (IS_FSWITCH_GROUP_ON(group)) {
for (int j = 0; j < NUM_FUNCTIONS_SWITCHES; j += 1) {
if (FSWITCH_GROUP(j) == group) {
FSWITCH_SET_CONFIG(j, SWITCH_2POS); // Toggle not valid
if (g_model.cfsGroupAlwaysOn(group)) {
for (int j = 0; j < switchGetMaxSwitches(); j += 1) {
if (switchIsCustomSwitch(j) && g_model.getSwitchGroup(j) == group) {
g_model.setSwitchType(j, SWITCH_2POS); // Toggle not valid
}
}
if (!groupHasSwitchOn(group)) {
@@ -260,16 +249,14 @@ void setGroupSwitchState(uint8_t group, int defaultSwitch)
if (sw >= 0)
setFSLogicalState(sw, 1); // Make sure a switch is on
}
if (groupDefaultSwitch(group) == NUM_FUNCTIONS_SWITCHES) {
if (groupDefaultSwitch(group) == switchGetMaxSwitches()) {
// Start state for all switches is off - set all to 'last'
for (int j = 0; j < NUM_FUNCTIONS_SWITCHES; j += 1)
if (FSWITCH_GROUP(j) == group)
FSWITCH_SET_STARTUP(j, FS_START_PREVIOUS);
for (int j = 0; j < switchGetMaxSwitches(); j += 1)
if (switchIsCustomSwitch(j) && g_model.getSwitchGroup(j) == group)
g_model.setSwitchStart(j, FS_START_PREVIOUS);
}
}
}
#else
uint8_t getFSLogicalState(uint8_t) { return false; }
#endif // FUNCTION_SWITCHES
div_t switchInfo(int switchPosition)
@@ -284,9 +271,9 @@ int switchLookupIdx(char c)
idx = 2; // SWx
}
auto max_switches = switchGetMaxSwitches() + switchGetMaxFctSwitches();
auto max_switches = switchGetMaxAllSwitches();
for (int i = 0; i < max_switches; i++) {
const char *name = switchGetName(i);
const char *name = switchGetDefaultName(i);
if (name[idx] == c) return i;
}
@@ -297,9 +284,9 @@ int switchLookupIdx(const char* name, size_t len)
{
if (len < 2 || (name[0] != 'S' && name[0] != 'F')) return -1;
auto max_switches = switchGetMaxSwitches() + switchGetMaxFctSwitches();
auto max_switches = switchGetMaxAllSwitches();
for (int i = 0; i < max_switches; i++) {
const char *sw_name = switchGetCanonicalName(i);
const char *sw_name = switchGetDefaultName(i);
if (strncmp(sw_name, name, len) == 0) return i;
}
@@ -308,44 +295,13 @@ int switchLookupIdx(const char* name, size_t len)
char switchGetLetter(uint8_t idx)
{
if (idx >= switchGetMaxSwitches() + switchGetMaxFctSwitches())
if (idx >= switchGetMaxAllSwitches() + MAX_FLEX_SWITCHES)
return -1;
uint8_t c = 1;
if (idx >= switchGetMaxSwitches() || switchIsFlex(idx)) c = 2;
const char* name = switchGetName(idx);
const char* name = switchGetDefaultName(idx);
if (!name) return -1;
return name[c];
}
static char _switchNames[MAX_SWITCHES][LEN_SWITCH_NAME + 1] = { 0 };
void switchSetCustomName(uint8_t idx, const char* str, size_t len)
{
strncpy(_switchNames[idx], str, min<size_t>(LEN_SWITCH_NAME, len));
_switchNames[idx][LEN_SWITCH_NAME] = '\0';
}
const char* switchGetCustomName(uint8_t idx)
{
#if defined(FUNCTION_SWITCHES)
if (idx >= switchGetMaxSwitches()) // Switch is a customisable switch
return g_model.switchNames[idx - switchGetMaxSwitches()];
else
#endif
return _switchNames[idx];
}
bool switchHasCustomName(uint8_t idx)
{
return *switchGetCustomName(idx) != 0;
}
const char* switchGetCanonicalName(uint8_t idx)
{
return switchGetName(idx);
return name[strlen(name) - 1];
}
const char* fsSwitchGroupGetCanonicalName(uint8_t idx)
@@ -412,7 +368,7 @@ static uint64_t checkSwitchPosition(uint8_t idx, bool startup)
void getSwitchesPosition(bool startup)
{
uint64_t newPos = 0;
for (unsigned i = 0; i < switchGetMaxSwitches(); i++) {
for (unsigned i = 0; i < switchGetMaxAllSwitches(); i++) {
if (!SWITCH_EXISTS(i)) continue;
newPos |= checkSwitchPosition(i, startup);
}
@@ -453,7 +409,7 @@ void getSwitchesPosition(bool startup)
uint8_t getSwitchCount()
{
int count = 0;
for (int i = 0; i < switchGetMaxSwitches(); ++i) {
for (int i = 0; i < switchGetMaxAllSwitches(); ++i) {
if (SWITCH_EXISTS(i)) {
++count;
}
@@ -461,10 +417,11 @@ uint8_t getSwitchCount()
return count;
}
#if !defined(COLORLCD)
uint8_t switchGetMaxRow(uint8_t col)
{
uint8_t lastrow = 0;
for (int i = 0; i < switchGetMaxSwitches(); ++i) {
for (int i = 0; i < switchGetMaxAllSwitches(); ++i) {
if (SWITCH_EXISTS(i)) {
auto switch_display = switchGetDisplayPosition(i);
if (switch_display.col == col)
@@ -473,6 +430,7 @@ uint8_t switchGetMaxRow(uint8_t col)
}
return lastrow;
}
#endif
getvalue_t getValueForLogicalSwitch(mixsrc_t i)
{
@@ -719,18 +677,16 @@ bool getSwitch(swsrc_t swtch, uint8_t flags)
else if (cs_idx <= SWSRC_LAST_SWITCH) {
cs_idx -= SWSRC_FIRST_SWITCH;
#if defined(FUNCTION_SWITCHES)
auto max_reg_pos = switchGetMaxSwitches() * 3;
if (cs_idx >= max_reg_pos && cs_idx - max_reg_pos < switchGetMaxFctSwitches() * 3) {
cs_idx -= max_reg_pos;
div_t qr = div(cs_idx, 3);
auto value = getFSLogicalState(qr.quot);
div_t qr = div(cs_idx, 3);
if (switchIsCustomSwitch(qr.quot)) {
auto value = g_model.cfsState(qr.quot);
result = qr.rem == 0 ? !value : (qr.rem == 2 ? value : false);
} else
#endif
{
div_t qr = div(cs_idx, 3);
if (SWITCH_EXISTS(qr.quot)) {
auto sw_cfg = (SwitchConfig)SWITCH_CONFIG(qr.quot);
auto sw_cfg = g_model.getSwitchType(qr.quot);
if (flags & GETSWITCH_MIDPOS_DELAY) {
result = SWITCH_POSITION(cs_idx);
// Handle 2POS switch installed in 3POS slot
@@ -829,7 +785,6 @@ static inline uint8_t _bits_set(uint8_t val, uint8_t bits)
}
swarnstate_t switches_states = 0;
uint8_t fsswitches_states = 0;
swsrc_t getMovedSwitch()
{
@@ -837,40 +792,28 @@ swsrc_t getMovedSwitch()
swsrc_t result = 0;
// Switches
auto max_reg_switches = switchGetMaxSwitches();
for (uint8_t i = 0; i < max_reg_switches; i++) {
auto max_switches = switchGetMaxAllSwitches();
for (uint8_t i = 0; i < max_switches; i++) {
if (SWITCH_EXISTS(i)) {
swarnstate_t mask = ((swarnstate_t) 0x07 << (i * 3));
uint8_t prev = (switches_states & mask) >> (i * 3);
uint8_t next = (1024 + getValue(MIXSRC_FIRST_SWITCH + i)) / 1024 + 1;
swarnstate_t mask = ((swarnstate_t) 0x03 << (i * 2));
uint8_t prev = (switches_states & mask) >> (i * 2);
uint8_t next;
#if defined(FUNCTION_SWITCHES)
if (switchIsCustomSwitch(i))
next = g_model.cfsState(i) ? 3 : 1;
else
next = (1024 + getValue(MIXSRC_FIRST_SWITCH + i)) / 1024 + 1;
#else
next = (1024 + getValue(MIXSRC_FIRST_SWITCH + i)) / 1024 + 1;
#endif
if (prev != next) {
switches_states =
(switches_states & (~mask)) | ((swarnstate_t)(next) << (i * 3));
(switches_states & (~mask)) | ((swarnstate_t)(next) << (i * 2));
result = (3 * i) + next;
}
}
}
#if defined(FUNCTION_SWITCHES)
auto fsswitches_cur_state = getFSLogicalState();
auto fsswitches_xor = fsswitches_cur_state ^ fsswitches_states;
fsswitches_states = fsswitches_cur_state;
if (fsswitches_xor) {
// we have some change...
if (_bits_set(fsswitches_xor, switchGetMaxFctSwitches()) > 1) {
// multiple bits change: use the one that turned ON
fsswitches_xor &= fsswitches_cur_state;
} else {
// only one bit changed: use the one that changed
}
auto sw = __builtin_ctz(fsswitches_xor);
auto pos = (fsswitches_cur_state & fsswitches_xor) ? 2 : 0;
result = (max_reg_switches + sw) * 3 + pos + SWSRC_FIRST_SWITCH;
}
#endif
// Multipos
for (int i = 0; i < MAX_POTS; i++) {
if (IS_POT_MULTIPOS(i)) {
@@ -894,17 +837,18 @@ swsrc_t getMovedSwitch()
bool isSwitchWarningRequired(uint16_t &bad_pots)
{
swarnstate_t states = g_model.switchWarning;
if (!mixerTaskRunning()) getADC();
getMovedSwitch();
bool warn = false;
for (int i = 0; i < switchGetMaxSwitches(); i++) {
for (int i = 0; i < switchGetMaxAllSwitches(); i++) {
if (SWITCH_WARNING_ALLOWED(i)) {
swarnstate_t mask = ((swarnstate_t)0x07 << (i * 3));
if ((states & mask) && !((states & mask) == (switches_states & mask))) {
warn = true;
uint8_t warnState = g_model.getSwitchWarning(i);
if (warnState) {
swarnstate_t swState = g_model.getSwitchStateForWarning(i);
if (warnState != swState) {
warn = true;
}
}
}
}
@@ -943,7 +887,6 @@ void checkSwitches()
void checkSwitches()
{
swarnstate_t last_bad_switches = 0xff;
swarnstate_t states = g_model.switchWarning;
uint16_t bad_pots = 0, last_bad_pots = 0xff;
#if defined(PWR_BUTTON_PRESS)
@@ -968,17 +911,16 @@ void checkSwitches()
int x = SWITCH_WARNING_LIST_X;
int y = SWITCH_WARNING_LIST_Y;
int numWarnings = 0;
for (int i = 0; i < switchGetMaxSwitches(); ++i) {
for (int i = 0; i < switchGetMaxAllSwitches(); ++i) {
if (SWITCH_WARNING_ALLOWED(i)) {
swarnstate_t mask = ((swarnstate_t)0x07 << (i*3));
if (states & mask) {
LcdFlags attr =
((states & mask) == (switches_states & mask)) ? 0 : INVERS;
if (attr) {
uint8_t warnState = g_model.getSwitchWarning(i);
if (warnState) {
swarnstate_t swState = g_model.getSwitchStateForWarning(i);
if (warnState != swState) {
if (++numWarnings < 6) {
const char* s = getSwitchWarnSymbol((states & mask) >> (i * 3));
drawSource(x, y, MIXSRC_FIRST_SWITCH + i, attr);
lcdDrawText(lcdNextPos, y, s, attr);
const char* s = getSwitchWarnSymbol(warnState);
drawSource(x, y, MIXSRC_FIRST_SWITCH + i, INVERS);
lcdDrawText(lcdNextPos, y, s, INVERS);
x = lcdNextPos + 3;
}
}
@@ -1219,10 +1161,10 @@ void setAllPreflightSwitchStates()
getMovedSwitch();
// Mask switches enabled for warnings
swarnstate_t sw_mask = 0;
for(uint8_t i = 0; i < switchGetMaxSwitches(); i++) {
for(uint8_t i = 0; i < switchGetMaxAllSwitches(); i++) {
if (SWITCH_WARNING_ALLOWED(i))
if (g_model.switchWarning & (0x07 << (3 * i)))
sw_mask |= (0x07 << (3 * i));
if (g_model.getSwitchWarning(i))
sw_mask |= (0x03 << (2 * i));
}
g_model.switchWarning = switches_states & sw_mask;
AUDIO_WARNING1();
+5 -13
View File
@@ -78,14 +78,8 @@ int switchLookupIdx(const char* name, size_t len);
// note: no customizable switches
char switchGetLetter(uint8_t idx);
// note: no customizable switches
const char* switchGetCanonicalName(uint8_t idx);
// customizable switches supported
const char* fsSwitchGroupGetCanonicalName(uint8_t idx);
void switchSetCustomName(uint8_t idx, const char* str, size_t len);
const char* switchGetCustomName(uint8_t idx);
bool switchHasCustomName(uint8_t idx);
uint8_t getSwitchCountInFSGroup(uint8_t index);
SwitchConfig switchGetMaxType(uint8_t idx);
@@ -96,20 +90,18 @@ void logicalSwitchesInit(bool force);
#if defined(FUNCTION_SWITCHES)
void setFSStartupPosition();
void evalFunctionSwitches();
uint8_t getFSLogicalState(uint8_t index);
void setFSLogicalState(uint8_t index, uint8_t value);
bool groupHasSwitchOn(uint8_t group);
int firstSwitchInGroup(uint8_t group);
int groupDefaultSwitch(uint8_t group);
void setGroupSwitchState(uint8_t group, int defaultSwitch = -1);
uint8_t getFSPhysicalState(uint8_t index);
extern uint8_t functionSwitchFunctionState;
void setGroupSwitchState(uint8_t group);
bool getFSPhysicalState(uint8_t index);
//led_driver.cpp
void fsLedOff(uint8_t);
void fsLedOn(uint8_t);
void fsLedOff(uint8_t index);
void fsLedOn(uint8_t index);
bool fsLedState(uint8_t index);
void fsLedRGB(uint8_t, uint32_t color);
void fsLedRGB(uint8_t index, uint32_t color);
uint32_t fsGetLedRGB(uint8_t index);
uint8_t getRGBColorIndex(uint32_t color);
#endif
@@ -24,7 +24,7 @@
SwitchHwPos stm32_switch_get_position(const stm32_switch_t* sw)
{
bool inv = sw->flags & SWITCH_HW_INVERTED;
bool inv = sw->inverted;
SwitchHwPos ret = SWITCH_HW_UP;
switch (sw->type) {
@@ -21,20 +21,29 @@
#pragma once
#include "hal.h"
#include "stm32_hal_ll.h"
#include "hal/switch_driver.h"
#include "edgetx_constants.h"
struct stm32_switch_t
{
const char* name;
GPIO_TypeDef* GPIOx_high;
uint32_t Pin_high;
GPIO_TypeDef* GPIOx_low;
uint32_t Pin_low;
SwitchHwType type;
uint8_t flags;
SwitchHwType type;
bool inverted;
SwitchConfig defaultType;
#if defined(FUNCTION_SWITCHES)
bool isCustomSwitch;
uint8_t customSwitchIdx;
#endif
};
SwitchHwPos stm32_switch_get_position(const stm32_switch_t* sw);
-13
View File
@@ -302,19 +302,6 @@ void bluetoothDisable();
#if defined(FUNCTION_SWITCHES)
#define NUM_FUNCTIONS_SWITCHES 6
#define NUM_FUNCTIONS_GROUPS 3
#define DEFAULT_FS_CONFIG \
(SWITCH_2POS << 10) + (SWITCH_2POS << 8) + (SWITCH_2POS << 6) + \
(SWITCH_2POS << 4) + (SWITCH_2POS << 2) + (SWITCH_2POS << 0)
#define DEFAULT_FS_GROUPS \
(1 << 10) + (1 << 8) + (1 << 6) + (1 << 4) + (1 << 2) + \
(1 << 0) // Set all FS to group 1 to act like a 6pos
#define DEFAULT_FS_STARTUP_CONFIG \
((FS_START_PREVIOUS << 10) + (FS_START_PREVIOUS << 8) + \
(FS_START_PREVIOUS << 6) + (FS_START_PREVIOUS << 4) + \
(FS_START_PREVIOUS << 2) + \
(FS_START_PREVIOUS << 0)) // keep last state by default
#else
#define NUM_FUNCTIONS_SWITCHES 0
+8
View File
@@ -156,36 +156,42 @@
#define HARDWARE_SWITCH_G
#define SWITCHES_GPIO_REG_G GPIOB
#define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_14 // PB.14
#define SWITCHES_G_CFS_IDX 0
//SW2
#define FUNCTION_SWITCH_2 SH
#define STORAGE_SWITCH_H
#define HARDWARE_SWITCH_H
#define SWITCHES_GPIO_REG_H GPIOD
#define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_13 // PD.13
#define SWITCHES_H_CFS_IDX 1
//SW3
#define FUNCTION_SWITCH_3 SI
#define STORAGE_SWITCH_I
#define HARDWARE_SWITCH_I
#define SWITCHES_GPIO_REG_I GPIOJ
#define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_7 // PJ.07
#define SWITCHES_I_CFS_IDX 2
//SW4
#define FUNCTION_SWITCH_4 SJ
#define STORAGE_SWITCH_J
#define HARDWARE_SWITCH_J
#define SWITCHES_GPIO_REG_J GPIOG
#define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_13 // PG.13
#define SWITCHES_J_CFS_IDX 3
//SW5
#define FUNCTION_SWITCH_5 SK
#define STORAGE_SWITCH_K
#define HARDWARE_SWITCH_K
#define SWITCHES_GPIO_REG_K GPIOJ
#define SWITCHES_GPIO_PIN_K LL_GPIO_PIN_8 // PJ.08
#define SWITCHES_K_CFS_IDX 4
//SW6
#define FUNCTION_SWITCH_6 SL
#define STORAGE_SWITCH_L
#define HARDWARE_SWITCH_L
#define SWITCHES_GPIO_REG_L GPIOB
#define SWITCHES_GPIO_PIN_L LL_GPIO_PIN_13 // PB.13
#define SWITCHES_L_CFS_IDX 5
#else
#define STORAGE_SWITCH_A
#define HARDWARE_SWITCH_A
@@ -1044,6 +1050,8 @@
#if defined(RADIO_V16)
// LED Strip
#define LED_STRIP_LENGTH 40
#define BLING_LED_STRIP_START 6
#define BLING_LED_STRIP_LENGTH 34
#define LED_STRIP_GPIO GPIO_PIN(GPIOA, 10) // PA.10 / TIM1_CH3
#define LED_STRIP_GPIO_AF LL_GPIO_AF_1 // TIM1/2
#define LED_STRIP_TIMER TIM1
+1 -17
View File
@@ -50,23 +50,7 @@ void ledInit()
#endif
}
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
// used to map switch number to led number in the rgbled chain
uint8_t ledMapping[] = {1, 2, 3, 4, 5, 6};
void fsLedOff(uint8_t index, uint32_t color)
{
rgbSetLedColor(ledMapping[index], GET_RED(color), GET_GREEN(color),
GET_BLUE(color));
}
void fsLedOn(uint8_t index, uint32_t color)
{
rgbSetLedColor(ledMapping[index], GET_RED(color), GET_GREEN(color),
GET_BLUE(color));
}
#elif defined(FUNCTION_SWITCHES)
#if defined(FUNCTION_SWITCHES) && !defined(FUNCTION_SWITCHES_RGB_LEDS)
gpio_t fsLeds[] = {FSLED_GPIO_1, FSLED_GPIO_2, FSLED_GPIO_3,
FSLED_GPIO_4, FSLED_GPIO_5, FSLED_GPIO_6};
-21
View File
@@ -1,21 +0,0 @@
/*
* Copyright (C) EdgeTX
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include "hal/switch_driver.h"
#include "stm32_switch_driver.h"
SwitchHwPos bsp_get_switch_position(const stm32_switch_t *sw, SwitchCategory cat, uint8_t idx) {return SWITCH_HW_MID;}
-2
View File
@@ -17,5 +17,3 @@
#include "hal/switch_driver.h"
#include "stm32_switch_driver.h"
SwitchHwPos bsp_get_switch_position(const stm32_switch_t *sw, SwitchCategory cat, uint8_t idx) {return SWITCH_HW_MID;}
+2
View File
@@ -830,6 +830,8 @@
// LED Strip
#if !defined(RADIO_NV14_FAMILY)
#define LED_STRIP_LENGTH 4
#define BLING_LED_STRIP_START 0
#define BLING_LED_STRIP_LENGTH 4
#define LED_STRIP_GPIO GPIO_PIN(GPIOH, 12) // PH.12 / TIM5_CH3
#define LED_STRIP_GPIO_AF LL_GPIO_AF_2 // TIM3/4/5
#define LED_STRIP_TIMER TIM5
@@ -32,7 +32,7 @@
static const char _switch_names[][4] = {"SW2", "SW3"};
SwitchHwPos boardSwitchGetPosition(SwitchCategory cat, uint8_t idx)
SwitchHwPos boardSwitchGetPosition(uint8_t idx)
{
if (idx <= 1) {
// uint16_t swVal = getAnalogValue(4);
@@ -55,7 +55,7 @@ SwitchHwPos boardSwitchGetPosition(SwitchCategory cat, uint8_t idx)
return SWITCH_HW_UP;
}
const char* boardSwitchGetName(SwitchCategory cat, uint8_t idx)
const char* boardSwitchGetName(uint8_t idx)
{
return _switch_names[idx];
}
+37 -34
View File
@@ -19,21 +19,26 @@
* GNU General Public License for more details.
*/
#include <stdint.h>
#include "edgetx.h"
#include "hal/rgbleds.h"
#include "definitions.h"
#include "board.h"
bool usbChargerLed() { return true; }
void ledRed() {}
void ledGreen() {}
void ledBlue() {}
void ledOff() {}
void rgbSetLedColor(uint8_t, uint8_t, uint8_t, uint8_t) {}
void rgbLedColorApply() {}
bool fsLedState(uint8_t i)
{
#if defined(FUNCTION_SWITCHES)
return g_model.customSwitches[i].state;
#else
return false;
#endif
}
uint8_t getRGBColorIndex(uint32_t color)
{
for (uint8_t i = 0; i < DIM(colorTable); i++) {
@@ -43,39 +48,37 @@ uint8_t getRGBColorIndex(uint32_t color)
return 0; // Custom value set with Companion
}
#if NUM_FUNCTIONS_SWITCHES > 0
static uint32_t _fs_switch_colors[NUM_FUNCTIONS_SWITCHES] = {0};
static uint32_t _fs_switch_color_mask = 0;
static uint32_t _fs_switch_mask = 0;
// RGB
#define WS2812_BYTES_PER_LED 3
void fsLedRGB(uint8_t index, uint32_t col)
// Maximum number of supported LEDs
#if !defined(WS2812_MAX_LEDS)
# define WS2812_MAX_LEDS 48
#endif
// Pixel values
static uint8_t _led_colors[WS2812_BYTES_PER_LED * WS2812_MAX_LEDS];
void rgbSetLedColor(uint8_t led, uint8_t r, uint8_t g, uint8_t b)
{
_fs_switch_color_mask |= (1 << index);
_fs_switch_colors[index] = col;
uint8_t* pixel = &_led_colors[led * WS2812_BYTES_PER_LED];
pixel[0] = g;
pixel[1] = r;
pixel[2] = b;
}
uint32_t rgbGetLedColor(uint8_t led)
{
uint8_t* pixel = &_led_colors[led * WS2812_BYTES_PER_LED];
return (pixel[1] << 16) + (pixel[0] << 8) + pixel[2];
}
void fsLedRGB(uint8_t idx, uint32_t color)
{
rgbSetLedColor(idx, (color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF);
}
uint32_t fsGetLedRGB(uint8_t index)
{
return _fs_switch_colors[index];
return rgbGetLedColor(index);
}
bool fsLedIsColorSet(uint8_t index)
{
return _fs_switch_color_mask & (1 << index);
}
bool fsLedState(uint8_t index)
{
return _fs_switch_mask & (1 << index);
}
void fsLedOn(uint8_t index)
{
_fs_switch_mask |= (1 << index);
}
void fsLedOff(uint8_t index)
{
_fs_switch_mask &= ~(1 << index);
}
#endif
@@ -30,6 +30,7 @@
#include "hal/adc_driver.h"
#include "hal/rotary_encoder.h"
#include "os/time.h"
#include "boards/generic_stm32/rgb_leds.h"
#include <QDebug>
#include <QElapsedTimer>
@@ -90,6 +91,16 @@ void firmwareTraceCb(const char * text)
}
}
void fsLedOn(uint8_t idx)
{
rgbSetLedColor(idx, 0xFF, 0xFF, 0xFF);
}
void fsLedOff(uint8_t idx)
{
rgbSetLedColor(idx, 0, 0, 0);
}
// Serial port handling needs to know about OpenTxSimulator, so we we
// need to update what's in simpgmspace.cpp when we have a simulator
// to point at.
@@ -751,6 +762,7 @@ void OpenTxSimulator::run()
++loops;
checkLcdChanged();
checkFuncSwitchChanged();
if (!(loops % 5)) {
checkOutputsChanged();
@@ -783,6 +795,19 @@ bool OpenTxSimulator::checkLcdChanged()
return false;
}
void OpenTxSimulator::checkFuncSwitchChanged()
{
#if defined(FUNCTION_SWITCHES)
for (int i = 0; i < CPN_MAX_SWITCHES; i += 1) {
if (switchIsCustomSwitch(i)) {
uint8_t cfs = switchGetCustomSwitchIdx(i);
uint32_t c = rgbGetLedColor(cfs);
emit fsColorChange(i, c);
}
}
#endif
}
void OpenTxSimulator::checkOutputsChanged()
{
static TxOutputs lastOutputs;
+1
View File
@@ -102,6 +102,7 @@ class DLLEXPORT OpenTxSimulator : public SimulatorInterface
void setStopRequested(bool stop);
bool checkLcdChanged();
void checkOutputsChanged();
void checkFuncSwitchChanged();
uint8_t getStickMode();
const char * getPhaseName(unsigned int phase);
const QString getCurrentPhaseName();
+44 -37
View File
@@ -65,6 +65,7 @@
#include "simpgmspace.h"
#include "hal/key_driver.h"
#include "hal/switch_driver.h"
#include "switches.h"
#include "audio.h"
@@ -316,26 +317,28 @@ static void draw_switches()
int sw_idx = 0;
for (int i = 0; i < switchGetMaxSwitches(); i++) {
if (sw_idx) ImGui::SameLine();
if (++sw_idx >= MAX_SWITCHES / 2) sw_idx = 0;
if (!SWITCH_EXISTS(i)) {
switches[i] = 0;
ImGui::Dummy(sw_size);
} else {
ImGui::PushID(i);
ImGui::VSliderInt("##sw", sw_size,
&switches[i], IS_CONFIG_3POS(i) ? 2 : 1,
0, "", ImGuiSliderFlags_NoInput);
if (ImGui::IsItemActive() || ImGui::IsItemHovered()) {
ImGui::SetTooltip("%s", switchGetCanonicalName(i));
if (!switchIsCustomSwitch(i)) {
if (++sw_idx >= MAX_SWITCHES / 2) sw_idx = 0;
if (!SWITCH_EXISTS(i)) {
switches[i] = 0;
ImGui::Dummy(sw_size);
} else {
ImGui::PushID(i);
ImGui::VSliderInt("##sw", sw_size,
&switches[i], IS_CONFIG_3POS(i) ? 2 : 1,
0, "", ImGuiSliderFlags_NoInput);
if (ImGui::IsItemActive() || ImGui::IsItemHovered()) {
ImGui::SetTooltip("%s", switchGetDefaultName(i));
}
ImGui::PopID();
}
if (IS_CONFIG_3POS(i)) {
simuSetSwitch(i, switches[i] == 0 ? -1 : switches[i] == 1 ? 0 : 1);
} else {
simuSetSwitch(i, switches[i] == 0 ? -1 : 1);
}
ImGui::PopID();
}
if (IS_CONFIG_3POS(i)) {
simuSetSwitch(i, switches[i] == 0 ? -1 : switches[i] == 1 ? 0 : 1);
} else {
simuSetSwitch(i, switches[i] == 0 ? -1 : 1);
}
}
@@ -346,8 +349,6 @@ static void draw_switches()
}
#if defined(FUNCTION_SWITCHES)
extern bool fsLedIsColorSet(uint8_t index);
static ImVec4 rgb2rgba(uint32_t col)
{
float r = (float)((col >> 16) & 0xff) / 255.0f;
@@ -365,9 +366,10 @@ static inline ImVec4 blend(const ImVec4& a, const ImVec4& b)
static void push_custom_switch_styles(int index)
{
bool sw_on = getFSLogicalState(index);
bool rgb_set = fsLedIsColorSet(index);
ImVec4 rgb = rgb2rgba(fsGetLedRGB(index));
int cfsIdx = switchGetCustomSwitchIdx(index);
bool sw_on = fsLedState(cfsIdx);
bool rgb_set = switchIsCustomSwitch(index);
ImVec4 rgb = rgb2rgba(fsGetLedRGB(cfsIdx));
ImVec4 btn, border;
if (sw_on) {
@@ -408,24 +410,29 @@ static void draw_custom_switches()
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_GrabRounding, 4.0f);
int sw_idx = switchGetMaxSwitches();
for (int i = 0; i < switchGetMaxFctSwitches(); i++, sw_idx++) {
if (i) ImGui::SameLine();
ImGui::PushID(i);
for (int i = 0, n = 0; i < switchGetMaxSwitches(); i += 1) {
if (switchIsCustomSwitch(i)) {
int cfsIdx = switchGetCustomSwitchIdx(i);
push_custom_switch_styles(i);
ImGui::Button("##csw", sw_size);
pop_custom_switch_styles();
if (n) ImGui::SameLine();
ImGui::PushID(i);
bool active = ImGui::IsItemActive();
if (active || ImGui::IsItemHovered()) {
const char* name = switchGetCanonicalName(sw_idx);
const char* on_off = getFSLogicalState(i) ? "on" : "off";
ImGui::SetTooltip("%s (%s)", name, on_off);
push_custom_switch_styles(i);
ImGui::Button("##csw", sw_size);
pop_custom_switch_styles();
bool active = ImGui::IsItemActive();
if (active || ImGui::IsItemHovered()) {
const char* name = switchGetDefaultName(i);
const char* on_off = fsLedState(cfsIdx) ? "on" : "off";
ImGui::SetTooltip("%s (%s)", name, on_off);
}
simuSetSwitch(i, active ? 1 : -1);
ImGui::PopID();
}
simuSetSwitch(sw_idx, active ? 1 : -1);
ImGui::PopID();
n += 1;
}
ImGui::PopStyleVar(3);
+20 -37
View File
@@ -29,17 +29,22 @@
#include <string.h>
struct hw_switch_def {
const char* name;
SwitchHwType type;
const char* name;
SwitchHwType type;
SwitchConfig defaultType;
#if defined(FUNCTION_SWITCHES)
bool isCustomSwitch;
uint8_t customSwitchIdx;
#endif
};
#include "simu_switches.inc"
int8_t switchesStates[MAX_SWITCHES] = { 0 };
int8_t switchesStates[MAX_SWITCHES];
void simuSetSwitch(uint8_t swtch, int8_t state)
{
assert(swtch < switchGetMaxSwitches() + switchGetMaxFctSwitches());
assert(swtch < switchGetMaxAllSwitches());
switchesStates[swtch] = state;
}
@@ -47,34 +52,8 @@ void boardInitSwitches() {
memset(switchesStates, -1, sizeof(switchesStates));
}
static uint8_t get_switch_index(uint8_t cat, uint8_t idx)
SwitchHwPos boardSwitchGetPosition(uint8_t idx)
{
switch(cat) {
case SWITCH_PHYSICAL:
assert(idx < n_switches);
return idx;
case SWITCH_FUNCTION:
assert(idx < n_fct_switches);
return idx + n_switches;
default:
assert(0);
return 0;
}
}
SwitchHwPos boardSwitchGetPosition(SwitchCategory cat, uint8_t idx)
{
idx = get_switch_index(cat, idx);
#if defined(FUNCTION_SWITCHES)
if (IS_SWITCH_FS(idx)) {
if (bfSingleBitGet(functionSwitchFunctionState, idx - n_switches))
return SWITCH_HW_DOWN;
}
#endif
if (switchesStates[idx] < 0)
return SWITCH_HW_UP;
else if (switchesStates[idx] == 0)
@@ -83,26 +62,30 @@ SwitchHwPos boardSwitchGetPosition(SwitchCategory cat, uint8_t idx)
return SWITCH_HW_DOWN;
}
const char* boardSwitchGetName(SwitchCategory cat, uint8_t idx)
const char* boardSwitchGetName(uint8_t idx)
{
idx = get_switch_index(cat, idx);
return _switch_defs[idx].name;
}
SwitchHwType boardSwitchGetType(SwitchCategory cat, uint8_t idx)
SwitchHwType boardSwitchGetType(uint8_t idx)
{
idx = get_switch_index(cat, idx);
return _switch_defs[idx].type;
}
uint8_t boardGetMaxSwitches() { return n_switches; }
uint8_t boardGetMaxFctSwitches() { return n_fct_switches; }
swconfig_t boardSwitchGetDefaultConfig() { return _switch_default_config; }
SwitchConfig boardSwitchGetDefaultConfig(uint8_t idx) { return _switch_defs[idx].defaultType; }
#if defined(FUNCTION_SWITCHES)
bool boardIsCustomSwitch(uint8_t idx) { return _switch_defs[idx].isCustomSwitch; }
uint8_t boardGetCustomSwitchIdx(uint8_t idx) { return _switch_defs[idx].customSwitchIdx; }
#endif
#if !defined(COLORLCD)
switch_display_pos_t switchGetDisplayPosition(uint8_t idx)
{
if (idx >= DIM(_switch_display)) return {0, 0};
return _switch_display[idx];
}
#endif
-13
View File
@@ -96,19 +96,6 @@ void EXTERNAL_MODULE_OFF(); /*gpio_clear(EXTMODULE_PWR_GPIO)*/
#if defined(FUNCTION_SWITCHES)
#define NUM_FUNCTIONS_SWITCHES 6
#define NUM_FUNCTIONS_GROUPS 3
#define DEFAULT_FS_CONFIG \
(SWITCH_2POS << 10) + (SWITCH_2POS << 8) + (SWITCH_2POS << 6) + \
(SWITCH_2POS << 4) + (SWITCH_2POS << 2) + (SWITCH_2POS << 0)
#define DEFAULT_FS_GROUPS \
(1 << 10) + (1 << 8) + (1 << 6) + (1 << 4) + (1 << 2) + \
(1 << 0) // Set all FS to group 1 to act like a 6pos
#define DEFAULT_FS_STARTUP_CONFIG \
((FS_START_PREVIOUS << 10) + (FS_START_PREVIOUS << 8) + \
(FS_START_PREVIOUS << 6) + (FS_START_PREVIOUS << 4) + \
(FS_START_PREVIOUS << 2) + \
(FS_START_PREVIOUS << 0)) // keep last state by default
#else
#define NUM_FUNCTIONS_SWITCHES 0
+10 -35
View File
@@ -21,10 +21,11 @@
#include "bsp_io.h"
#include "drivers/pca95xx.h"
#include "stm32_i2c_driver.h"
#include "stm32_switch_driver.h"
extern const stm32_switch_t* boardGetSwitchDef(uint8_t idx);
#define BSP_IN_I2C_BUS I2C_Bus_2
#define BSP_IN_I2C_ADDR 0x20
@@ -95,45 +96,19 @@ uint16_t bsp_input_get()
return inputState;
}
SwitchHwPos bsp_get_switch_position(const stm32_switch_t *sw,
SwitchCategory cat, uint8_t idx)
SwitchHwPos boardSwitchGetPosition(uint8_t idx)
{
const stm32_switch_t* sw = boardGetSwitchDef(idx);
if (sw->type == SWITCH_HW_ADC || sw->GPIOx_high != nullptr)
return stm32_switch_get_position(sw);
bool val = false;
uint16_t pins = bsp_input_get();
if (cat == SWITCH_PHYSICAL) {
switch (idx) {
case 6:
val = (pins & BSP_BACK_KEY1) != 0;
break;
case 7:
val = (pins & BSP_BACK_KEY2) != 0;
break;
}
} else if (cat == SWITCH_FUNCTION) {
switch (idx) {
case 0:
val = (pins & BSP_EXT_KEY1) != 0;
break;
case 1:
val = (pins & BSP_EXT_KEY2) != 0;
break;
case 2:
val = (pins & BSP_EXT_KEY3) != 0;
break;
case 3:
val = (pins & BSP_EXT_KEY4) != 0;
break;
case 4:
val = (pins & BSP_EXT_KEY5) != 0;
break;
case 5:
val = (pins & BSP_EXT_KEY6) != 0;
break;
}
}
val = (pins & sw->Pin_high) != 0;
if (sw->flags & SWITCH_HW_INVERTED) val = !val;
if (sw->inverted) val = !val;
return val ? SWITCH_HW_UP : SWITCH_HW_DOWN;
}
-13
View File
@@ -25,16 +25,6 @@
#include "hal/switch_driver.h"
// Input port expander
#define BSP_EXT_KEY1 PCA95XX_PIN_0
#define BSP_EXT_KEY2 PCA95XX_PIN_1
#define BSP_EXT_KEY3 PCA95XX_PIN_2
#define BSP_EXT_KEY4 PCA95XX_PIN_3
#define BSP_EXT_KEY5 PCA95XX_PIN_4
#define BSP_EXT_KEY6 PCA95XX_PIN_5
#define BSP_BACK_KEY1 PCA95XX_PIN_6
#define BSP_BACK_KEY2 PCA95XX_PIN_7
#define BSP_TR1U PCA95XX_PIN_8
#define BSP_TR1D PCA95XX_PIN_9
#define BSP_TR3L PCA95XX_PIN_10
@@ -63,6 +53,3 @@ void bsp_output_set(uint16_t pin);
void bsp_output_clear(uint16_t pin);
uint16_t bsp_input_get();
struct stm32_switch_t;
SwitchHwPos bsp_get_switch_position(const stm32_switch_t *sw, SwitchCategory cat, uint8_t idx);
+33 -11
View File
@@ -79,12 +79,30 @@
// function switches
#define FUNCTION_SWITCH_1 I2C
#define FUNCTION_SWITCH_2 I2C
#define FUNCTION_SWITCH_3 I2C
#define FUNCTION_SWITCH_4 I2C
#define FUNCTION_SWITCH_5 I2C
#define FUNCTION_SWITCH_6 I2C
#define FUNCTION_SWITCH_1 SK
#define SWITCHES_GPIO_REG_K
#define SWITCHES_GPIO_PIN_K PCA95XX_PIN_0
#define SWITCHES_K_CFS_IDX 0
#define FUNCTION_SWITCH_2 SL
#define SWITCHES_GPIO_REG_L
#define SWITCHES_GPIO_PIN_L PCA95XX_PIN_1
#define SWITCHES_L_CFS_IDX 1
#define FUNCTION_SWITCH_3 SM
#define SWITCHES_GPIO_REG_M
#define SWITCHES_GPIO_PIN_M PCA95XX_PIN_2
#define SWITCHES_M_CFS_IDX 2
#define FUNCTION_SWITCH_4 SN
#define SWITCHES_GPIO_REG_N
#define SWITCHES_GPIO_PIN_N PCA95XX_PIN_3
#define SWITCHES_N_CFS_IDX 3
#define FUNCTION_SWITCH_5 SO
#define SWITCHES_GPIO_REG_O
#define SWITCHES_GPIO_PIN_O PCA95XX_PIN_4
#define SWITCHES_O_CFS_IDX 4
#define FUNCTION_SWITCH_6 SP
#define SWITCHES_GPIO_REG_P
#define SWITCHES_GPIO_PIN_P PCA95XX_PIN_5
#define SWITCHES_P_CFS_IDX 5
// Direct switches
@@ -92,15 +110,15 @@
#define STORAGE_SWITCH_G
#define HARDWARE_SWITCH_G
#define SWITCHES_G_2POS
//#define SWITCHES_GPIO_REG_G GPIOI
//#define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_3 // PI.03
#define SWITCHES_GPIO_REG_G
#define SWITCHES_GPIO_PIN_G PCA95XX_PIN_6
// Key 2
#define STORAGE_SWITCH_H
#define HARDWARE_SWITCH_H
#define SWITCHES_H_2POS
//#define SWITCHES_GPIO_REG_H GPIOI
//#define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_11 // PI.11
#define SWITCHES_GPIO_REG_H
#define SWITCHES_GPIO_PIN_H PCA95XX_PIN_7
// Key 3
@@ -402,7 +420,11 @@
// LED Strip
#define LED_STRIP_LENGTH 24
#define LED_STRIP_RESERVED_AT_END 12
#define BLING_LED_STRIP_START 0
#define BLING_LED_STRIP_LENGTH 12
#define CFS_LED_STRIP_START 12
#define CFS_LED_STRIP_LENGTH 12
#define CFS_LEDS_PER_SWITCH 2
#define LED_STRIP_GPIO GPIO_PIN(GPIOA, 15) // PA.15 / TIM2_CH1
#define LED_STRIP_GPIO_AF LL_GPIO_AF_1 // TIM1/2/16/17
#define LED_STRIP_TIMER TIM2
+4 -8
View File
@@ -60,20 +60,16 @@ void ledInit()
}
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
// used to map switch number to led number in the rgbled chain
uint8_t ledMapping[] = {12, 14, 16, 18, 20, 22};
void fsLedRGB(uint8_t index, uint32_t color)
{
rgbSetLedColor(ledMapping[index], GET_RED(color), \
GET_GREEN(color),GET_BLUE(color));
rgbSetLedColor(ledMapping[index]+1, GET_RED(color), \
GET_GREEN(color),GET_BLUE(color));
index = (index * 2) + CFS_LED_STRIP_START;
rgbSetLedColor(index, GET_RED(color), GET_GREEN(color),GET_BLUE(color));
rgbSetLedColor(index+1, GET_RED(color), GET_GREEN(color),GET_BLUE(color));
}
uint32_t fsGetLedRGB(uint8_t index)
{
return rgbGetLedColor(ledMapping[index]);
return rgbGetLedColor((index * 2) + CFS_LED_STRIP_START);
}
uint8_t getRGBColorIndex(uint32_t color)
-2
View File
@@ -17,5 +17,3 @@
#include "hal/switch_driver.h"
#include "stm32_switch_driver.h"
SwitchHwPos bsp_get_switch_position(const stm32_switch_t *sw, SwitchCategory cat, uint8_t idx) {return SWITCH_HW_MID;}
+6 -15
View File
@@ -96,24 +96,15 @@ enum {
#if defined(FUNCTION_SWITCHES)
#if defined(RADIO_GX12)
#define NUM_FUNCTIONS_SWITCHES 8
#define NUM_FUNCTIONS_GROUPS 4
#else
#define NUM_FUNCTIONS_SWITCHES 6
#define NUM_FUNCTIONS_GROUPS 3
#endif
#define DEFAULT_FS_CONFIG \
(SWITCH_2POS << 10) + (SWITCH_2POS << 8) + (SWITCH_2POS << 6) + \
(SWITCH_2POS << 4) + (SWITCH_2POS << 2) + (SWITCH_2POS << 0)
#define DEFAULT_FS_GROUPS \
(1 << 10) + (1 << 8) + (1 << 6) + (1 << 4) + (1 << 2) + \
(1 << 0) // Set all FS to group 1 to act like a 6pos
#define DEFAULT_FS_STARTUP_CONFIG \
((FS_START_PREVIOUS << 10) + (FS_START_PREVIOUS << 8) + \
(FS_START_PREVIOUS << 6) + (FS_START_PREVIOUS << 4) + \
(FS_START_PREVIOUS << 2) + \
(FS_START_PREVIOUS << 0)) // keep last state by default
#else
#else //FUNCTION_SWITCHES
#define NUM_FUNCTIONS_SWITCHES 0
-21
View File
@@ -1,21 +0,0 @@
/*
* Copyright (C) EdgeTX
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include "hal/switch_driver.h"
#include "stm32_switch_driver.h"
SwitchHwPos bsp_get_switch_position(const stm32_switch_t *sw, SwitchCategory cat, uint8_t idx) {return SWITCH_HW_MID;}
+24 -74
View File
@@ -19,19 +19,24 @@
* GNU General Public License for more details.
*/
#include "bsp_io.h"
#include "hal/switch_driver.h"
#include "drivers/pca95xx.h"
#include "stm32_i2c_driver.h"
#include "timers_driver.h"
#include "delays_driver.h"
#include "stm32_ws2812.h"
#include "stm32_switch_driver.h"
#include "os/async.h"
#include "os/timer.h"
#include "myeeprom.h"
#define IO_INT_GPIO GPIO_PIN(GPIOE, 14)
#define IO_RESET_GPIO GPIO_PIN(GPIOE, 15)
extern const stm32_switch_t* boardGetSwitchDef(uint8_t idx);
struct bsp_io_expander {
pca95xx_t exp;
uint32_t mask;
@@ -79,8 +84,8 @@ static void _poll_switches(void *param1, uint32_t trigger_source)
timer_reset(&_poll_timer);
}
bsp_io_read_switches();
bsp_io_read_fs_switches();
_read_io_expander(&_io_switches);
_read_io_expander(&_io_fs_switches);
}
static void _io_int_handler()
@@ -126,90 +131,41 @@ int bsp_io_init()
gpio_init(IO_RESET_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
gpio_set(IO_RESET_GPIO);
bsp_io_read_switches();
bsp_io_read_fs_switches();
_read_io_expander(&_io_switches);
_read_io_expander(&_io_fs_switches);
start_poll_timer();
return 0;
}
uint32_t bsp_io_read_switches()
{
return _read_io_expander(&_io_switches);
}
uint32_t bsp_io_read_fs_switches()
{
return _read_io_expander(&_io_fs_switches);
}
void boardInitSwitches()
{
bsp_io_init();
}
struct bsp_io_sw_def {
uint32_t pin_high;
uint32_t pin_low;
};
static constexpr uint32_t RGB_OFFSET = (1 << 16); // first after bspio pins
static uint16_t soft2POSLogicalState = 0xFFFF;
static const bsp_io_sw_def _switch_defs[] = {
{ SWITCH_A, RGB_OFFSET + 7 },
{ SWITCH_B_H, SWITCH_B_L },
{ SWITCH_C_H, SWITCH_C_L },
{ SWITCH_D, RGB_OFFSET + 6 },
{ SWITCH_E_H, SWITCH_E_L },
{ SWITCH_F_H, SWITCH_F_L },
{ SWITCH_G, 0 },
{ SWITCH_H, 0 },
};
static SwitchHwPos _get_switch_pos(uint8_t idx)
{
static uint32_t oldState = 0;
SwitchHwPos pos = SWITCH_HW_UP;
const bsp_io_sw_def* def = &_switch_defs[idx];
const stm32_switch_t* def = boardGetSwitchDef(idx);
uint32_t state = _io_switches.state;
if (def->pin_low > RGB_OFFSET) {
// Potential soft 2pos
if ((SWITCH_CONFIG(idx) == SWITCH_TOGGLE)) {
if ((state & def->pin_high) == 0) {
pos = SWITCH_HW_DOWN;
}
}
else {
if (((state & def->pin_high) == 0) && ((state & def->pin_high) != (oldState & def->pin_high))) {
soft2POSLogicalState ^= def->pin_high;
}
if ((soft2POSLogicalState & def->pin_high) == 0) {
pos = SWITCH_HW_DOWN;
}
else {
pos = SWITCH_HW_UP;
}
}
if (pos == SWITCH_HW_UP) {
ws2812_set_color(def->pin_low - RGB_OFFSET, 0x0, 0x0, 0x0);
if (def->isCustomSwitch) {
if ((state & def->Pin_high) == 0) {
return SWITCH_HW_DOWN;
} else {
ws2812_set_color(def->pin_low - RGB_OFFSET, 0xFF, 0xFF, 0xFF);
return SWITCH_HW_UP;
}
}
else if (!def->pin_low) {
else if (!def->Pin_low) {
// 2POS switch
if ((state & def->pin_high) == 0) {
if ((state & def->Pin_high) == 0) {
pos = SWITCH_HW_DOWN;
}
} else {
bool hi = state & def->pin_high;
bool lo = state & def->pin_low;
bool hi = state & def->Pin_high;
bool lo = state & def->Pin_low;
if (hi && lo) {
pos = SWITCH_HW_MID;
@@ -218,29 +174,23 @@ static SwitchHwPos _get_switch_pos(uint8_t idx)
}
}
if (idx == switchGetMaxSwitches() - 1)
oldState = state;
return pos;
}
static SwitchHwPos _get_fs_switch_pos(uint8_t idx)
{
const stm32_switch_t* def = boardGetSwitchDef(idx);
uint32_t state = _io_fs_switches.state;
if ((state & (1 << idx)) == 0) {
if ((state & def->Pin_high) == 0) {
return SWITCH_HW_DOWN;
} else {
return SWITCH_HW_UP;
}
}
SwitchHwPos boardSwitchGetPosition(SwitchCategory cat, uint8_t idx)
SwitchHwPos boardSwitchGetPosition(uint8_t idx)
{
if (cat == SWITCH_PHYSICAL) {
if (idx < 8)
return _get_switch_pos(idx);
} else if (cat == SWITCH_FUNCTION){
return _get_fs_switch_pos(idx);
}
return SWITCH_HW_UP;
return _get_fs_switch_pos(idx);
}
-59
View File
@@ -1,59 +0,0 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include "drivers/pca95xx.h"
// Port expander 1 (0x74)
#define SWITCH_H PCA95XX_PIN_0
#define SWITCH_D PCA95XX_PIN_1
#define SWITCH_F_H PCA95XX_PIN_3
#define SWITCH_F_L PCA95XX_PIN_2
#define SWITCH_C_L PCA95XX_PIN_4
#define SWITCH_C_H PCA95XX_PIN_5
#define SWITCH_B_H PCA95XX_PIN_10
#define SWITCH_B_L PCA95XX_PIN_11
#define SWITCH_E_H PCA95XX_PIN_12
#define SWITCH_E_L PCA95XX_PIN_13
#define SWITCH_A PCA95XX_PIN_14
#define SWITCH_G PCA95XX_PIN_15
#define IO_INT_GPIO GPIO_PIN(GPIOE, 14)
#define IO_RESET_GPIO GPIO_PIN(GPIOE, 15)
// Port expander 1 (0x75)
#define FSSWITCH_1 PCA95XX_PIN_0
#define FSSWITCH_2 PCA95XX_PIN_1
#define FSSWITCH_3 PCA95XX_PIN_2
#define FSSWITCH_4 PCA95XX_PIN_3
#define FSSWITCH_5 PCA95XX_PIN_4
#define FSSWITCH_6 PCA95XX_PIN_5
int bsp_io_init();
uint32_t bsp_io_read_switches();
uint32_t bsp_io_read_fs_switches();
+91 -13
View File
@@ -645,6 +645,9 @@
#define SWITCHES_GPIO_PIN_A LL_GPIO_PIN_13 // PC.13
#elif defined(RADIO_GX12)
#define SWITCHES_A_2POS
#define SWITCHES_A_CFS_IDX 7
#define SWITCHES_GPIO_REG_A
#define SWITCHES_GPIO_PIN_A PCA95XX_PIN_14
#elif defined(RADIO_T14) || defined(RADIO_T12MAX)
#define SWITCHES_GPIO_REG_A GPIOC
#define SWITCHES_GPIO_PIN_A LL_GPIO_PIN_5 // PC.05
@@ -747,6 +750,10 @@
#define SWITCHES_GPIO_PIN_B LL_GPIO_PIN_11 // PD.11
#elif defined(RADIO_GX12)
#define SWITCHES_B_3POS
#define SWITCHES_GPIO_REG_B_H
#define SWITCHES_GPIO_PIN_B_H PCA95XX_PIN_10
#define SWITCHES_GPIO_REG_B_L
#define SWITCHES_GPIO_PIN_B_L PCA95XX_PIN_11
#elif defined(RADIO_V14) || defined(RADIO_V12)
// ADC based switch
#elif defined(PCBX7)
@@ -825,6 +832,10 @@
#define SWITCHES_GPIO_PIN_C LL_GPIO_PIN_13 // PC.13
#elif defined(RADIO_GX12)
#define SWITCHES_C_3POS
#define SWITCHES_GPIO_REG_C_H
#define SWITCHES_GPIO_PIN_C_H PCA95XX_PIN_5
#define SWITCHES_GPIO_REG_C_L
#define SWITCHES_GPIO_PIN_C_L PCA95XX_PIN_4
#elif defined(RADIO_V14) || defined(RADIO_V12)
// ADC based switch
#elif defined(PCBX7)
@@ -892,6 +903,9 @@
#define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_3 // PC.03
#elif defined(RADIO_GX12)
#define SWITCHES_D_2POS
#define SWITCHES_D_CFS_IDX 6
#define SWITCHES_GPIO_REG_D
#define SWITCHES_GPIO_PIN_D PCA95XX_PIN_1
#elif defined(RADIO_V14) || defined(RADIO_V12)
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
@@ -968,6 +982,10 @@
// ADC based switch/pot
#elif defined(RADIO_GX12)
#define SWITCHES_E_3POS
#define SWITCHES_GPIO_REG_E_H
#define SWITCHES_GPIO_PIN_E_H PCA95XX_PIN_12
#define SWITCHES_GPIO_REG_E_L
#define SWITCHES_GPIO_PIN_E_L PCA95XX_PIN_13
#elif defined(RADIO_V14) || defined(RADIO_V12)
// ADC based switch
#elif defined(PCBX7)
@@ -1025,12 +1043,16 @@
#define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_5 // PB.05
#elif defined(RADIO_MT12)
// ADC based switch/pot
#elif defined(RADIO_T8) || defined(RADIO_TLITE) || defined(RADIO_TPROV2) || defined(RADIO_COMMANDO8) || defined(RADIO_LR3PRO) || defined(RADIO_POCKET)
#elif defined(RADIO_T8) || defined(RADIO_TLITE) || defined(RADIO_COMMANDO8) || defined(RADIO_LR3PRO) || defined(RADIO_POCKET)
// no SWF
#elif defined(RADIO_T12)
// no SWF
#elif defined(RADIO_GX12)
#define SWITCHES_F_3POS
#define SWITCHES_GPIO_REG_F_H
#define SWITCHES_GPIO_PIN_F_H PCA95XX_PIN_3
#define SWITCHES_GPIO_REG_F_L
#define SWITCHES_GPIO_PIN_F_L PCA95XX_PIN_2
#elif defined(RADIO_V14) || defined(RADIO_V12)
// ADC based switch
#elif defined(PCBX7)
@@ -1061,6 +1083,7 @@
#define FUNCTION_SWITCH_1 SG
#define SWITCHES_GPIO_REG_G GPIOG
#define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_7 // PG.07
#define SWITCHES_G_CFS_IDX 0
#elif defined(RADIO_BUMBLEBEE)
#define SWITCHES_GPIO_REG_G GPIOD
#define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_15// PD.15 - Left trim push
@@ -1070,6 +1093,8 @@
#define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_15 // PD.15
#elif defined(RADIO_GX12)
#define SWITCHES_G_2POS
#define SWITCHES_GPIO_REG_G
#define SWITCHES_GPIO_PIN_G PCA95XX_PIN_15
#elif defined(PCBX7) || defined(PCBXLITE) || defined(PCBX9LITE) || defined(RADIO_T8) || defined(RADIO_COMMANDO8) || defined(RADIO_MT12) || defined(RADIO_POCKET) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS)
// no SWG
#else
@@ -1099,6 +1124,7 @@
#define FUNCTION_SWITCH_2 SH
#define SWITCHES_GPIO_REG_H GPIOG
#define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_6 // PG.06
#define SWITCHES_H_CFS_IDX 1
#elif defined(RADIO_BUMBLEBEE)
#define SWITCHES_GPIO_REG_H GPIOF
#define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_0 // PF.00 - Right trim push
@@ -1106,10 +1132,12 @@
//TRIM right low
#define SWITCHES_GPIO_REG_H GPIOF
#define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_0 // PF.00
#elif defined(RADIO_TLITE) || defined(RADIO_TPROV2) || defined(RADIO_TPROS) || defined(RADIO_LR3PRO)
#elif defined(RADIO_TLITE) || defined(RADIO_TPROS) || defined(RADIO_LR3PRO)
// no SWH
#elif defined(RADIO_GX12)
#define SWITCHES_H_2POS
#define SWITCHES_GPIO_REG_H
#define SWITCHES_GPIO_PIN_H PCA95XX_PIN_0
#elif defined(PCBX7)
#define SWITCHES_GPIO_REG_H GPIOD
#define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_14 // PD.14
@@ -1147,68 +1175,84 @@
#define FUNCTION_SWITCH_1 SI
#define SWITCHES_GPIO_REG_I GPIOG
#define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_7 // PG.07
#define SWITCHES_I_CFS_IDX 0
// SW2
#define FUNCTION_SWITCH_2 SJ
#define SWITCHES_GPIO_REG_J GPIOG
#define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_6 // PG.06
#define SWITCHES_J_CFS_IDX 1
// SW3
#define FUNCTION_SWITCH_3 SK
#define SWITCHES_GPIO_REG_K GPIOG
#define SWITCHES_GPIO_PIN_K LL_GPIO_PIN_5 // PG.05
#define SWITCHES_K_CFS_IDX 2
// SW4
#define FUNCTION_SWITCH_4 SL
#define SWITCHES_GPIO_REG_L GPIOG
#define SWITCHES_GPIO_PIN_L LL_GPIO_PIN_4 // PG.04
#define SWITCHES_L_CFS_IDX 3
// SW5
#define FUNCTION_SWITCH_5 SM
#define SWITCHES_GPIO_REG_M GPIOG
#define SWITCHES_GPIO_PIN_M LL_GPIO_PIN_3 // PG.03
#define SWITCHES_M_CFS_IDX 4
// SW6
#define FUNCTION_SWITCH_6 SO
#define SWITCHES_GPIO_REG_O GPIOG
#define SWITCHES_GPIO_PIN_O LL_GPIO_PIN_2 // PG.02
#define FUNCTION_SWITCH_6 SN
#define SWITCHES_GPIO_REG_N GPIOG
#define SWITCHES_GPIO_PIN_N LL_GPIO_PIN_2 // PG.02
#define SWITCHES_N_CFS_IDX 5
#elif defined(RADIO_BUMBLEBEE)
// SW1
#define FUNCTION_SWITCH_1 SJ
#define SWITCHES_GPIO_REG_J GPIOE
#define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_15 // PE.15
#define SWITCHES_J_CFS_IDX 0
// SW2
#define FUNCTION_SWITCH_2 SK
#define SWITCHES_GPIO_REG_K GPIOE
#define SWITCHES_GPIO_PIN_K LL_GPIO_PIN_14 // PE.14
#define SWITCHES_K_CFS_IDX 1
// SW3
#define FUNCTION_SWITCH_3 SL
#define SWITCHES_GPIO_REG_L GPIOE
#define SWITCHES_GPIO_PIN_L LL_GPIO_PIN_13 // PE.13
#define SWITCHES_L_CFS_IDX 2
// SW4
#define FUNCTION_SWITCH_4 SM
#define SWITCHES_GPIO_REG_M GPIOE
#define SWITCHES_GPIO_PIN_M LL_GPIO_PIN_10 // PE.10
#define SWITCHES_M_CFS_IDX 3
// SW5
#define FUNCTION_SWITCH_5 SO
#define SWITCHES_GPIO_REG_O GPIOE
#define SWITCHES_GPIO_PIN_O LL_GPIO_PIN_8 // PE.08
#define SWITCHES_O_CFS_IDX 4
// SW6
#define FUNCTION_SWITCH_6 SP
#define SWITCHES_GPIO_REG_P GPIOE
#define SWITCHES_GPIO_PIN_P LL_GPIO_PIN_12 // PE.12
#define SWITCHES_P_CFS_IDX 5
#elif defined(RADIO_TPRO)
// SW3
#define FUNCTION_SWITCH_3 SI
#define SWITCHES_GPIO_REG_I GPIOG
#define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_5 // PG.05
#define SWITCHES_I_CFS_IDX 2
// SW4
#define FUNCTION_SWITCH_4 SJ
#define SWITCHES_GPIO_REG_J GPIOG
#define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_4 // PG.04
#define SWITCHES_J_CFS_IDX 3
// SW5
#define FUNCTION_SWITCH_5 SK
#define SWITCHES_GPIO_REG_K GPIOG
#define SWITCHES_GPIO_PIN_K LL_GPIO_PIN_3 // PG.03
#define SWITCHES_K_CFS_IDX 4
// SW6
#define FUNCTION_SWITCH_6 SL
#define SWITCHES_GPIO_REG_L GPIOG
#define SWITCHES_GPIO_PIN_L LL_GPIO_PIN_2 // PG.02
#define SWITCHES_L_CFS_IDX 5
#elif defined(RADIO_FAMILY_T20)
//TRIM left up
#define SWITCHES_GPIO_REG_I GPIOG
@@ -1230,41 +1274,65 @@
#define FUNCTION_SWITCH_1 SK
#define SWITCHES_GPIO_REG_K GPIOE
#define SWITCHES_GPIO_PIN_K LL_GPIO_PIN_10 // PE.10
#define SWITCHES_K_CFS_IDX 0
//SW2
#define FUNCTION_SWITCH_2 SL
#define SWITCHES_GPIO_REG_L GPIOE
#define SWITCHES_GPIO_PIN_L LL_GPIO_PIN_8 // PE.08
#define SWITCHES_L_CFS_IDX 1
//SW3
#define FUNCTION_SWITCH_3 SM
#define SWITCHES_GPIO_REG_M GPIOE
#define SWITCHES_GPIO_PIN_M LL_GPIO_PIN_12 // PE.12
#define SWITCHES_M_CFS_IDX 2
//SW4
#define FUNCTION_SWITCH_4 SN
#define SWITCHES_GPIO_REG_N GPIOE
#define SWITCHES_GPIO_PIN_N LL_GPIO_PIN_13 // PE.13
#define SWITCHES_N_CFS_IDX 3
//SW5
#define FUNCTION_SWITCH_5 SO
#define SWITCHES_GPIO_REG_O GPIOE
#define SWITCHES_GPIO_PIN_O LL_GPIO_PIN_14 // PE.14
#define SWITCHES_O_CFS_IDX 4
//SW6
#define FUNCTION_SWITCH_6 SP
#define SWITCHES_GPIO_REG_P GPIOE
#define SWITCHES_GPIO_PIN_P LL_GPIO_PIN_15 // PE.15
#define SWITCHES_P_CFS_IDX 5
#endif
#if defined(RADIO_GX12)
//SW1
#define FUNCTION_SWITCH_1
#define SWITCHES_GPIO_REG_I
#define SWITCHES_GPIO_PIN_I PCA95XX_PIN_0
#define SWITCHES_I_CFS_IDX 0
#define FUNCTION_SWITCH_1 SI
//SW2
#define FUNCTION_SWITCH_2
#define SWITCHES_GPIO_REG_J
#define SWITCHES_GPIO_PIN_J PCA95XX_PIN_1
#define SWITCHES_J_CFS_IDX 1
#define FUNCTION_SWITCH_2 SJ
//SW3
#define FUNCTION_SWITCH_3
#define SWITCHES_GPIO_REG_K
#define SWITCHES_GPIO_PIN_K PCA95XX_PIN_2
#define SWITCHES_K_CFS_IDX 2
#define FUNCTION_SWITCH_3 SK
//SW4
#define FUNCTION_SWITCH_4
#define SWITCHES_GPIO_REG_L
#define SWITCHES_GPIO_PIN_L PCA95XX_PIN_3
#define SWITCHES_L_CFS_IDX 3
#define FUNCTION_SWITCH_4 SL
//SW5
#define FUNCTION_SWITCH_5
#define SWITCHES_GPIO_REG_M
#define SWITCHES_GPIO_PIN_M PCA95XX_PIN_4
#define SWITCHES_M_CFS_IDX 4
#define FUNCTION_SWITCH_5 SM
//SW6
#define FUNCTION_SWITCH_6
#define SWITCHES_GPIO_REG_N
#define SWITCHES_GPIO_PIN_N PCA95XX_PIN_5
#define SWITCHES_N_CFS_IDX 5
#define FUNCTION_SWITCH_6 SN
#endif
#if defined(PCBX9E)
@@ -1979,9 +2047,15 @@
#if defined(RGBLEDS)
#if defined(RADIO_GX12)
#define LED_STRIP_LENGTH 8
#define RGB_LED_OFFSET 8
#define BLING_LED_STRIP_START 0
#define BLING_LED_STRIP_LENGTH 0
#define CFS_LED_STRIP_START 0
#define CFS_LED_STRIP_LENGTH 8
#define CFS_LEDS_PER_SWITCH 1
#else
#define LED_STRIP_LENGTH 7
#define BLING_LED_STRIP_START 0
#define BLING_LED_STRIP_LENGTH 7
#endif
#define LED_STRIP_GPIO GPIO_PIN(GPIOA, 8) // PA.08 / TIM1_CH1
#define LED_STRIP_GPIO_AF LL_GPIO_AF_1 // TIM1 / TIM2
@@ -1997,10 +2071,14 @@
#elif defined(RADIO_T14) || defined(RADIO_V14) || defined(RADIO_V12)
#if defined(RADIO_V14)
#define LED_STRIP_LENGTH 38
#define BLING_LED_STRIP_START 6
#define BLING_LED_STRIP_LENGTH 32
#elif defined(RADIO_V12)
#define LED_STRIP_LENGTH 6
#define LED_STRIP_LENGTH 6 // 6POS switches only?
#else
#define LED_STRIP_LENGTH 1
#define BLING_LED_STRIP_START 0
#define BLING_LED_STRIP_LENGTH 1
#endif
#define LED_STRIP_GPIO GPIO_PIN(GPIOA, 10) // PA.10 / TIM1_CH3
#define LED_STRIP_GPIO_AF LL_GPIO_AF_1
+2 -5
View File
@@ -60,18 +60,15 @@ void ledInit()
}
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
// used to map switch number to led number in the rgbled chain
uint8_t ledMapping[] = {0, 1, 2, 3, 4, 5, 6};
void fsLedRGB(uint8_t index, uint32_t color)
{
ws2812_set_color(ledMapping[index], GET_RED(color), GET_GREEN(color),
ws2812_set_color(index + CFS_LED_STRIP_START, GET_RED(color), GET_GREEN(color),
GET_BLUE(color));
}
uint32_t fsGetLedRGB(uint8_t index)
{
return rgbGetLedColor(ledMapping[index]);
return rgbGetLedColor(index + CFS_LED_STRIP_START);
}
uint8_t getRGBColorIndex(uint32_t color)
+27 -16
View File
@@ -21,7 +21,7 @@
#include "gtests.h"
class SpecialFunctionsTest : public OpenTxTest {};
class SpecialFunctionsTest : public EdgeTxTest {};
TEST_F(SpecialFunctionsTest, SwitchFiledSize)
{
@@ -38,22 +38,27 @@ TEST_F(SpecialFunctionsTest, SwitchFiledSize)
TEST_F(SpecialFunctionsTest, FlightReset)
{
g_model.customFn[0].swtch = SWSRC_FIRST_SWITCH;
int sw;
for (sw = 0; sw < switchGetMaxAllSwitches(); sw += 1)
if (g_model.getSwitchType(sw) == SWITCH_3POS)
break;
int swPos = (sw * 3) + SWSRC_FIRST_SWITCH;
g_model.customFn[0].swtch = swPos;
g_model.customFn[0].func = FUNC_RESET;
g_model.customFn[0].all.val = FUNC_RESET_FLIGHT;
g_model.customFn[0].active = true;
mainRequestFlags = 0;
simuSetSwitch(0, 0);
EXPECT_EQ(false, getSwitch(SWSRC_FIRST_SWITCH));
simuSetSwitch(sw, 0);
EXPECT_EQ(false, getSwitch(swPos));
evalFunctions(g_model.customFn, modelFunctionsContext);
EXPECT_EQ((bool)(mainRequestFlags & (1 << REQUEST_FLIGHT_RESET)), false);
// now trigger SA0
simuSetSwitch(0, -1);
EXPECT_EQ(true, getSwitch(SWSRC_FIRST_SWITCH));
simuSetSwitch(sw, -1);
EXPECT_EQ(true, getSwitch(swPos));
// flightReset() should be called
evalFunctions(g_model.customFn, modelFunctionsContext);
@@ -68,9 +73,15 @@ TEST_F(SpecialFunctionsTest, FlightReset)
#if defined(GVARS)
TEST_F(SpecialFunctionsTest, GvarsInc)
{
simuSetSwitch(0, 0); // SA-
int sw;
for (sw = 0; sw < switchGetMaxAllSwitches(); sw += 1)
if (g_model.getSwitchType(sw) == SWITCH_3POS)
break;
int swPos = (sw * 3) + SWSRC_FIRST_SWITCH;
g_model.customFn[0].swtch = SWSRC_FIRST_SWITCH;
simuSetSwitch(sw, 0); // SA-
g_model.customFn[0].swtch = swPos;
g_model.customFn[0].func = FUNC_ADJUST_GVAR;
g_model.customFn[0].all.mode = FUNC_ADJUST_GVAR_INCDEC;
g_model.customFn[0].all.param = 0; // GV1
@@ -82,39 +93,39 @@ TEST_F(SpecialFunctionsTest, GvarsInc)
EXPECT_EQ(g_model.flightModeData[0].gvars[0], 10);
// now trigger SA0
simuSetSwitch(0, -1); // SAdown
simuSetSwitch(sw, -1); // SAdown
evalFunctions(g_model.customFn, modelFunctionsContext);
EXPECT_EQ(g_model.flightModeData[0].gvars[0], 9);
evalFunctions(g_model.customFn, modelFunctionsContext);
EXPECT_EQ(g_model.flightModeData[0].gvars[0], 9);
simuSetSwitch(0, 0); // SA-
simuSetSwitch(sw, 0); // SA-
evalFunctions(g_model.customFn, modelFunctionsContext);
EXPECT_EQ(g_model.flightModeData[0].gvars[0], 9);
simuSetSwitch(0, -1); // SAdown
simuSetSwitch(sw, -1); // SAdown
evalFunctions(g_model.customFn, modelFunctionsContext);
EXPECT_EQ(g_model.flightModeData[0].gvars[0], 8);
evalFunctions(g_model.customFn, modelFunctionsContext);
EXPECT_EQ(g_model.flightModeData[0].gvars[0], 8);
simuSetSwitch(0, 0); // SA-
simuSetSwitch(sw, 0); // SA-
evalFunctions(g_model.customFn, modelFunctionsContext);
EXPECT_EQ(g_model.flightModeData[0].gvars[0], 8);
g_model.customFn[0].all.val = 10; // inc/dec value
simuSetSwitch(0, -1); // SAdown
simuSetSwitch(sw, -1); // SAdown
evalFunctions(g_model.customFn, modelFunctionsContext);
EXPECT_EQ(g_model.flightModeData[0].gvars[0], 18);
evalFunctions(g_model.customFn, modelFunctionsContext);
EXPECT_EQ(g_model.flightModeData[0].gvars[0], 18);
simuSetSwitch(0, 0); // SA-
simuSetSwitch(sw, 0); // SA-
evalFunctions(g_model.customFn, modelFunctionsContext);
EXPECT_EQ(g_model.flightModeData[0].gvars[0], 18);
simuSetSwitch(0, -1); // SAdown
simuSetSwitch(sw, -1); // SAdown
evalFunctions(g_model.customFn, modelFunctionsContext);
EXPECT_EQ(g_model.flightModeData[0].gvars[0], 28);
evalFunctions(g_model.customFn, modelFunctionsContext);
+8
View File
@@ -129,6 +129,14 @@ uint16_t simu_get_analog(uint8_t idx)
void simuQueueAudio(const uint8_t*, uint32_t) {}
void fsLedOn(uint8_t idx)
{
}
void fsLedOff(uint8_t idx)
{
}
static char _stringResult[200];
const char * nchar2string(const char * string, int size)
+22 -3
View File
@@ -44,8 +44,27 @@ extern const char * nchar2string(const char * string, int size);
#define EXPECT_ZSTREQ(c_string, z_string) EXPECT_STREQ(c_string, zchar2string(z_string, sizeof(z_string)))
#define EXPECT_STRNEQ(c_string, n_string) EXPECT_STREQ(c_string, nchar2string(n_string, sizeof(n_string)))
#if defined(RADIO_GX12)
#define RADIO_RESET() \
g_eeGeneral.switchConfig = 0x00007bff
g_eeGeneral.switchSetType(0, SWITCH_2POS); \
g_eeGeneral.switchSetType(1, SWITCH_3POS); \
g_eeGeneral.switchSetType(2, SWITCH_3POS); \
g_eeGeneral.switchSetType(3, SWITCH_2POS); \
g_eeGeneral.switchSetType(4, SWITCH_3POS); \
g_eeGeneral.switchSetType(5, SWITCH_2POS); \
g_eeGeneral.switchSetType(6, SWITCH_TOGGLE); \
g_eeGeneral.switchSetType(7, SWITCH_TOGGLE)
#else
#define RADIO_RESET() \
g_eeGeneral.switchSetType(0, SWITCH_3POS); \
g_eeGeneral.switchSetType(1, SWITCH_3POS); \
g_eeGeneral.switchSetType(2, SWITCH_3POS); \
g_eeGeneral.switchSetType(3, SWITCH_3POS); \
g_eeGeneral.switchSetType(4, SWITCH_3POS); \
g_eeGeneral.switchSetType(5, SWITCH_2POS); \
g_eeGeneral.switchSetType(6, SWITCH_3POS); \
g_eeGeneral.switchSetType(7, SWITCH_TOGGLE)
#endif
inline void SYSTEM_RESET()
{
@@ -54,7 +73,7 @@ inline void SYSTEM_RESET()
#endif
generalDefault();
g_eeGeneral.templateSetup = 0;
for (int i=0; i<switchGetMaxSwitches(); i++) {
for (int i=0; i<switchGetMaxAllSwitches(); i++) {
simuSetSwitch(i, -1);
}
}
@@ -91,7 +110,7 @@ inline void TELEMETRY_RESET()
memclear(g_model.telemetrySensors, sizeof(g_model.telemetrySensors));
}
class OpenTxTest : public testing::Test
class EdgeTxTest : public testing::Test
{
protected: // You should make the members protected s.t. they can be
// accessed from sub-classes.
+54 -34
View File
@@ -22,8 +22,8 @@
#include "gtests.h"
#include "hal/adc_driver.h"
class TrimsTest : public OpenTxTest {};
class MixerTest : public OpenTxTest {};
class TrimsTest : public EdgeTxTest {};
class MixerTest : public EdgeTxTest {};
#define CHECK_NO_MOVEMENT(channel, value, duration) \
for (int i=1; i<=(duration); i++) { \
@@ -660,7 +660,7 @@ TEST_F(MixerTest, RecursiveAddChannel)
TEST_F(MixerTest, RecursiveAddChannelAfterInactivePhase)
{
if (switchGetMaxSwitches() < 4) return;
if (switchGetMaxAllSwitches() < 4) return;
g_model.flightModeData[1].swtch = SWSRC_FIRST_SWITCH + 1;
g_model.mixData[0].destCh = 0;
@@ -711,22 +711,26 @@ TEST_F(MixerTest, SlowOnPhase)
TEST_F(MixerTest, SlowOnSwitchSource)
{
int sw;
for (sw = 0; sw < switchGetMaxAllSwitches(); sw += 1)
if (g_model.getSwitchType(sw) == SWITCH_3POS)
break;
if (sw >= switchGetMaxAllSwitches()) return;
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_eeGeneral.switchConfig = 0x03;
g_model.mixData[0].srcRaw = MIXSRC_FIRST_SWITCH;
int switchIndex = 0;
g_model.mixData[0].srcRaw = sw + MIXSRC_FIRST_SWITCH;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[0].speedUp = 50;
g_model.mixData[0].speedDown = 50;
s_mixer_first_run_done = true;
simuSetSwitch(switchIndex, -1);
simuSetSwitch(sw, -1);
CHECK_SLOW_MOVEMENT(0, -1, 250, 500);
EXPECT_EQ(chans[0], -CHANNEL_MAX);
simuSetSwitch(switchIndex, 1);
simuSetSwitch(sw, 1);
CHECK_SLOW_MOVEMENT(0, +1, 500, 500);
}
@@ -755,11 +759,15 @@ TEST_F(MixerTest, SlowOnPhasePrec10ms)
TEST_F(MixerTest, SlowOnSwitchSourcePrec10ms)
{
int sw;
for (sw = 0; sw < switchGetMaxAllSwitches(); sw += 1)
if (g_model.getSwitchType(sw) == SWITCH_3POS)
break;
if (sw >= switchGetMaxAllSwitches()) return;
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_eeGeneral.switchConfig = 0x03;
g_model.mixData[0].srcRaw = MIXSRC_FIRST_SWITCH;
int switchIndex = 0;
g_model.mixData[0].srcRaw = sw + MIXSRC_FIRST_SWITCH;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[0].speedUp = 50;
g_model.mixData[0].speedDown = 50;
@@ -767,11 +775,11 @@ TEST_F(MixerTest, SlowOnSwitchSourcePrec10ms)
s_mixer_first_run_done = true;
simuSetSwitch(switchIndex, -1);
simuSetSwitch(sw, -1);
CHECK_SLOW_MOVEMENT(0, -1, 25, 50);
EXPECT_EQ(chans[0], -CHANNEL_MAX);
simuSetSwitch(switchIndex, 1);
simuSetSwitch(sw, 1);
CHECK_SLOW_MOVEMENT(0, +1, 50, 50);
}
@@ -790,61 +798,66 @@ TEST_F(MixerTest, SlowDisabledOnStartup)
TEST_F(MixerTest, DelayOnSwitch)
{
int sw;
for (sw = 0; sw < switchGetMaxAllSwitches(); sw += 1)
if (g_model.getSwitchType(sw) == SWITCH_3POS)
break;
if (sw >= switchGetMaxAllSwitches()) return;
int swPos = (sw * 3) + SWSRC_FIRST_SWITCH + 2;
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_MAX;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[0].swtch = SWSRC_FIRST_SWITCH + 2;
g_model.mixData[0].swtch = swPos;
g_model.mixData[0].delayUp = 50;
g_model.mixData[0].delayDown = 50;
int switch_index = 0;
simuSetSwitch(switch_index, -1);
simuSetSwitch(sw, -1);
evalFlightModeMixes(e_perout_mode_normal, 0);
EXPECT_EQ(chans[0], 0);
simuSetSwitch(switch_index, 1);
simuSetSwitch(sw, 1);
CHECK_DELAY(0, 500);
evalFlightModeMixes(e_perout_mode_normal, 1);
EXPECT_EQ(chans[0], CHANNEL_MAX);
auto sw_cfg = (SwitchConfig)SWITCH_CONFIG(switch_index);
if (sw_cfg == SWITCH_3POS) {
simuSetSwitch(switch_index, 0);
CHECK_DELAY(0, 500);
simuSetSwitch(sw, 0);
CHECK_DELAY(0, 500);
evalFlightModeMixes(e_perout_mode_normal, 1);
EXPECT_EQ(chans[0], 0);
}
evalFlightModeMixes(e_perout_mode_normal, 1);
EXPECT_EQ(chans[0], 0);
}
TEST_F(MixerTest, DelayOnSwitch2)
{
g_eeGeneral.switchConfig = SWITCH_3POS;
int sw;
for (sw = 0; sw < switchGetMaxAllSwitches(); sw += 1)
if (g_model.getSwitchType(sw) == SWITCH_3POS)
break;
if (sw >= switchGetMaxAllSwitches()) return;
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_FIRST_SWITCH;
g_model.mixData[0].srcRaw = sw + MIXSRC_FIRST_SWITCH;
g_model.mixData[0].weight = makeSourceNumVal(100);
// g_model.mixData[0].swtch = SWSRC_ON;
g_model.mixData[0].delayUp = 50;
g_model.mixData[0].delayDown = 50;
int switch_index = 0;
simuSetSwitch(switch_index, -1);
simuSetSwitch(sw, -1);
evalFlightModeMixes(e_perout_mode_normal, 0);
EXPECT_EQ(chans[0], 0);
simuSetSwitch(switch_index, 1);
simuSetSwitch(sw, 1);
CHECK_DELAY(0, 500);
evalFlightModeMixes(e_perout_mode_normal, 1);
EXPECT_EQ(chans[0], CHANNEL_MAX);
simuSetSwitch(switch_index, 0);
simuSetSwitch(sw, 0);
CHECK_DELAY(0, 500);
evalFlightModeMixes(e_perout_mode_normal, 1);
@@ -1018,11 +1031,18 @@ TEST(Trainer, UnpluggedTest)
TEST_F(MixerTest, flightModeTransition)
{
int sw;
for (sw = 0; sw < switchGetMaxAllSwitches(); sw += 1)
if (g_model.getSwitchType(sw) == SWITCH_3POS)
break;
if (sw >= switchGetMaxAllSwitches()) return;
int swPos = (sw * 3) + SWSRC_FIRST_SWITCH + 2;
SYSTEM_RESET();
MODEL_RESET();
MIXER_RESET();
setModelDefaults();
g_model.flightModeData[1].swtch = SWSRC_FIRST_SWITCH + 2;
g_model.flightModeData[1].swtch = swPos;
g_model.flightModeData[0].fadeIn = 100;
g_model.flightModeData[0].fadeOut = 100;
g_model.flightModeData[1].fadeIn = 100;
@@ -1038,7 +1058,7 @@ TEST_F(MixerTest, flightModeTransition)
g_model.mixData[1].flightModes = 0b11101;
g_model.mixData[1].weight = makeSourceNumVal(-10);
evalMixes(1);
simuSetSwitch(0, 1);
simuSetSwitch(sw, 1);
CHECK_FLIGHT_MODE_TRANSITION(0, 1000, 1024, -102);
}
+72 -58
View File
@@ -47,22 +47,28 @@ TEST(getSwitch, OldTypeStickyCSW)
MODEL_RESET();
MIXER_RESET();
setLogicalSwitch(0, LS_FUNC_AND, SWSRC_FIRST_SWITCH, SWSRC_NONE);
int sw;
for (sw = 0; sw < switchGetMaxAllSwitches(); sw += 1)
if (g_model.getSwitchType(sw) == SWITCH_3POS)
break;
int swPos = (sw * 3) + SWSRC_FIRST_SWITCH;
setLogicalSwitch(0, LS_FUNC_AND, swPos, SWSRC_NONE);
setLogicalSwitch(1, LS_FUNC_OR, SWSRC_SW1, SWSRC_SW2);
simuSetSwitch(0, 0);
simuSetSwitch(sw, 0);
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
// now trigger SA0, both switches should become true
simuSetSwitch(0, -1);
simuSetSwitch(sw, -1);
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
EXPECT_EQ(getSwitch(SWSRC_SW2), true);
// now release SA0 and SW2 should stay true
simuSetSwitch(0, 0);
simuSetSwitch(sw, 0);
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
EXPECT_EQ(getSwitch(SWSRC_SW2), true);
@@ -135,38 +141,41 @@ TEST(evalLogicalSwitches, playFile)
#undef MODELNAME
}
#define SWSRC_SA2 (SWSRC_FIRST_SWITCH + 2)
#define SWSRC_SD2 (SWSRC_FIRST_SWITCH + 3 * 3 + 2)
TEST(getSwitch, edgeInstant)
{
if (switchGetMaxSwitches() < 6) return;
int sw1, sw2;
for (sw1 = 0; sw1 < switchGetMaxAllSwitches(); sw1 += 1)
if (g_model.getSwitchType(sw1) == SWITCH_3POS)
break;
for (sw2 = sw1 + 1; sw2 < switchGetMaxAllSwitches(); sw2 += 1)
if (g_model.getSwitchType(sw2) == SWITCH_3POS)
break;
int sw1Pos = (sw1 * 3) + SWSRC_FIRST_SWITCH;
int sw2Pos = (sw2 * 3) + SWSRC_FIRST_SWITCH;
MODEL_RESET();
MIXER_RESET();
// LS1 setup: EDGE SDup (0:instant)
// LS2 setup: (EDGE SDup (0:instant)) AND SAup
setLogicalSwitch(0, LS_FUNC_EDGE, SWSRC_SD2, -129, -1);
setLogicalSwitch(1, LS_FUNC_EDGE, SWSRC_SD2, -129, -1, 0, 0, SWSRC_SA2);
// LS1 setup: EDGE SD down (0:instant)
// LS2 setup: (EDGE SD down (0:instant)) AND SA down
setLogicalSwitch(0, LS_FUNC_EDGE, sw2Pos + 2, -129, -1);
setLogicalSwitch(1, LS_FUNC_EDGE, sw2Pos + 2, -129, -1, 0, 0, sw1Pos + 2);
simuSetSwitch(0, -1); //SA down
simuSetSwitch(3, 0); //SD down
// EXPECT_EQ(getSwitch(SWSRC_SD2), false);
simuSetSwitch(sw1, -1); //SA up
simuSetSwitch(sw2, 0); //SD mid
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
// now trigger SFup, LS1 should become true
simuSetSwitch(3, 1); //SD up
// EXPECT_EQ(getSwitch(SWSRC_SD2), true);
// now trigger SD donw, LS1 should become true
simuSetSwitch(sw2, 1); //SD down
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
// now release SA0 and SW2 should stay true
simuSetSwitch(3, 0); //SD down
// now release SD and LS1 should become false
simuSetSwitch(sw2, 0); //SD mid
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
@@ -179,27 +188,24 @@ TEST(getSwitch, edgeInstant)
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
// second part with SA down
// second part with SAup
simuSetSwitch(0, 1); //SA up
simuSetSwitch(3, 0); //SD down
// EXPECT_EQ(getSwitch(SWSRC_SD2), false);
simuSetSwitch(sw1, 1); //SA down
simuSetSwitch(sw2, 0); //SD mid
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
// now trigger SFup, LS1 should become true
simuSetSwitch(3, 1); //SD up
// EXPECT_EQ(getSwitch(SWSRC_SD2), true);
// now trigger SD down, LS1 & LS2 should become true
simuSetSwitch(sw2, 1); //SD down
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
EXPECT_EQ(getSwitch(SWSRC_SW2), true);
// now release SA0 and SW2 should stay true
simuSetSwitch(3, 0); //SD down
// now release SA and LS1 & LS2 should stay false
simuSetSwitch(sw2, 0); //SD mid
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
@@ -213,23 +219,23 @@ TEST(getSwitch, edgeInstant)
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
// now bug #2939
// SD is kept up and SA is toggled
simuSetSwitch(0, -1); //SA down
simuSetSwitch(3, 1); //SD up
// SD is kept down and SA is toggled
simuSetSwitch(sw1, -1); //SA up
simuSetSwitch(sw2, 1); //SD down
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
simuSetSwitch(0, 1); //SA up
simuSetSwitch(3, 1); //SD up
simuSetSwitch(sw1, 1); //SA down
simuSetSwitch(sw2, 1); //SD down
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
simuSetSwitch(0, -1); //SA down
simuSetSwitch(3, 1); //SD up
simuSetSwitch(sw1, -1); //SA up
simuSetSwitch(sw2, 1); //SD down
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
@@ -238,8 +244,8 @@ TEST(getSwitch, edgeInstant)
//test what happens when EDGE condition is true and
//logical switches are reset - the switch should fire again
simuSetSwitch(0, 1); //SA up
simuSetSwitch(3, 1); //SD up
simuSetSwitch(sw1, 1); //SA down
simuSetSwitch(sw2, 1); //SD down
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false); //switch will not trigger, because SF was already up
@@ -259,30 +265,38 @@ TEST(getSwitch, edgeInstant)
TEST(getSwitch, edgeRelease)
{
if (switchGetMaxSwitches() < 6) return;
int sw1, sw2;
for (sw1 = 0; sw1 < switchGetMaxAllSwitches(); sw1 += 1)
if (g_model.getSwitchType(sw1) == SWITCH_3POS)
break;
for (sw2 = sw1 + 1; sw2 < switchGetMaxAllSwitches(); sw2 += 1)
if (g_model.getSwitchType(sw2) == SWITCH_3POS)
break;
int sw1Pos = (sw1 * 3) + SWSRC_FIRST_SWITCH;
int sw2Pos = (sw2 * 3) + SWSRC_FIRST_SWITCH;
MODEL_RESET();
MIXER_RESET();
// test for issue #2728
// LS1 setup: EDGE SDup (0:release)
// LS2 setup: (EDGE SDup (0:release)) AND SAup
setLogicalSwitch(0, LS_FUNC_EDGE, SWSRC_SD2, -129, 0);
setLogicalSwitch(1, LS_FUNC_EDGE, SWSRC_SD2, -129, 0, 0, 0, SWSRC_SA2 );
setLogicalSwitch(0, LS_FUNC_EDGE, sw2Pos + 2, -129, 0);
setLogicalSwitch(1, LS_FUNC_EDGE, sw2Pos + 2, -129, 0, 0, 0, sw1Pos + 2 );
simuSetSwitch(0, -1); //SA down
simuSetSwitch(3, 0); //SD down
simuSetSwitch(sw1, -1); //SA down
simuSetSwitch(sw2, 0); //SD down
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
simuSetSwitch(3, 1); //SD up
simuSetSwitch(sw2, 1); //SD up
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
simuSetSwitch(3, 0); //SD down
simuSetSwitch(sw2, 0); //SD down
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
@@ -290,20 +304,20 @@ TEST(getSwitch, edgeRelease)
// second part with SAup
simuSetSwitch(0, 1); //SA up
simuSetSwitch(3, 0); //SD down
simuSetSwitch(sw1, 1); //SA up
simuSetSwitch(sw2, 0); //SD down
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
simuSetSwitch(3, 1); //SD up
simuSetSwitch(sw2, 1); //SD up
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
simuSetSwitch(3, 0); //SD down
simuSetSwitch(sw2, 0); //SD down
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
@@ -327,7 +341,7 @@ TEST(FlexSwitches, switchGetPosition)
switchInit();
auto sw_idx = boardGetMaxSwitches();
auto sw_name = switchGetName(sw_idx);
auto sw_name = switchGetDefaultName(sw_idx);
EXPECT_STREQ("FL1", sw_name);
EXPECT_FALSE(switchIsFlexValid(sw_idx));
@@ -358,8 +372,8 @@ TEST(FlexSwitches, getValue)
auto sw_idx = boardGetMaxSwitches();
switchConfigFlex(sw_idx, 0);
g_eeGeneral.switchConfig = (swconfig_t)SWITCH_3POS << (sw_idx * SW_CFG_BITS);
EXPECT_EQ(SWITCH_3POS, SWITCH_CONFIG(sw_idx));
g_eeGeneral.switchSetType(sw_idx, SWITCH_3POS);
EXPECT_EQ(SWITCH_3POS, g_model.getSwitchType(sw_idx));
auto offset = adcGetInputOffset(ADC_INPUT_FLEX);
anaSetFiltered(offset, -1024);
@@ -371,8 +385,8 @@ TEST(FlexSwitches, getValue)
anaSetFiltered(offset, +1024);
EXPECT_EQ(+1024, getValue(MIXSRC_FIRST_SWITCH + sw_idx));
g_eeGeneral.switchConfig = (swconfig_t)SWITCH_2POS << (sw_idx * SW_CFG_BITS);
EXPECT_EQ(SWITCH_2POS, SWITCH_CONFIG(sw_idx));
g_eeGeneral.switchSetType(sw_idx, SWITCH_2POS);
EXPECT_EQ(SWITCH_2POS, g_model.getSwitchType(sw_idx));
anaSetFiltered(offset, -1024);
EXPECT_EQ(-1024, getValue(MIXSRC_FIRST_SWITCH + sw_idx));
@@ -395,8 +409,8 @@ TEST(FlexSwitches, getSwitch)
auto sw_idx = boardGetMaxSwitches();
switchConfigFlex(sw_idx, 0);
g_eeGeneral.switchConfig = (swconfig_t)SWITCH_3POS << (sw_idx * SW_CFG_BITS);
EXPECT_EQ(SWITCH_3POS, SWITCH_CONFIG(sw_idx));
g_eeGeneral.switchSetType(sw_idx, SWITCH_3POS);
EXPECT_EQ(SWITCH_3POS, g_model.getSwitchType(sw_idx));
auto offset = adcGetInputOffset(ADC_INPUT_FLEX);
anaSetFiltered(offset, -1024);
+1 -2
View File
@@ -170,8 +170,7 @@ const char STR_MS[] = TR_MS;
const char STR_SWITCH[] = TR_SWITCH;
#if defined(FUNCTION_SWITCHES)
const char STR_GROUPS[] = TR_GROUPS;
const char STR_FS_ON_COLOR[] = TR_FS_ON_COLOR;
const char STR_FS_OFF_COLOR[] = TR_FS_OFF_COLOR;
const char STR_LUA_OVERRIDE[] = TR_LUA_OVERRIDE;
const char STR_LAST[] = TR_LAST;
const char STR_MORE_INFO[] = TR_MORE_INFO;
const char STR_SWITCH_TYPE[] = TR_SWITCH_TYPE;
+1 -2
View File
@@ -295,8 +295,7 @@ extern const char STR_MS[];
extern const char STR_SWITCH[];
extern const char STR_FUNCTION_SWITCHES[];
extern const char STR_GROUP[];
extern const char STR_FS_ON_COLOR[];
extern const char STR_FS_OFF_COLOR[];
extern const char STR_LUA_OVERRIDE[];
extern const char* const STR_FS_COLOR_LIST[];
extern const char STR_GROUP_ALWAYS_ON[];
extern const char STR_GROUPS[];
+5 -2
View File
@@ -50,7 +50,11 @@
#define TR_TRNCHN "CH1","CH2","CH3","CH4"
#define TR_AUX_SERIAL_MODES "调试","回传镜像","回传输入","SBUS教练","LUA脚本","CLI","GPS","Debug","SpaceMouse","外置发射"
#if defined(FUNCTION_SWITCHES)
#define TR_SWTYPES "无","回弹","2段","3段","全局"
#else
#define TR_SWTYPES "无","回弹","2段","3段"
#endif
#define TR_POTTYPES "无","无中点旋钮",TR("中点旋钮","有中点旋钮"),"侧滑块",TR("多段","多段按键"),"X 轴","Y 轴","开关"
#define TR_VPERSISTENT "禁用","随飞行记录复位","随手动复位"
#define TR_COUNTRY_CODES "美国","日本","欧洲"
@@ -289,8 +293,7 @@
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_FS_ON_COLOR TR("ON:","ON Color")
#define TR_FS_OFF_COLOR TR("OFF:","OFF Color")
#define TR_LUA_OVERRIDE "Allow Lua override"
#define TR_GROUPS "Always on groups"
#define TR_LAST "Last"
#define TR_MORE_INFO "More info"

Some files were not shown because too many files have changed in this diff Show More