diff --git a/src/myeeprom.h b/src/myeeprom.h index ddeb65d29..8603c5f16 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -388,11 +388,8 @@ PACK(typedef struct t_SwashRingData { // Swash Ring data #if defined(PCBV4) #if defined(MOD_EXTRA_ROTARY_ENCODERS) #define NUM_EXTRA_ROTARY_ENCODERS 3 -#define VPOT_STEP 5 -#define VPOT_MAX 1000 -#define VPOT_MIN -VPOT_MAX #else //MOD_EXTRA_ROTARY_ENCODERS -#define NUM_EXTRA_ROTARY_ENCODERS 3 +#define NUM_EXTRA_ROTARY_ENCODERS 0 #endif //MOD_EXTRA_ROTARY_ENCODERS #define NUM_ROTARY_ENCODERS (2+NUM_EXTRA_ROTARY_ENCODERS) #define ROTARY_ENCODER_MAX 1024 diff --git a/src/open9x.cpp b/src/open9x.cpp index ba8c27d77..0d229d534 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -2189,6 +2189,42 @@ ISR(TIMER3_CAPT_vect) // G: High frequency noise can cause stack overflo with IS #endif } +#if defined (PCBV4) & defined(MOD_EXTRA_ROTARY_ENCODERS) + +uint8_t vpotToChange = 0; +uint8_t vpot_mod_state = 0; + +ISR(USART2_RX_vect) +{ + //receive data from extension board + //bit 9 = 1 mean encoder number, following byte with bit 9 = 0 is increment value + /* Get status and 9th bit, then data */ + /* from buffer */ + //uint8_t status = UCSR2A; + uint16_t resh = UCSR2B; + uint16_t resl = UDR2; + uint16_t res = 0; + //if ( status & (1<> 1) & 0x01; + res = ((resh << 8) | resl); + if((res & 0x100) == 0x100){ + vpotToChange = res & 0xff; + vpot_mod_state = 1; + }else{ + if(vpot_mod_state & (vpotToChange>0) & (vpotToChange<=NUM_EXTRA_ROTARY_ENCODERS)) + { + int8_t vpot_inc = res & 0xff; + if(vpot_inc){ + incRotaryEncoder(NUM_ROTARY_ENCODERS-NUM_EXTRA_ROTARY_ENCODERS+vpotToChange-1, vpot_inc); + } + vpot_mod_state = 0; + } + } +} +#endif //MOD_EXTRA_ROTARY_ENCODERS + extern uint16_t g_timeMain; /* @@ -2546,6 +2582,19 @@ int main(void) */ OCR4A = 0x7d; TCCR4B = (1 << WGM42) | (3<