From 2a509187dd550f16121a469475ce714e21b5edf0 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Fri, 7 Jan 2022 23:57:41 +0100 Subject: [PATCH] Fix 6POS switch (de-)serialization (#1367) --- companion/src/firmwares/edgetx/yaml_rawswitch.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_rawswitch.cpp b/companion/src/firmwares/edgetx/yaml_rawswitch.cpp index 34ae49321..46d3d15ca 100644 --- a/companion/src/firmwares/edgetx/yaml_rawswitch.cpp +++ b/companion/src/firmwares/edgetx/yaml_rawswitch.cpp @@ -45,8 +45,8 @@ std::string YamlRawSwitchEncode(const RawSwitch& rhs) case SWITCH_TYPE_MULTIPOS_POT: sw_str += "6P"; - sw_str += std::to_string(sval / multiposcnt); - sw_str += std::to_string(sval % multiposcnt); + sw_str += std::to_string((sval - 1) / multiposcnt); + sw_str += std::to_string((sval - 1) % multiposcnt); break; case SWITCH_TYPE_TRIM: @@ -111,7 +111,7 @@ RawSwitch YamlRawSwitchDecode(const std::string& sw_str) (val[3] >= '0' && val[3] < (multiposcnt + '0'))) { rhs = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, - (val[2] - '0') * multiposcnt + (val[3] - '0')); + (val[2] - '0') * multiposcnt + (val[3] - '0') + 1); } else if (val_len == 3 && val[0] == 'F' && val[1] == 'M' && (val[2] >= '0' && val[2] <= '9')) {