Skip to content

Commit

Permalink
Remove hysteresis on 4x encoders
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tucvbif authored and drashna committed Jul 29, 2021
1 parent 935079f commit c107b61
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions quantum/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit c107b61

Please sign in to comment.