diff options
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/encoder.c | 22 | ||||
-rw-r--r-- | quantum/encoder.h | 2 |
2 files changed, 11 insertions, 13 deletions
diff --git a/quantum/encoder.c b/quantum/encoder.c index 25ddab0c3c..7b3738f9a1 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c @@ -56,7 +56,7 @@ static int8_t encoder_LUT[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, static uint8_t encoder_state[NUM_ENCODERS] = {0}; static int8_t encoder_pulses[NUM_ENCODERS] = {0}; -static bool encoder_external_update[NUM_ENCODERS] = {false}; +static bool encoder_interrupt_update[NUM_ENCODERS] = {false}; // encoder counts static uint8_t thisCount; @@ -222,16 +222,23 @@ bool encoder_read(void) { bool changed = false; for (uint8_t i = 0; i < thisCount; i++) { uint8_t new_status = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1); - if ((encoder_state[i] & 0x3) != new_status || encoder_external_update[i]) { + if ((encoder_state[i] & 0x3) != new_status || encoder_interrupt_update[i]) { encoder_state[i] <<= 2; encoder_state[i] |= new_status; changed |= encoder_update(i, encoder_state[i]); - encoder_external_update[i] = false; + encoder_interrupt_update[i] = false; } } return changed; } +void encoder_inerrupt_read(uint8_t index) { + encoder_state[index] <<= 2; + encoder_state[index] |= (readPin(encoders_pad_a[index]) << 0) | (readPin(encoders_pad_b[index]) << 1); + encoder_pulses[index] += encoder_LUT[encoder_state[index] & 0xF]; + encoder_interrupt_update[index] = true; +} + #ifdef SPLIT_KEYBOARD void last_encoder_activity_trigger(void); @@ -270,12 +277,3 @@ void encoder_update_raw(uint8_t *slave_state) { if (changed) last_encoder_activity_trigger(); } #endif - -void encoder_insert_state(void) { - for (uint8_t i = 0; i < thisCount; i++) { - encoder_state[i] <<= 2; - encoder_state[i] |= (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1); - encoder_pulses[i] += encoder_LUT[encoder_state[i] & 0xF]; - encoder_external_update[i] = true; - } -} diff --git a/quantum/encoder.h b/quantum/encoder.h index bc02889ee8..fb0fd18aa8 100644 --- a/quantum/encoder.h +++ b/quantum/encoder.h @@ -25,7 +25,7 @@ bool encoder_read(void); bool encoder_update_kb(uint8_t index, bool clockwise); bool encoder_update_user(uint8_t index, bool clockwise); -void encoder_insert_state(void); +void encoder_inerrupt_read(uint8_t index); #ifdef SPLIT_KEYBOARD |