From 5c8504add6beb538822f71b9d4b6f9e6e4c75ba5 Mon Sep 17 00:00:00 2001 From: bsongis Date: Tue, 15 Apr 2014 12:25:46 +0200 Subject: [PATCH] Better fix for #977 --- .../src/firmwares/opentx/opentxeeprom.cpp | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 803a91b39..5eacd1190 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -752,22 +752,29 @@ class FlightModeField: public TransformedField { } } else { - int trim; - if (board == BOARD_STOCK || (board == BOARD_M128 && version >= 215)) - trim = ((trimBase[i]) << 2) + (trimExt[i] & 0x03); - else - trim = trimBase[i]; - if (trim > 500) { - phase.trimRef[i] = trim - 501; - if (phase.trimRef[i] >= index) - phase.trimRef[i] += 1; + if (phase.swtch == RawSwitch(SWITCH_TYPE_NONE)) { + phase.trimRef[i] = 0; phase.trimMode[i] = 0; phase.trim[i] = 0; } else { - phase.trimRef[i] = (trim == 0 ? 0 : index/*own trim*/); - phase.trimMode[i] = 0; - phase.trim[i] = trim; + int trim; + if (board == BOARD_STOCK || (board == BOARD_M128 && version >= 215)) + trim = ((trimBase[i]) << 2) + (trimExt[i] & 0x03); + else + trim = trimBase[i]; + if (trim > 500) { + phase.trimRef[i] = trim - 501; + if (phase.trimRef[i] >= index) + phase.trimRef[i] += 1; + phase.trimMode[i] = 0; + phase.trim[i] = 0; + } + else { + phase.trimRef[i] = index/*own trim*/; + phase.trimMode[i] = 0; + phase.trim[i] = trim; + } } } }