Add Zadig 101 to docs (#6585)
[jackhill/qmk/firmware.git] / docs / feature_debounce_type.md
CommitLineData
4db27a2c
AO
1# Debounce algorithm
2
3QMK supports multiple debounce algorithms through its debounce API.
4
4db27a2c
AO
5The logic for which debounce method called is below. It checks various defines that you have set in rules.mk
6
7```
c7c4937e 8DEBOUNCE_DIR:= $(QUANTUM_DIR)/debounce
7d8c6299 9DEBOUNCE_TYPE?= sym_g
c7c4937e
JC
10ifneq ($(strip $(DEBOUNCE_TYPE)), custom)
11 QUANTUM_SRC += $(DEBOUNCE_DIR)/$(strip $(DEBOUNCE_TYPE)).c
4db27a2c
AO
12endif
13```
a55c8389 14
4db27a2c 15# Debounce selection
e8e62687 16
c7c4937e
JC
17| DEBOUNCE_TYPE | Description | What else is needed |
18| ------------- | --------------------------------------------------- | ----------------------------- |
19| Not defined | Use the default algorithm, currently sym_g | Nothing |
20| custom | Use your own debounce.c | ```SRC += debounce.c``` add your own debounce.c and implement necessary functions |
21| anything_else | Use another algorithm from quantum/debounce/* | Nothing |
4db27a2c 22
c7c4937e 23**Regarding split keyboards**:
574fc644 24The debounce code is compatible with split keyboards.
4db27a2c
AO
25
26# Use your own debouncing code
7d8c6299 27* Set ```DEBOUNCE_TYPE = custom ```.
4db27a2c 28* Add ```SRC += debounce.c```
c7c4937e 29* Add your own ```debounce.c```. Look at current implementations in ```quantum/debounce``` for examples.
4db27a2c 30* Debouncing occurs after every raw matrix scan.
7d8c6299 31* Use num_rows rather than MATRIX_ROWS, so that split keyboards are supported correctly.
4db27a2c
AO
32
33# Changing between included debouncing methods
34You can either use your own code, by including your own debounce.c, or switch to another included one.
35Included debounce methods are:
17e7762d
AO
36* eager_pr - debouncing per row. On any state change, response is immediate, followed by locking the row ```DEBOUNCE_DELAY``` milliseconds of no further input for that row.
37For use in keyboards where refreshing ```NUM_KEYS``` 8-bit counters is computationally expensive / low scan rate, and fingers usually only hit one row at a time. This could be
38appropriate for the ErgoDox models; the matrix is rotated 90°, and hence its "rows" are really columns, and each finger only hits a single "row" at a time in normal use.
39* eager_pk - debouncing per key. On any state change, response is immediate, followed by ```DEBOUNCE_DELAY``` milliseconds of no further input for that key
c7c4937e 40* sym_g - debouncing per keyboard. On any state change, a global timer is set. When ```DEBOUNCE_DELAY``` milliseconds of no changes has occured, all input changes are pushed.
4db27a2c
AO
41
42