From 55944ab92d87156d8d4506c04c24427fc82021e8 Mon Sep 17 00:00:00 2001 From: Neil Horne Date: Thu, 25 Apr 2024 11:21:55 +1000 Subject: [PATCH] fix(cpn): correctly map T-Pro customizable switches (#4902) --- .../src/firmwares/edgetx/yaml_rawswitch.cpp | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/companion/src/firmwares/edgetx/yaml_rawswitch.cpp b/companion/src/firmwares/edgetx/yaml_rawswitch.cpp index d3b4cf5077d..ec4cade4c88 100644 --- a/companion/src/firmwares/edgetx/yaml_rawswitch.cpp +++ b/companion/src/firmwares/edgetx/yaml_rawswitch.cpp @@ -22,6 +22,20 @@ #include "eeprominterface.h" #include "boardjson.h" +// v2.10, v2.9 +static const StringTagMappingTable funcSwitchConversionTable = { + {"SA", "SA"}, + {"SB", "SB"}, + {"SC", "SC"}, + {"SD", "SD"}, + {"SW1", "SE"}, + {"SW2", "SF"}, + {"SW3", "SG"}, + {"SW4", "SH"}, + {"SW5", "SI"}, + {"SW6", "SJ"}, +}; + std::string YamlRawSwitchEncode(const RawSwitch& rhs) { Board::Type board = getCurrentBoard(); @@ -166,7 +180,12 @@ RawSwitch YamlRawSwitchDecode(const std::string& sw_str) val[1] >= 'A' && val[1] <= 'Z' && val[2] >= '0' && val[2] <= '2')) { - int sw_idx = Boards::getSwitchYamlIndex(sw_str_tmp.substr(0, val_len - 1).c_str(), BoardJson::YLT_REF); + std::string tmp = sw_str_tmp.substr(0, val_len - 1); + + if (modelSettingsVersion < SemanticVersion(QString(CPN_ADC_REFACTOR_VERSION)) && IS_JUMPER_TPRO(board)) + tmp = DataHelpers::getStringTagMappingName(funcSwitchConversionTable, tmp.c_str()); + + int sw_idx = Boards::getSwitchYamlIndex(tmp.c_str(), BoardJson::YLT_REF); if (sw_idx >= 0) { rhs.type = SWITCH_TYPE_SWITCH; rhs.index = sw_idx * 3 + (val[val_len - 1] - '0' + 1);