diff --git a/src/board_gruvin9x.cpp b/src/board_gruvin9x.cpp index 4b277e1c1..d2a1ba172 100644 --- a/src/board_gruvin9x.cpp +++ b/src/board_gruvin9x.cpp @@ -101,7 +101,11 @@ inline void board_init() EICRA = (1<> 1) & 0x01; @@ -148,11 +150,11 @@ ISR(USART2_RX_vect) vpot_mod_state = 1; } else { - if(vpot_mod_state & (vpotToChange>0) & (vpotToChange<=NUM_EXTRA_ROTARY_ENCODERS)) + if(vpot_mod_state & (vpotToChange>0) & (vpotToChange<=NUM_UART_ROTARY_ENCODERS)) { int8_t vpot_inc = res & 0xff; if(vpot_inc){ - incRotaryEncoder(NUM_ROTARY_ENCODERS-NUM_EXTRA_ROTARY_ENCODERS+vpotToChange-1, vpot_inc); + incRotaryEncoder((NUM_ROTARY_ENCODERS - NUM_UART_ROTARY_ENCODERS) + (vpotToChange - 1), vpot_inc); } vpot_mod_state = 0; } @@ -260,8 +262,12 @@ void readKeysAndTrims() uint8_t enuk = KEY_MENU; +#if !defined(EXTRA_ROTARY_ENCODERS) keys[BTN_REa].input(~PIND & 0x20, BTN_REa); keys[BTN_REb].input(~PIND & 0x10, BTN_REb); +#else //EXTRA_ROTARY_ENCODERS + keys[BTN_REa].input(~PIND & 0x10, BTN_REa); +#endif //EXTRA_ROTARY_ENCODERS uint8_t tin = ~PINL; uint8_t in; diff --git a/src/lcd.cpp b/src/lcd.cpp index 42e8442b6..096b08856 100644 --- a/src/lcd.cpp +++ b/src/lcd.cpp @@ -581,7 +581,11 @@ void putsTrimMode(uint8_t x, uint8_t y, uint8_t phase, uint8_t idx, uint8_t att) #if defined(PCBV4) void putsRotaryEncoderMode(uint8_t x, uint8_t y, uint8_t phase, uint8_t idx, uint8_t att) { - int16_t v = phaseaddress(phase)->rotaryEncoders[idx]; + int16_t v; + if(idx < (NUM_ROTARY_ENCODERS - NUM_EXTRA_ROTARY_ENCODERS)) + v = phaseaddress(phase)->rotaryEncoders[idx]; + else + v = g_model.rotaryEncodersExtra[phase][idx - (NUM_ROTARY_ENCODERS - NUM_EXTRA_ROTARY_ENCODERS)]; if (v > ROTARY_ENCODER_MAX) { uint8_t p = v - ROTARY_ENCODER_MAX - 1; diff --git a/src/main_views.cpp b/src/main_views.cpp index fe2e4c7b7..e3041cacf 100644 --- a/src/main_views.cpp +++ b/src/main_views.cpp @@ -313,8 +313,8 @@ void menuMainView(uint8_t event) int16_t val = getRotaryEncoder(i); int8_t len = limit((int16_t)0, (int16_t)(((val+1024) * BAR_HEIGHT) / 2048), (int16_t)BAR_HEIGHT); // TODO uint16_t? #if defined(EXTRA_ROTARY_ENCODERS) -#define V_BAR_W 4 - V_BAR(SCREEN_WIDTH/2-9+V_BAR_W*i, SCREEN_HEIGHT-8, len) +#define V_BAR_W 5 + V_BAR(SCREEN_WIDTH/2-8+V_BAR_W*i, SCREEN_HEIGHT-8, len) #else //EXTRA_ROTARY_ENCODERS #define V_BAR_W 5 V_BAR(SCREEN_WIDTH/2-3+V_BAR_W*i, SCREEN_HEIGHT-8, len) diff --git a/src/model_menus.cpp b/src/model_menus.cpp index d35d453b8..f981f58e7 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -860,12 +860,19 @@ void menuProcPhaseOne(uint8_t event) for (uint8_t t=0; t0) ? BLINK|INVERS : INVERS) : 0); if (attr && m_posHorz==4+t && ((s_editMode>0) || p1valdiff)) { - int16_t v = phaseaddress(s_currIdx)->rotaryEncoders[t]; + int16_t v; + if(t < (NUM_ROTARY_ENCODERS - NUM_EXTRA_ROTARY_ENCODERS)) + v = phaseaddress(s_currIdx)->rotaryEncoders[t]; + else + v = g_model.rotaryEncodersExtra[s_currIdx][t-(NUM_ROTARY_ENCODERS - NUM_EXTRA_ROTARY_ENCODERS)]; if (v < ROTARY_ENCODER_MAX) v = ROTARY_ENCODER_MAX; v = checkIncDec(event, v, ROTARY_ENCODER_MAX, ROTARY_ENCODER_MAX+MAX_PHASES-1, EE_MODEL); if (checkIncDec_Ret) { if (v == ROTARY_ENCODER_MAX) v = 0; - phaseaddress(s_currIdx)->rotaryEncoders[t] = v; + if(t < (NUM_ROTARY_ENCODERS - NUM_EXTRA_ROTARY_ENCODERS)) + phaseaddress(s_currIdx)->rotaryEncoders[t] = v; + else + g_model.rotaryEncodersExtra[s_currIdx][t-(NUM_ROTARY_ENCODERS - NUM_EXTRA_ROTARY_ENCODERS)] = v; } } } diff --git a/src/myeeprom.h b/src/myeeprom.h index 98800d01f..ee29b6227 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -443,17 +443,24 @@ PACK(typedef struct t_SwashRingData { // Swash Ring data #if defined(PCBV4) #if defined(EXTRA_ROTARY_ENCODERS) -#define NUM_EXTRA_ROTARY_ENCODERS 3 -#else -#define NUM_EXTRA_ROTARY_ENCODERS 0 -#endif +#define NUM_EXTRA_ROTARY_ENCODERS 2 #define NUM_ROTARY_ENCODERS (2+NUM_EXTRA_ROTARY_ENCODERS) +#define NUM_UART_ROTARY_ENCODERS 3 +#define ROTARY_ENCODER_ARRAY_EXTRA int16_t rotaryEncodersExtra[MAX_PHASES][2]; +#else //EXTRA_ROTARY_ENCODERS +#define NUM_EXTRA_ROTARY_ENCODERS 0 +#define NUM_ROTARY_ENCODERS 2 +#define ROTARY_ENCODER_ARRAY_EXTRA +#endif //EXTRA_ROTARY_ENCODERS #define ROTARY_ENCODER_MAX 1024 -#define ROTARY_ENCODER_ARRAY int16_t rotaryEncoders[NUM_ROTARY_ENCODERS]; -#else +#define ROTARY_ENCODER_ARRAY int16_t rotaryEncoders[2]; + +#else //PCBV4 #define NUM_ROTARY_ENCODERS 0 +#define NUM_EXTRA_ROTARY_ENCODERS 0 #define ROTARY_ENCODER_ARRAY -#endif +#define ROTARY_ENCODER_ARRAY_EXTRA +#endif //PCBV4 #if defined(PCBSTD) #define TRIM_ARRAY int8_t trim[4]; int8_t trim_ext:8 @@ -576,6 +583,7 @@ PACK(typedef struct t_ModelData { uint8_t varioSpeedDownMin; uint8_t switchWarningStates; + ROTARY_ENCODER_ARRAY_EXTRA; }) ModelData; extern EEGeneral g_eeGeneral; diff --git a/src/open9x.cpp b/src/open9x.cpp index f15d6969f..8208f9462 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -685,7 +685,11 @@ uint8_t getRotaryEncoderFlightPhase(uint8_t idx) uint8_t phase = s_perout_flight_phase; for (uint8_t i=0; irotaryEncoders[idx]; + int16_t value = 0; + if(idx<(NUM_ROTARY_ENCODERS - NUM_EXTRA_ROTARY_ENCODERS)) + value = phaseaddress(phase)->rotaryEncoders[idx]; + else + value = g_model.rotaryEncodersExtra[phase][idx-(NUM_ROTARY_ENCODERS - NUM_EXTRA_ROTARY_ENCODERS)]; if (value <= ROTARY_ENCODER_MAX) return phase; uint8_t result = value-ROTARY_ENCODER_MAX-1; if (result >= phase) result++; @@ -696,13 +700,20 @@ uint8_t getRotaryEncoderFlightPhase(uint8_t idx) int16_t getRotaryEncoder(uint8_t idx) { - return phaseaddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]; + if(idx < (NUM_ROTARY_ENCODERS - NUM_EXTRA_ROTARY_ENCODERS)) + return phaseaddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]; + else + return g_model.rotaryEncodersExtra[getRotaryEncoderFlightPhase(idx)][idx-(NUM_ROTARY_ENCODERS - NUM_EXTRA_ROTARY_ENCODERS)]; } void incRotaryEncoder(uint8_t idx, int8_t inc) { g_rotenc[idx] += inc; - int16_t *value = &(phaseaddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]); + int16_t *value; + if(idx < (NUM_ROTARY_ENCODERS - NUM_EXTRA_ROTARY_ENCODERS)) + value = &(phaseaddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]); + else + value = &(g_model.rotaryEncodersExtra[getRotaryEncoderFlightPhase(idx)][idx-(NUM_ROTARY_ENCODERS - NUM_EXTRA_ROTARY_ENCODERS)]); *value = limit((int16_t)-1024, (int16_t)(*value + (inc * 8)), (int16_t)+1024); eeDirty(EE_MODEL); } @@ -1445,7 +1456,7 @@ void evalFunctions() } } - if (~active_switches & switch_mask) { + if (~active_switches & switch_mask) { if (sd->func == FUNC_RESET) { switch (sd->param) { case 0: @@ -2470,6 +2481,7 @@ volatile uint8_t g_rotenc[2] = {0}; #ifndef SIMU #if defined (PCBV4) +#if !defined(EXTRA_ROTARY_ENCODERS) ISR(INT2_vect) { uint8_t input = PIND & 0b00001100; @@ -2480,16 +2492,24 @@ ISR(INT3_vect) uint8_t input = PIND & 0b00001100; if (input == 0 || input == 0b00001100) incRotaryEncoder(0, +1); } +#endif //EXTRA_ROTARY_ENCODERS + +#if !defined(EXTRA_ROTARY_ENCODERS) +#define ENC_B_ID 1 +#else +#define ENC_B_ID 0 +#endif + ISR(INT5_vect) { uint8_t input = PINE & 0b01100000; - if (input == 0 || input == 0b01100000) incRotaryEncoder(1, +1); + if (input == 0 || input == 0b01100000) incRotaryEncoder(ENC_B_ID, +1); } ISR(INT6_vect) { uint8_t input = PINE & 0b01100000; - if (input == 0 || input == 0b01100000) incRotaryEncoder(1, -1); + if (input == 0 || input == 0b01100000) incRotaryEncoder(ENC_B_ID, -1); } #endif @@ -2708,9 +2728,9 @@ int main(void) lcd_putcAtt( 72, 24, 'B', DBLSIZE ) ; refreshDisplay() ; #if defined(HAPTIC) - hapticOff() ; + hapticOff(); #endif - /* end force haptic to be disabled in this mode */ + /* end force haptic to be disabled in this mode */ usb_mode(); } #endif diff --git a/src/translations/cz.h b/src/translations/cz.h index 57f8786ae..dcd1e3260 100644 --- a/src/translations/cz.h +++ b/src/translations/cz.h @@ -32,7 +32,7 @@ #define LEN_RETA123 "\001" #if defined(PCBV4) #if defined(EXTRA_ROTARY_ENCODERS) -#define TR_RETA123 "SVPK123abcde" +#define TR_RETA123 "SVPK123abcd" #else //EXTRA_ROTARY_ENCODERS #define TR_RETA123 "SVPK123ab" #endif //EXTRA_ROTARY_ENCODERS @@ -186,7 +186,7 @@ #define LEN_VSRCRAW "\004" #if defined(PCBV4) #if defined(EXTRA_ROTARY_ENCODERS) -#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd ""REe " +#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd " #else #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " #endif diff --git a/src/translations/de.h b/src/translations/de.h index 8bb32e8d1..0ce27a7a8 100644 --- a/src/translations/de.h +++ b/src/translations/de.h @@ -32,7 +32,7 @@ #define LEN_RETA123 "\001" #if defined(PCBV4) #if defined(EXTRA_ROTARY_ENCODERS) -#define TR_RETA123 "RETA123abcde" +#define TR_RETA123 "RETA123abcd" #else //EXTRA_ROTARY_ENCODERS #define TR_RETA123 "RETA123ab" #endif //EXTRA_ROTARY_ENCODERS @@ -186,7 +186,7 @@ #define LEN_VSRCRAW "\004" #if defined(PCBV4) #if defined(EXTRA_ROTARY_ENCODERS) -#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd ""REe " +#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd " #else #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " #endif diff --git a/src/translations/en.h b/src/translations/en.h index dce940688..080da5f8f 100644 --- a/src/translations/en.h +++ b/src/translations/en.h @@ -32,7 +32,7 @@ #define LEN_RETA123 "\001" #if defined(PCBV4) #if defined(EXTRA_ROTARY_ENCODERS) -#define TR_RETA123 "RETA123abcde" +#define TR_RETA123 "RETA123abcd" #else //EXTRA_ROTARY_ENCODERS #define TR_RETA123 "RETA123ab" #endif //EXTRA_ROTARY_ENCODERS @@ -186,7 +186,7 @@ #define LEN_VSRCRAW "\004" #if defined(PCBV4) #if defined(EXTRA_ROTARY_ENCODERS) -#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd ""REe " +#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd " #else #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " #endif diff --git a/src/translations/fr.h b/src/translations/fr.h index 6ba4d9ad9..766093e81 100644 --- a/src/translations/fr.h +++ b/src/translations/fr.h @@ -32,7 +32,7 @@ #define LEN_RETA123 "\001" #if defined(PCBV4) #if defined(EXTRA_ROTARY_ENCODERS) -#define TR_RETA123 "RETA123abcde" +#define TR_RETA123 "RETA123abcd" #else //EXTRA_ROTARY_ENCODERS #define TR_RETA123 "RETA123ab" #endif //EXTRA_ROTARY_ENCODERS @@ -189,7 +189,7 @@ #define LEN_VSRCRAW "\004" #if defined(PCBV4) #if defined(EXTRA_ROTARY_ENCODERS) -#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd ""REe " +#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd " #else #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " #endif diff --git a/src/translations/it.h b/src/translations/it.h index 40c55802a..89ef9c3f5 100644 --- a/src/translations/it.h +++ b/src/translations/it.h @@ -32,7 +32,7 @@ #define LEN_RETA123 "\001" #if defined(PCBV4) #if defined(EXTRA_ROTARY_ENCODERS) -#define TR_RETA123 "RETA123abcde" +#define TR_RETA123 "RETA123abcd" #else //EXTRA_ROTARY_ENCODERS #define TR_RETA123 "RETA123ab" #endif //EXTRA_ROTARY_ENCODERS @@ -186,7 +186,7 @@ #define LEN_VSRCRAW "\004" #if defined(PCBV4) #if defined(EXTRA_ROTARY_ENCODERS) -#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd ""REe " +#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd " #else #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " #endif diff --git a/src/translations/se.h b/src/translations/se.h index ad54f9b1a..237505a4e 100644 --- a/src/translations/se.h +++ b/src/translations/se.h @@ -29,13 +29,13 @@ #define LEN_VTRIMINC "\006" #define TR_VTRIMINC "Exp ""xFin ""Fin ""Medel.""Grov " -#define LEN_RETA123 "\001" -#if defined(PCBV4) -#if defined(EXTRA_ROTARY_ENCODERS) -#define TR_RETA123 "RHGS123abcde" -#else //EXTRA_ROTARY_ENCODERS -#define TR_RETA123 "RHGS123ab" -#endif //EXTRA_ROTARY_ENCODERS +#define LEN_RETA123 "\001" +#if defined(PCBV4) +#if defined(EXTRA_ROTARY_ENCODERS) +#define TR_RETA123 "RHGS123abcd" +#else //EXTRA_ROTARY_ENCODERS +#define TR_RETA123 "RHGS123ab" +#endif //EXTRA_ROTARY_ENCODERS #else #define TR_RETA123 "RHGS123" #endif @@ -186,13 +186,13 @@ #define TR_VSWITCHES "GAS""ROD""H\205J""ID0""ID1""ID2""SKE""LAN""TRN""BR1""BR2""BR3""BR4""BR5""BR6""BR7""BR8""BR9""BRA""BRB""BRC" #endif -#define LEN_VSRCRAW "\004" -#if defined(PCBV4) -#if defined(EXTRA_ROTARY_ENCODERS) -#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd ""REe " -#else -#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " -#endif +#define LEN_VSRCRAW "\004" +#if defined(PCBV4) +#if defined(EXTRA_ROTARY_ENCODERS) +#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd " +#else +#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " +#endif #else #define TR_ROTARY_ENCODERS_VSRCRAW #endif