Improve ENCODER_DEFAULT_POS to recognize lost ticks (#16932)
parent
3ecb0a80af
commit
b8e8a20ca6
|
@ -163,27 +163,38 @@ static bool encoder_update(uint8_t index, uint8_t state) {
|
||||||
index += thisHand;
|
index += thisHand;
|
||||||
#endif
|
#endif
|
||||||
encoder_pulses[i] += encoder_LUT[state & 0xF];
|
encoder_pulses[i] += encoder_LUT[state & 0xF];
|
||||||
|
|
||||||
|
#ifdef ENCODER_DEFAULT_POS
|
||||||
|
if ((encoder_pulses[i] >= resolution) || (encoder_pulses[i] <= -resolution) || ((state & 0x3) == ENCODER_DEFAULT_POS)) {
|
||||||
|
if (encoder_pulses[i] >= 1) {
|
||||||
|
#else
|
||||||
if (encoder_pulses[i] >= resolution) {
|
if (encoder_pulses[i] >= resolution) {
|
||||||
encoder_value[index]++;
|
#endif
|
||||||
changed = true;
|
|
||||||
|
encoder_value[index]++;
|
||||||
|
changed = true;
|
||||||
#ifdef ENCODER_MAP_ENABLE
|
#ifdef ENCODER_MAP_ENABLE
|
||||||
encoder_exec_mapping(index, ENCODER_COUNTER_CLOCKWISE);
|
encoder_exec_mapping(index, ENCODER_COUNTER_CLOCKWISE);
|
||||||
#else // ENCODER_MAP_ENABLE
|
#else // ENCODER_MAP_ENABLE
|
||||||
encoder_update_kb(index, ENCODER_COUNTER_CLOCKWISE);
|
encoder_update_kb(index, ENCODER_COUNTER_CLOCKWISE);
|
||||||
#endif // ENCODER_MAP_ENABLE
|
#endif // ENCODER_MAP_ENABLE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENCODER_DEFAULT_POS
|
||||||
|
if (encoder_pulses[i] <= -1) {
|
||||||
|
#else
|
||||||
if (encoder_pulses[i] <= -resolution) { // direction is arbitrary here, but this clockwise
|
if (encoder_pulses[i] <= -resolution) { // direction is arbitrary here, but this clockwise
|
||||||
encoder_value[index]--;
|
#endif
|
||||||
changed = true;
|
encoder_value[index]--;
|
||||||
|
changed = true;
|
||||||
#ifdef ENCODER_MAP_ENABLE
|
#ifdef ENCODER_MAP_ENABLE
|
||||||
encoder_exec_mapping(index, ENCODER_CLOCKWISE);
|
encoder_exec_mapping(index, ENCODER_CLOCKWISE);
|
||||||
#else // ENCODER_MAP_ENABLE
|
#else // ENCODER_MAP_ENABLE
|
||||||
encoder_update_kb(index, ENCODER_CLOCKWISE);
|
encoder_update_kb(index, ENCODER_CLOCKWISE);
|
||||||
#endif // ENCODER_MAP_ENABLE
|
#endif // ENCODER_MAP_ENABLE
|
||||||
}
|
}
|
||||||
encoder_pulses[i] %= resolution;
|
encoder_pulses[i] %= resolution;
|
||||||
#ifdef ENCODER_DEFAULT_POS
|
#ifdef ENCODER_DEFAULT_POS
|
||||||
if ((state & 0x3) == ENCODER_DEFAULT_POS) {
|
|
||||||
encoder_pulses[i] = 0;
|
encoder_pulses[i] = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue