diff --git a/companion/src/firmwares/edgetx/yaml_modeldata.cpp b/companion/src/firmwares/edgetx/yaml_modeldata.cpp index 6a6bf0490..d4623f0b4 100644 --- a/companion/src/firmwares/edgetx/yaml_modeldata.cpp +++ b/companion/src/firmwares/edgetx/yaml_modeldata.cpp @@ -163,18 +163,19 @@ struct YamlSwitchWarningState { static constexpr size_t MASK = (1 << MASK_LEN) - 1; std::string src_str; - uint64_t enabled; + unsigned int enabled; YamlSwitchWarningState() = default; YamlSwitchWarningState(uint64_t cpn_value, unsigned int switchWarningEnable) + : enabled(~switchWarningEnable) { uint64_t states = cpn_value; std::stringstream ss; for (int i = 0; i < Boards::getCapability(getCurrentBoard(), Board::Switches); i++) { //TODO: exclude 2-pos toggle from switch warnings - if (!(switchWarningEnable & (1 << i))) { + if (enabled & (1 << i)) { std::string tag = getCurrentFirmware()->getSwitchesTag(i); const char *sw = tag.data(); @@ -870,17 +871,15 @@ bool convert::decode(const Node& node, ModelData& rhs) { if (!node.IsMap()) return false; + unsigned int modelIds[CPN_MAX_MODULES]; + memset(modelIds, 0, sizeof(modelIds)); + if (node["header"]) { const auto& header = node["header"]; if (header.IsMap()) { header["name"] >> rhs.name; header["bitmap"] >> rhs.bitmap; - - unsigned int modelIds[CPN_MAX_MODULES]; header["modelId"] >> modelIds; - for (int i=0; i::decode(const Node& node, ModelData& rhs) } node["rssiAlarms"] >> rhs.rssiAlarms; - node["trainerMode"] >> trainerModeLut >> rhs.trainerMode; + node["moduleData"] >> rhs.moduleData; + for (int i=0; i> rhs.scriptData; node["telemetrySensors"] >> rhs.sensorData; diff --git a/companion/src/firmwares/edgetx/yaml_moduledata.cpp b/companion/src/firmwares/edgetx/yaml_moduledata.cpp index 55d41058f..2089ee683 100644 --- a/companion/src/firmwares/edgetx/yaml_moduledata.cpp +++ b/companion/src/firmwares/edgetx/yaml_moduledata.cpp @@ -188,6 +188,9 @@ void convertEtxProtocolToMulti(int *protocol, int *subprotocol) } } +static int exportPpmDelay(int delay) { return (delay - 300) / 50; } +static int importPpmDelay(int delay) { return 300 + 50 * delay; } + namespace YAML { Node convert::encode(const ModuleData& rhs) @@ -284,9 +287,9 @@ Node convert::encode(const ModuleData& rhs) // TODO: afhds3, flysky default: { Node ppm; - ppm["delay"] = rhs.ppm.delay; - ppm["pulsePol"] = rhs.ppm.pulsePol; - ppm["outputType"] = rhs.ppm.outputType; + ppm["delay"] = exportPpmDelay(rhs.ppm.delay); + ppm["pulsePol"] = (int)rhs.ppm.pulsePol; + ppm["outputType"] = (int)rhs.ppm.outputType; ppm["frameLength"] = rhs.ppm.frameLength; mod["ppm"] = ppm; } break; @@ -347,10 +350,11 @@ bool convert::decode(const Node& node, ModuleData& rhs) node["failsafeMode"] >> failsafeLut >> rhs.failsafeMode; if (node["mod"]) { - Node mod = node["mod"]; + const Node& mod = node["mod"]; if (mod["ppm"]) { - Node ppm = mod["ppm"]; + const Node& ppm = mod["ppm"]; ppm["delay"] >> rhs.ppm.delay; + rhs.ppm.delay = importPpmDelay(rhs.ppm.delay); ppm["pulsePol"] >> rhs.ppm.pulsePol; ppm["outputType"] >> rhs.ppm.outputType; ppm["frameLength"] >> rhs.ppm.frameLength; diff --git a/companion/src/firmwares/edgetx/yaml_ops.h b/companion/src/firmwares/edgetx/yaml_ops.h index f6ca8c6fc..52a40ab65 100644 --- a/companion/src/firmwares/edgetx/yaml_ops.h +++ b/companion/src/firmwares/edgetx/yaml_ops.h @@ -102,7 +102,12 @@ void operator>>(const YAML::Node& node, T (&value)[N]) int idx = std::stoi(elmt.first.Scalar()); if (idx < 0 || idx >= (int)N) return; - elmt.second >> value[idx]; + if (elmt.second.IsMap() && (elmt.second.size() == 1) && + elmt.second["val"]) { + elmt.second["val"] >> value[idx]; + } else { + elmt.second >> value[idx]; + } } catch (...) { return; } diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 1c9248814..c611aa1f5 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -1321,6 +1321,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge Board::SwitchInfo switchInfo = Boards::getSwitchInfo(board, i); switchInfo.config = Board::SwitchType(generalSettings.switchConfig[i]); if (switchInfo.config == Board::SWITCH_NOT_AVAILABLE || switchInfo.config == Board::SWITCH_TOGGLE) { + model.switchWarningEnable |= (1 << i); continue; } RawSource src(RawSourceType::SOURCE_TYPE_SWITCH, i);