From 796f0b75ff77210840fb82ac09933e929a19d164 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 18 Nov 2016 22:52:31 +0100 Subject: [PATCH] [X9E] Switch warning export issue --- companion/src/eepromimportexport.h | 13 ++++++------ .../src/firmwares/opentx/opentxeeprom.cpp | 4 ++-- companion/src/modeledit/setup.cpp | 21 +++++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/companion/src/eepromimportexport.h b/companion/src/eepromimportexport.h index a70d7e133..e647f18f0 100644 --- a/companion/src/eepromimportexport.h +++ b/companion/src/eepromimportexport.h @@ -113,19 +113,19 @@ class BaseUnsignedField: public DataField { DataField("Unsigned"), field(field), min(0), - max(UINT_MAX) + max(std::numeric_limits::max()) { } - BaseUnsignedField(container & field, const char *name): + BaseUnsignedField(container & field, const char * name): DataField(name), field(field), min(0), - max(UINT_MAX) + max(std::numeric_limits::max()) { } - BaseUnsignedField(container & field, unsigned int min, unsigned int max, const char *name="Unsigned"): + BaseUnsignedField(container & field, container min, container max, const char * name="Unsigned"): DataField(name), field(field), min(min), @@ -141,8 +141,9 @@ class BaseUnsignedField: public DataField { output.resize(N); for (int i=0; i: 0x%3(%4)").arg(name).arg(N).arg(field, 0, 16).arg(field); } diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index f96280874..de58c0ff3 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2072,7 +2072,7 @@ class SwitchesWarningField: public TransformedField { virtual void beforeExport() { - _sw = sw; + _sw = sw; } virtual void afterImport() @@ -2092,7 +2092,7 @@ class SwitchesWarningField: public TransformedField { protected: BaseUnsignedField internalField; - uint64_t &sw; + uint64_t & sw; uint64_t _sw; BoardEnum board; unsigned int version; diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index a7f1d8007..5b300e068 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -910,18 +910,19 @@ void SetupPanel::updateStartupSwitches() { lock = true; - unsigned int switchStates = model->switchWarningStates; - unsigned int value; + uint64_t switchStates = model->switchWarningStates; + uint64_t value; for (int i=0; iproperty("index").toInt(); bool enabled = !(model->switchWarningEnable & (1 << index)); if (IS_TARANIS(GetEepromInterface()->getBoard())) { value = (switchStates >> 2*index) & 0x03; - if (generalSettings.switchConfig[index] != Firmware::SWITCH_3POS && value == 2) + if (generalSettings.switchConfig[index] != Firmware::SWITCH_3POS && value == 2) { value = 1; + } } else { value = (i==0 ? switchStates & 0x3 : switchStates & 0x1); @@ -939,12 +940,12 @@ void SetupPanel::startupSwitchEdited(int value) { if (!lock) { int shift = 0; - unsigned int mask; + uint64_t mask; int index = sender()->property("index").toInt(); if (IS_TARANIS(GetEepromInterface()->getBoard())) { shift = index * 2; - mask = 0x03 << shift; + mask = 0x03ul << shift; } else { if (index == 0) { @@ -952,18 +953,20 @@ void SetupPanel::startupSwitchEdited(int value) } else { shift = index+1; - mask = 0x01 << shift; + mask = 0x01ul << shift; } } model->switchWarningStates &= ~mask; if (IS_TARANIS(GetEepromInterface()->getBoard()) && generalSettings.switchConfig[index] != Firmware::SWITCH_3POS) { - if (value == 1) value = 2; + if (value == 1) { + value = 2; + } } if (value) { - model->switchWarningStates |= (value << shift); + model->switchWarningStates |= ((uint64_t)value << shift); } updateStartupSwitches();