From 48c4629b927c625c7d140e55edcf4e245fd7df80 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 23 Sep 2019 15:22:32 +0200 Subject: [PATCH] Cleaning --- .../src/firmwares/opentx/opentxeeprom.cpp | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index f13881149..a81457e23 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1935,16 +1935,25 @@ class SensorField: public TransformedField { void afterImport() override { if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) { - sensor.id = _id; - sensor.subid = _subid; - if (model.moduleData[0].isPxx1Module() || model.moduleData[1].isPxx1Module()) - sensor.instance = (_instance & 0x1F) + (version <= 218 ? -1 : 0); // 5 bits instance - else - sensor.instance = _instance & 0x1F; - sensor.rxIdx = (_instance >> 5) & 0x03; // 2 bits Rx idx - sensor.moduleIdx = (_instance >> 7) & 0x1; // 1 bit module idx - sensor.ratio = _ratio; - sensor.offset = _offset; + if (strlen(sensor.label) == 0) { + sensor.clear(); + } + else { + sensor.id = _id; + sensor.subid = _subid; + if (model.moduleData[0].isPxx1Module() || model.moduleData[1].isPxx1Module()) { + sensor.instance = (_instance & 0x1F) + (version <= 218 ? -1 : 0); // 5 bits instance + sensor.rxIdx = 0x03; // 2 bits Rx idx + sensor.moduleIdx = 0x01; // 1 bit module idx + } + else { + sensor.instance = _instance & 0x1F; + sensor.rxIdx = (_instance >> 5) & 0x03; // 2 bits Rx idx + sensor.moduleIdx = (_instance >> 7) & 0x1; // 1 bit module idx + } + sensor.ratio = _ratio; + sensor.offset = _offset; + } } else { sensor.persistentValue = _id;