-
-
Notifications
You must be signed in to change notification settings - Fork 40.4k
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
Debounce refactor / API #3720
Debounce refactor / API #3720
Conversation
What about the split common stuff, which has a matrix used? (and sets the custom matrix, as well) https://github.com/qmk/qmk_firmware/blob/master/common_features.mk#L212-L226 |
@drashna Making debouncing working with the debounce API would be a future work, but would be as simple as:
I havent included it yet since i'm guessing we should check this huge change for stability first. |
I've now changed it so (SPLIT_KEYBOARD = yes) results in manual debouncing. In the future we can remove that and apply the debounce API to split_common stuff. |
is there a way to automate this when custom_matrix=yes as eg i have a few keyboards that are not split, but have a custom matrix |
@yiancar not sure what you are asking: yes, yes -> Remove all debouncing code, scan straight to matrix, call import debounce.h, call debounce If this change gets merged, all your keyboards with custom_matrix=yes will be completely unaffected by this pull request.
|
Perfect! can you add this information in docs as well so people know what to do? |
82e53d2
to
3cf7f73
Compare
Table wasn't working due to missing newline.
Due to the fact that I've added documentation so that it is more clear. |
Is this api going to ever be merged/rejected? @drashna |
@alex-ong "eventually". It would be @jackhumbert or @skullydazed that would make that decision, ultimately though. And they've been quite busy "IRL". Tagged them, just to "bump" this. |
I know no one is asking about feedback on this, but I grabbed a copy of OP's fork and updated TKC1800 to use eager_pk on my test bed/work 1800. It works perfectly, and it fixed an issue I was having with one of the passwords I use - I type it faster than the keyboard can keep up with |
Thanks for the feedback. Yeah i'm a bit of a performance junkie - eager_pk_row also should help the dreaded latency from the ergodox. It is a memory/speed tradeoff. Also if scanning isn't fast enough, eager-pk can also be slower. In my case, i got the following vague results:
I tested scan rate consistency by printing out whenever the timer had shifted by more than 1ms every scan. This would show when processing took too long. SYM_G, although fast and memory efficient had the problem of resetting the timer on consective presses, and then only sending one key per millisecond by default. Imagine pressing "fdsa" 4 ms apart - it would wait 4+4+4+5ms, then send (a, s, d, f) 1ms apart (default behavior, QMK_KEYS_PER_SCAN == 1). Eager-pk with QMK_KEYS_PER_SCAN ==1 would at least get the order right. |
…ile for compilation when custom_matrix is used.
Fingers crossed that it passes TravisCI! After a bajillion commits/reverts, it was actually only a very small change in the end to get everything working. It now supports split_keyboards too, thanks to #4772 |
Quick update on usage:
Switching algos (once people write more algos) should be as simple as a one line change in rules.mk. |
Just a couple of minor nitpicks from me: Don't use MATRIX_ROWS, you'll cause a buffer overflow on a split kb. Always use the num_rows passed in to the functions. This does mean if you need extra state you have to malloc it in debounce_init(), but it's a restricted case (allocated at startup, never freed) so I feel it's justifiable. The debounce.c I had did it properly, but the almost identical debounce_sym_g.c it was replaced with doesn't. (I don't understand the name there, btw)
|
Thanks i'll refer to that code. EDIT: oh i see, yeah it was a typo when i copy pasted my old code and then ended up modifying it to be the "same" as yours.
for pk/g/pr/pc
Sure,
Right - i had a commit somewhere where i #defined a new constant/type for row/column count, to remove all the scan_row/scan_col and replace with scan_direction, but scrapped it. removing it now... |
…irmware into debounce_refactor
update: working on a non-split. Just need to test on a split keyboard when i get into work.... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the docs are inconsistent with the actual code
Also, testing on my Iris (split, via split common), and this appears to work just fine. |
… debounce_type.mk
FIxed it up, should be good to go. |
I've added an eager_pr algorithm (same as eager_pk, but 10~ counters instead of 60+). Next step is to integrate with ergodox. I'm gonna do it as a new request... See #5496. After thats done i can patch ErgoDox_EZ but i don't have one so someone will have to be my guinea pig :) Also see #5498 - this enables someone with ergodox_ez to test the new debounce algorithm / api. I think that it should increase scanrate quite a bit, since it debounces using 14 counters instead of 80+, and updating those counters is can actually be quite time consuming. For the EZ, It might also be worth trying the "old" algorithm, which just has as global counter (1 counter for entire keyboard), since that would increase scanrate at the expense of keys being out of order. |
Awesome, thanks! And as for guinea pig, that's what Drashna CI is for, :D |
Huge refactor, allowing shared debouncing code between keyboards.
Future work would be to migrate everything over (first split keyboards, then all the other keyboards) to shared debounce API, and add a few more algorithms. I've added a few ideas for algorithms, some which are already implemented in other keyboards. Look at readme.md inside tmk_core/common/debounce folder.
Partial solution to #3646
Since this is a potentially keyboard-breaking change, i recommend letting this get pushed into qmk/debounce_refactor rather than qmk/master (I couldn't figure out how to make a new branch)