From 88aea7f78017c11a949729456a8449e38ab97f53 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Fri, 28 Aug 2015 19:25:48 +0200 Subject: [PATCH] Fix #2738 --- companion/src/firmwares/opentx/opentxeeprom.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 5c039727b..588caec82 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2820,7 +2820,8 @@ class SensorField: public TransformedField { if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) { _id = sensor.id; _instance = sensor.instance; - _param = (sensor.ratio) + ((unsigned int)sensor.offset << 16); + _ratio = sensor.ratio; + _offset = sensor.offset; } else { _id = sensor.persistentValue; @@ -2841,8 +2842,8 @@ class SensorField: public TransformedField { if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) { sensor.id = _id; sensor.instance = _instance; - sensor.ratio = _param & 0xFFFF; - sensor.offset = (_param >> 16) & 0xFFFF; + sensor.ratio = _ratio; + sensor.offset = _offset; } else { sensor.persistentValue = _id; @@ -2868,6 +2869,10 @@ class SensorField: public TransformedField { union { unsigned int _param; uint8_t _sources[4]; + struct { + uint16_t _ratio; + int16_t _offset; + }; }; };