Skip to content

Commit

Permalink
fix(cpn): correctly map T-Pro customizable switches (#4902)
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Horne authored Apr 25, 2024
1 parent 4f0d168 commit 55944ab
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion companion/src/firmwares/edgetx/yaml_rawswitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 55944ab

Please sign in to comment.