diff --git a/companion/src/firmwares/edgetx/yaml_moduledata.cpp b/companion/src/firmwares/edgetx/yaml_moduledata.cpp index a6c84d8d5..11d263265 100644 --- a/companion/src/firmwares/edgetx/yaml_moduledata.cpp +++ b/companion/src/firmwares/edgetx/yaml_moduledata.cpp @@ -37,6 +37,15 @@ // receiverTelemetryOff: 0 // receiverHigherChannels: 0 +// type: TYPE_GHOST +// subType: 0 +// channelsStart: 0 +// channelsCount: 16 +// failsafeMode: NOT_SET +// mod: +// ghost: +// raw12bits: 0 + static const YamlLookupTable protocolLut = { { PULSES_OFF, "TYPE_NONE" }, { PULSES_PPM, "TYPE_PPM" }, @@ -284,6 +293,11 @@ Node convert::encode(const ModuleData& rhs) sbus["refreshRate"] = rhs.ppm.frameLength; mod["sbus"] = sbus; } break; + case PULSES_GHOST: { + Node ghost; + ghost["raw12bits"] = (int)rhs.ghost.raw12bits; + mod["ghost"] = ghost; + } break; // TODO: afhds3, flysky default: { Node ppm; @@ -384,6 +398,9 @@ bool convert::decode(const Node& node, ModuleData& rhs) for (const auto& rx : pxx2["receiverName"]) { rx >> rhs.access.receiverName; } + } else if (mod["ghost"]) { + Node ghost = mod["ghost"]; + ghost["raw12bits"] >> rhs.ghost.raw12bits; } else if (mod["flysky"]) { //TODO } else if (mod["afhds3"]) { diff --git a/companion/src/firmwares/moduledata.h b/companion/src/firmwares/moduledata.h index b1606f0d5..dbf9111b6 100644 --- a/companion/src/firmwares/moduledata.h +++ b/companion/src/firmwares/moduledata.h @@ -227,6 +227,10 @@ class ModuleData { int antennaMode; // false = internal antenna, true = external antenna } pxx; + struct GHOST { + bool raw12bits; + } ghost; + struct Access { unsigned int receivers; char receiverName[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME+1]; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 52f2b9d4c..a9f7f2a37 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2260,6 +2260,29 @@ class ModuleUnionField: public UnionField { char receiverName[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME+1] = {}; }; + class GhostField: public UnionField::TransformedMember { + public: + GhostField(DataField * parent, ModuleData& module): + UnionField::TransformedMember(parent, internalField), + internalField(this, "GHOST") + { + internalField.Append(new BoolField<1>(this, module.ghost.raw12bits)); + internalField.Append(new SpareBitsField<7>(this)); + } + + bool select(const unsigned int & attr) const override + { + return attr == PULSES_GHOST; + } + + void beforeExport() override {} + + void afterImport() override {} + + private: + StructField internalField; + }; + public: ModuleUnionField(DataField * parent, ModuleData & module, Board::Type board, unsigned int version): UnionField(parent, module.protocol) @@ -2267,6 +2290,7 @@ class ModuleUnionField: public UnionField { if (version >= 219) { Append(new AccessField(parent, module)); Append(new Afhds3Field(parent, module)); + Append(new GhostField(parent, module)); } Append(new PxxField(parent, module, version)); Append(new MultiField(parent, module)); diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 19fc67aa7..93dc45fd6 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -202,6 +202,7 @@ void TimerPanel::onModeChanged(int index) #define MASK_RX_FREQ (1<<14) #define MASK_RF_POWER (1<<15) #define MASK_RF_RACING_MODE (1<<16) +#define MASK_GHOST (1<<17) quint8 ModulePanel::failsafesValueDisplayType = ModulePanel::FAILSAFE_DISPLAY_PERCENT; @@ -445,7 +446,7 @@ void ModulePanel::update() case PULSES_CROSSFIRE: mask |= MASK_CHANNELS_RANGE | MASK_RX_NUMBER; case PULSES_GHOST: - mask |= MASK_CHANNELS_RANGE; + mask |= MASK_CHANNELS_RANGE | MASK_GHOST; module.channelsCount = 16; break; case PULSES_PPM: @@ -616,6 +617,12 @@ void ModulePanel::update() ui->label_option->setText(qApp->translate("Multiprotocols", qPrintable(pdef.optionsstr))); } + // Ghost settings fields + ui->raw12bits->setVisible(mask & MASK_GHOST); + if (mask & MASK_GHOST) { + ui->raw12bits->setChecked(module.ghost.raw12bits); + } + if (mask & MASK_ACCESS) { ui->rx1->setText(module.access.receiverName[0]); ui->rx2->setText(module.access.receiverName[1]); @@ -827,6 +834,11 @@ void ModulePanel::on_disableChMap_stateChanged(int state) module.multi.disableMapping = (state == Qt::Checked); } +void ModulePanel::on_raw12bits_stateChanged(int state) +{ + module.ghost.raw12bits = (state == Qt::Checked); +} + void ModulePanel::on_racingMode_stateChanged(int state) { module.access.racingMode = (state == Qt::Checked); diff --git a/companion/src/modeledit/setup.h b/companion/src/modeledit/setup.h index 1f80722aa..85915f923 100644 --- a/companion/src/modeledit/setup.h +++ b/companion/src/modeledit/setup.h @@ -99,6 +99,7 @@ class ModulePanel : public ModelPanel void onSubTypeChanged(); void on_autoBind_stateChanged(int state); void on_disableChMap_stateChanged(int state); + void on_raw12bits_stateChanged(int state); void on_racingMode_stateChanged(int state); void on_disableTelem_stateChanged(int state); void on_lowPower_stateChanged(int state); diff --git a/companion/src/modeledit/setup_module.ui b/companion/src/modeledit/setup_module.ui index 4689f6a8d..0c95b81da 100644 --- a/companion/src/modeledit/setup_module.ui +++ b/companion/src/modeledit/setup_module.ui @@ -1051,7 +1051,7 @@ - + Qt::Horizontal @@ -1071,6 +1071,13 @@ + + + + Raw 12 bits + + + diff --git a/companion/src/modelprinter.cpp b/companion/src/modelprinter.cpp index 1c4c5f7ba..2c625cec0 100644 --- a/companion/src/modelprinter.cpp +++ b/companion/src/modelprinter.cpp @@ -230,6 +230,9 @@ QString ModelPrinter::printModule(int idx) str << printLabelValue(tr("RF Output Power"), module.powerValueToString(firmware)); str << printLabelValue(tr("RX Output Frequency"), QString("%1Hz").arg(module.afhds3.rxFreq)); } + if (module.protocol == PULSES_GHOST) { + str << printLabelValue(tr("Raw 12 bits"), printBoolean(module.ghost.raw12bits, BOOLEAN_YN)); + } } } result = str.join(" ");