diff --git a/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp b/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp index e35ba46fd6b..87f4ec1f931 100644 --- a/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp +++ b/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp @@ -376,16 +376,27 @@ bool convert::decode(const Node& node, def.ignore(); } - int en = 0; - def >> en; - rhs.enabled = en; + // Need to handle older YAML files where only one of enabled/repeat was present + std::string en, repeat; + getline(def, en, ','); + getline(def, repeat); - if(fnHasRepeat(rhs.func)) { - if (def.peek() == ',') { - def.ignore(); + if (repeat.empty()) { + // Only one value left to parse + if (fnHasRepeat(rhs.func)) { + // Assume it is repeat and set enabled to true + repeat = en; + rhs.enabled = 1; + } else { + // Func does not have repeat + rhs.enabled = en[0] == '1' ? 1 : 0; } - std::string repeat; - getline(def, repeat); + } else { + // Two values - first is 'enabled' flag + rhs.enabled = en[0] == '1' ? 1 : 0; + } + + if(fnHasRepeat(rhs.func)) { if (rhs.func == FuncPlayScript || rhs.func == FuncRGBLed) { rhs.repeatParam = (repeat == "1x") ? 1 : 0; } else if (repeat == "1x") {