Browse Source

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
pull/14052/head
tucvbif 2 years ago
committed by GitHub
parent
commit
703f027717
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions
  1. +6
    -0
      docs/feature_encoders.md
  2. +5
    -0
      quantum/encoder.c

+ 6
- 0
docs/feature_encoders.md View File

@ -38,6 +38,12 @@ It can also be defined per-encoder, by instead defining:
#define ENCODER_RESOLUTIONS { 4, 2 }
```
For 4× encoders you also can assign default position if encoder skips pulses when it changes direction. For example, if your encoder send high level on both pins by default, define this:
```c
#define ENCODER_DEFAULT_POS 0x3
```
## Split Keyboards
If you are using different pinouts for the encoders on each half of a split keyboard, you can define the pinout (and optionally, resolutions) for the right half like this:


+ 5
- 0
quantum/encoder.c View File

@ -119,6 +119,11 @@ static bool encoder_update(uint8_t index, uint8_t state) {
encoder_update_kb(index, ENCODER_CLOCKWISE);
}
encoder_pulses[i] %= resolution;
#ifdef ENCODER_DEFAULT_POS
if ((state & 0x3) == ENCODER_DEFAULT_POS) {
encoder_pulses[i] = 0;
}
#endif
return changed;
}


Loading…
Cancel
Save