diff --git a/companion/src/firmwares/edgetx/yaml_modeldata.cpp b/companion/src/firmwares/edgetx/yaml_modeldata.cpp index 8c7b91423..4cc939147 100644 --- a/companion/src/firmwares/edgetx/yaml_modeldata.cpp +++ b/companion/src/firmwares/edgetx/yaml_modeldata.cpp @@ -245,6 +245,14 @@ struct YamlSwitchWarningState { } }; +template <> +void operator >> (const YAML::Node& node, FlightModeData& value) +{ + if (node && !node.IsNull()) { + YAML::convert::decode(node, value); + } +} + namespace YAML { Node convert::encode(const TimerData& rhs) @@ -419,25 +427,23 @@ Node EncodeFMData(const FlightModeData& rhs, int phaseIdx) return node; } -template <> -struct convert { - static bool decode(const Node& node, FlightModeData& rhs) - { - YamlTrim trims[CPN_MAX_TRIMS]; - node["trim"] >> trims; - for (size_t i=0; i> rhs.swtch; - node["name"] >> rhs.name; - node["fadeIn"] >> rhs.fadeIn; - node["fadeOut"] >> rhs.fadeOut; - node["gvars"] >> rhs.gvars; - return true; +bool convert::decode(const Node& node, + FlightModeData& rhs) +{ + YamlTrim trims[CPN_MAX_TRIMS]; + node["trim"] >> trims; + for (size_t i = 0; i < CPN_MAX_TRIMS; i++) { + rhs.trimMode[i] = trims[i].mode; + rhs.trimRef[i] = trims[i].ref; + rhs.trim[i] = trims[i].value; } -}; + node["swtch"] >> rhs.swtch; + node["name"] >> rhs.name; + node["fadeIn"] >> rhs.fadeIn; + node["fadeOut"] >> rhs.fadeOut; + node["gvars"] >> rhs.gvars; + return true; +} template <> struct convert { diff --git a/companion/src/firmwares/edgetx/yaml_modeldata.h b/companion/src/firmwares/edgetx/yaml_modeldata.h index 25b05a471..c3355c113 100644 --- a/companion/src/firmwares/edgetx/yaml_modeldata.h +++ b/companion/src/firmwares/edgetx/yaml_modeldata.h @@ -29,6 +29,11 @@ struct convert { static bool decode(const Node& node, TimerData& rhs); }; +template <> +struct convert { + static bool decode(const Node& node, FlightModeData& rhs); +}; + template <> struct convert { static Node encode(const ModelData& rhs);