From 40fe6022b40a3da334c2bac839753c604be4f016 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Wed, 28 Aug 2019 11:38:44 +0200 Subject: [PATCH] [Companion] Change instance only for FrSky telemetry (#6671) (#6677) * [Companion] Change instance only for FrSky telemetry (#6671) * same for all PXX1 modules --- companion/src/firmwares/moduledata.cpp | 14 ++++++++++++++ companion/src/firmwares/moduledata.h | 1 + companion/src/firmwares/opentx/opentxeeprom.cpp | 11 ++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/companion/src/firmwares/moduledata.cpp b/companion/src/firmwares/moduledata.cpp index d2cc4fd1b..4a9e59a29 100644 --- a/companion/src/firmwares/moduledata.cpp +++ b/companion/src/firmwares/moduledata.cpp @@ -44,6 +44,20 @@ bool ModuleData::isPxx2Module() const } } +bool ModuleData::isPxx1Module() const +{ + switch(protocol){ + case PULSES_PXX_XJT_X16: + case PULSES_PXX_R9M: + case PULSES_PXX_R9M_LITE: + case PULSES_PXX_R9M_LITE_PRO: + return true; + default: + return false; + } +} + + QString ModuleData::rfProtocolToString() const { switch (protocol) { diff --git a/companion/src/firmwares/moduledata.h b/companion/src/firmwares/moduledata.h index e87d7475f..72d7cff07 100644 --- a/companion/src/firmwares/moduledata.h +++ b/companion/src/firmwares/moduledata.h @@ -183,6 +183,7 @@ class ModuleData { void clear() { memset(this, 0, sizeof(ModuleData)); } void convert(RadioDataConversionState & cstate); bool isPxx2Module() const; + bool isPxx1Module() const; QString polarityToString() const { return ppm.pulsePol ? tr("Positive") : tr("Negative"); } QString rfProtocolToString() const; QString subTypeToString(int type = -1) const; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 48f678b93..ff991cf48 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1856,10 +1856,11 @@ class CustomScreenField: public StructField { class SensorField: public TransformedField { public: - SensorField(DataField * parent, SensorData & sensor, Board::Type board, unsigned int version): + SensorField(DataField * parent, const ModelData& model, SensorData & sensor, Board::Type board, unsigned int version): TransformedField(parent, internalField), internalField(this, "Sensor"), sensor(sensor), + model(model), version(version), _param(0) { @@ -1921,7 +1922,10 @@ class SensorField: public TransformedField { if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) { sensor.id = _id; sensor.subid = _subid; - sensor.instance = (_instance & 0x1F) + (version <= 218 ? -1 : 0); // 5 bits instance + if (model.moduleData[0].isPxx1Module() || model.moduleData[1].isPxx1Module()) + sensor.instance = (_instance & 0x1F) + (version <= 218 ? -1 : 0); // 5 bits instance + else + sensor.instance = _instance; sensor.rxIdx = (_instance >> 5) & 0x03; // 2 bits Rx idx sensor.moduleIdx = (_instance >> 7) & 0x1; // 1 bit module idx sensor.ratio = _ratio; @@ -1954,6 +1958,7 @@ class SensorField: public TransformedField { protected: StructField internalField; SensorData & sensor; + const ModelData& model; unsigned int version; unsigned int _id; unsigned int _subid; @@ -2426,7 +2431,7 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, Board::Type board, unsig } for (int i=0; i