From cdd933d6e12133bff104e4da6aab10bbf1527c5d Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 16 Jan 2022 11:46:55 +0100 Subject: [PATCH] Fix shift for logical switches in raw sources Resolves #1439 --- companion/src/firmwares/edgetx/yaml_rawsource.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_rawsource.cpp b/companion/src/firmwares/edgetx/yaml_rawsource.cpp index 89b6df13a..d9bbbbfef 100644 --- a/companion/src/firmwares/edgetx/yaml_rawsource.cpp +++ b/companion/src/firmwares/edgetx/yaml_rawsource.cpp @@ -49,7 +49,7 @@ std::string YamlRawSourceEncode(const RawSource& rhs) break; case SOURCE_TYPE_CUSTOM_SWITCH: src_str += "ls("; - src_str += std::to_string(rhs.index); + src_str += std::to_string(rhs.index + 1); src_str += ")"; break; case SOURCE_TYPE_CYC: @@ -139,8 +139,8 @@ RawSource YamlRawSourceDecode(const std::string& src_str) std::stringstream src(src_str.substr(3)); int ls = 0; src >> ls; - if (ls < CPN_MAX_LOGICAL_SWITCHES) - rhs = RawSource(SOURCE_TYPE_CUSTOM_SWITCH, ls); + if (ls > 0 && ls < CPN_MAX_LOGICAL_SWITCHES) + rhs = RawSource(SOURCE_TYPE_CUSTOM_SWITCH, ls - 1); } else if (val_len > 3 && val[0] == 't' &&