diff --git a/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp b/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp index 4975a207b..22d59f191 100644 --- a/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp +++ b/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp @@ -142,6 +142,7 @@ Node convert::encode(const CustomFunctionData& rhs) } node["func"] = LookupValue(customFnLut, fn); + bool add_comma = true; std::string def; switch(fn) { case FuncOverrideCH1: @@ -202,16 +203,17 @@ Node convert::encode(const CustomFunctionData& rhs) def += std::to_string(rhs.param); break; default: + add_comma = false; break; } if (fnHasEnable(rhs.func)) { - if (!def.empty()) { + if (add_comma) { def += ","; } def += std::to_string((int)rhs.enabled); } else if(fnHasRepeat(rhs.func)) { - if (!def.empty()) { + if (add_comma) { def += ","; } if (rhs.repeatParam == 0) { @@ -352,7 +354,9 @@ bool convert::decode(const Node& node, } else if (repeat == "!1x") { rhs.repeatParam = -1; } else { - rhs.repeatParam = std::stoi(repeat); + try { + rhs.repeatParam = std::stoi(repeat); + } catch(...) {} } }