Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle older model files in companion.
Browse files Browse the repository at this point in the history
philmoz authored and pfeerick committed Nov 12, 2023
1 parent f5b4d07 commit 32c4733
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp
Original file line number Diff line number Diff line change
@@ -376,16 +376,27 @@ bool convert<CustomFunctionData>::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") {

0 comments on commit 32c4733

Please sign in to comment.