From abd4de973b17f432b6ba4dc47678d02ed3fb1f46 Mon Sep 17 00:00:00 2001 From: bsongis Date: Sun, 15 Apr 2012 22:34:39 +0000 Subject: [PATCH] Makefile option renamed (EXTRA_ROTARY_ENCODERS) Fixed a bug with option EXTRA_ROTARY_ENCODERS: mixes shifted after REb 30 models when open9x / gruvin9x board LIMITS min and max range fixed --- src/Makefile | 6 ++--- src/board_ersky9x.cpp | 26 +------------------ src/board_gruvin9x.cpp | 16 ++++++------ src/board_stock.cpp | 2 +- src/eeprom_avr.cpp | 48 +++++++++++++++------------------- src/eeprom_avr.h | 40 ++++++++++++++++++++++++----- src/general_menus.cpp | 2 +- src/main_views.cpp | 14 +++++----- src/menus.cpp | 6 ++--- src/menus.h | 4 +-- src/model_menus.cpp | 34 ++++++++++++------------- src/myeeprom.h | 19 +++++++++----- src/open9x.h | 5 ++-- src/simpgmspace.cpp | 33 +++++++++++++++++++++--- src/simu.cpp | 58 ++++++++++++++++++++++++++++++++++-------- src/translations/en.h | 8 +++--- src/translations/fr.h | 8 +++--- src/translations/se.h | 8 +++--- 18 files changed, 200 insertions(+), 137 deletions(-) diff --git a/src/Makefile b/src/Makefile index 8f480deed..ac602936f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -105,7 +105,7 @@ EEPROM_PROGRESS_BAR = NO # Enable extra rotary encoders (V4 board only) # Values = YES, NO -MOD_EXTRA_ROTARY_ENCODERS = NO +EXTRA_ROTARY_ENCODERS = NO # DEBUG mode DEBUG = NO @@ -321,8 +321,8 @@ ifeq ($(PCB), V4) CPPDEFS += -DSOMO endif - ifeq ($(MOD_EXTRA_ROTARY_ENCODERS), YES) - CPPDEFS += -DMOD_EXTRA_ROTARY_ENCODERS + ifeq ($(EXTRA_ROTARY_ENCODERS), YES) + CPPDEFS += -DEXTRA_ROTARY_ENCODERS MODS:=${MODS}X endif diff --git a/src/board_ersky9x.cpp b/src/board_ersky9x.cpp index 17da1ef00..5bc31102e 100644 --- a/src/board_ersky9x.cpp +++ b/src/board_ersky9x.cpp @@ -960,8 +960,6 @@ void read_9_adc() register uint32_t y; register uint32_t x; -// PMC->PMC_PCER0 |= 0x20000000L ; // Enable peripheral clock to ADC - padc = ADC; y = padc->ADC_ISR; // Clear EOC flags for (y = NUMBER_ANALOG+1; --y > 0;) { @@ -993,44 +991,22 @@ void read_9_adc() if ( Temperature > maxTemperature ) { maxTemperature = Temperature ; } - -// Power save -// PMC->PMC_PCER0 &= ~0x20000000L ; // Disable peripheral clock to ADC } void readKeysAndTrims() { register uint32_t i; - /* Fix pulldown resistor on RF-POWER - if (PIOC->PIO_ODSR & 0x00080000) { - PIOC->PIO_CODR = 0x00200000L; // Set bit C19 OFF - } - else { - PIOC->PIO_SODR = 0x00200000L; // Set bit C19 ON - } */ - uint8_t enuk = KEY_MENU; uint8_t in = ~read_keys(); for (i = 1; i < 7; i++) { -//INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6 keys[enuk].input(in & (1 << i), (EnumKeys) enuk); ++enuk; } -// static const uint8_t crossTrim[]={ -// 1< 0 && (maxcol & ZCHAR)) { if (m_posHorz < maxcol-ZCHAR) { m_posHorz++; @@ -579,7 +579,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 (event == EVT_KEY_LONG(BTN_RE1)) { + if (event == EVT_KEY_LONG(BTN_REa)) { if (value == s_inflight_value) { s_inflight_value = NULL; } diff --git a/src/menus.h b/src/menus.h index 885835e26..5512a29b0 100644 --- a/src/menus.h +++ b/src/menus.h @@ -82,8 +82,8 @@ void menuProcDebug(uint8_t event); #if defined(NAVIGATION_RE1) extern int8_t scrollRE; extern int16_t p1valdiff; -#define IS_RE1_EVT_TYPE(event, type) (event==type(BTN_RE1)) -#define IS_RE1_EVT(event) ((event&0x0f)==BTN_RE1) +#define IS_RE1_EVT_TYPE(event, type) (event==type(BTN_REa)) +#define IS_RE1_EVT(event) ((event&0x0f)==BTN_REa) #else #define IS_RE1_EVT_TYPE(event, type) (0) #define IS_RE1_EVT(event) (0) diff --git a/src/model_menus.cpp b/src/model_menus.cpp index fce8c721c..6548ba947 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -190,10 +190,10 @@ void menuProcModelSelect(uint8_t event) } break; #ifdef NAVIGATION_RE1 - case EVT_KEY_BREAK(BTN_RE1): + case EVT_KEY_BREAK(BTN_REa): s_editMode = (s_editMode == 0 && sub == g_eeGeneral.currModel) ? -1 : 0; break; - case EVT_KEY_LONG(BTN_RE1): + case EVT_KEY_LONG(BTN_REa): #endif case EVT_KEY_LONG(KEY_MENU): case EVT_KEY_BREAK(KEY_MENU): @@ -406,10 +406,10 @@ void EditName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, boo if (nextmin-100), attr | INFLIGHT(ld->min)); if (active) { - CHECK_INFLIGHT_INCDEC_MODELVAR(event, ld->min, -limit, limit, +100, STR_MINLIMIT); + CHECK_INFLIGHT_INCDEC_MODELVAR(event, ld->min, -limit, 25, +100, STR_MINLIMIT); } break; case 2: lcd_outdezAtt(16*FW, y, (int8_t)(ld->max+100), attr | INFLIGHT(ld->max)); if (active) { - CHECK_INFLIGHT_INCDEC_MODELVAR(event, ld->max, -limit, limit, -100, STR_MAXLIMIT); + CHECK_INFLIGHT_INCDEC_MODELVAR(event, ld->max, -25, limit, -100, STR_MAXLIMIT); } break; case 3: @@ -1732,7 +1732,7 @@ void menuProcCurvesAll(uint8_t event) case EVT_KEY_FIRST(KEY_RIGHT): case EVT_KEY_FIRST(KEY_MENU): #ifdef NAVIGATION_RE1 - case EVT_KEY_BREAK(BTN_RE1): + case EVT_KEY_BREAK(BTN_REa): #endif if (sub >= 0) { s_curveChan = sub; diff --git a/src/myeeprom.h b/src/myeeprom.h index 077e05a74..ac0e59f4c 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -49,7 +49,7 @@ #define BEEP_VAL ( (g_eeGeneral.warnOpts & WARN_BVAL_BIT) >>3 ) #if defined(PCBV4) -#define EEPROM_VER 206 +#define EEPROM_VER 207 #else #define EEPROM_VER 205 #endif @@ -174,8 +174,13 @@ enum MixSources { MIXSRC_P2, MIXSRC_P3, #if defined(PCBV4) - MIXSRC_RE1, - MIXSRC_RE2, + MIXSRC_REa, + MIXSRC_REb, +#if defined(EXTRA_ROTARY_ENCODERS) + MIXSRC_REc, + MIXSRC_REd, + MIXSRC_REe, +#endif #endif MIXSRC_MAX , MIXSRC_3POS, @@ -387,11 +392,11 @@ PACK(typedef struct t_SwashRingData { // Swash Ring data #define TRIM_MIN (-TRIM_MAX) #if defined(PCBV4) -#if defined(MOD_EXTRA_ROTARY_ENCODERS) +#if defined(EXTRA_ROTARY_ENCODERS) #define NUM_EXTRA_ROTARY_ENCODERS 3 -#else //MOD_EXTRA_ROTARY_ENCODERS +#else //EXTRA_ROTARY_ENCODERS #define NUM_EXTRA_ROTARY_ENCODERS 0 -#endif //MOD_EXTRA_ROTARY_ENCODERS +#endif //EXTRA_ROTARY_ENCODERS #define NUM_ROTARY_ENCODERS (2+NUM_EXTRA_ROTARY_ENCODERS) #define ROTARY_ENCODER_MAX 1024 #define ROTARY_ENCODER_ARRAY int16_t rotaryEncoders[NUM_ROTARY_ENCODERS]; @@ -414,6 +419,8 @@ PACK(typedef struct t_PhaseData { #if defined(PCBARM) #define MAX_MODELS 60 +#elif defined(PCBV4) +#define MAX_MODELS 30 #else #define MAX_MODELS 16 #endif diff --git a/src/open9x.h b/src/open9x.h index 9fc0dc849..f0fb656bc 100644 --- a/src/open9x.h +++ b/src/open9x.h @@ -294,8 +294,8 @@ enum EnumKeys { TRM_RH_DWN , TRM_RH_UP , #ifdef PCBV4 - BTN_RE1, - BTN_RE2, + BTN_REa, + BTN_REb, #endif //SW_NC , //SW_ON , @@ -309,7 +309,6 @@ enum EnumKeys { SW_Gear , SW_Trainer, NUM_KEYS = SW_ThrCt - }; class Key diff --git a/src/simpgmspace.cpp b/src/simpgmspace.cpp index 92391b9e7..d4ad385b2 100644 --- a/src/simpgmspace.cpp +++ b/src/simpgmspace.cpp @@ -33,7 +33,7 @@ #include "open9x.h" -volatile uint8_t pinb=0, pinc=0xff, pind, pine=0xff, ping=0xff, pinh=0xff, pinj=0xff, pinl=0; +volatile uint8_t pinb=0xff, pinc=0xff, pind, pine=0xff, ping=0xff, pinh=0xff, pinj=0xff, pinl=0; uint8_t portb, portc, porth=0, dummyport; uint16_t dummyport16; const char *eepromFile = NULL; @@ -60,13 +60,37 @@ void setSwitch(int8_t swtch) { switch (swtch) { case DSW_ID0: - ping |= (1<PIO_PDSR &= ~0x00004000; +#elif defined(PCBV4) + ping |= (1<PIO_PDSR |= 0x00004800; +#elif defined(PCBV4) + ping &= ~(1<PIO_PDSR &= ~0x00000800; +#elif defined(PCBV4) + ping &= ~(1<PIO_PDSR = 0xFDFFFFFF; - PIOB->PIO_PDSR = 0xFFFFFFFF; - PIOA->PIO_PDSR = 0xFFFFFFFF; + PIOC->PIO_PDSR |= ERSKY9X_DOWN_MASK | ERSKY9X_UP_MASK | ERSKY9X_RIGHT_MASK | ERSKY9X_LEFT_MASK ; + ERSKY9X_EXIT_PIO->PIO_PDSR |= ERSKY9X_EXIT_MASK; + PIOB->PIO_PDSR |= ERSKY9X_MENU_MASK; +// PIOA->PIO_PDSR = 0xFFFFFFFF; Temperature = 1000; maxTemperature = 1500; +#elif defined(PCBV4) + pinl &= ~ 0x3f; +#else + pinb &= ~ 0x7e; #endif for(unsigned i=0; igetKeyState(keys1[i])) { - pinb |= (1<PIO_PDSR &= ~(keys1[i+4]); +#elif defined(PCBV4) + pinl |= (1<PIO_PDSR &= ~(0x00800000 | 0x01000000 | 0x00000002 | 0x00000001 ); +#elif defined(PCBV4) pinj = 0; #else pind = 0; #endif for(unsigned i=0; igetKeyState(keys2[i])) { -#ifdef PCBV4 +#if defined(PCBARM) + switch(i) { + case 0: + PIOA->PIO_PDSR |= 0x00800000; + break; + } +#elif defined(PCBV4) pinj |= (1<PIO_PDSR, 0x00100000, 0 }, + { KEY_6, PIOA->PIO_PDSR, 0x00000004, 0 }, + { KEY_2, PIOA->PIO_PDSR, 0x00008000, 0 }, + { KEY_3, PIOC->PIO_PDSR, 0x80000000, 0 }, + { KEY_7, PIOC->PIO_PDSR, 0x00010000, 0 }, + { KEY_8, PIOC->PIO_PDSR, 0x00000100, 0 } }; +#else #if defined(PCBV4) || defined(JETI) || defined(FRSKY) || defined(NMEA) || defined(ARDUPILOT) { KEY_1, pinc, INP_C_ThrCt, 0 }, { KEY_6, pinc, INP_C_AileDR, 0 }, @@ -361,15 +391,20 @@ void Open9xSim::refreshDiplay() #endif { KEY_2, ping, INP_G_RuddDR, 0 }, { KEY_3, pine, INP_E_ElevDR, 0 }, - //KEY_4, ping, INP_G_ID1, 0, - //KEY_5, pine, INP_E_ID2, 0, + //KEY_4, ping, INP_G_ID1, 0, + //KEY_5, pine, INP_E_ID2, 0, { KEY_7, pine, INP_E_Gear, 0 }, { KEY_8, pine, INP_E_Trainer, 0 } }; +#endif for(unsigned i=0; igetKeyState(keys3[i].key); if (ks != keys3[i].value) { +#if defined(PCBARM) + if (ks) keys3[i].pin ^= (keys3[i].shift); +#else if (ks) keys3[i].pin ^= (1<