From 51f66a9e79db0562bca3f1401393e268070fd0a9 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 19 Dec 2021 09:16:30 +0100 Subject: [PATCH] modelID and small fixes --- .../src/firmwares/edgetx/yaml_modeldata.cpp | 50 +++++++++++++------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_modeldata.cpp b/companion/src/firmwares/edgetx/yaml_modeldata.cpp index e738fa9c5..cafcebdf9 100644 --- a/companion/src/firmwares/edgetx/yaml_modeldata.cpp +++ b/companion/src/firmwares/edgetx/yaml_modeldata.cpp @@ -195,7 +195,7 @@ struct YamlSwitchWarningState { uint64_t states = 0; for (unsigned int i = 0; i < src_str.size() / 2; i++) { - const char* val = src_str.substr(i * 2, 2).c_str(); + auto val = src_str.substr(i * 2, 2); if (val[0] >= 'A' && val[0] <= 'Z' && ( val[1] == 'u' || val[1] == '-' || val[1] == 'd')) { @@ -505,7 +505,7 @@ struct convert { static Node encode(const RSSIAlarmData& rhs) { Node node; - node["disabled"] = rhs.disabled; + node["disabled"] = (int)rhs.disabled; node["warning"] = rhs.warning - 45; node["critical"] = rhs.critical - 42; return node; @@ -525,9 +525,18 @@ struct convert { Node convert::encode(const ModelData& rhs) { Node node; - node["header"]["name"] = rhs.name; - node["header"]["bitmap"] = rhs.bitmap; - // TODO: modelId + auto board = getCurrentBoard(); + + Node header; + header["name"] = rhs.name; + header["bitmap"] = rhs.bitmap; + + for (int i=0; i::encode(const ModelData& rhs) } } - node["toplcdTimer"] = rhs.toplcdTimer; + if (IS_TARANIS_X9E(board)) { + node["toplcdTimer"] = rhs.toplcdTimer; + } - for (int i=0; igetCapability(FunctionSwitches)) { @@ -707,11 +720,16 @@ bool convert::decode(const Node& node, ModelData& rhs) if (node["header"]) { const auto& header = node["header"]; - if (!header.IsMap()) return false; + if (header.IsMap()) { + header["name"] >> rhs.name; + header["bitmap"] >> rhs.bitmap; - header["name"] >> rhs.name; - header["bitmap"] >> rhs.bitmap; - // TODO: modelId + unsigned int modelIds[CPN_MAX_MODULES]; + header["modelId"] >> modelIds; + for (int i=0; i