diff options
author | tucvbif <47757803+tucvbif@users.noreply.github.com> | 2021-08-18 02:40:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-18 09:40:00 +1000 |
commit | 703f0277170c7e2d1acaa00b274f6fd479045abd (patch) | |
tree | af753085faaf1faefaf47441046ee8c4714af9be /quantum/encoder.c | |
parent | b8e913c8db73ebf890e4604ee41991a34354a600 (diff) | |
download | qmk_firmware-703f0277170c7e2d1acaa00b274f6fd479045abd.tar.gz qmk_firmware-703f0277170c7e2d1acaa00b274f6fd479045abd.zip |
Allow for removal of hysteresis on 4x encoders (#13698)
* Remove hysteresis on 4x encoders
Sometimes, controller skips encoder pulses and when it returns to default position, the encoder_pulses variable isn't equals 0. And when I turn encoder in opposite direciton, it skips first click becase of encoder_pulses crosses zero. To prevent this, I add the ENCODER_DEFAULT_POS constant, and reset encoder_pulses into 0 when the state variable equals ENCODER_DEFAULT_POS.
* Documentation for ENCODER_DEFAULT_POS
Diffstat (limited to 'quantum/encoder.c')
-rw-r--r-- | quantum/encoder.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/quantum/encoder.c b/quantum/encoder.c index c30bf01cb..8fb87281c 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c | |||
@@ -119,6 +119,11 @@ static bool encoder_update(uint8_t index, uint8_t state) { | |||
119 | encoder_update_kb(index, ENCODER_CLOCKWISE); | 119 | encoder_update_kb(index, ENCODER_CLOCKWISE); |
120 | } | 120 | } |
121 | encoder_pulses[i] %= resolution; | 121 | encoder_pulses[i] %= resolution; |
122 | #ifdef ENCODER_DEFAULT_POS | ||
123 | if ((state & 0x3) == ENCODER_DEFAULT_POS) { | ||
124 | encoder_pulses[i] = 0; | ||
125 | } | ||
126 | #endif | ||
122 | return changed; | 127 | return changed; |
123 | } | 128 | } |
124 | 129 | ||