diff --git a/companion/src/firmwares/boardjson.cpp b/companion/src/firmwares/boardjson.cpp index 2b946d2c826..a4ed2dad968 100644 --- a/companion/src/firmwares/boardjson.cpp +++ b/companion/src/firmwares/boardjson.cpp @@ -126,6 +126,30 @@ void BoardJson::afterLoadFixups(Board::Type board, InputsTable * inputs, Switche switches->insert(switches->end(), defn); } } + + // Function switches names are not in the json file and are relative to last real switch name + std::string lastswitch; + + for (const auto &swtch : *switches) { + if (isSwitchStd(swtch) && lastswitch < swtch.name) + lastswitch = swtch.name; + } + + if (lastswitch.size() == 2) { + const std::string prfx = lastswitch.substr(0, 1); + char lastsw[1]; + lastswitch.copy(lastsw, 1, 1); + + for (auto &swtch : *switches) { + if (isSwitchFunc(swtch)) { + swtch.name = prfx; + char fsnum[1]; + swtch.tag.copy(fsnum, 1, swtch.tag.size() - 1); + char swnum = lastsw[0] + fsnum[0] - '0'; + swtch.name += std::string(1, swnum); + } + } + } } // called from Boards::getCapability if no capability match diff --git a/companion/src/firmwares/edgetx/yaml_rawswitch.cpp b/companion/src/firmwares/edgetx/yaml_rawswitch.cpp index d3b4cf5077d..fc261a3f336 100644 --- a/companion/src/firmwares/edgetx/yaml_rawswitch.cpp +++ b/companion/src/firmwares/edgetx/yaml_rawswitch.cpp @@ -157,9 +157,8 @@ RawSwitch YamlRawSwitchDecode(const std::string& sw_str) rhs.index = tsw_idx + 1; } - } else if ((val_len >= 4 && ( - (val[0] == 'F' && val[1] == 'L') || - (val[0] == 'S' && val[1] == 'W')) && + } else if ((val_len >= 4 && + val[0] == 'F' && val[1] == 'L' && val[2] >= '1' && val[2] <= '9' && val[val_len - 1] >= '0' && val[val_len - 1] <= '2') || (val_len >= 3 && val[0] == 'S' && @@ -169,6 +168,14 @@ RawSwitch YamlRawSwitchDecode(const std::string& sw_str) int sw_idx = Boards::getSwitchYamlIndex(sw_str_tmp.substr(0, val_len - 1).c_str(), BoardJson::YLT_REF); if (sw_idx >= 0) { rhs.type = SWITCH_TYPE_SWITCH; + + if (modelSettingsVersion < SemanticVersion(QString(CPN_ADC_REFACTOR_VERSION))) { + if (IS_JUMPER_TPRO(board) && sw_idx >= 4) { + // added support for real switches SE & SF so need to shift function switches + sw_idx += 2; + } + } + rhs.index = sw_idx * 3 + (val[val_len - 1] - '0' + 1); } diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 6059f2c6789..68449a89a30 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -1263,7 +1263,7 @@ FunctionSwitchesPanel::FunctionSwitchesPanel(QWidget * parent, ModelData & model for (int i = 0; i < switchcnt; i++) { QLabel * lblSwitchId = new QLabel(this); - lblSwitchId->setText(tr("SW%1").arg(i + 1)); + lblSwitchId->setText(Boards::getSwitchName(Boards::getSwitchIndex(QString("SW%1").arg(i + 1), Board::LVT_TAG))); AutoLineEdit * aleName = new AutoLineEdit(this); aleName->setProperty("index", i);