From e94730afc4625c129543732978ee1f3215c4fcd1 Mon Sep 17 00:00:00 2001 From: Neil Horne Date: Sun, 6 Feb 2022 12:22:07 +1100 Subject: [PATCH] fix: Companion not correctly reading/writing trainer settings (#1560) --- .../src/firmwares/edgetx/yaml_modeldata.cpp | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_modeldata.cpp b/companion/src/firmwares/edgetx/yaml_modeldata.cpp index 36562c88d..11b6d09f9 100644 --- a/companion/src/firmwares/edgetx/yaml_modeldata.cpp +++ b/companion/src/firmwares/edgetx/yaml_modeldata.cpp @@ -873,7 +873,6 @@ Node convert::encode(const ModelData& rhs) } node["rssiAlarms"] = rhs.rssiAlarms; - node["trainerMode"] = trainerModeLut << rhs.trainerMode; for (int i=0; i::encode(const ModelData& rhs) } } + node["trainerData"]["mode"] = trainerModeLut << rhs.trainerMode; + node["trainerData"]["channelsStart"] = rhs.moduleData[2].channelsStart; + node["trainerData"]["channelsCount"] = (rhs.moduleData[2].channelsCount - 8); + node["trainerData"]["frameLength"] = rhs.moduleData[2].ppm.frameLength; + node["trainerData"]["delay"] = ((rhs.moduleData[2].ppm.delay - 300) / 50); + node["trainerData"]["pulsePol"] = (int)rhs.moduleData[2].ppm.pulsePol; + for (int i=0; i 0) { node["scriptData"][std::to_string(i)] = rhs.scriptData[i]; @@ -1057,7 +1063,6 @@ bool convert::decode(const Node& node, ModelData& rhs) } node["rssiAlarms"] >> rhs.rssiAlarms; - node["trainerMode"] >> trainerModeLut >> rhs.trainerMode; node["moduleData"] >> rhs.moduleData; for (int i=0; i::decode(const Node& node, ModelData& rhs) } } + if (node["trainerData"]) { + const auto& trainer = node["trainerData"]; + if (!trainer.IsMap()) return false; + trainer["mode"] >> trainerModeLut >> rhs.trainerMode; + trainer["channelsStart"] >> rhs.moduleData[2].channelsStart; + trainer["channelsCount"] >> rhs.moduleData[2].channelsCount; + rhs.moduleData[2].channelsCount += 8; + trainer["frameLength"] >> rhs.moduleData[2].ppm.frameLength; + trainer["delay"] >> rhs.moduleData[2].ppm.delay; + rhs.moduleData[2].ppm.delay = 300 + 50 * rhs.moduleData[2].ppm.delay; + trainer["pulsePol"] >> rhs.moduleData[2].ppm.pulsePol; + } + node["scriptData"] >> rhs.scriptData; node["telemetrySensors"] >> rhs.sensorData;