summaryrefslogtreecommitdiff
path: root/quantum/debounce
AgeCommit message (Collapse)Author
2024-01-30Update asymmetric debounce code comment (#22981)フィルターペーパー
2023-09-25[Enhancement] Improvements for debounce test coverage + bug fixes for ↵Andre Brait
sym_defer_g and sym_eager_pr (#21667) Co-authored-by: Nebuleon <2391500+Nebuleon@users.noreply.github.com>
2023-07-09debounce: remove direct `quantum.h` includes (#21480)Ryan
2023-06-08Reset `matrix_need_update` properly in eager debouncing algorithms (#21154)dexter93
The `matrix_need_update` variable needs to be reset to `false` in `transfer_matrix_values()`, otherwise that function continues to be invoked for every scanning loop (forever with `sym_eager_pk` and `sym_eager_pk`, or until some key gets released with `asym_eager_defer_pk`), and the scanning rate gets much lower because of all that useless work. Co-authored-by: Sergey Vlasov <sigprof@gmail.com>
2022-07-07Make debounce() signal changes in the cooked matrix as return value (#17554)Stefan Kerkmann
2022-02-12Format code according to conventions (#16322)QMK Bot
2021-12-27Format code according to conventions (#15590)QMK Bot
2021-12-27Add sym_defer_pr debouncer type (#14948)Chad Austin
2021-11-29[Core] Remove matrix_is_modified() and debounce_is_active() (#15349)Stefan Kerkmann
2021-11-19Move tmk_core/common/<plat> (#13918)Joel Challis
2021-11-01Manually format develop (#15003)Joel Challis
2021-06-16Add asym_eager_defer_pk debounce type (#12689)Simon Arlott
2021-06-09Avoid 8-bit timer overflows in debounce algorithms (#12240)Simon Arlott
* Add fast_timer_t that is 16-bit or 32-bit based on architecture A 16-bit timer will overflow sooner but be faster to compare on AVR. * Avoid 8-bit timer overflows in debounce algorithms Count down remaining elapsed time instead of trying to do 8-bit timer comparisons. Add a "none" implementation that is automatically used if DEBOUNCE is 0 otherwise it will break the _pk/_pr count down. * Avoid unnecessary polling of the entire matrix in sym_eager_pk The matrix only needs to be updated when a debounce timer expires. * Avoid unnecessary polling of the entire matrix in sym_eager_pr The matrix only needs to be updated when a debounce timer expires. The use of the "needed_update" variable is trying to do what "matrix_need_update" was added to fix but didn't work because it only applied when all keys finished debouncing. * Fix sym_defer_g timing inconsistency compared to other debounce algorithms DEBOUNCE=5 should process the key after 5ms, not 6ms * Add debounce tests
2021-01-29Enforce memory allocator for ChibiOS builds with allocating debounce ↵Nick Brassel
algorithms (#11630)
2020-12-17Run cformat and dos2unix manually (#11235)Ryan
2020-09-06quantum/debounce: rename debouncing algorithms (#9564)Purdea Andrei
* quantum/debounce: rename debouncing algorithms according to Issue 8763 This is the second attempt at implementation, with no ts_ and cy_ prefixes, since those will be implemented with macros. * Debouncing documentation: Refactor, add some generic info, and merge into a single document
2020-04-11quantum/debounce: Added sym_pk debounce algorithm (#8587)Purdea Andrei
* quantum/debounce: Added sym_pk debounce algorithm * Apply suggestions from code review Co-Authored-By: Ryan <fauxpark@gmail.com> * quantum/debounce/sym_pk: delete comments and rename functions following code review * quantum/debounce/sym_pk: Modifications for code readability according to code review * quantum/debounce/sym_pk: Modifications for code readability according to code review (2) * quantum/debounce/sym_pk: code review: cleaner code Co-Authored-By: Nick Brassel <nick@tzarc.org> Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Nick Brassel <nick@tzarc.org>
2020-04-11format code according to conventions [skip ci]QMK Bot
2020-04-11Various fixes to how timer differences are calculated (#8585)Purdea Andrei
* tmk_core/common: Fixing TIMER_DIFF macro to calculate difference correctly after the timer wraps. Let's go through an example, using the following macro: If the first timer read is 0xe4 and the second one is 0x32, the timer wrapped. If the timer would have had more bits, it's new value would have been 0x132, and the correct difference in time is 0x132 - 0xe4 = 0x4e old code TIMER_DIFF_8(0x32, 0xe4) = 0xff - 0xe4 + 0x32 = 0x4d, which is wrong. new code TIMER_DIFF_8(0x32, 0xe4) = 0xff + 1 - 0xe4 + 0x32 = 0x4e, which is correct. This also gives a chance for a smart compiler to optimize the code using normal integer overflow. For example on AVR, the following C code: uint8_t __attribute__ ((noinline)) test(uint8_t current_timer, uint8_t start_timer) { return TIMER_DIFF_8(current_timer, start_timer); } With the original code, it gets translated to the following list of instructions: 00004c6e <test>: 4c6e: 98 2f mov r25, r24 4c70: 86 1b sub r24, r22 4c72: 96 17 cp r25, r22 4c74: 08 f4 brcc .+2 ; 0x4c78 <test+0xa> 4c76: 81 50 subi r24, 0x01 ; 1 4c78: 08 95 ret But with this commit, it gets translated to a single instruction: 00004c40 <test>: 4c40: 86 1b sub r24, r22 4c42: 08 95 ret This unfortunately doesn't always work so nicely, for example the following C code: int __attribute__ ((noinline)) test(uint8_t current_timer, uint8_t start_timer) { return TIMER_DIFF_8(current_timer, start_timer); } (Note: return type changed to int) With the original code it gets translated to: 00004c6e <test>: 4c6e: 28 2f mov r18, r24 4c70: 30 e0 ldi r19, 0x00 ; 0 4c72: 46 2f mov r20, r22 4c74: 50 e0 ldi r21, 0x00 ; 0 4c76: 86 17 cp r24, r22 4c78: 20 f0 brcs .+8 ; 0x4c82 <test+0x14> 4c7a: c9 01 movw r24, r18 4c7c: 84 1b sub r24, r20 4c7e: 95 0b sbc r25, r21 4c80: 08 95 ret 4c82: c9 01 movw r24, r18 4c84: 84 1b sub r24, r20 4c86: 95 0b sbc r25, r21 4c88: 81 50 subi r24, 0x01 ; 1 4c8a: 9f 4f sbci r25, 0xFF ; 255 4c8c: 08 95 ret Wth this commit it gets translated to: 00004c40 <test>: 4c40: 28 2f mov r18, r24 4c42: 30 e0 ldi r19, 0x00 ; 0 4c44: 46 2f mov r20, r22 4c46: 50 e0 ldi r21, 0x00 ; 0 4c48: 86 17 cp r24, r22 4c4a: 20 f0 brcs .+8 ; 0x4c54 <test+0x14> 4c4c: c9 01 movw r24, r18 4c4e: 84 1b sub r24, r20 4c50: 95 0b sbc r25, r21 4c52: 08 95 ret 4c54: c9 01 movw r24, r18 4c56: 84 1b sub r24, r20 4c58: 95 0b sbc r25, r21 4c5a: 93 95 inc r25 4c5c: 08 95 ret There is not much performance improvement in this case, however at least with this commit it functions correctly. Note: The following commit will improve compiler output for the latter example. * tmk_core/common: Improve code generation for TIMER_DIFF* macros Because of integer promotion the compiler is having a hard time generating efficient code to calculate TIMER_DIFF* macros in some situations. In the below example, the return value is "int", and this is causing the trouble. Example C code: int __attribute__ ((noinline)) test(uint8_t current_timer, uint8_t start_timer) { return TIMER_DIFF_8(current_timer, start_timer); } BEFORE: (with -Os) 00004c40 <test>: 4c40: 28 2f mov r18, r24 4c42: 30 e0 ldi r19, 0x00 ; 0 4c44: 46 2f mov r20, r22 4c46: 50 e0 ldi r21, 0x00 ; 0 4c48: 86 17 cp r24, r22 4c4a: 20 f0 brcs .+8 ; 0x4c54 <test+0x14> 4c4c: c9 01 movw r24, r18 4c4e: 84 1b sub r24, r20 4c50: 95 0b sbc r25, r21 4c52: 08 95 ret 4c54: c9 01 movw r24, r18 4c56: 84 1b sub r24, r20 4c58: 95 0b sbc r25, r21 4c5a: 93 95 inc r25 4c5c: 08 95 ret AFTER: (with -Os) 00004c40 <test>: 4c40: 86 1b sub r24, r22 4c42: 90 e0 ldi r25, 0x00 ; 0 4c44: 08 95 ret Note: the example is showing -Os but improvements can be seen at all optimization levels, including -O0. We never use -O0, but I tested it to make sure that no extra code is generated in that case.OA * quantum/debounce: Fix custom wrapping timers in eager_pr and eager_pk debounce algorithms Please see the below simulated sequence of events: Column A is the 16-bit value returned by read_timer(); Column B is the value returned by custom_wrap_timer_read(); Column C is the original code: (timer_read() % MAX_DEBOUNCE) A, B, C 65530, 19, 30 65531, 20, 31 65532, 21, 32 65533, 22, 33 65534, 23, 34 65535, 24, 35 0 25, 0 1, 26, 1 2, 27, 2 3, 28, 3 4, 29, 4 5, 30, 5 read_timer() wraps about every 1.09 seconds, and so debouncing might fail at these times without this commit. * quantum/debounce/eager_pr and eager_pk: modifications for code readability according to code review. * quantum/debounce/eager_pr and eager_pk: modifications for code readability according to code review. (2)
2019-08-30clang-format changesskullY
2019-07-09Fix debouncing issue for eager algorithms (#6081)Drashna Jaelre
* Fix debouncing issue for eager algos * Fix up typo issue
2019-04-18[core] Fix for eager_pr #5643Alex Ong
Added extra transfer_matrix_values() call whenever counters don't need updating
2019-04-15Eager pk/pr optimization (#5621)Alex Ong
* Optimizations to eager_pk * eager_pr also uses changed boolean now.
2019-04-03Eager Per Row Debouncing added (added to Ergodox) (#5498)Alex Ong
* Implemented Eager Per Row debouncing algorithm. Good for when fingers can only press one row at a time (e.g. when keyboard is wired so that "rows" are vertical) * Added documentation for eager_pr * Ported ergodox_ez to eager_pr debouncing. * Removed check for changes in matrix_scan. * Added further clarification in docs. * Accidental merge with ergodox_ez * Small cleanup in eager_pr * Forgot to debounce_init - this would probably cause seg-faults.
2019-03-04Clean up debounce a bit (#5255)James Churchill
2019-01-27Fix compile error in debounce_eager_pkalex-ong
2019-01-26Merge branch 'debounce_refactor' of https://github.com/alex-ong/qmk_firmware ↵alex-ong
into debounce_refactor
2019-01-26Malloc array in debounce_eager_pk, since split keyboards only use MATRIX_ROWS/2.alex-ong
2019-01-26Fixed compilation error with debounce_sym_gAlex Ong
2019-01-26Bug fix - was using MATRIX_ROWS instead of num_rowsAlex Ong
2019-01-26Moved debouncing_time variable to inside #if debouncealex-ong
2019-01-26Working eager_pkalex-ong
2019-01-26DO NOT USE Revert back to original API to support split_keyboards.alex-ong
2019-01-26DO NOT USE - debounce successfully compiled.alex-ong