fix: Companion read/write of failsafe settings, how displayed on radio (#1399)
* Fix failsafe settings Resolve #1393 * trigger save if failsafe numbers changed + cleanup Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
co-authored by
Peter Feerick
parent
71b0e72dd0
commit
7a628d4c15
@@ -337,7 +337,6 @@ struct convert<LimitData> {
|
||||
node["offset"] = YamlWriteLimitValue(rhs.offset);
|
||||
node["ppmCenter"] = rhs.ppmCenter;
|
||||
node["symetrical"] = (int)rhs.symetrical;
|
||||
node["failsafe"] = rhs.failsafe;
|
||||
node["name"] = rhs.name;
|
||||
node["curve"] = rhs.curve.value;
|
||||
return node;
|
||||
@@ -357,7 +356,6 @@ struct convert<LimitData> {
|
||||
node["revert"] >> rhs.revert;
|
||||
node["ppmCenter"] >> rhs.ppmCenter;
|
||||
node["symetrical"] >> rhs.symetrical;
|
||||
node["failsafe"] >> rhs.failsafe;
|
||||
node["name"] >> rhs.name;
|
||||
node["curve"] >> rhs.curve.value;
|
||||
return true;
|
||||
@@ -873,6 +871,12 @@ Node convert<ModelData>::encode(const ModelData& rhs)
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<CPN_MAX_CHNOUT; i++) {
|
||||
if (rhs.limitData[i].failsafe != 0) {
|
||||
node["failsafeChannels"][std::to_string(i)]["val"] = rhs.limitData[i].failsafe;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<CPN_MAX_SCRIPTS; i++) {
|
||||
if (strlen(rhs.scriptData[i].filename) > 0) {
|
||||
node["scriptData"][std::to_string(i)] = rhs.scriptData[i];
|
||||
@@ -1046,6 +1050,15 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
|
||||
rhs.moduleData[i].modelId = modelIds[i];
|
||||
}
|
||||
|
||||
if (node["failsafeChannels"]) {
|
||||
int failsafeChans[CPN_MAX_CHNOUT];
|
||||
memset(failsafeChans, 0, sizeof(failsafeChans));
|
||||
node["failsafeChannels"] >> failsafeChans;
|
||||
for (int i=0; i<CPN_MAX_CHNOUT; i++) {
|
||||
rhs.limitData[i].failsafe = failsafeChans[i];
|
||||
}
|
||||
}
|
||||
|
||||
node["scriptData"] >> rhs.scriptData;
|
||||
node["telemetrySensors"] >> rhs.sensorData;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user