2nd attempt to fix #7613 (#7670)

This commit is contained in:
Bertrand Songis
2020-06-04 15:13:32 +02:00
committed by GitHub
parent f34b5216a7
commit a468005ada
3 changed files with 12 additions and 14 deletions
@@ -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;
}
+7 -2
View File
@@ -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;
})
});
+1 -1
View File
@@ -499,7 +499,7 @@ int setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t subId, ui
{
bool sensorFound = false;
for (int index=0; index<MAX_TELEMETRY_SENSORS; index++) {
for (int index = 0; index < MAX_TELEMETRY_SENSORS; index++) {
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[index];
if (telemetrySensor.type == TELEM_TYPE_CUSTOM && telemetrySensor.id == id && telemetrySensor.subId == subId && (telemetrySensor.isSameInstance(protocol, instance) || g_model.ignoreSensorIds)) {
telemetryItems[index].setValue(telemetrySensor, value, unit, prec);