diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index b49a4a7ab..ec702514c 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1880,7 +1880,7 @@ class CustomScreenField: public StructField { class SensorField: public TransformedField { public: - SensorField(DataField * parent, const ModelData& model, 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), @@ -1948,16 +1948,9 @@ class SensorField: public TransformedField { else { sensor.id = _id; sensor.subid = _subid; - if (model.moduleData[0].isPxx1Module() || model.moduleData[1].isPxx1Module()) { - sensor.instance = (_instance & 0x1F) + (version <= 218 ? 0 : 1); // 5 bits instance - sensor.rxIdx = 0x03; // 2 bits Rx idx - sensor.moduleIdx = 0x01; // 1 bit module idx - } - else { - sensor.instance = (_instance & 0x1F) + 1; - sensor.rxIdx = (_instance >> 5) & 0x03; // 2 bits Rx idx - sensor.moduleIdx = (_instance >> 7) & 0x1; // 1 bit module idx - } + sensor.instance = (_instance & 0x1F) + (version <= 218 ? 0 : 1); // 5 bits instance + sensor.rxIdx = (_instance >> 5) & 0x03; // 2 bits Rx idx + sensor.moduleIdx = (_instance >> 7) & 0x1; // 1 bit module idx sensor.ratio = _ratio; sensor.offset = _offset; } diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index 213d9cc4d..899190096 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -387,10 +387,15 @@ PACK(struct TelemetrySensor { return true; if (protocol == PROTOCOL_TELEMETRY_FRSKY_SPORT) { +#if defined(SIMU) + if (((this->instance ^ instance) & 0x1F) == 0) + return true; +#else if (((this->instance ^ instance) & 0x9F) == 0 && (this->instance >> 5) != TELEMETRY_ENDPOINT_SPORT && (instance >> 5) != TELEMETRY_ENDPOINT_SPORT) { this->instance = instance; // update the instance in case we had telemetry switching return true; } +#endif } return false; @@ -471,11 +476,11 @@ PACK(struct ModuleData { // Helper functions to set both of the rfProto protocol at the same time NOBACKUP(inline uint8_t getMultiProtocol() { - return ((uint8_t) (rfProtocol & 0x0f)) + (multi.rfProtocolExtra << 4); + return ((uint8_t) (rfProtocol & 0x0F)) + (multi.rfProtocolExtra << 4); }) NOBACKUP(inline void setMultiProtocol(uint8_t proto) { - rfProtocol = (uint8_t) (proto & 0x0f); + rfProtocol = (uint8_t) (proto & 0x0F); multi.rfProtocolExtra = (proto & 0x70) >> 4; }) }); diff --git a/radio/src/telemetry/telemetry_sensors.cpp b/radio/src/telemetry/telemetry_sensors.cpp index 1d0eb89b6..449879c5a 100644 --- a/radio/src/telemetry/telemetry_sensors.cpp +++ b/radio/src/telemetry/telemetry_sensors.cpp @@ -499,7 +499,7 @@ int setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t subId, ui { bool sensorFound = false; - for (int index=0; index