From cae4d1ecf6c9f327e1681454d82300b74e795a6b Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 6 Feb 2014 14:36:54 +0100 Subject: [PATCH] Issue #592 - All boards will have this feature available, it costs only 50bytes on stock board (I saved more in this same branch) --- radio/src/eeprom_conversions.cpp | 4 +- radio/src/gui/menu_model.cpp | 6 +- radio/src/myeeprom.h | 2 - radio/src/opentx.cpp | 4 +- radio/src/opentx.h | 1 + radio/src/targets/gruvin9x/board_gruvin9x.cpp | 58 ++++++++----------- radio/src/targets/sky9x/keys_driver.cpp | 5 ++ radio/src/targets/stock/board_stock.cpp | 45 +++++++------- radio/src/targets/taranis/keys_driver.cpp | 5 ++ radio/src/translations/en.h | 4 +- 10 files changed, 67 insertions(+), 67 deletions(-) diff --git a/radio/src/eeprom_conversions.cpp b/radio/src/eeprom_conversions.cpp index 4bf4d38d8..58c07b74f 100644 --- a/radio/src/eeprom_conversions.cpp +++ b/radio/src/eeprom_conversions.cpp @@ -199,7 +199,7 @@ int ConvertSwitch_215_to_216(int swtch) if (swtch <= SWSRC_LAST_SWITCH) return swtch; else - return swtch + 4 + (2*6); // 4 trims and 2 * 6-pos added as switches + return swtch + (2*4) + (2*6); // 4 trims and 2 * 6-pos added as switches } #else inline int ConvertSwitch_215_to_216(int swtch) @@ -207,7 +207,7 @@ inline int ConvertSwitch_215_to_216(int swtch) if (swtch <= SWSRC_LAST_SWITCH) return swtch; else - return swtch + 4 + 1; // 4 trims and REa added + return swtch + (2*4) + 1; // 4 trims and REa added } #endif diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 7f54eb54e..41ad48820 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4233,7 +4233,7 @@ void menuModelCustomSwitchOne(uint8_t event) { lcd_putsLeft(y, STR_V1); int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM; - if (cstate == CS_VBOOL) { + if (cstate == CS_VBOOL || cstate == CS_VSTICKY) { putsSwitches(CSWONE_2ND_COLUMN, y, cs->v1, attr); v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; } @@ -4253,7 +4253,7 @@ void menuModelCustomSwitchOne(uint8_t event) { lcd_putsLeft(y, STR_V2); int8_t v2_min=0, v2_max=MIXSRC_LAST_TELEM; - if (cstate == CS_VBOOL) { + if (cstate == CS_VBOOL || cstate == CS_VSTICKY) { putsSwitches(CSWONE_2ND_COLUMN, y, cs->v2, attr); v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1; } @@ -4358,7 +4358,7 @@ void menuModelCustomSwitches(uint8_t event) // CSW params uint8_t cstate = cswFamily(cs->func); - if (cstate == CS_VBOOL) { + if (cstate == CS_VBOOL || cstate == CS_VSTICKY) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0); putsSwitches(CSW_3RD_COLUMN, y, cs->v2, 0); } diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 96dc9ffac..f4fbf7aa3 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -1193,7 +1193,6 @@ enum SwitchSources { SWSRC_P26 = SWSRC_P21+5, #endif -#if defined(CPUARM) SWSRC_FIRST_TRIM, SWSRC_TrimRudLeft = SWSRC_FIRST_TRIM, SWSRC_TrimRudRight, @@ -1204,7 +1203,6 @@ enum SwitchSources { SWSRC_TrimAilLeft, SWSRC_TrimAilRight, SWSRC_LAST_TRIM = SWSRC_TrimAilRight, -#endif #if defined(PCBSKY9X) SWSRC_REa, diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index f48586a20..cd04b387c 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1390,11 +1390,9 @@ bool getSwitch(int8_t swtch) result = POT_POSITION(cs_idx-SWSRC_P11); } #endif -#if defined(CPUARM) else if (cs_idx <= SWSRC_LAST_TRIM) { - result = readTrims() & (1 << (cs_idx-SWSRC_FIRST_TRIM)); + result = trimDown(cs_idx-SWSRC_FIRST_TRIM); } -#endif #if ROTARY_ENCODERS > 0 else if (cs_idx == SWSRC_REa) { result = REA_DOWN(); diff --git a/radio/src/opentx.h b/radio/src/opentx.h index c243ae139..70116bbaa 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -806,6 +806,7 @@ enum PowerState { }; bool switchState(EnumKeys enuk); +uint8_t trimDown(uint8_t idx); void readKeysAndTrims(); uint16_t evalChkSum(); diff --git a/radio/src/targets/gruvin9x/board_gruvin9x.cpp b/radio/src/targets/gruvin9x/board_gruvin9x.cpp index adb5c4974..97ac9a5d9 100644 --- a/radio/src/targets/gruvin9x/board_gruvin9x.cpp +++ b/radio/src/targets/gruvin9x/board_gruvin9x.cpp @@ -255,58 +255,50 @@ bool switchState(EnumKeys enuk) return result; } +static const pm_uchar crossTrim[] PROGMEM = { + 1<> 3; - for (int i=1; i<7; i++) { - //INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6 + // INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6 keys[enuk].input(in & (1<