From 95170b5930adfc8222a6f60e92b3cc0fdc3ce105 Mon Sep 17 00:00:00 2001 From: bsongis Date: Wed, 11 Jul 2012 13:21:03 +0000 Subject: [PATCH] [ersky9x] rotary encoders inversion RE1 and RE2 renamed as REa and REb (will be needed for Flight Phases uses) --- src/Makefile | 4 ++-- src/board_ersky9x.cpp | 7 ++++--- src/board_gruvin9x.cpp | 6 +++--- src/general_menus.cpp | 12 ++++++------ src/main_views.cpp | 8 ++++---- src/menus.cpp | 25 ++++++++++++------------- src/menus.h | 4 ++-- src/model_menus.cpp | 34 +++++++++++++++++----------------- src/open9x.cpp | 6 +++++- src/open9x.h | 14 +++++++++----- src/translations.cpp | 2 +- src/translations.h | 6 +++--- src/translations/cz.h | 4 ++-- src/translations/de.h | 4 ++-- src/translations/en.h | 4 ++-- src/translations/fr.h | 4 ++-- src/translations/it.h | 4 ++-- src/translations/se.h | 4 ++-- 18 files changed, 80 insertions(+), 72 deletions(-) diff --git a/src/Makefile b/src/Makefile index 1decd2e1b..25f69e95e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -334,7 +334,7 @@ RUN_FROM_FLASH = 1 ifeq ($(PCB), ARM) # V4 ARM, so ... OPT = 2 - CPPDEFS += -DPCBARM -DAUDIO -DHAPTIC -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS + CPPDEFS += -DPCBARM -DAUDIO -DHAPTIC -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1 EXTRAINCDIRS += ersky9x CoOS/kernel CoOS/portable BOARDSRC = board_ersky9x.cpp SRC += ersky9x/core_cm3.c ersky9x/board_lowlevel.c ersky9x/crt.c ersky9x/vectors_sam3s.c @@ -352,7 +352,7 @@ endif ifeq ($(PCB), V4) # V4 PCB, so ... OPT = 2 - CPPDEFS += -DPCBV4 -DAUDIO -DHAPTIC -DROTARY_ENCODERS + CPPDEFS += -DPCBV4 -DAUDIO -DHAPTIC -DROTARY_ENCODERS=2 EXTRAINCDIRS += gruvin9x stock FatFs FatFs/option BOARDSRC += board_gruvin9x.cpp EEPROMSRC = eeprom_avr.cpp diff --git a/src/board_ersky9x.cpp b/src/board_ersky9x.cpp index aeeb782ea..0461f5dde 100644 --- a/src/board_ersky9x.cpp +++ b/src/board_ersky9x.cpp @@ -171,6 +171,7 @@ inline void setup_switches() #ifdef SIMU #define end_ppm_capture() +#define stop_rotary_encoder() #define sam_boot() #else @@ -444,11 +445,11 @@ extern "C" void PIOC_IRQHandler() { if ( ( Rotary_position & 0x01 ) ^ ( ( dummy & 0x04) >> 2 ) ) { - incRotaryEncoder(0, -1); + incRotaryEncoder(0, +1); } else { - incRotaryEncoder(0, +1); + incRotaryEncoder(0, -1); } Rotary_position &= ~0x45 ; Rotary_position |= dummy ; @@ -1023,7 +1024,7 @@ void readKeysAndTrims() register uint32_t i; #if defined(ROTARY_ENCODERS) - keys[BTN_RE1].input(PIOB->PIO_PDSR & 0x40, BTN_RE1); + keys[BTN_REa].input(PIOB->PIO_PDSR & 0x40, BTN_REa); #endif uint8_t enuk = KEY_MENU; diff --git a/src/board_gruvin9x.cpp b/src/board_gruvin9x.cpp index ee4c82ee8..4d51a8463 100644 --- a/src/board_gruvin9x.cpp +++ b/src/board_gruvin9x.cpp @@ -156,7 +156,7 @@ ISR(USART1_RX_vect) resh = (resh >> 1) & 0x01; res = ((resh << 8) | resl); if((res == 0x180) | (res == 0x1C0)){ //button REb filter - keys[BTN_RE1].input((res & 0x1C0) == 0x1C0, BTN_RE1); + keys[BTN_REa].input((res & 0x1C0) == 0x1C0, BTN_REa); } else if((res & 0x100) == 0x100){ //rotary filter vpotToChange = res & 0xEF; vpot_mod_state = 1; @@ -275,9 +275,9 @@ void readKeysAndTrims() uint8_t enuk = KEY_MENU; #if !defined(EXTRA_ROTARY_ENCODERS) - keys[BTN_RE1].input(~PIND & 0x20, BTN_RE1); + keys[BTN_REa].input(~PIND & 0x20, BTN_REa); #endif //!EXTRA_ROTARY_ENCODERS - keys[BTN_RE2].input(~PIND & 0x10, BTN_RE2); + keys[BTN_REb].input(~PIND & 0x10, BTN_REb); uint8_t tin = ~PINL; uint8_t in; diff --git a/src/general_menus.cpp b/src/general_menus.cpp index 0a819dc0f..625d2ab99 100644 --- a/src/general_menus.cpp +++ b/src/general_menus.cpp @@ -300,10 +300,10 @@ void menuProcSetup(uint8_t event) #if defined(ROTARY_ENCODERS) case ITEM_SETUP_RE_NAVIGATION: - g_eeGeneral.reNavigation = selectMenuItem(y, STR_RENAVIG, STR_VRENAVIG, g_eeGeneral.reNavigation, 0, 2, attr, event); + g_eeGeneral.reNavigation = selectMenuItem(y, STR_RENAVIG, STR_VRENAVIG, g_eeGeneral.reNavigation, 0, ROTARY_ENCODERS, attr, event); if (attr && checkIncDec_Ret) { - g_rotenc[0] = 0; - g_rotenc[1] = 0; + for (uint8_t i=0; i cursor down/up @@ -193,17 +200,9 @@ void check_rotary_encoder() if (g_eeGeneral.reNavigation) { uint8_t re = g_eeGeneral.reNavigation - 1; p1valdiff = 0; -#if defined(PCBARM) - scrollRE = re1valprev - g_rotenc[re] /4; -#else - scrollRE = re1valprev - g_rotenc[re]; -#endif + scrollRE = re1valprev - (g_rotenc[re] / ROTARY_ENCODER_GRANULARITY); if (scrollRE) { -#if defined(PCBARM) - re1valprev = g_rotenc[re] / 4; -#else - re1valprev = g_rotenc[re]; -#endif + re1valprev = (g_rotenc[re] / ROTARY_ENCODER_GRANULARITY); if (s_editMode > 0) { p1valdiff = -scrollRE; scrollRE = 0; @@ -238,12 +237,12 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa #if defined(ROTARY_ENCODERS) if (!(s_warning || s_sdcard_error || s_menu_count)) check_rotary_encoder(); - if (m_posVert < 0 && (event==EVT_KEY_FIRST(BTN_RE1) || event==EVT_KEY_FIRST(BTN_RE2) || event==EVT_KEY_FIRST(KEY_MENU))) { + if (m_posVert < 0 && (event==EVT_KEY_FIRST(BTN_REa) || event==EVT_KEY_FIRST(BTN_REb) || event==EVT_KEY_FIRST(KEY_MENU))) { popMenu(); killEvents(event); return false; } - if (g_eeGeneral.reNavigation && event == EVT_KEY_BREAK(BTN_RE1+g_eeGeneral.reNavigation-1)) { + if (g_eeGeneral.reNavigation && event == EVT_KEY_BREAK(BTN_REa+g_eeGeneral.reNavigation-1)) { if (s_editMode > 0 && (maxcol & ZCHAR)) { if (m_posHorz < maxcol-ZCHAR) { m_posHorz++; @@ -681,7 +680,7 @@ void checkInFlightIncDecModel(uint8_t event, int8_t *value, int8_t i_min, int8_t { *value = (((uint8_t)(*value)) & ((1 << bitshift) - 1)) + ((i_shift + checkIncDecModel(event, (((uint8_t)(*value)) >> bitshift)-i_shift, i_min, i_max)) << bitshift); - if (g_eeGeneral.reNavigation && event == EVT_KEY_LONG(BTN_RE1+g_eeGeneral.reNavigation-1)) { + if (g_eeGeneral.reNavigation && event == EVT_KEY_LONG(BTN_REa+g_eeGeneral.reNavigation-1)) { if (value == s_inflight_value) { s_inflight_value = NULL; } diff --git a/src/menus.h b/src/menus.h index 91255bc9f..f1984c42e 100644 --- a/src/menus.h +++ b/src/menus.h @@ -82,8 +82,8 @@ void menuProcDebug(uint8_t event); #if defined(ROTARY_ENCODERS) extern int8_t scrollRE; extern int16_t p1valdiff; -#define IS_RE_NAVIGATION_EVT_TYPE(event, type) (g_eeGeneral.reNavigation && event==type(BTN_RE1 + g_eeGeneral.reNavigation - 1)) -#define IS_RE_NAVIGATION_EVT(event) (g_eeGeneral.reNavigation && (event&EVT_KEY_MASK)==(BTN_RE1 + g_eeGeneral.reNavigation - 1)) +#define IS_RE_NAVIGATION_EVT_TYPE(event, type) (g_eeGeneral.reNavigation && event==type(BTN_REa + g_eeGeneral.reNavigation - 1)) +#define IS_RE_NAVIGATION_EVT(event) (g_eeGeneral.reNavigation && (event&EVT_KEY_MASK)==(BTN_REa + g_eeGeneral.reNavigation - 1)) #else #define IS_RE_NAVIGATION_EVT_TYPE(event, type) (0) #define IS_RE_NAVIGATION_EVT(event) (0) diff --git a/src/model_menus.cpp b/src/model_menus.cpp index 15a29c10d..49b825932 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -269,13 +269,13 @@ void menuProcModelSelect(uint8_t event) } break; #if defined(ROTARY_ENCODERS) - case EVT_KEY_BREAK(BTN_RE1): - case EVT_KEY_BREAK(BTN_RE2): + case EVT_KEY_BREAK(BTN_REa): + case EVT_KEY_BREAK(BTN_REb): if (navigationRotaryEncoder(_event)) s_editMode = (s_editMode == 0 && sub == g_eeGeneral.currModel) ? -1 : 0; break; - case EVT_KEY_LONG(BTN_RE1): - case EVT_KEY_LONG(BTN_RE2): + case EVT_KEY_LONG(BTN_REa): + case EVT_KEY_LONG(BTN_REb): if (!navigationRotaryEncoder(_event)) break; #endif @@ -518,13 +518,13 @@ void EditName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, boo if (next