From 12997bd1692c6360854b172e65937b63f288cfc6 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 10 Feb 2014 10:22:12 +0100 Subject: [PATCH] Bug on ID2 fixed --- .../src/firmwares/opentx/opentxeeprom.cpp | 8 ++----- companion/src/modeledit/setup.cpp | 10 ++------ radio/src/gui/menu_model.cpp | 23 ++++++++++--------- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 2d327d71b..093f464fe 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1293,7 +1293,7 @@ class SwitchesWarningField: public TransformedField { virtual void beforeExport() { bool release21March2013 = IS_RELEASE_21_MARCH_2013(board, version); - if (release21March2013) { + if (release21March2013 && version < 216) { _sw = (sw & 0xC1) + ((sw & 0x30) >> 3) + ((sw & 0x0E) << 2); } else { @@ -1304,7 +1304,7 @@ class SwitchesWarningField: public TransformedField { virtual void afterImport() { bool release21March2013 = IS_RELEASE_21_MARCH_2013(board, version); - if (release21March2013) { + if (release21March2013 && version < 216) { sw = (_sw & 0xC1) + ((_sw & 0x38) >> 2) + ((_sw & 0x06) << 3); } else { @@ -1941,10 +1941,6 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u internalField.Append(new MavlinkField(modelData.mavlink, board, version)); } - if (!IS_ARM(board) && (version >= 216)) { - internalField.Append(new UnsignedField<8>(modelData.nSwToWarn)); - } - if (IS_TARANIS(board) && version < 215) { internalField.Append(new CharField<10>(modelData.bitmap)); } diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 4f6e51ecf..91cf9502e 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -588,12 +588,11 @@ void Setup::updateStartupSwitches() lock = true; unsigned int switchStates = model.switchWarningStates; - bool enabled; for (int i=0; igetCapability(Switches)-1; i++) { QSlider * slider = startupSwitchesSliders[i]; QCheckBox * cb = startupSwitchesCheckboxes[i]; - enabled = !(model.nSwToWarn & (1 << i)); + bool enabled = !(model.nSwToWarn & (1 << i)); slider->setEnabled(enabled); cb->setChecked(enabled); if (IS_TARANIS(GetEepromInterface()->getBoard())) { @@ -640,12 +639,7 @@ void Setup::startupSwitchEdited(int value) model.switchWarningStates &= ~mask; if (value) { - if (shift == 0) { - model.switchWarningStates |= value; - } - else { - model.switchWarningStates |= (value << shift); - } + model.switchWarningStates |= (value << shift); } updateStartupSwitches(); diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index ace199ec9..914678779 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -1163,17 +1163,18 @@ void menuModelSetup(uint8_t event) switch(event) { CASE_EVT_ROTARY_BREAK case EVT_KEY_BREAK(KEY_ENTER): - killEvents(event); + killEvents(event); #if defined(CPUM64) + g_model.nSwToWarn ^= (1 << m_posHorz); + eeDirty(EE_MODEL); +#else + if (m_posHorz < NUM_SWITCHES-1) { g_model.nSwToWarn ^= (1 << m_posHorz); eeDirty(EE_MODEL); -#else - if (m_posHorz < NUM_SWITCHES-1) { - g_model.nSwToWarn ^= (1 << m_posHorz); - eeDirty(EE_MODEL); - } + } #endif break; + case EVT_KEY_LONG(KEY_ENTER): #if defined(CPUM64) getMovedSwitch(); @@ -1189,7 +1190,7 @@ void menuModelSetup(uint8_t event) eeDirty(EE_MODEL); } #endif - break; + break; } } } @@ -1200,7 +1201,7 @@ void menuModelSetup(uint8_t event) #if defined(PCBTARANIS) c = "\300-\301"[states & 0x03]; lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+i*(2*FW), y, 'A'+i, line && (m_posHorz == i) ? INVERS : 0); - if(swactive) lcd_putc(MODEL_SETUP_2ND_COLUMN+i*(2*FW)+FWNUM, y, c); + if (swactive) lcd_putc(MODEL_SETUP_2ND_COLUMN+i*(2*FW)+FWNUM, y, c); lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+((NUM_SWITCHES-1)*2*FW+2), y, PSTR("<]"), (m_posHorz == NUM_SWITCHES-1 && !s_noHi) ? line : 0); states >>= 2; #else @@ -1211,14 +1212,14 @@ void menuModelSetup(uint8_t event) states >>= 2; } else { - if (states & 0x01 && swactive) + if ((states & 0x01) && swactive) attr = INVERS; c = pgm_read_byte(STR_VSWITCHES - 2 + 9 + (3*i)); states >>= 1; } - if(line && (m_posHorz == i)) { + if (line && (m_posHorz == i)) { attr = BLINK; - if(swactive) + if (swactive) attr |= INVERS; } lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+i*FW, y, (swactive || (attr & BLINK)) ? c : '-', attr);