From d97afb6f8ed6d95e3734dca313a88c3e6803ea6c Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Fri, 7 Jan 2022 01:31:37 +0100 Subject: [PATCH] Fix switch indexes (#1362) Resolves #1353 --- companion/src/firmwares/edgetx/yaml_rawsource.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_rawsource.cpp b/companion/src/firmwares/edgetx/yaml_rawsource.cpp index 4d8e98cfd..2e32bcf3c 100644 --- a/companion/src/firmwares/edgetx/yaml_rawsource.cpp +++ b/companion/src/firmwares/edgetx/yaml_rawsource.cpp @@ -45,8 +45,7 @@ std::string YamlRawSourceEncode(const RawSource& rhs) src_str += "MAX"; break; case SOURCE_TYPE_SWITCH: - src_str += "S"; - src_str += (rhs.index + 'A'); + src_str += getCurrentFirmware()->getSwitchesTag(rhs.index); break; case SOURCE_TYPE_CUSTOM_SWITCH: src_str += "ls("; @@ -114,8 +113,8 @@ RawSource YamlRawSourceDecode(const std::string& src_str) && val[1] >= 'A' && val[1] <= 'Z') { - int idx = val[1] - 'A'; - if (idx < CPN_MAX_SWITCHES) + int idx = getCurrentFirmware()->getSwitchesIndex(src_str.c_str()); + if (idx >= 0 && idx < CPN_MAX_SWITCHES) rhs = RawSource(SOURCE_TYPE_SWITCH, idx); } else if (val_len > 4 &&