Browse Source

Fix `encoder_queue_full_advanced()` for non-power-of-2 queue sizes

`(events->tail - 1) % MAX_QUEUED_ENCODER_EVENTS` did not calculate what
the rest of code expected when `events->tail` was 0, except when
`MAX_QUEUED_ENCODER_EVENTS` happened to be a power of 2, so the code
seemed to work when the number of encoders was less than 4 (in that case
`MAX_QUEUED_ENCODER_EVENTS` was set to 4), but broke when the number of
encoders was 4 or more.  Fix the queue full check to avoid negative
numbers in calculations.
pull/23595/head
Sergey Vlasov 1 week ago
parent
commit
af6fd646e0
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      quantum/encoder.c

+ 1
- 1
quantum/encoder.c View File

@ -83,7 +83,7 @@ bool encoder_task(void) {
}
bool encoder_queue_full_advanced(encoder_events_t *events) {
return events->head == (events->tail - 1) % MAX_QUEUED_ENCODER_EVENTS;
return events->tail == (events->head + 1) % MAX_QUEUED_ENCODER_EVENTS;
}
bool encoder_queue_full(void) {


Loading…
Cancel
Save