summaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/encoder.c11
-rw-r--r--quantum/encoder.h1
2 files changed, 11 insertions, 1 deletions
diff --git a/quantum/encoder.c b/quantum/encoder.c
index 3aee340249..2730ff60c3 100644
--- a/quantum/encoder.c
+++ b/quantum/encoder.c
@@ -40,6 +40,7 @@ extern volatile bool isLeftHand;
static pin_t encoders_pad_a[NUM_ENCODERS_MAX_PER_SIDE] = ENCODERS_PAD_A;
static pin_t encoders_pad_b[NUM_ENCODERS_MAX_PER_SIDE] = ENCODERS_PAD_B;
+static bool encoder_interrupt_update[NUM_ENCODERS] = {false};
#ifdef ENCODER_RESOLUTIONS
static uint8_t encoder_resolutions[NUM_ENCODERS] = ENCODER_RESOLUTIONS;
@@ -221,15 +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) {
+ 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_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);
diff --git a/quantum/encoder.h b/quantum/encoder.h
index 4eb67fa25d..fb0fd18aa8 100644
--- a/quantum/encoder.h
+++ b/quantum/encoder.h
@@ -25,6 +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_inerrupt_read(uint8_t index);
#ifdef SPLIT_KEYBOARD