chore: Companion - port of OpenTX function switches management (#1694)

* TPro - Port of OpenTX function switches management (https://github.com/opentx/opentx/pull/8847)

* cleanup

* Corrections

* Fix YAML generation and adjusted switches to match TPRO firmware

Co-authored-by: Batam <batam@macbook-pro.home>
This commit is contained in:
Batambatam
2022-03-21 10:43:27 +10:00
committed by GitHub
co-authored by Batam
parent 1d7c153979
commit ab15a5a514
22 changed files with 434 additions and 186 deletions
@@ -957,7 +957,7 @@ Node convert<ModelData>::encode(const ModelData& rhs)
node["modelRegistrationID"] = rhs.registrationId;
if (getCurrentFirmware()->getCapability(FunctionSwitches)) {
if (Boards::getCapability(getCurrentBoard(), Board::FunctionSwitches)) {
node["functionSwitchConfig"] = rhs.functionSwitchConfig;
node["functionSwitchGroup"] = rhs.functionSwitchGroup;
node["functionSwitchStartConfig"] = rhs.functionSwitchStartConfig;
@@ -965,8 +965,7 @@ Node convert<ModelData>::encode(const ModelData& rhs)
for (int i = 0; i < CPN_MAX_FUNCTION_SWITCHES; i++) {
if (strlen(rhs.functionSwitchNames[i]) > 0) {
node["functionSwitchNames"][std::to_string(i)] =
rhs.functionSwitchNames[i];
node["switchNames"][std::to_string(i)]["val"] = rhs.functionSwitchNames[i];
}
}
}
@@ -1137,8 +1136,7 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
node["functionSwitchGroup"] >> rhs.functionSwitchGroup;
node["functionSwitchStartConfig"] >> rhs.functionSwitchStartConfig;
node["functionSwitchLogicalState"] >> rhs.functionSwitchLogicalState;
node["functionSwitchNames"] >> rhs.functionSwitchNames;
node["switchNames"] >> rhs.functionSwitchNames;
return true;
}