From c28210e3e44fedfffb84c3a8c3716e3622053474 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Tue, 30 Apr 2019 14:55:21 +0200 Subject: [PATCH] Rotary encoder refactoring --- radio/src/cli.cpp | 2 +- radio/src/dataconstants.h | 22 ---- radio/src/datastructs.h | 11 +- radio/src/functions.cpp | 27 ----- radio/src/gui/128x64/gui.h | 16 +-- radio/src/gui/128x64/lcd.cpp | 16 --- radio/src/gui/128x64/lcd.h | 4 - radio/src/gui/128x64/model_flightmodes.cpp | 38 +------ radio/src/gui/128x64/model_inputs_mixes.cpp | 8 -- radio/src/gui/128x64/model_select.cpp | 24 ---- radio/src/gui/128x64/model_setup.cpp | 29 +++-- radio/src/gui/128x64/radio_diagkeys.cpp | 20 +--- radio/src/gui/128x64/radio_hardware.cpp | 9 +- radio/src/gui/128x64/radio_setup.cpp | 12 +- radio/src/gui/128x64/view_main.cpp | 2 - radio/src/gui/212x64/model_setup.cpp | 4 +- radio/src/gui/212x64/radio_setup.cpp | 2 +- radio/src/gui/480x272/model_setup.cpp | 2 +- radio/src/gui/common/stdlcd/popups.cpp | 24 ++-- .../src/gui/common/stdlcd/radio_sdmanager.cpp | 18 +-- radio/src/keys.cpp | 7 -- radio/src/mixer.cpp | 18 --- radio/src/opentx.cpp | 57 +--------- radio/src/opentx.h | 30 +---- radio/src/simu.cpp | 3 - radio/src/switches.cpp | 10 -- .../arm/stm32/bootloader/CMakeLists.txt | 13 +++ .../common/arm/stm32/bootloader/boot.cpp | 16 ++- .../common/arm/stm32/f2/CMakeLists.txt | 2 + .../common/arm/stm32/f4/CMakeLists.txt | 2 + .../arm/stm32/rotary_encoder_driver.cpp | 103 ++++++++++++++++++ radio/src/targets/horus/CMakeLists.txt | 2 +- radio/src/targets/horus/board.cpp | 8 +- radio/src/targets/horus/board.h | 5 +- radio/src/targets/horus/hal.h | 7 ++ radio/src/targets/horus/keys_driver.cpp | 62 ----------- radio/src/targets/simu/opentxsimulator.cpp | 3 - radio/src/targets/simu/simpgmspace.cpp | 15 ++- radio/src/targets/sky9x/board.cpp | 5 +- radio/src/targets/sky9x/board.h | 9 +- radio/src/targets/sky9x/keys_driver.cpp | 4 - radio/src/targets/sky9x/rotenc_driver.cpp | 40 +++---- radio/src/targets/taranis/CMakeLists.txt | 7 ++ radio/src/targets/taranis/board.cpp | 72 ++++++++---- radio/src/targets/taranis/board.h | 7 +- radio/src/targets/taranis/hal.h | 59 +++++++--- radio/src/targets/taranis/keys_driver.cpp | 29 ----- radio/src/translations.cpp | 6 - radio/src/translations.h | 10 +- radio/src/translations/cz.h.txt | 10 +- radio/src/translations/de.h.txt | 10 +- radio/src/translations/en.h.txt | 10 +- radio/src/translations/es.h.txt | 10 +- radio/src/translations/fi.h.txt | 10 +- radio/src/translations/fr.h.txt | 10 +- radio/src/translations/it.h.txt | 10 +- radio/src/translations/nl.h.txt | 10 +- radio/src/translations/pl.h.txt | 10 +- radio/src/translations/pt.h.txt | 10 +- radio/src/translations/se.h.txt | 14 +-- 60 files changed, 363 insertions(+), 652 deletions(-) create mode 100644 radio/src/targets/common/arm/stm32/rotary_encoder_driver.cpp diff --git a/radio/src/cli.cpp b/radio/src/cli.cpp index f43dd5eb8..a431b2031 100644 --- a/radio/src/cli.cpp +++ b/radio/src/cli.cpp @@ -963,7 +963,7 @@ int cliDisplay(const char ** argv) serialPrint("[%s] = %s", name, keyState(i) ? "on" : "off"); } #if defined(ROTARY_ENCODER_NAVIGATION) - serialPrint("[Enc.] = %d", rotencValue[0] / ROTARY_ENCODER_GRANULARITY); + serialPrint("[Enc.] = %d", rotencValue / ROTARY_ENCODER_GRANULARITY); #endif for (int i=TRM_BASE; i<=TRM_LAST; i++) { serialPrint("[Trim%d] = %s", i-TRM_BASE, keyState(i) ? "on" : "off"); diff --git a/radio/src/dataconstants.h b/radio/src/dataconstants.h index 68aeac48e..db963f9ef 100644 --- a/radio/src/dataconstants.h +++ b/radio/src/dataconstants.h @@ -144,17 +144,6 @@ enum CurveType { #define XPOTS_MULTIPOS_COUNT 6 -#if defined(PCBSKY9X) && defined(REVX) - #define MAX_ROTARY_ENCODERS 1 - #define NUM_ROTARY_ENCODERS 0 -#elif defined(PCBSKY9X) - #define MAX_ROTARY_ENCODERS 1 - #define NUM_ROTARY_ENCODERS 1 -#else - #define MAX_ROTARY_ENCODERS 0 - #define NUM_ROTARY_ENCODERS 0 -#endif - #if defined(COLORLCD) enum MainViews { VIEW_BLANK, @@ -607,11 +596,6 @@ enum MixSources { MIXSRC_GYRO2, LUA_EXPORT("gyry", "Gyro Y") #endif -#if defined(PCBSKY9X) - MIXSRC_REa, - MIXSRC_LAST_ROTARY_ENCODER = MIXSRC_REa, -#endif - MIXSRC_MAX, MIXSRC_FIRST_HELI, @@ -799,12 +783,6 @@ enum ResetFunctionParam { FUNC_RESET_FLIGHT, #if defined(TELEMETRY_FRSKY) FUNC_RESET_TELEMETRY, -#endif -#if ROTARY_ENCODERS > 0 - FUNC_RESET_ROTENC1, -#endif -#if ROTARY_ENCODERS > 1 - FUNC_RESET_ROTENC2, #endif FUNC_RESET_PARAM_FIRST_TELEM, FUNC_RESET_PARAM_LAST_TELEM = FUNC_RESET_PARAM_FIRST_TELEM + MAX_TELEMETRY_SENSORS, diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index e3f62b4fc..f872aa79b 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -185,12 +185,6 @@ PACK(struct trim_t { typedef int16_t gvar_t; -#if MAX_ROTARY_ENCODERS > 0 - #define FLIGHT_MODE_ROTARY_ENCODERS_FIELD int16_t rotaryEncoders[MAX_ROTARY_ENCODERS]; -#else - #define FLIGHT_MODE_ROTARY_ENCODERS_FIELD -#endif - PACK(struct FlightModeData { trim_t trim[NUM_TRIMS]; NOBACKUP(char name[LEN_FLIGHT_MODE_NAME]); @@ -198,7 +192,6 @@ PACK(struct FlightModeData { int16_t spare:7; uint8_t fadeIn; uint8_t fadeOut; - FLIGHT_MODE_ROTARY_ENCODERS_FIELD gvar_t gvars[MAX_GVARS]; }); @@ -866,7 +859,7 @@ static inline void check_struct() CHKSIZE(ExpoData, 17); CHKSIZE(LimitData, 11); CHKSIZE(CustomFunctionData, 9); - CHKSIZE(FlightModeData, 38); + CHKSIZE(FlightModeData, 36); CHKSIZE(TimerData, 11); CHKSIZE(SwashRingData, 8); CHKSIZE(FrSkyBarData, 5); @@ -917,7 +910,7 @@ static inline void check_struct() CHKSIZE(ModelData, 6601); #elif defined(PCBSKY9X) CHKSIZE(RadioData, 735); - CHKSIZE(ModelData, 5319); + CHKSIZE(ModelData, 5301); #elif defined(PCBHORUS) CHKSIZE(RadioData, 855); CHKSIZE(ModelData, 9734); diff --git a/radio/src/functions.cpp b/radio/src/functions.cpp index b57fb9e0c..62282afb6 100644 --- a/radio/src/functions.cpp +++ b/radio/src/functions.cpp @@ -130,10 +130,6 @@ void evalFunctions(const CustomFunctionData * functions, CustomFunctionsContext uint8_t playFirstIndex = (functions == g_model.customFn ? 1 : 1+MAX_SPECIAL_FUNCTIONS); #define PLAY_INDEX (i+playFirstIndex) -#if defined(ROTARY_ENCODERS) && defined(GVARS) - static rotenc_t rePreviousValues[ROTARY_ENCODERS]; -#endif - #if defined(OVERRIDE_CHANNEL_FUNCTION) for (uint8_t i=0; i 0 - case FUNC_RESET_ROTENC1: -#if ROTARY_ENCODERS > 1 - case FUNC_RESET_ROTENC2: -#endif - rotencValue[CFN_PARAM(cfn)-FUNC_RESET_ROTENC1] = 0; - break; -#endif } if (CFN_PARAM(cfn)>=FUNC_RESET_PARAM_FIRST_TELEM) { uint8_t item = CFN_PARAM(cfn)-FUNC_RESET_PARAM_FIRST_TELEM; @@ -257,14 +244,6 @@ void evalFunctions(const CustomFunctionData * functions, CustomFunctionsContext else if (CFN_PARAM(cfn) >= MIXSRC_FIRST_TRIM && CFN_PARAM(cfn) <= MIXSRC_LAST_TRIM) { trimGvar[CFN_PARAM(cfn)-MIXSRC_FIRST_TRIM] = CFN_GVAR_INDEX(cfn); } -#if defined(ROTARY_ENCODERS) - else if (CFN_PARAM(cfn) >= MIXSRC_REa && CFN_PARAM(cfn) < MIXSRC_TrimRud) { - int8_t scroll = rePreviousValues[CFN_PARAM(cfn)-MIXSRC_REa] - (rotencValue[CFN_PARAM(cfn)-MIXSRC_REa] / ROTARY_ENCODER_GRANULARITY); - if (scroll) { - SET_GVAR(CFN_GVAR_INDEX(cfn), limit(MODEL_GVAR_MIN(CFN_GVAR_INDEX(cfn)), GVAR_VALUE(CFN_GVAR_INDEX(cfn), getGVarFlightMode(mixerCurrentFlightMode, CFN_GVAR_INDEX(cfn))) + scroll, MODEL_GVAR_MAX(CFN_GVAR_INDEX(cfn))), mixerCurrentFlightMode); - } - } -#endif else { SET_GVAR(CFN_GVAR_INDEX(cfn), limit(MODEL_GVAR_MIN(CFN_GVAR_INDEX(cfn)), calcRESXto100(getValue(CFN_PARAM(cfn))), MODEL_GVAR_MAX(CFN_GVAR_INDEX(cfn))), mixerCurrentFlightMode); } @@ -419,11 +398,5 @@ void evalFunctions(const CustomFunctionData * functions, CustomFunctionsContext functionsContext.activeSwitches = newActiveSwitches; functionsContext.activeFunctions = newActiveFunctions; - -#if defined(ROTARY_ENCODERS) && defined(GVARS) - for (uint8_t i=0; i 0 -void putsRotaryEncoderMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att) -{ - int16_t v = flightModeAddress(phase)->rotaryEncoders[idx]; - - if (v > ROTARY_ENCODER_MAX) { - uint8_t p = v - ROTARY_ENCODER_MAX - 1; - if (p >= phase) p++; - lcdDrawChar(x, y, '0'+p, att); - } - else { - lcdDrawChar(x, y, 'a'+idx, att); - } -} -#endif - void drawValueWithUnit(coord_t x, coord_t y, lcdint_t val, uint8_t unit, LcdFlags att) { // convertUnit(val, unit); diff --git a/radio/src/gui/128x64/lcd.h b/radio/src/gui/128x64/lcd.h index a10b916fa..26ba779f4 100644 --- a/radio/src/gui/128x64/lcd.h +++ b/radio/src/gui/128x64/lcd.h @@ -145,10 +145,6 @@ void drawTimerMode(coord_t x, coord_t y, int8_t mode, LcdFlags att=0); void drawTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att); void drawShortTrimMode(coord_t x, coord_t y, uint8_t mode, uint8_t idx, LcdFlags att); -#if defined(ROTARY_ENCODERS) - void putsRotaryEncoderMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att); -#endif - #define putsChn(x, y, idx, att) drawSource(x, y, MIXSRC_CH1+idx-1, att) void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags attr); diff --git a/radio/src/gui/128x64/model_flightmodes.cpp b/radio/src/gui/128x64/model_flightmodes.cpp index a9dd6fa4a..ecfe6725c 100644 --- a/radio/src/gui/128x64/model_flightmodes.cpp +++ b/radio/src/gui/128x64/model_flightmodes.cpp @@ -36,7 +36,6 @@ enum MenuModelFlightModeItems { ITEM_MODEL_FLIGHT_MODE_NAME, ITEM_MODEL_FLIGHT_MODE_SWITCH, ITEM_MODEL_FLIGHT_MODE_TRIMS, - IF_ROTARY_ENCODERS(ITEM_MODEL_FLIGHT_MODE_ROTARY_ENCODERS) ITEM_MODEL_FLIGHT_MODE_FADE_IN, ITEM_MODEL_FLIGHT_MODE_FADE_OUT, #if defined(GVARS) @@ -72,7 +71,7 @@ void menuModelFlightModeOne(event_t event) #define VERTICAL_SHIFT (ITEM_MODEL_FLIGHT_MODE_FADE_IN-ITEM_MODEL_FLIGHT_MODE_SWITCH) static const uint8_t mstate_tab_fm1[] = {0, 0, 0, (uint8_t)-1, 1, 1, 1, 1, 1}; #endif - static const uint8_t mstate_tab_others[] = {0, 0, 3, IF_ROTARY_ENCODERS(NUM_ROTARY_ENCODERS-1) 0, 0, (uint8_t)-1, 2, 2, 2, 2, 2}; + static const uint8_t mstate_tab_others[] = {0, 0, 3, 0, 0, (uint8_t)-1, 2, 2, 2, 2, 2}; check(event, 0, NULL, 0, (s_currIdx == 0) ? mstate_tab_fm1 : mstate_tab_others, DIM(mstate_tab_others)-1, ITEM_MODEL_FLIGHT_MODE_MAX - HEADER_LINE - (s_currIdx==0 ? (ITEM_MODEL_FLIGHT_MODE_FADE_IN-ITEM_MODEL_FLIGHT_MODE_SWITCH-1) : 0)); @@ -80,7 +79,7 @@ void menuModelFlightModeOne(event_t event) #define PHASE_ONE_FIRST_LINE (1+1*FH) #else - SUBMENU(STR_MENUFLIGHTMODE, 3 + (s_currIdx==0 ? 0 : 2 + (bool)NUM_ROTARY_ENCODERS), {0, 0, 3, IF_ROTARY_ENCODERS(NUM_ROTARY_ENCODERS-1) 0/*, 0*/}); + SUBMENU(STR_MENUFLIGHTMODE, 3 + (s_currIdx==0 ? 0 : 2), {0, 0, 3, 0/*, 0*/}); #define PHASE_ONE_FIRST_LINE (1+1*FH) #endif @@ -121,24 +120,6 @@ void menuModelFlightModeOne(event_t event) } break; -#if ROTARY_ENCODERS > 0 - case ITEM_MODEL_FLIGHT_MODE_ROTARY_ENCODERS: - lcdDrawTextAlignedLeft(y, STR_ROTARY_ENCODER); - for (uint8_t t=0; t 0) { - int16_t v = flightModeAddress(s_currIdx)->rotaryEncoders[t]; - if (v < ROTARY_ENCODER_MAX) v = ROTARY_ENCODER_MAX; - v = checkIncDec(event, v, ROTARY_ENCODER_MAX, ROTARY_ENCODER_MAX+MAX_FLIGHT_MODES-1, EE_MODEL); - if (checkIncDec_Ret) { - if (v == ROTARY_ENCODER_MAX) v = 0; - flightModeAddress(s_currIdx)->rotaryEncoders[t] = v; - } - } - } - break; -#endif - case ITEM_MODEL_FLIGHT_MODE_FADE_IN: fm->fadeIn = EDIT_DELAY(0, y, event, attr, STR_FADEIN, fm->fadeIn); break; @@ -191,19 +172,7 @@ void menuModelFlightModeOne(event_t event) } } -#if defined(ROTARY_ENCODERS) - #if ROTARY_ENCODERS > 2 - #define NAME_OFS (-4-12) - #define SWITCH_OFS (-FW/2-2-13) - #define TRIMS_OFS (-FW/2-4-15) - #define ROTARY_ENC_OFS (0) - #else - #define NAME_OFS (-4) - #define SWITCH_OFS (-FW/2-2) - #define TRIMS_OFS (-FW/2-4) - #define ROTARY_ENC_OFS (2) - #endif -#elif defined(PCBTARANIS) +#if defined(PCBTARANIS) #define NAME_POS 20 #define SWITCH_POS 59 #define TRIMS_POS 79 @@ -220,7 +189,6 @@ void menuModelFlightModesAll(event_t event) int8_t sub = menuVerticalPosition - HEADER_LINE; switch (event) { - CASE_EVT_ROTARY_BREAK case EVT_KEY_FIRST(KEY_ENTER): if (sub == MAX_FLIGHT_MODES) { s_editMode = 0; diff --git a/radio/src/gui/128x64/model_inputs_mixes.cpp b/radio/src/gui/128x64/model_inputs_mixes.cpp index c35954d9d..0c991fd6e 100644 --- a/radio/src/gui/128x64/model_inputs_mixes.cpp +++ b/radio/src/gui/128x64/model_inputs_mixes.cpp @@ -382,14 +382,7 @@ void menuModelMixOne(event_t event) MixData * md2 = mixAddress(s_currIdx) ; putsChn(lcdLastRightPos+1*FW, 0, md2->destCh+1,0); -#if defined(ROTARY_ENCODERS) - if ((menuVerticalPosition == MIX_FIELD_TRIM && md2->srcRaw > NUM_STICKS) || (menuVerticalPosition == MIX_FIELD_CURVE && md2->curveMode == MODE_CURVE)) - SUBMENU_NOTITLE(MIX_FIELD_COUNT, {0, 0, 0, 0, 0, 0, CASE_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/}) - else - SUBMENU_NOTITLE(MIX_FIELD_COUNT, {0, 0, 0, 0, 1, 1, CASE_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/}); -#else SUBMENU_NOTITLE(MIX_FIELD_COUNT, {0, 0, 0, 0, 1, 1, CASE_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0, 0 /*, ...*/}); -#endif int8_t sub = menuVerticalPosition; int8_t editMode = s_editMode; @@ -654,7 +647,6 @@ void menuModelExpoMix(uint8_t expo, event_t event) } // no break - CASE_EVT_ROTARY_BREAK case EVT_KEY_LONG(KEY_ENTER): killEvents(event); if (s_copyTgtOfs) { diff --git a/radio/src/gui/128x64/model_select.cpp b/radio/src/gui/128x64/model_select.cpp index 8b7aa6b33..9a6a39498 100644 --- a/radio/src/gui/128x64/model_select.cpp +++ b/radio/src/gui/128x64/model_select.cpp @@ -113,21 +113,6 @@ void menuModelSelect(event_t event) } break; -#if defined(ROTARY_ENCODERS) - case EVT_ROTARY_LONG: - killEvents(event); - if (s_editMode < 0) { - popMenu(); - break; - } - else if (!s_copyMode) { - menuVerticalPosition = sub = g_eeGeneral.currModel; - s_copyMode = 0; - s_editMode = EDIT_MODE_INIT; - } - // no break -#endif - case EVT_KEY_BREAK(KEY_EXIT): if (s_copyMode) { sub = menuVerticalPosition = (s_copyMode == MOVE_MODE || s_copySrcRow<0) ? (MAX_MODELS+sub+s_copyTgtOfs) % MAX_MODELS : s_copySrcRow; @@ -141,15 +126,6 @@ void menuModelSelect(event_t event) } break; -#if defined(ROTARY_ENCODERS) - case EVT_ROTARY_BREAK: - if (s_editMode == -1) { - s_editMode = 0; - break; - } - // no break; -#endif - case EVT_KEY_LONG(KEY_ENTER): case EVT_KEY_BREAK(KEY_ENTER): s_editMode = 0; diff --git a/radio/src/gui/128x64/model_setup.cpp b/radio/src/gui/128x64/model_setup.cpp index 67cdddae1..5d11c9904 100644 --- a/radio/src/gui/128x64/model_setup.cpp +++ b/radio/src/gui/128x64/model_setup.cpp @@ -551,7 +551,7 @@ void menuModelSetup(event_t event) SW_WARN_ROWS, // Switch warning POT_WARN_ITEMS(), // Pot warning - NUM_STICKS + NUM_POTS + NUM_SLIDERS + NUM_ROTARY_ENCODERS - 1, // Center beeps + NUM_STICKS + NUM_POTS + NUM_SLIDERS - 1, // Center beeps 0, // Global functions uint8_t((isDefaultModelRegistrationID() || (warningText && popupFunc == runPopupRegister)) ? HIDDEN_ROW : READONLY_ROW), // Registration ID @@ -588,7 +588,7 @@ void menuModelSetup(event_t event) TRAINER_ROWS }); #else - MENU_TAB({ HEADER_LINE_COLUMNS 0, TIMER_ROWS, TIMER_ROWS, TIMER_ROWS, 0, 1, 0, 0, 0, 0, 0, LABEL(PreflightCheck), 0, 0, NUM_SWITCHES-1, NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_ROTARY_ENCODERS-1, 0, + MENU_TAB({ HEADER_LINE_COLUMNS 0, TIMER_ROWS, TIMER_ROWS, TIMER_ROWS, 0, 1, 0, 0, 0, 0, 0, LABEL(PreflightCheck), 0, 0, NUM_SWITCHES-1, NUM_STICKS+NUM_POTS+NUM_SLIDERS-1, 0, LABEL(ExternalModule), EXTERNAL_MODULE_MODE_ROWS, MULTIMODULE_SUBTYPE_ROWS(EXTERNAL_MODULE) @@ -882,7 +882,6 @@ void menuModelSetup(event_t event) s_editMode = 0; if (!READ_ONLY()) { switch (event) { - CASE_EVT_ROTARY_BREAK case EVT_KEY_BREAK(KEY_ENTER): if (menuHorizontalPosition < NUM_SWITCHES-1) { g_model.switchWarningEnable ^= (1 << menuHorizontalPosition); @@ -980,7 +979,7 @@ void menuModelSetup(event_t event) case ITEM_MODEL_BEEP_CENTER: lcdDrawTextAlignedLeft(y, STR_BEEPCTR); - for (uint8_t i=0; i 0) { - popupMenuItemsCount = min(reusableBuffer.moduleSetup.bindInformation.candidateReceiversCount, PXX2_MAX_RECEIVERS_PER_MODULE); - for (uint8_t i=0; i 0) { + popupMenuItemsCount = min(reusableBuffer.moduleSetup.bindInformation.candidateReceiversCount, PXX2_MAX_RECEIVERS_PER_MODULE); + for (uint8_t i = 0; i < popupMenuItemsCount; i++) { + popupMenuItems[i] = reusableBuffer.moduleSetup.bindInformation.candidateReceiversNames[i]; + } + popupMenuTitle = STR_PXX2_SELECT_RX; + POPUP_MENU_START(onPXX2BindMenu); + } + else { + drawMessageBox("Waiting for RX..."); } - popupMenuTitle = STR_PXX2_SELECT_RX; - POPUP_MENU_START(onPXX2BindMenu); } } diff --git a/radio/src/gui/128x64/radio_diagkeys.cpp b/radio/src/gui/128x64/radio_diagkeys.cpp index 214d14726..3a7da7c2a 100644 --- a/radio/src/gui/128x64/radio_diagkeys.cpp +++ b/radio/src/gui/128x64/radio_diagkeys.cpp @@ -86,25 +86,17 @@ void menuRadioDiagKeys(event_t event) } #if defined(ROTARY_ENCODER_NAVIGATION) - for (uint8_t i=0; i=POT1 && i 0) { - popupMenuItemsCount = min(reusableBuffer.sdManager.otaInformation.candidateReceiversCount, PXX2_MAX_RECEIVERS_PER_MODULE); - for (uint8_t i=0; i 0) { + popupMenuItemsCount = min(reusableBuffer.sdManager.otaInformation.candidateReceiversCount, PXX2_MAX_RECEIVERS_PER_MODULE); + for (uint8_t i=0; i 0 - return getRotaryEncoder(i - MIXSRC_REa); -#else - return 0; -#endif - } -#endif - else if (i == MIXSRC_MAX) { return 1024; } @@ -499,14 +489,6 @@ void evalInputs(uint8_t mode) } } -#if defined(ROTARY_ENCODERS) - for (uint8_t i=0; i 0 for (uint8_t i=0; irotaryEncoders[idx]; - if (value <= ROTARY_ENCODER_MAX) return phase; - uint8_t result = value-ROTARY_ENCODER_MAX-1; - if (result >= phase) result++; - phase = result; - } - return 0; -} - -int16_t getRotaryEncoder(uint8_t idx) -{ - return flightModeAddress(getRotaryEncoderFlightMode(idx))->rotaryEncoders[idx]; -} - -void incRotaryEncoder(uint8_t idx, int8_t inc) -{ - rotencValue[idx] += inc; - int16_t *value = &(flightModeAddress(getRotaryEncoderFlightMode(idx))->rotaryEncoders[idx]); - *value = limit((int16_t)-RESX, (int16_t)(*value + (inc * 8)), (int16_t)+RESX); - storageDirty(EE_MODEL); -} -#endif - getvalue_t convert16bitsTelemValue(source_t channel, ls_telemetry_value_t value) { return value; @@ -1366,10 +1327,6 @@ void evalTrims() } } -uint8_t mSwitchDuration[1+NUM_ROTARY_ENCODERS] = { 0 }; -#define CFN_PRESSLONG_DURATION 100 - - uint8_t s_mixer_first_run_done = false; void doMixerCalculations() @@ -1766,20 +1723,12 @@ void moveTrimsToOffsets() // copy state of 3 primary to subtrim AUDIO_WARNING2(); } -#if defined(ROTARY_ENCODERS) - volatile rotenc_t rotencValue[ROTARY_ENCODERS] = {0}; -#elif defined(ROTARY_ENCODER_NAVIGATION) - volatile rotenc_t rotencValue[1] = {0}; -#endif - #if defined(ROTARY_ENCODER_NAVIGATION) -uint8_t rotencSpeed; + volatile rotenc_t rotencValue = 0; + uint8_t rotencSpeed; #endif - - #define OPENTX_INIT_ARGS - -void opentxInit(OPENTX_INIT_ARGS) +void opentxInit() { TRACE("opentxInit"); diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 032a7134c..8a2b0888c 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -178,10 +178,6 @@ #define CASE_CAPACITY(x) #endif -#if ROTARY_ENCODERS > 0 - #define ROTARY_ENCODER_NAVIGATION -#endif - #if defined(FAI) #define IS_FAI_ENABLED() true #define IF_FAI_CHOICE(x) @@ -294,12 +290,6 @@ void memswap(void * a, void * b, uint8_t size); #define GET_LOWRES_POT_POSITION(i) (getValue(MIXSRC_FIRST_POT+(i)) >> 4) #define SAVE_POT_POSITION(i) g_model.potsWarnPosition[i] = GET_LOWRES_POT_POSITION(i) -#if ROTARY_ENCODERS > 0 - #define IF_ROTARY_ENCODERS(x) x, -#else - #define IF_ROTARY_ENCODERS(x) -#endif - #define PPM_CENTER 1500 #if defined(PPM_CENTER_ADJUSTABLE) @@ -386,17 +376,10 @@ extern uint8_t channel_order(uint8_t x); #define SPLASH_TIMEOUT (4*100) // 4 seconds #endif -#if defined(ROTARY_ENCODERS) - #define IS_ROTARY_ENCODER_NAVIGATION_ENABLE() g_eeGeneral.reNavigation - extern volatile rotenc_t rotencValue[ROTARY_ENCODERS]; - #define ROTARY_ENCODER_NAVIGATION_VALUE rotencValue[g_eeGeneral.reNavigation - 1] -#elif defined(ROTARY_ENCODER_NAVIGATION) - #define IS_ROTARY_ENCODER_NAVIGATION_ENABLE() true - extern volatile rotenc_t rotencValue[1]; - #define ROTARY_ENCODER_NAVIGATION_VALUE rotencValue[0] -#endif - #if defined(ROTARY_ENCODER_NAVIGATION) + #define IS_ROTARY_ENCODER_NAVIGATION_ENABLE() true + extern volatile rotenc_t rotencValue; + #define ROTARY_ENCODER_NAVIGATION_VALUE rotencValue extern uint8_t rotencSpeed; #define ROTENC_LOWSPEED 1 #define ROTENC_MIDSPEED 5 @@ -549,12 +532,7 @@ int getTrimValue(uint8_t phase, uint8_t idx); bool setTrimValue(uint8_t phase, uint8_t idx, int trim); -#if defined(ROTARY_ENCODERS) - int16_t getRotaryEncoder(uint8_t idx); - void incRotaryEncoder(uint8_t idx, int8_t inc); -#endif - -#if defined(PCBSKY9X) +#if defined(PCBSKY9X) #define ROTARY_ENCODER_GRANULARITY (2 << g_eeGeneral.rotarySteps) #elif defined(PCBHORUS) #define ROTARY_ENCODER_GRANULARITY (1) diff --git a/radio/src/simu.cpp b/radio/src/simu.cpp index 662a8538a..133cbbeba 100644 --- a/radio/src/simu.cpp +++ b/radio/src/simu.cpp @@ -274,9 +274,6 @@ void Open9xSim::updateKeysAndSwitches(bool start) KEY_Left, KEY_LEFT, KEY_Up, KEY_UP, KEY_Down, KEY_DOWN, -#if defined(ROTARY_ENCODER_NAVIGATION) - KEY_F, BTN_REa, -#endif #endif }; diff --git a/radio/src/switches.cpp b/radio/src/switches.cpp index c180f67aa..54d9bc569 100644 --- a/radio/src/switches.cpp +++ b/radio/src/switches.cpp @@ -452,16 +452,6 @@ bool getSwitch(swsrc_t swtch, uint8_t flags) idx = (CONVERT_MODE_TRIMS(idx/2) << 1) + (idx & 1); result = trimDown(idx); } -#if ROTARY_ENCODERS > 0 - else if (cs_idx == SWSRC_REa) { - result = REA_DOWN(); - } -#endif -#if ROTARY_ENCODERS > 1 - else if (cs_idx == SWSRC_REb) { - result = REB_DOWN(); - } -#endif else if (cs_idx >= SWSRC_FIRST_SENSOR) { result = !telemetryItems[cs_idx-SWSRC_FIRST_SENSOR].isOld(); } diff --git a/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt b/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt index bb55c6af4..67a047592 100644 --- a/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt @@ -8,7 +8,9 @@ if(PCB STREQUAL X12S OR PCB STREQUAL X10) ../f4/system_stm32f4xx.c ../../../../../targets/${TARGET_DIR}/startup_stm32f42_43xxx.s ../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c + ../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c ../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c + ../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c ../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c ../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmc.c ../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_ltdc.c @@ -23,7 +25,9 @@ elseif(PCB STREQUAL X9E) ../f4/system_stm32f4xx.c ../../../../../targets/${TARGET_DIR}/startup_stm32f40_41xxx.s ../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c + ../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c ../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c + ../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c ../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c ../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c ../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/misc.c @@ -34,7 +38,9 @@ else() ../f2/system_stm32f2xx.c ../../../../../${STM32LIB_DIR}/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s ../../../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c + ../../../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_syscfg.c ../../../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c + ../../../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_exti.c ../../../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_spi.c ../../../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_i2c.c ../../../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/misc.c @@ -78,6 +84,13 @@ set(BOOTLOADER_SRC bin_files.cpp ) +if(PCB STREQUAL X12S OR PCB STREQUAL X10 OR PCB STREQUAL X9E OR PCB STREQUAL X7 OR PCB STREQUAL X3) + set(BOOTLOADER_SRC + ${BOOTLOADER_SRC} + ../../../../../targets/common/arm/stm32/rotary_encoder_driver.cpp + ) +endif() + if(NOT (PCB STREQUAL X10 OR PCB STREQUAL X12S)) set(BOOTLOADER_SRC ${BOOTLOADER_SRC} diff --git a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp index 20b22f78d..c34cc38ed 100644 --- a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp +++ b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp @@ -50,7 +50,7 @@ const uint8_t bootloaderVersion[] __attribute__ ((section(".version"), used)) = { 'B', 'O', 'O', 'T', '1', '0' }; #if defined(ROTARY_ENCODER_NAVIGATION) -volatile rotenc_t rotencValue[1] = {0}; +volatile rotenc_t rotencValue = 0; #endif /*---------------------------------------------------------------------------- @@ -86,18 +86,12 @@ void interrupt10ms(void) } #if defined(ROTARY_ENCODER_NAVIGATION) - checkRotaryEncoder(); static rotenc_t rePreviousValue; - rotenc_t reNewValue = (rotencValue[0] / ROTARY_ENCODER_GRANULARITY); + rotenc_t reNewValue = (rotencValue / ROTARY_ENCODER_GRANULARITY); int8_t scrollRE = reNewValue - rePreviousValue; if (scrollRE) { rePreviousValue = reNewValue; - if (scrollRE < 0) { - putEvent(EVT_KEY_FIRST(KEY_UP)); //EVT_ROTARY_LEFT - } - else { - putEvent(EVT_KEY_FIRST(KEY_DOWN)); //EVT_ROTARY_RIGHT - } + putEvent(scrollRE < 0 ? EVT_KEY_FIRST(KEY_UP) : EVT_KEY_FIRST(KEY_DOWN)); } #endif } @@ -221,6 +215,10 @@ int main() keysInit(); +#if defined(ROTARY_ENCODER_NAVIGATION) + rotaryEncoderInit(); +#endif + // wait for inputs to stabilize for (uint32_t i = 0; i < 50000; i += 1) { wdt_reset(); diff --git a/radio/src/targets/common/arm/stm32/f2/CMakeLists.txt b/radio/src/targets/common/arm/stm32/f2/CMakeLists.txt index 1dec044f2..c0ffd4af0 100644 --- a/radio/src/targets/common/arm/stm32/f2/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/f2/CMakeLists.txt @@ -11,8 +11,10 @@ set(STM32LIB_SRC CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s STM32F2xx_StdPeriph_Driver/src/misc.c STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c + STM32F2xx_StdPeriph_Driver/src/stm32f2xx_exti.c STM32F2xx_StdPeriph_Driver/src/stm32f2xx_dbgmcu.c STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c + STM32F2xx_StdPeriph_Driver/src/stm32f2xx_syscfg.c STM32F2xx_StdPeriph_Driver/src/stm32f2xx_spi.c STM32F2xx_StdPeriph_Driver/src/stm32f2xx_i2c.c STM32F2xx_StdPeriph_Driver/src/stm32f2xx_dma.c diff --git a/radio/src/targets/common/arm/stm32/f4/CMakeLists.txt b/radio/src/targets/common/arm/stm32/f4/CMakeLists.txt index 297c76dba..aafce8b63 100644 --- a/radio/src/targets/common/arm/stm32/f4/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/f4/CMakeLists.txt @@ -10,8 +10,10 @@ set(STM32LIB_SRC ${STM32LIB_SRC} STM32F4xx_StdPeriph_Driver/src/misc.c STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dbgmcu.c STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.c diff --git a/radio/src/targets/common/arm/stm32/rotary_encoder_driver.cpp b/radio/src/targets/common/arm/stm32/rotary_encoder_driver.cpp new file mode 100644 index 000000000..f6a47d071 --- /dev/null +++ b/radio/src/targets/common/arm/stm32/rotary_encoder_driver.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "opentx.h" + +uint32_t rotencPosition; + +void rotaryEncoderInit() +{ + SYSCFG_EXTILineConfig(ROTARY_ENCODER_EXTI_PortSource, ROTARY_ENCODER_EXTI_PinSource1); + +#if defined(ROTARY_ENCODER_EXTI_LINE2) + SYSCFG_EXTILineConfig(ROTARY_ENCODER_EXTI_PortSource, ROTARY_ENCODER_EXTI_PinSource2); +#endif + + EXTI_InitTypeDef EXTI_InitStructure; + EXTI_StructInit(&EXTI_InitStructure); + EXTI_InitStructure.EXTI_Line = ROTARY_ENCODER_EXTI_LINE1; + EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; + EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; + EXTI_InitStructure.EXTI_LineCmd = ENABLE; + EXTI_Init(&EXTI_InitStructure); + +#if defined(ROTARY_ENCODER_EXTI_LINE2) + EXTI_InitStructure.EXTI_Line = ROTARY_ENCODER_EXTI_LINE2; + EXTI_Init(&EXTI_InitStructure); +#endif + + NVIC_InitTypeDef NVIC_InitStructure; + NVIC_InitStructure.NVIC_IRQChannel = ROTARY_ENCODER_EXTI_IRQn1; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 8; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; /* Not used as 4 bits are used for the pre-emption priority. */; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); + +#if defined(ROTARY_ENCODER_EXTI_IRQn2) + NVIC_InitStructure.NVIC_IRQChannel = ROTARY_ENCODER_EXTI_IRQn2; + NVIC_Init(&NVIC_InitStructure); +#endif + + rotencPosition = ROTARY_ENCODER_POSITION(); +} + +void rotaryEncoderCheck() +{ + uint32_t newpos = ROTARY_ENCODER_POSITION(); + if (newpos != rotencPosition && !keyState(KEY_ENTER)) { + if ((rotencPosition & 0x01) ^ ((newpos & 0x02) >> 1)) { + --rotencValue; + } + else { + ++rotencValue; + } + rotencPosition = newpos; +#if !defined(BOOT) + if (g_eeGeneral.backlightMode & e_backlight_mode_keys) { + backlightOn(); + } +#endif + } +} + +extern "C" void ROTARY_ENCODER_EXTI_IRQHandler1(void) +{ + if (EXTI_GetITStatus(ROTARY_ENCODER_EXTI_LINE1) != RESET) { + rotaryEncoderCheck(); + EXTI_ClearITPendingBit(ROTARY_ENCODER_EXTI_LINE1); + } + +#if !defined(ROTARY_ENCODER_EXTI_IRQn2) + if (EXTI_GetITStatus(ROTARY_ENCODER_EXTI_LINE2) != RESET) { + rotaryEncoderCheck(); + EXTI_ClearITPendingBit(ROTARY_ENCODER_EXTI_LINE2); + } +#endif +} + +#if defined(ROTARY_ENCODER_EXTI_IRQn2) +extern "C" void ROTARY_ENCODER_EXTI_IRQHandler2(void) +{ + if (EXTI_GetITStatus(ROTARY_ENCODER_EXTI_LINE2) != RESET) { + rotaryEncoderCheck(); + EXTI_ClearITPendingBit(ROTARY_ENCODER_EXTI_LINE2); + } +} +#endif diff --git a/radio/src/targets/horus/CMakeLists.txt b/radio/src/targets/horus/CMakeLists.txt index b7797db21..1de49d3e8 100644 --- a/radio/src/targets/horus/CMakeLists.txt +++ b/radio/src/targets/horus/CMakeLists.txt @@ -36,7 +36,6 @@ if (PCB STREQUAL X10) ../common/arm/stm32/adc_driver.cpp ../common/arm/stm32/sticks_pwm_driver.cpp ) - set(BITMAPS_TARGET x10_bitmaps) set(FONTS_TARGET x10_fonts) set(LCD_DRIVER lcd_driver.cpp) @@ -133,6 +132,7 @@ set(TARGET_SRC trainer_driver.cpp ../common/arm/stm32/intmodule_serial_driver.cpp ../common/arm/stm32/bluetooth_driver.cpp + ../common/arm/stm32/rotary_encoder_driver.cpp ) set(FIRMWARE_TARGET_SRC diff --git a/radio/src/targets/horus/board.cpp b/radio/src/targets/horus/board.cpp index b47d9b29c..6a09bb3fe 100644 --- a/radio/src/targets/horus/board.cpp +++ b/radio/src/targets/horus/board.cpp @@ -86,10 +86,6 @@ void interrupt1ms() per10ms(); DEBUG_TIMER_STOP(debugTimerPer10ms); } - - DEBUG_TIMER_START(debugTimerRotEnc); - checkRotaryEncoder(); - DEBUG_TIMER_STOP(debugTimerRotEnc); } extern "C" void INTERRUPT_xMS_IRQHandler() @@ -168,7 +164,8 @@ void boardInit() BACKLIGHT_RCC_APB1Periph, ENABLE); - RCC_APB2PeriphClockCmd(LCD_RCC_APB2Periph | + RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG | + LCD_RCC_APB2Periph | ADC_RCC_APB2Periph | HAPTIC_RCC_APB2Periph | INTMODULE_RCC_APB2Periph | @@ -196,6 +193,7 @@ void boardInit() memset(&g_FATFS_Obj, 0, sizeof(g_FATFS_Obj)); keysInit(); + rotaryEncoderInit(); #if NUM_PWMSTICKS > 0 sticksPwmInit(); diff --git a/radio/src/targets/horus/board.h b/radio/src/targets/horus/board.h index 76d758640..f99f4ec0f 100644 --- a/radio/src/targets/horus/board.h +++ b/radio/src/targets/horus/board.h @@ -37,7 +37,9 @@ extern "C" { #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rcc.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_syscfg.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_gpio.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_exti.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_spi.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_i2c.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rtc.h" @@ -344,7 +346,8 @@ uint32_t readTrims(void); // Rotary encoder driver #define ROTARY_ENCODER_NAVIGATION -void checkRotaryEncoder(void); +void rotaryEncoderInit(void); +void rotaryEncoderCheck(void); // WDT driver #define WDTO_500MS 500 diff --git a/radio/src/targets/horus/hal.h b/radio/src/targets/horus/hal.h index c462e0d3e..74faad1ff 100644 --- a/radio/src/targets/horus/hal.h +++ b/radio/src/targets/horus/hal.h @@ -62,6 +62,13 @@ #define ROTARY_ENCODER_GPIO_PIN_A GPIO_Pin_11 // PH.11 #define ROTARY_ENCODER_GPIO_PIN_B GPIO_Pin_10 // PH.10 #define ROTARY_ENCODER_POSITION() ((ROTARY_ENCODER_GPIO->IDR >> 10) & 0x03) +#define ROTARY_ENCODER_EXTI_LINE1 EXTI_Line11 +#define ROTARY_ENCODER_EXTI_LINE2 EXTI_Line10 +#define ROTARY_ENCODER_EXTI_IRQn1 EXTI15_10_IRQn +#define ROTARY_ENCODER_EXTI_IRQHandler1 EXTI15_10_IRQHandler +#define ROTARY_ENCODER_EXTI_PortSource EXTI_PortSourceGPIOH +#define ROTARY_ENCODER_EXTI_PinSource1 EXTI_PinSource11 +#define ROTARY_ENCODER_EXTI_PinSource2 EXTI_PinSource10 // Switches #define SWITCHES_GPIO_REG_A_H GPIOH->IDR diff --git a/radio/src/targets/horus/keys_driver.cpp b/radio/src/targets/horus/keys_driver.cpp index 5ccf57b02..82e3dc388 100644 --- a/radio/src/targets/horus/keys_driver.cpp +++ b/radio/src/targets/horus/keys_driver.cpp @@ -20,68 +20,6 @@ #include "opentx.h" -/* - * Rotary encoder handling based on state table: - * Copyright (C) by Ben Buxton - * - * This includes the state table definition bellow - * as well as the implementation of checkRotaryEncoder(). - * - * The below state table has, for each state (row), the new state - * to set based on the next encoder output. From left to right in, - * the table, the encoder outputs are 00, 01, 10, 11, and the value - * in that position is the new state to set. - */ - -#define R_START 0x0 -#define DIR_CW 0x10 -#define DIR_CCW 0x20 - -// Use the half-step state table (emits a code at 00 and 11) -#define R_CCW_BEGIN 0x1 -#define R_CW_BEGIN 0x2 -#define R_START_M 0x3 -#define R_CW_BEGIN_M 0x4 -#define R_CCW_BEGIN_M 0x5 -const unsigned char rotenc_table[6][4] = { - // R_START (00) - {R_START_M, R_CW_BEGIN, R_CCW_BEGIN, R_START}, - // R_CCW_BEGIN - {R_START_M | DIR_CCW, R_START, R_CCW_BEGIN, R_START}, - // R_CW_BEGIN - {R_START_M | DIR_CW, R_CW_BEGIN, R_START, R_START}, - // R_START_M (11) - {R_START_M, R_CCW_BEGIN_M, R_CW_BEGIN_M, R_START}, - // R_CW_BEGIN_M - {R_START_M, R_START_M, R_CW_BEGIN_M, R_START | DIR_CW}, - // R_CCW_BEGIN_M - {R_START_M, R_CCW_BEGIN_M, R_START_M, R_START | DIR_CCW}, -}; - -void checkRotaryEncoder() -{ - static uint8_t state = 0; - uint32_t pins = ROTARY_ENCODER_POSITION(); - - state = rotenc_table[state & 0x0F][pins]; - if ((state & 0x30) && !keyState(KEY_ENTER)) { - if ((state & 0x30) == DIR_CW) { - --rotencValue[0]; - } - else { - ++rotencValue[0]; - } -#if !defined(BOOT) - if (g_eeGeneral.backlightMode & e_backlight_mode_keys) - backlightOn(); -#endif - } -} - -/* - * End of the rotary encoder handler code - */ - uint32_t readKeys() { uint32_t result = 0; diff --git a/radio/src/targets/simu/opentxsimulator.cpp b/radio/src/targets/simu/opentxsimulator.cpp index e7bbc8807..e3b1e27c0 100644 --- a/radio/src/targets/simu/opentxsimulator.cpp +++ b/radio/src/targets/simu/opentxsimulator.cpp @@ -362,9 +362,6 @@ const int OpenTxSimulator::getCapability(Capability cap) break; case CAP_ROTARY_ENC : - #ifdef ROTARY_ENCODERS - ret = ROTARY_ENCODERS; - #endif break; case CAP_ROTARY_ENC_NAV : diff --git a/radio/src/targets/simu/simpgmspace.cpp b/radio/src/targets/simu/simpgmspace.cpp index 09d3d1805..f9cbf0d26 100644 --- a/radio/src/targets/simu/simpgmspace.cpp +++ b/radio/src/targets/simu/simpgmspace.cpp @@ -150,9 +150,8 @@ void simuInit() for (int i = 0; i < 2*NUM_TRIMS; i++) simuSetTrim(i, false); -#if defined(ROTARY_ENCODERS) || defined(ROTARY_ENCODER_NAVIGATION) - for (uint8_t i=0; i < DIM(rotencValue); i++) - rotencValue[i] = 0; +#if defined(ROTARY_ENCODER_NAVIGATION) + rotencValue = 0; #endif } @@ -225,9 +224,6 @@ void simuSetKey(uint8_t key, bool state) KEY_CASE(KEY_LEFT, KEYS_GPIO_REG_LEFT, KEYS_GPIO_PIN_LEFT) KEY_CASE(KEY_UP, KEYS_GPIO_REG_UP, KEYS_GPIO_PIN_UP) KEY_CASE(KEY_DOWN, KEYS_GPIO_REG_DOWN, KEYS_GPIO_PIN_DOWN) -#endif -#if defined(PCBSKY9X) && !defined(REVX) && !defined(AR9X) && defined(ROTARY_ENCODERS) - KEY_CASE(BTN_REa, PIOB->PIO_PDSR, 0x40) #endif } } @@ -692,6 +688,13 @@ void RCC_LSEConfig(uint8_t RCC_LSE) { } void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks) { }; FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG) { return SET; } +// EXTI fake functions +void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex) { } +void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct) { } +ITStatus EXTI_GetITStatus(uint32_t EXTI_Line) { return RESET; } +void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct) { } +void EXTI_ClearITPendingBit(uint32_t EXTI_Line) { } + // RTC fake functions ErrorStatus RTC_Init(RTC_InitTypeDef* RTC_InitStruct) { return SUCCESS; } void RTC_TimeStructInit(RTC_TimeTypeDef* RTC_TimeStruct) { } diff --git a/radio/src/targets/sky9x/board.cpp b/radio/src/targets/sky9x/board.cpp index fca8b297c..522a9f6fb 100644 --- a/radio/src/targets/sky9x/board.cpp +++ b/radio/src/targets/sky9x/board.cpp @@ -475,10 +475,7 @@ void boardInit() eepromInit(); -#if defined(ROTARY_ENCODERS) - rotencInit(); -#endif - + rotaryEncoderInit(); init_SDcard(); } #else diff --git a/radio/src/targets/sky9x/board.h b/radio/src/targets/sky9x/board.h index 84a8cfd67..a4a67dfcc 100644 --- a/radio/src/targets/sky9x/board.h +++ b/radio/src/targets/sky9x/board.h @@ -38,11 +38,10 @@ void boardInit(void); #define boardOff() pwrOff() // Rotary Encoder driver -void rotencInit(); -void rotencEnd(); +void rotaryEncoderInit(); +void rotaryEncoderEnd(); #if !defined(REVX) && !defined(AR9X) - #define ROTARY_ENCODERS 1 #define ROTARY_ENCODER_NAVIGATION #define REA_DOWN() (!(PIOB->PIO_PDSR & 0x40)) #else @@ -74,10 +73,6 @@ enum EnumKeys TRM_RH_UP, TRM_LAST = TRM_RH_UP, -#if defined(ROTARY_ENCODERS) - BTN_REa, -#endif - NUM_KEYS }; diff --git a/radio/src/targets/sky9x/keys_driver.cpp b/radio/src/targets/sky9x/keys_driver.cpp index 66f836cf0..df04748e2 100644 --- a/radio/src/targets/sky9x/keys_driver.cpp +++ b/radio/src/targets/sky9x/keys_driver.cpp @@ -109,10 +109,6 @@ void readKeysAndTrims() { uint32_t i; -#if ROTARY_ENCODERS > 0 - keys[BTN_REa].input(REA_DOWN()); -#endif - uint8_t index = 0; uint8_t keys_input = readKeys(); for (i = 1; i < 7; i++) { diff --git a/radio/src/targets/sky9x/rotenc_driver.cpp b/radio/src/targets/sky9x/rotenc_driver.cpp index 5bf1dbdd6..fe444987a 100644 --- a/radio/src/targets/sky9x/rotenc_driver.cpp +++ b/radio/src/targets/sky9x/rotenc_driver.cpp @@ -20,38 +20,38 @@ #include "opentx.h" -void rotencInit() +void rotaryEncoderInit() { - configure_pins( PIO_PC19 | PIO_PC21, PIN_ENABLE | PIN_INPUT | PIN_PORTC | PIN_PULLUP ) ; // 19 and 21 are rotary encoder - configure_pins( PIO_PB6, PIN_ENABLE | PIN_INPUT | PIN_PORTB | PIN_PULLUP ) ; // rotary encoder switch - PIOC->PIO_IER = PIO_PC19 | PIO_PC21 ; - NVIC_EnableIRQ(PIOC_IRQn) ; + configure_pins(PIO_PC19 | PIO_PC21, PIN_ENABLE | PIN_INPUT | PIN_PORTC | PIN_PULLUP); // 19 and 21 are rotary encoder + configure_pins(PIO_PB6, PIN_ENABLE | PIN_INPUT | PIN_PORTB | PIN_PULLUP); // rotary encoder switch + PIOC->PIO_IER = PIO_PC19 | PIO_PC21; + NVIC_EnableIRQ(PIOC_IRQn); } -void rotencEnd() +void rotaryEncoderEnd() { - NVIC_DisableIRQ(PIOC_IRQn) ; - PIOC->PIO_IDR = PIO_PC19 | PIO_PC21 ; + NVIC_DisableIRQ(PIOC_IRQn); + PIOC->PIO_IDR = PIO_PC19 | PIO_PC21; } -volatile uint32_t Rotary_position ; +volatile uint32_t Rotary_position; extern "C" void PIOC_IRQHandler() { uint32_t dummy; - dummy = PIOC->PIO_ISR ; // Read and clear status register - (void) dummy ; // Discard value - prevents compiler warning + dummy = PIOC->PIO_ISR; // Read and clear status register + (void) dummy; // Discard value - prevents compiler warning - dummy = PIOC->PIO_PDSR ; // Read Rotary encoder (PC19, PC21) - dummy >>= 19 ; - dummy &= 0x05 ; // pick out the three bits - if ( dummy != ( Rotary_position & 0x05 ) ) { - if ( ( Rotary_position & 0x01 ) ^ ( ( dummy & 0x04) >> 2 ) ) - incRotaryEncoder(0, -1); + dummy = PIOC->PIO_PDSR; // Read Rotary encoder (PC19, PC21) + dummy >>= 19; + dummy &= 0x05; // pick out the three bits + if (dummy != (Rotary_position & 0x05)) { + if ((Rotary_position & 0x01) ^ ((dummy & 0x04) >> 2)) + rotencValue -= 1; else - incRotaryEncoder(0, +1); + rotencValue += 1; - Rotary_position &= ~0x45 ; - Rotary_position |= dummy ; + Rotary_position &= ~0x45; + Rotary_position |= dummy; } } diff --git a/radio/src/targets/taranis/CMakeLists.txt b/radio/src/targets/taranis/CMakeLists.txt index 33b73b307..e514de5a8 100644 --- a/radio/src/targets/taranis/CMakeLists.txt +++ b/radio/src/targets/taranis/CMakeLists.txt @@ -188,6 +188,13 @@ if(NOT PCB STREQUAL XLITE) ) endif() +if(PCB STREQUAL X9E OR PCB STREQUAL X7 OR PCB STREQUAL X3) + set(TARGET_SRC + ${TARGET_SRC} + ../common/arm/stm32/rotary_encoder_driver.cpp + ) +endif() + if(PCB STREQUAL X9E OR PCB STREQUAL X7 OR PCB STREQUAL XLITE OR PCB STREQUAL XLITES) add_definitions(-DBLUETOOTH) set(TARGET_SRC diff --git a/radio/src/targets/taranis/board.cpp b/radio/src/targets/taranis/board.cpp index e0f660259..0d2d06f6f 100644 --- a/radio/src/targets/taranis/board.cpp +++ b/radio/src/targets/taranis/board.cpp @@ -88,10 +88,6 @@ void interrupt5ms() per10ms(); DEBUG_TIMER_STOP(debugTimerPer10ms); } - -#if defined(ROTARY_ENCODER_NAVIGATION) - checkRotaryEncoder(); -#endif } #if !defined(SIMU) @@ -143,28 +139,53 @@ void sportUpdatePowerOff() void boardInit() { #if !defined(SIMU) - RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph | PCBREV_RCC_AHB1Periph | - KEYS_RCC_AHB1Periph | LCD_RCC_AHB1Periph | - AUDIO_RCC_AHB1Periph | BACKLIGHT_RCC_AHB1Periph | - ADC_RCC_AHB1Periph | I2C_RCC_AHB1Periph | - SD_RCC_AHB1Periph | HAPTIC_RCC_AHB1Periph | - INTMODULE_RCC_AHB1Periph | EXTMODULE_RCC_AHB1Periph | - TELEMETRY_RCC_AHB1Periph | SPORT_UPDATE_RCC_AHB1Periph | - SERIAL_RCC_AHB1Periph | TRAINER_RCC_AHB1Periph | - HEARTBEAT_RCC_AHB1Periph | BT_RCC_AHB1Periph | GYRO_RCC_AHB1Periph, + RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph | + PCBREV_RCC_AHB1Periph | + KEYS_RCC_AHB1Periph | + LCD_RCC_AHB1Periph | + AUDIO_RCC_AHB1Periph | + BACKLIGHT_RCC_AHB1Periph | + ADC_RCC_AHB1Periph | + I2C_RCC_AHB1Periph | + SD_RCC_AHB1Periph | + HAPTIC_RCC_AHB1Periph | + INTMODULE_RCC_AHB1Periph | + EXTMODULE_RCC_AHB1Periph | + TELEMETRY_RCC_AHB1Periph | + SPORT_UPDATE_RCC_AHB1Periph | + SERIAL_RCC_AHB1Periph | + TRAINER_RCC_AHB1Periph | + HEARTBEAT_RCC_AHB1Periph | + BT_RCC_AHB1Periph | + GYRO_RCC_AHB1Periph, ENABLE); - RCC_APB1PeriphClockCmd(LCD_RCC_APB1Periph | AUDIO_RCC_APB1Periph | ADC_RCC_APB1Periph | - BACKLIGHT_RCC_APB1Periph | HAPTIC_RCC_APB1Periph | INTERRUPT_xMS_RCC_APB1Periph | - TIMER_2MHz_RCC_APB1Periph | I2C_RCC_APB1Periph | - SD_RCC_APB1Periph | TRAINER_RCC_APB1Periph | - TELEMETRY_RCC_APB1Periph | SERIAL_RCC_APB1Periph | - INTMODULE_RCC_APB1Periph | BT_RCC_APB1Periph | GYRO_RCC_APB1Periph, ENABLE); + RCC_APB1PeriphClockCmd(LCD_RCC_APB1Periph | + AUDIO_RCC_APB1Periph | + ADC_RCC_APB1Periph | + BACKLIGHT_RCC_APB1Periph | + HAPTIC_RCC_APB1Periph | + INTERRUPT_xMS_RCC_APB1Periph | + TIMER_2MHz_RCC_APB1Periph | + I2C_RCC_APB1Periph | + SD_RCC_APB1Periph | + TRAINER_RCC_APB1Periph | + TELEMETRY_RCC_APB1Periph | + SERIAL_RCC_APB1Periph | + INTMODULE_RCC_APB1Periph | + BT_RCC_APB1Periph | + GYRO_RCC_APB1Periph, + ENABLE); - RCC_APB2PeriphClockCmd(BACKLIGHT_RCC_APB2Periph | ADC_RCC_APB2Periph | - HAPTIC_RCC_APB2Periph | INTMODULE_RCC_APB2Periph | - EXTMODULE_RCC_APB2Periph | HEARTBEAT_RCC_APB2Periph | - BT_RCC_APB2Periph, ENABLE); + RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG | + BACKLIGHT_RCC_APB2Periph | + ADC_RCC_APB2Periph | + HAPTIC_RCC_APB2Periph | + INTMODULE_RCC_APB2Periph | + EXTMODULE_RCC_APB2Periph | + HEARTBEAT_RCC_APB2Periph | + BT_RCC_APB2Periph, + ENABLE); #if defined(BLUETOOTH) bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE, true); @@ -181,6 +202,11 @@ void boardInit() #endif keysInit(); + +#if defined(ROTARY_ENCODER_NAVIGATION) + rotaryEncoderInit(); +#endif + delaysInit(); #if NUM_PWMSTICKS > 0 diff --git a/radio/src/targets/taranis/board.h b/radio/src/targets/taranis/board.h index 50ced0edf..4bcb5d196 100644 --- a/radio/src/targets/taranis/board.h +++ b/radio/src/targets/taranis/board.h @@ -39,7 +39,9 @@ extern "C" { #if defined(STM32F4) #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rcc.h" + #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_syscfg.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_gpio.h" + #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_exti.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_tim.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_adc.h" #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_spi.h" @@ -54,7 +56,9 @@ extern "C" { #else #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h" #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_rcc.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_syscfg.h" #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_gpio.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_exti.h" #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_tim.h" #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_adc.h" #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_spi.h" @@ -420,7 +424,8 @@ uint32_t readTrims(void); #if defined(PCBX9E) || defined(PCBX7) || defined(PCBX3) // Rotary Encoder driver #define ROTARY_ENCODER_NAVIGATION -void checkRotaryEncoder(void); +void rotaryEncoderInit(void); +void rotaryEncoderCheck(void); #endif // WDT driver diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index f167718fc..9b602e085 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -81,28 +81,51 @@ // Rotary Encoder #if defined(PCBX9E) - #define ENC_GPIO GPIOD - #define ENC_GPIO_PIN_A GPIO_Pin_12 // PD.12 - #define ENC_GPIO_PIN_B GPIO_Pin_13 // PD.13 - #define ROTARY_ENCODER_POSITION() (ENC_GPIO->IDR >> 12) & 0x03 + #define ROTARY_ENCODER_GPIO GPIOD + #define ROTARY_ENCODER_GPIO_PIN_A GPIO_Pin_12 // PD.12 + #define ROTARY_ENCODER_GPIO_PIN_B GPIO_Pin_13 // PD.13 + #define ROTARY_ENCODER_POSITION() (ROTARY_ENCODER_GPIO->IDR >> 12) & 0x03 + #define ROTARY_ENCODER_EXTI_LINE1 EXTI_Line12 + #define ROTARY_ENCODER_EXTI_LINE2 EXTI_Line13 + #define ROTARY_ENCODER_EXTI_IRQn1 EXTI15_10_IRQn + #define ROTARY_ENCODER_EXTI_IRQHandler1 EXTI15_10_IRQHandler + #define ROTARY_ENCODER_EXTI_PortSource EXTI_PortSourceGPIOD + #define ROTARY_ENCODER_EXTI_PinSource1 EXTI_PinSource12 + #define ROTARY_ENCODER_EXTI_PinSource2 EXTI_PinSource13 #elif defined(PCBX7) - #define ENC_GPIO GPIOE - #define ENC_GPIO_PIN_A GPIO_Pin_9 // PE.09 - #define ENC_GPIO_PIN_B GPIO_Pin_11 // PE.11 - #define ROTARY_ENCODER_POSITION() (((ENC_GPIO->IDR >> 10) & 0x02) + ((ENC_GPIO->IDR >> 9) & 0x01)) + #define ROTARY_ENCODER_GPIO GPIOE + #define ROTARY_ENCODER_GPIO_PIN_A GPIO_Pin_9 // PE.09 + #define ROTARY_ENCODER_GPIO_PIN_B GPIO_Pin_11 // PE.11 + #define ROTARY_ENCODER_POSITION() (((ROTARY_ENCODER_GPIO->IDR >> 10) & 0x02) + ((ROTARY_ENCODER_GPIO->IDR >> 9) & 0x01)) + #define ROTARY_ENCODER_EXTI_LINE1 EXTI_Line9 + #define ROTARY_ENCODER_EXTI_LINE2 EXTI_Line11 + #define ROTARY_ENCODER_EXTI_IRQn1 EXTI9_5_IRQn + #define ROTARY_ENCODER_EXTI_IRQHandler1 EXTI9_5_IRQHandler + #define ROTARY_ENCODER_EXTI_IRQn2 EXTI15_10_IRQn + #define ROTARY_ENCODER_EXTI_IRQHandler2 EXTI15_10_IRQHandler + #define ROTARY_ENCODER_EXTI_PortSource EXTI_PortSourceGPIOE + #define ROTARY_ENCODER_EXTI_PinSource1 EXTI_PinSource9 + #define ROTARY_ENCODER_EXTI_PinSource2 EXTI_PinSource11 #elif defined(PCBX3) - #define ENC_GPIO GPIOE - #define ENC_GPIO_PIN_A GPIO_Pin_10 // PE.10 - #define ENC_GPIO_PIN_B GPIO_Pin_12 // PE.12 - #define ROTARY_ENCODER_POSITION() (((ENC_GPIO->IDR >> 12) & 0x01) + ((ENC_GPIO->IDR >> 9) & 0x02)) + #define ROTARY_ENCODER_GPIO GPIOE + #define ROTARY_ENCODER_GPIO_PIN_A GPIO_Pin_10 // PE.10 + #define ROTARY_ENCODER_GPIO_PIN_B GPIO_Pin_12 // PE.12 + #define ROTARY_ENCODER_POSITION() (((ROTARY_ENCODER_GPIO->IDR >> 12) & 0x01) + ((ROTARY_ENCODER_GPIO->IDR >> 9) & 0x02)) + #define ROTARY_ENCODER_EXTI_LINE1 EXTI_Line10 + #define ROTARY_ENCODER_EXTI_LINE2 EXTI_Line12 + #define ROTARY_ENCODER_EXTI_IRQn1 EXTI15_10_IRQn + #define ROTARY_ENCODER_EXTI_IRQHandler1 EXTI15_10_IRQHandler + #define ROTARY_ENCODER_EXTI_PortSource EXTI_PortSourceGPIOE + #define ROTARY_ENCODER_EXTI_PinSource1 EXTI_PinSource10 + #define ROTARY_ENCODER_EXTI_PinSource2 EXTI_PinSource12 #endif // This is for SIMU: reuse rotary encoder pins to map UP and DOWN keyboard keys #if defined(SIMU) && (defined(PCBX9E) || defined(PCBX7) || defined(PCBX3)) - #define KEYS_GPIO_REG_PLUS ENC_GPIO->IDR - #define KEYS_GPIO_PIN_PLUS ENC_GPIO_PIN_A - #define KEYS_GPIO_REG_MINUS ENC_GPIO->IDR - #define KEYS_GPIO_PIN_MINUS ENC_GPIO_PIN_B + #define KEYS_GPIO_REG_PLUS ROTARY_ENCODER_GPIO->IDR + #define KEYS_GPIO_PIN_PLUS ROTARY_ENCODER_GPIO_PIN_A + #define KEYS_GPIO_REG_MINUS ROTARY_ENCODER_GPIO->IDR + #define KEYS_GPIO_PIN_MINUS ROTARY_ENCODER_GPIO_PIN_B #endif // Trims @@ -403,7 +426,7 @@ #define KEYS_GPIOA_PINS (SWITCHES_GPIO_PIN_M_L) #define KEYS_GPIOB_PINS (SWITCHES_GPIO_PIN_N_H | SWITCHES_GPIO_PIN_N_L | SWITCHES_GPIO_PIN_R_H) #define KEYS_GPIOC_PINS (TRIMS_GPIO_PIN_RVD | TRIMS_GPIO_PIN_RVU | TRIMS_GPIO_PIN_RHL | TRIMS_GPIO_PIN_RHR) - #define KEYS_GPIOD_PINS (KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_PAGE | SWITCHES_GPIO_PIN_A_H | SWITCHES_GPIO_PIN_A_L | ENC_GPIO_PIN_A | ENC_GPIO_PIN_B) + #define KEYS_GPIOD_PINS (KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_PAGE | SWITCHES_GPIO_PIN_A_H | SWITCHES_GPIO_PIN_A_L | ROTARY_ENCODER_GPIO_PIN_A | ROTARY_ENCODER_GPIO_PIN_B) #define KEYS_GPIOE_PINS (TRIMS_GPIO_PIN_LVU | TRIMS_GPIO_PIN_LVD | SWITCHES_GPIO_PIN_D_H | SWITCHES_GPIO_PIN_D_L| SWITCHES_GPIO_PIN_E_H | SWITCHES_GPIO_PIN_E_L | SWITCHES_GPIO_PIN_F | SWITCHES_GPIO_PIN_I_L | SWITCHES_GPIO_PIN_L_H | SWITCHES_GPIO_PIN_L_L | SWITCHES_GPIO_PIN_M_H | SWITCHES_GPIO_PIN_O_L | SWITCHES_GPIO_PIN_R_L) #define KEYS_GPIOF_PINS (KEYS_GPIO_PIN_ENTER | SWITCHES_GPIO_PIN_C_H | SWITCHES_GPIO_PIN_C_L | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L | SWITCHES_GPIO_PIN_H | SWITCHES_GPIO_PIN_I_H | SWITCHES_GPIO_PIN_O_H | SWITCHES_GPIO_PIN_P_H | SWITCHES_GPIO_PIN_P_L | SWITCHES_GPIO_PIN_Q_H | SWITCHES_GPIO_PIN_Q_L) #define KEYS_GPIOG_PINS (TRIMS_GPIO_PIN_LHL | TRIMS_GPIO_PIN_LHR| SWITCHES_GPIO_PIN_B_H | SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_J_H | SWITCHES_GPIO_PIN_J_L | SWITCHES_GPIO_PIN_K_H | SWITCHES_GPIO_PIN_K_L) @@ -431,7 +454,7 @@ #define KEYS_GPIOA_PINS SWITCHES_GPIO_PIN_B_H #define KEYS_GPIOC_PINS (TRIMS_GPIO_PIN_LHR | TRIMS_GPIO_PIN_RVD | TRIMS_GPIO_PIN_RVU) #define KEYS_GPIOD_PINS (TRIMS_GPIO_PIN_LHL | KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_PAGE | SWITCHES_GPIO_PIN_C_L | SWITCHES_GPIO_PIN_H) - #define KEYS_GPIOE_PINS (ENC_GPIO_PIN_A | ENC_GPIO_PIN_B | KEYS_GPIO_PIN_ENTER | TRIMS_GPIO_PIN_RHR | TRIMS_GPIO_PIN_RHL | TRIMS_GPIO_PIN_LVD | TRIMS_GPIO_PIN_LVU | SWITCHES_GPIO_PIN_C_H | SWITCHES_GPIO_PIN_D_L | SWITCHES_GPIO_PIN_D_H | SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_A_L | SWITCHES_GPIO_PIN_A_H | SWITCHES_GPIO_PIN_F) + #define KEYS_GPIOE_PINS (ROTARY_ENCODER_GPIO_PIN_A | ROTARY_ENCODER_GPIO_PIN_B | KEYS_GPIO_PIN_ENTER | TRIMS_GPIO_PIN_RHR | TRIMS_GPIO_PIN_RHL | TRIMS_GPIO_PIN_LVD | TRIMS_GPIO_PIN_LVU | SWITCHES_GPIO_PIN_C_H | SWITCHES_GPIO_PIN_D_L | SWITCHES_GPIO_PIN_D_H | SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_A_L | SWITCHES_GPIO_PIN_A_H | SWITCHES_GPIO_PIN_F) #elif defined(PCBX3) #define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE) #define KEYS_GPIOA_PINS (GPIO_Pin_5) diff --git a/radio/src/targets/taranis/keys_driver.cpp b/radio/src/targets/taranis/keys_driver.cpp index b4a061d6f..02bd29efc 100644 --- a/radio/src/targets/taranis/keys_driver.cpp +++ b/radio/src/targets/taranis/keys_driver.cpp @@ -20,10 +20,6 @@ #include "opentx.h" -#if defined(ROTARY_ENCODER_NAVIGATION) -uint32_t rotencPosition; -#endif - uint32_t readKeys() { uint32_t result = 0; @@ -114,27 +110,6 @@ bool keyDown() return readKeys() || readTrims(); } -#if defined(ROTARY_ENCODER_NAVIGATION) -void checkRotaryEncoder() -{ - uint32_t newpos = ROTARY_ENCODER_POSITION(); - if (newpos != rotencPosition && !keyState(KEY_ENTER)) { - if ((rotencPosition & 0x01) ^ ((newpos & 0x02) >> 1)) { - --rotencValue[0]; - } - else { - ++rotencValue[0]; - } - rotencPosition = newpos; -#if !defined(BOOT) - if (g_eeGeneral.backlightMode & e_backlight_mode_keys) { - backlightOn(); - } -#endif - } -} -#endif - /* TODO common to ARM */ void readKeysAndTrims() { @@ -289,8 +264,4 @@ void keysInit() GPIO_InitStructure.GPIO_Pin = KEYS_GPIOG_PINS; GPIO_Init(GPIOG, &GPIO_InitStructure); #endif - -#if defined(ROTARY_ENCODER_NAVIGATION) - rotencPosition = ROTARY_ENCODER_POSITION(); -#endif } diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 82827e03b..953210963 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -31,9 +31,6 @@ const char STR_OPEN9X[] = ISTR(VBEEPLEN) #endif ISTR(VBEEPMODE) -#if defined(ROTARY_ENCODERS) - ISTR(VRENAVIG) -#endif #if defined(ROTARY_ENCODER_NAVIGATION) ISTR(VRENCODERS) #endif @@ -224,9 +221,6 @@ const char STR_RSSISHUTDOWNALARM[] = TR_RSSISHUTDOWNALARM; const char STR_MODEL_STILL_POWERED[] = TR_MODEL_STILL_POWERED; const char STR_MODEL_SHUTDOWN[] = TR_MODEL_SHUTDOWN; const char STR_PRESS_ENTER_TO_CONFIRM[] = TR_PRESS_ENTER_TO_CONFIRM; -#if defined(ROTARY_ENCODERS) -const char STR_RENAVIG[] = TR_RENAVIG; -#endif const char STR_THROTTLEREVERSE[] = TR_THROTTLEREVERSE; const char STR_TIMER_NAME[] = TR_TIMER_NAME; const char STR_MINUTEBEEP[] = TR_MINUTEBEEP; diff --git a/radio/src/translations.h b/radio/src/translations.h index b04ad4cc0..d4a1a31e2 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -115,11 +115,7 @@ extern const char STR_OPEN9X[]; #define OFS_VBEEPLEN (OFS_NCHANNELS + sizeof(TR_NCHANNELS)) #define OFS_VBEEPMODE (OFS_VBEEPLEN + sizeof(TR_VBEEPLEN)) #endif -#if defined(ROTARY_ENCODERS) -#define OFS_VRENAVIG (OFS_VBEEPMODE + sizeof(TR_VBEEPMODE)) -#define OFS_VRENCODERS (OFS_VRENAVIG + sizeof(TR_VRENAVIG)) -#define OFS_TRNMODE (OFS_VRENCODERS + sizeof(TR_VRENCODERS)) -#elif defined(ROTARY_ENCODER_NAVIGATION) +#if defined(ROTARY_ENCODER_NAVIGATION) #define OFS_VRENCODERS (OFS_VBEEPMODE + sizeof(TR_VBEEPMODE)) #define OFS_TRNMODE (OFS_VRENCODERS + sizeof(TR_VRENCODERS)) #else @@ -275,10 +271,6 @@ extern const char STR_OPEN9X[]; #endif #define STR_VTMRMODES (STR_OPEN9X + OFS_VTMRMODES) -#if defined(ROTARY_ENCODERS) - #define STR_VRENAVIG (STR_OPEN9X + OFS_VRENAVIG) -#endif - #if defined(ROTARY_ENCODER_NAVIGATION) #define STR_VRENCODERS (STR_OPEN9X + OFS_VRENCODERS) #endif diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index ba5dd364a..c362176ac 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -297,21 +297,13 @@ #define TR_FSW_RESET_TELEM #endif -#if ROTARY_ENCODERS == 2 - #define TR_FSW_RESET_ROTENC TR("REa\0""REb\0", "RotEnc A\0 ""RotEnc B\0 ") -#elif ROTARY_ENCODERS == 1 - #define TR_FSW_RESET_ROTENC TR("RoEn", "RotEnc\0 ") -#else - #define TR_FSW_RESET_ROTENC -#endif - #if LCD_W >= 212 #define TR_FSW_RESET_TIMERS "Stopky1\0 ""Stopky2\0 ""Stopky3\0 " #else #define TR_FSW_RESET_TIMERS "Tmr1""Tmr2""Tmr3" #endif -#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "Vše\0" TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC, TR_FSW_RESET_TIMERS "Vše\0 " TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC) +#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "Vše\0" TR_FSW_RESET_TELEM, TR_FSW_RESET_TIMERS "Vše\0 " TR_FSW_RESET_TELEM) #define LEN_FUNCSOUNDS TR("\004", "\006") #define TR_FUNCSOUNDS TR("Bp1\0""Bp2\0""Bp3\0""Wrn1""Wrn2""Chee""Rata""Tick""Sirn""Ring""SciF""Robt""Chrp""Tada""Crck""Alrm", "Beep1 ""Beep2 ""Beep3 ""Warn1 ""Warn2 ""Cheep ""Ratata""Tick ""Siren ""Ring ""SciFi ""Robot ""Chirp ""Tada ""Crickt""AlmClk") diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index 5b5f6125a..8d096ded4 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -302,21 +302,13 @@ #define TR_FSW_RESET_TELEM #endif -#if ROTARY_ENCODERS == 2 - #define TR_FSW_RESET_ROTENC TR("DGa\0""DGb\0", "DrehGb A\0""DrehGb B\0") -#elif ROTARY_ENCODERS == 1 - #define TR_FSW_RESET_ROTENC TR("D.G.", "DrehGb\0 ") -#else - #define TR_FSW_RESET_ROTENC -#endif - #if LCD_W >= 212 #define TR_FSW_RESET_TIMERS "Timer 1\0 ""Timer 2\0 ""Timer 3\0 " #else #define TR_FSW_RESET_TIMERS "Tmr1""Tmr2""Tmr3" #endif -#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC, TR_FSW_RESET_TIMERS "All\0 " TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC) +#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM, TR_FSW_RESET_TIMERS "All\0 " TR_FSW_RESET_TELEM) #define LEN_FUNCSOUNDS TR("\004", "\006") #define TR_FUNCSOUNDS TR("Bp1\0""Bp2\0""Bp3\0""Wrn1""Wrn2""Chee""Rata""Tick""Sirn""Ring""SciF""Robt""Chrp""Tada""Crck""Alrm", "Piep1\0""Piep2\0""Piep3\0""Warn1 ""Warn2 ""Cheep ""Ratata""Tick ""Siren ""Ring ""SciFi ""Robot ""Chirp ""Tada ""Crickt""AlmClk") diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index e438fb712..30a94dff1 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -301,21 +301,13 @@ #define TR_FSW_RESET_TELEM #endif -#if ROTARY_ENCODERS == 2 - #define TR_FSW_RESET_ROTENC TR("REa\0""REb\0", "RotEnc A\0""RotEnc B\0") -#elif ROTARY_ENCODERS == 1 - #define TR_FSW_RESET_ROTENC TR("R.E.", "RotEnc\0 ") -#else - #define TR_FSW_RESET_ROTENC -#endif - #if LCD_W >= 212 #define TR_FSW_RESET_TIMERS "Timer 1\0 ""Timer 2\0 ""Timer 3\0 " #else #define TR_FSW_RESET_TIMERS "Tmr1""Tmr2""Tmr3" #endif -#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC, TR_FSW_RESET_TIMERS "Flight\0 " TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC) +#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM, TR_FSW_RESET_TIMERS "Flight\0 " TR_FSW_RESET_TELEM) #define LEN_FUNCSOUNDS TR("\004", "\006") #define TR_FUNCSOUNDS TR("Bp1\0""Bp2\0""Bp3\0""Wrn1""Wrn2""Chee""Rata""Tick""Sirn""Ring""SciF""Robt""Chrp""Tada""Crck""Alrm", "Beep1 ""Beep2 ""Beep3 ""Warn1 ""Warn2 ""Cheep ""Ratata""Tick ""Siren ""Ring ""SciFi ""Robot ""Chirp ""Tada ""Crickt""AlmClk") diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index 24f3f41fc..05c9c1867 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -299,21 +299,13 @@ #define TR_FSW_RESET_TELEM #endif -#if ROTARY_ENCODERS == 2 - #define TR_FSW_RESET_ROTENC TR("REa\0""REb\0", "RotEnc A\0""RotEnc B\0") -#elif ROTARY_ENCODERS == 1 - #define TR_FSW_RESET_ROTENC TR("R.E.", "RotEnc\0 ") -#else - #define TR_FSW_RESET_ROTENC -#endif - #if defined(PCBTARANIS) #define TR_FSW_RESET_TIMERS "Timer 1\0 ""Timer 2\0 ""Timer 3\0 " #else #define TR_FSW_RESET_TIMERS "Tmr1""Tmr2""Tmr3" #endif -#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC, TR_FSW_RESET_TIMERS "All\0 " TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC) +#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM, TR_FSW_RESET_TIMERS "All\0 " TR_FSW_RESET_TELEM) #define LEN_FUNCSOUNDS TR("\004", "\006") #define TR_FUNCSOUNDS TR("Bp1\0""Bp2\0""Bp3\0""Avs1""Avs2""Chee""Rata""Tick""Sirn""Ring""SciF""Robt""Chrp""Tada""Crck""Alrm", "Beep1 ""Beep2 ""Beep3 ""Aviso1""Aviso2""Cheep ""Ratata""Tick ""Sirena""Ring ""SciFi ""Robot ""Chirp ""Tada ""Crickt""AlmClk") diff --git a/radio/src/translations/fi.h.txt b/radio/src/translations/fi.h.txt index c13f4411d..1226dcc9f 100644 --- a/radio/src/translations/fi.h.txt +++ b/radio/src/translations/fi.h.txt @@ -299,21 +299,13 @@ #define TR_FSW_RESET_TELEM #endif -#if ROTARY_ENCODERS == 2 - #define TR_FSW_RESET_ROTENC TR("REa\0""REb\0", "RotEnc A\0""RotEnc B\0") -#elif ROTARY_ENCODERS == 1 - #define TR_FSW_RESET_ROTENC TR("R.E.", "RotEnc\0 ") -#else - #define TR_FSW_RESET_ROTENC -#endif - #if defined(PCBTARANIS) #define TR_FSW_RESET_TIMERS "Timer 1\0 ""Timer 2\0 ""Timer 3\0 " #else #define TR_FSW_RESET_TIMERS "Tmr1""Tmr2""Tmr3" #endif -#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC, TR_FSW_RESET_TIMERS "All\0 " TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC) +#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM, TR_FSW_RESET_TIMERS "All\0 " TR_FSW_RESET_TELEM) #define LEN_FUNCSOUNDS TR("\004", "\006") #define TR_FUNCSOUNDS TR("Bp1\0""Bp2\0""Bp3\0""Wrn1""Wrn2""Chee""Rata""Tick""Sirn""Ring""SciF""Robt""Chrp""Tada""Crck""Alrm", "Beep1 ""Beep2 ""Beep3 ""Warn1 ""Warn2 ""Cheep ""Ratata""Tick ""Siren ""Ring ""SciFi ""Robot ""Chirp ""Tada ""Crickt""AlmClk") diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index c88773f74..d70d0167f 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -301,21 +301,13 @@ #define TR_FSW_RESET_TELEM #endif -#if ROTARY_ENCODERS == 2 - #define TR_FSW_RESET_ROTENC TR("ERa\0""ERb\0", "Enc.Rot.A\0""Enc.Rot.B\0") -#elif ROTARY_ENCODERS == 1 - #define TR_FSW_RESET_ROTENC TR("EncR", "Enc.Rot\0 ") -#else - #define TR_FSW_RESET_ROTENC -#endif - #if LCD_W >= 212 #define TR_FSW_RESET_TIMERS "Chrono 1\0 ""Chrono 2\0 ""Chrono 3\0 " #else #define TR_FSW_RESET_TIMERS "Chr1""Chr2""Chr3" #endif -#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "Tout" TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC, TR_FSW_RESET_TIMERS "Tout\0 " TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC) +#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "Tout" TR_FSW_RESET_TELEM, TR_FSW_RESET_TIMERS "Tout\0 " TR_FSW_RESET_TELEM) #define LEN_FUNCSOUNDS TR("\004", "\006") #define TR_FUNCSOUNDS TR("Bp1\0""Bp2\0""Bp3\0""Wrn1""Wrn2""Chee""Rata""Tick""Sirn""Ring""SciF""Robt""Chrp""Tada""Crck""Alrm", "Beep1 ""Beep2 ""Beep3 ""Warn1 ""Warn2 ""Cheep ""Ratata""Tick ""Siren ""Ring ""SciFi ""Robot ""Chirp ""Tada ""Crickt""AlmClk") diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index 4842284f5..0ae8dfc53 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -301,21 +301,13 @@ #define TR_FSW_RESET_TELEM #endif -#if ROTARY_ENCODERS == 2 - #define TR_FSW_RESET_ROTENC TR("REa\0""REb\0", "EncRot A\0""EncRot B\0") -#elif ROTARY_ENCODERS == 1 - #define TR_FSW_RESET_ROTENC TR("R.E.", "EncRot\0 ") -#else - #define TR_FSW_RESET_ROTENC -#endif - #if LCD_W >= 212 #define TR_FSW_RESET_TIMERS "Timer 1\0 ""Timer 2\0 ""Timer 3\0 " #else #define TR_FSW_RESET_TIMERS "Tmr1""Tmr2""Tmr3" #endif -#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC, TR_FSW_RESET_TIMERS "Tutto\0 " TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC) +#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM, TR_FSW_RESET_TIMERS "Tutto\0 " TR_FSW_RESET_TELEM) #define LEN_FUNCSOUNDS TR("\004", "\006") #define TR_FUNCSOUNDS TR("Bp1\0""Bp2\0""Bp3\0""Wrn1""Wrn2""Chee""Rata""Tick""Sirn""Ring""SciF""Robt""Chrp""Tada""Crck""Alrm", "Beep1 ""Beep2 ""Beep3 ""Warn1 ""Warn2 ""Cheep ""Ratata""Tick ""Siren ""Ring ""SciFi ""Robot ""Chirp ""Tada ""Crickt""AlmClk") diff --git a/radio/src/translations/nl.h.txt b/radio/src/translations/nl.h.txt index 01b381e4c..d770d95e0 100644 --- a/radio/src/translations/nl.h.txt +++ b/radio/src/translations/nl.h.txt @@ -303,21 +303,13 @@ #define TR_FSW_RESET_TELEM #endif -#if ROTARY_ENCODERS == 2 - #define TR_FSW_RESET_ROTENC TR("REa\0""REb\0", "RotEnc A\0 ""RotEnc B\0 ") -#elif ROTARY_ENCODERS == 1 - #define TR_FSW_RESET_ROTENC TR("R.E.", "RotEnc\0 ") -#else - #define TR_FSW_RESET_ROTENC -#endif - #if LCD_W >= 212 #define TR_FSW_RESET_TIMERS "Timer 1\0 ""Timer 2\0 ""Timer 3\0 " #else #define TR_FSW_RESET_TIMERS "Tmr1""Tmr2""Tmr3" #endif -#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC, TR_FSW_RESET_TIMERS "Vliegdata\0" TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC) +#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM, TR_FSW_RESET_TIMERS "Vliegdata\0" TR_FSW_RESET_TELEM) #define LEN_FUNCSOUNDS TR("\004", "\006") #define TR_FUNCSOUNDS TR("Bp1\0""Bp2\0""Bp3\0""Wrn1""Wrn2""Chee""Rata""Tick""Sirn""Ring""SciF""Robt""Chrp""Tada""Crck""Alrm", "Beep1 ""Beep2 ""Beep3 ""Warn1 ""Warn2 ""Cheep ""Ratata""Tick ""Siren ""Ring ""SciFi ""Robot ""Chirp ""Tada ""Crickt""AlmClk") diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index 1a1a58c33..82f2e91f0 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -302,21 +302,13 @@ #define TR_FSW_RESET_TELEM #endif -#if ROTARY_ENCODERS == 2 - #define TR_FSW_RESET_ROTENC TR("REa\0""REb\0", "RotEnc A\0""RotEnc B\0") -#elif ROTARY_ENCODERS == 1 - #define TR_FSW_RESET_ROTENC TR("R.E.", "RotEnc\0 ") -#else - #define TR_FSW_RESET_ROTENC -#endif - #if LCD_W >= 212 #define TR_FSW_RESET_TIMERS "Timer 1\0 ""Timer 2\0 ""Timer 3\0 " #else #define TR_FSW_RESET_TIMERS "Tmr1""Tmr2""Tmr3" #endif -#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC, TR_FSW_RESET_TIMERS "All\0 " TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC) +#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM, TR_FSW_RESET_TIMERS "All\0 " TR_FSW_RESET_TELEM) #define LEN_FUNCSOUNDS TR("\004", "\006") #define TR_FUNCSOUNDS TR("Bp1\0""Bp2\0""Bp3\0""Ost1""Ost2""Chee""Rata""Tik ""Syre""Dzwo""SciF""Robt""Chrp""Tada""Crck""Alrm", "Beep1 ""Beep2 ""Beep3 ""Ostrz1""Ostrz1""Cheep ""Ratata""Tick ""Syrena""Dzwone""SciFi ""Robot ""Chirp ""Tada ""Krytcz""AlmZeg") diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index 884da125d..f33f2379b 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -298,21 +298,13 @@ #define TR_FSW_RESET_TELEM #endif -#if ROTARY_ENCODERS == 2 - #define TR_FSW_RESET_ROTENC TR("REa\0""REb\0", "RotEnc A\0""RotEnc B\0") -#elif ROTARY_ENCODERS == 1 - #define TR_FSW_RESET_ROTENC TR("R.E.", "RotEnc\0 ") -#else - #define TR_FSW_RESET_ROTENC -#endif - #if defined(PCBTARANIS) #define TR_FSW_RESET_TIMERS "Timer 1\0 ""Timer 2\0 ""Timer 3\0 " #else #define TR_FSW_RESET_TIMERS "Tmr1""Tmr2""Tmr3" #endif -#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC, TR_FSW_RESET_TIMERS "All\0 " TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC) +#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM, TR_FSW_RESET_TIMERS "All\0 " TR_FSW_RESET_TELEM) #define LEN_FUNCSOUNDS TR("\004", "\006") #define TR_FUNCSOUNDS TR("Bp1\0""Bp2\0""Bp3\0""Wrn1""Wrn2""Chee""Rata""Tick""Sirn""Ring""SciF""Robt""Chrp""Tada""Crck""Alrm", "Beep1 ""Beep2 ""Beep3 ""Avis1 ""Avis2 ""Cheep ""Ratata""Tick ""Siren ""Ring ""SciFi ""Robot ""Chirp ""Tada ""Crickt""AlmClk") diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index 00353eda2..941b5d8ca 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -299,21 +299,13 @@ #define TR_FSW_RESET_TELEM #endif -#if ROTARY_ENCODERS == 2 - #define TR_FSW_RESET_ROTENC TR("REa\0""REb\0", "RotEnk A\0""RotEnk B\0") -#elif ROTARY_ENCODERS == 1 - #define TR_FSW_RESET_ROTENC TR("R.E.", "RotEnk\0 ") -#else - #define TR_FSW_RESET_ROTENC -#endif - #if defined(PCBTARANIS) #define TR_FSW_RESET_TIMERS "Timer 1\0 ""Timer 2\0 ""Timer 3\0 " #else #define TR_FSW_RESET_TIMERS "Tmr1""Tmr2""Tmr3" #endif -#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC, TR_FSW_RESET_TIMERS "Alla\0 " TR_FSW_RESET_TELEM TR_FSW_RESET_ROTENC) +#define TR_VFSWRESET TR(TR_FSW_RESET_TIMERS "All\0" TR_FSW_RESET_TELEM, TR_FSW_RESET_TIMERS "Alla\0 " TR_FSW_RESET_TELEM) #define LEN_FUNCSOUNDS TR("\004", "\006") #define TR_FUNCSOUNDS TR("Bp1\0""Bp2\0""Bp3\0""Wrn1""Wrn2""Chee""Rata""Tick""Sirn""Ring""SciF""Robt""Chrp""Tada""Crck""Alrm", "Beep1 ""Beep2 ""Beep3 ""Warn1 ""Warn2 ""Cheep ""Ratata""Tick ""Siren ""Ring ""SciFi ""Robot ""Chirp ""Tada ""Crickt""AlmClk") @@ -496,8 +488,8 @@ #define TR_CYC_VSRCRAW "[C1]""[C2]""[C3]" #endif - #define TR_RESERVE_VSRCRAW "[--]" - #define TR_EXTRA_VSRCRAW "Batt""Tid\0""GPS\0" TR_RESERVE_VSRCRAW TR_RESERVE_VSRCRAW TR_RESERVE_VSRCRAW TR_RESERVE_VSRCRAW "Tmr1""Tmr2""Tmr3" +#define TR_RESERVE_VSRCRAW "[--]" +#define TR_EXTRA_VSRCRAW "Batt""Tid\0""GPS\0" TR_RESERVE_VSRCRAW TR_RESERVE_VSRCRAW TR_RESERVE_VSRCRAW TR_RESERVE_VSRCRAW "Tmr1""Tmr2""Tmr3" #define TR_VSRCRAW "---\0" TR_STICKS_VSRCRAW TR_POTS_VSRCRAW TR_ROTARY_ENCODERS TR_GYR_VSRCRAW "Max\0" TR_CYC_VSRCRAW TR_TRIMS_VSRCRAW TR_SW_VSRCRAW TR_EXTRA_VSRCRAW