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:
co-authored by
philmoz
3djc
elecpower
parent
28833f42e6
commit
0c8c39b134
@@ -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[] = {
|
||||
|
||||
Reference in New Issue
Block a user