feat: stick inversion (#6394)

Co-authored-by: philmoz <phil.a.mitchell@gmail.com>
This commit is contained in:
3djc
2025-07-25 13:02:16 +10:00
committed by GitHub
co-authored by philmoz
parent d3263df782
commit 6bb65dfa9c
55 changed files with 388 additions and 208 deletions
@@ -338,6 +338,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -355,6 +355,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -774,16 +774,34 @@ static bool w_stick_name(void* user, uint8_t* data, uint32_t bitoffs,
return _write_analog_name(ADC_INPUT_MAIN, user, data, bitoffs, wf, opaque);
}
static void r_stick_inv(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
{
auto tw = reinterpret_cast<YamlTreeWalker*>(user);
uint16_t idx = tw->getElmts(1);
setStickInversion(idx, val[0] != '0');
}
static bool w_stick_inv(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);
return wf(opaque, getStickInversion(idx) ? "1" : "0", 1);
}
static bool stick_name_valid(void* user, uint8_t* data, uint32_t bitoffs)
{
auto tw = reinterpret_cast<YamlTreeWalker*>(user);
uint16_t idx = tw->getElmts();
if (getStickInversion(idx)) return true;
return analogHasCustomLabel(ADC_INPUT_MAIN, idx);
}
static const struct YamlNode struct_stickConfig[] = {
YAML_IDX,
YAML_CUSTOM( "name", r_stick_name, w_stick_name),
YAML_CUSTOM("inv", r_stick_inv, w_stick_inv),
YAML_END
};
@@ -339,6 +339,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -348,6 +348,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -355,6 +355,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -355,6 +355,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -348,6 +348,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -355,6 +355,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -355,6 +355,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -339,6 +339,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -339,6 +339,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -354,6 +354,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -338,6 +338,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -338,6 +338,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -338,6 +338,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -338,6 +338,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),
@@ -340,6 +340,7 @@ static const struct YamlNode struct_RadioData[] = {
YAML_ARRAY("serialPort", 8, 4, struct_serialConfig, nullptr),
YAML_ARRAY("sticksConfig", 0, MAX_STICKS, struct_stickConfig, stick_name_valid),
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("flexSwitches", 0, MAX_FLEX_SWITCHES, struct_flexSwitch, flex_sw_valid),