-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Debounce can happen at (DEBOUNCE - 1)ms due to >= check #21735
Comments
Proposal for a high precision timer based on the current value of
|
@drashna (tagging you just so you can maybe let me know who can take a better look at this and read my proposal / help with the HW part) |
Closing this, as I have collected some evidence yesterday that showed that this does not actually happen or that, when it does, it's not significant. |
I'm not quite sure that this has "not significant" effect. There are way too many reports in keyboard chatter on reddit on different QMK hardware that there is NO issue in debouncing. "Spacebar double tap, happening all 20 minutes or so" is a classic. Often reported on brown switches (Cherry or Gateron, doesn't really matter) Is there really no chance to have a look again on your proposal? |
@boessu by all means, go ahead and check it, but at least on my boards (two versions of the Glorious GMMK Pro), I found that the evaluation happens at each millisecond anyways and never twice on the same millisecond nor skipping milliseconds. I don't know if that goes for every board, though. And mine was pretty rudimentary debugging with printing information and whatnot. Perhaps more refined debugging could uncover other details. |
Describe the Bug
(From #21667, opening this as an issue to discuss it separately without interfering with that PR more than it already has)
It seems that, for most platforms, we get the time from ISRs or hardware clocks and we (or the platform) integer-divide them to get the number of milliseconds the clock is currently at.
Using AVR as an example, and considering the usage of prescalers and integer division, we have a timing problem, because the current checks are basically (in all algorithms)
timer_elapsed >= DEBOUNCE
, and that>=
will possibly be true anywhere starting fromDEBOUNCE - 1 + (1 clock cycle above the prescaler)
, not atDEBOUNCE
milliseconds or greater.As an example (frequency of 16MHz and prescaler of 64, getting us 1 interrupt every 1ms, or 1 interrupt every 250 CPU cycles, and a
DEBOUNCE
of 5).10 * 250 + 230
getting (for example) a value of 10.15 * 250 + 10
clock cycles, meaning we get 15 as return.15 >= 10 + 5
, and send the matrix update.We finished debouncing at less than 5 ms here. Currently, our approach only guarantees the debounce will happen at
>= DEBOUNCE -1
time.So we have two choices here:
>
Originally posted by @andrebrait in #21667 (comment)
Keyboard Used
No response
Link to product page (if applicable)
No response
Operating System
No response
qmk doctor Output
No response
Is AutoHotKey / Karabiner installed
Other keyboard-related software installed
No response
Additional Context
Not keyboard related. It's a core bug.
The text was updated successfully, but these errors were encountered: