Mercurial > louis > kiibohd-controller
annotate Scan/MatrixARM/capabilities.kll @ 343:e464aaa4730f
Adding timing based debounce code
- Uses expiry timer to decide on when to allow a state change
- Initial state transitions are unaffected
- Use MinDebounceTime define in kll to configure
- ms granularity
author | Jacob Alexander <haata@kiibohd.com> |
---|---|
date | Fri, 19 Jun 2015 01:50:56 -0700 |
parents | c856f826bd49 |
children |
rev | line source |
---|---|
293
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
1 Name = MatrixArmCapabilities; |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
2 Version = 0.1; |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
3 Author = "HaaTa (Jacob Alexander) 2015"; |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
4 KLL = 0.3a; |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
5 |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
6 # Modified Date |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
7 Date = 2015-02-28; |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
8 |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
9 # Defines available to the MatrixArm sub-module |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
10 # This debounce scheme uses a rolling counter for press/unpress on each key |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
11 # Each counter is incremented if pressed/unpressed and the opposite counter is divided by 2 |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
12 # Using the default division threshold (0xFFFF), there are approximately 13 cycles in a perfect cycle |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
13 # If debounce is actually necessary, this will increase (better switches will debounce faster) |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
14 # |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
15 # The maximum threshold is 0xFFFFFFFF, which will give around ~32 -> 36 cycles per perfect cycle |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
16 # Using a threshold higher than 0xFFFF will require 32 bit variables, and double the ram usage. |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
17 DebounceDivThreshold => DebounceDivThreshold_define; |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
18 DebounceDivThreshold = 0xFFFF; # Default debounce |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
19 #DebounceDivThreshold = 0xFFFFFFFF; # Max debounce |
57f40871c726
Adding configurable DebounceDivThreshold
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
20 |
299
c856f826bd49
Adding DebounceThrottleDiv define to slow down the debounce rate.
Jacob Alexander <haata@kiibohd.com>
parents:
293
diff
changeset
|
21 # This defines how often the matrix is scanned |
c856f826bd49
Adding DebounceThrottleDiv define to slow down the debounce rate.
Jacob Alexander <haata@kiibohd.com>
parents:
293
diff
changeset
|
22 # By, default the key matrix is scanned once per macro processing loop |
c856f826bd49
Adding DebounceThrottleDiv define to slow down the debounce rate.
Jacob Alexander <haata@kiibohd.com>
parents:
293
diff
changeset
|
23 # For fast uCs and bouncy switches, this can be non-ideal |
c856f826bd49
Adding DebounceThrottleDiv define to slow down the debounce rate.
Jacob Alexander <haata@kiibohd.com>
parents:
293
diff
changeset
|
24 # 0 - Bit-shift of 0 |
c856f826bd49
Adding DebounceThrottleDiv define to slow down the debounce rate.
Jacob Alexander <haata@kiibohd.com>
parents:
293
diff
changeset
|
25 # 1 - Bit-shift of 1 (i.e. divide by 2) |
c856f826bd49
Adding DebounceThrottleDiv define to slow down the debounce rate.
Jacob Alexander <haata@kiibohd.com>
parents:
293
diff
changeset
|
26 # 2 - Bit-shift of 2 (i.e. divide by 4) |
c856f826bd49
Adding DebounceThrottleDiv define to slow down the debounce rate.
Jacob Alexander <haata@kiibohd.com>
parents:
293
diff
changeset
|
27 # 3 - Bit-shift of 3 (i.e. divide by 8) |
c856f826bd49
Adding DebounceThrottleDiv define to slow down the debounce rate.
Jacob Alexander <haata@kiibohd.com>
parents:
293
diff
changeset
|
28 # etc. |
c856f826bd49
Adding DebounceThrottleDiv define to slow down the debounce rate.
Jacob Alexander <haata@kiibohd.com>
parents:
293
diff
changeset
|
29 # Depending on the architecture, this is either a maximum of 16 or 32 |
c856f826bd49
Adding DebounceThrottleDiv define to slow down the debounce rate.
Jacob Alexander <haata@kiibohd.com>
parents:
293
diff
changeset
|
30 # Increasing this value will increase switch latency |
c856f826bd49
Adding DebounceThrottleDiv define to slow down the debounce rate.
Jacob Alexander <haata@kiibohd.com>
parents:
293
diff
changeset
|
31 DebounceThrottleDiv => DebounceThrottleDiv_define; |
c856f826bd49
Adding DebounceThrottleDiv define to slow down the debounce rate.
Jacob Alexander <haata@kiibohd.com>
parents:
293
diff
changeset
|
32 DebounceThrottleDiv = 0; # Default |
c856f826bd49
Adding DebounceThrottleDiv define to slow down the debounce rate.
Jacob Alexander <haata@kiibohd.com>
parents:
293
diff
changeset
|
33 #DebounceThrottleDiv = 2; # /4 divider |
c856f826bd49
Adding DebounceThrottleDiv define to slow down the debounce rate.
Jacob Alexander <haata@kiibohd.com>
parents:
293
diff
changeset
|
34 |
343
e464aaa4730f
Adding timing based debounce code
Jacob Alexander <haata@kiibohd.com>
parents:
299
diff
changeset
|
35 # This defines the minimum amount of time after a transition until allowing another transition |
e464aaa4730f
Adding timing based debounce code
Jacob Alexander <haata@kiibohd.com>
parents:
299
diff
changeset
|
36 # Generally switches require a minimum 5 ms debounce period |
e464aaa4730f
Adding timing based debounce code
Jacob Alexander <haata@kiibohd.com>
parents:
299
diff
changeset
|
37 # Since a decision can usually be made quite quickly, there is little latency on each press |
e464aaa4730f
Adding timing based debounce code
Jacob Alexander <haata@kiibohd.com>
parents:
299
diff
changeset
|
38 # However, this defines the latency at which the switch state can change |
e464aaa4730f
Adding timing based debounce code
Jacob Alexander <haata@kiibohd.com>
parents:
299
diff
changeset
|
39 MinDebounceTime => MinDebounceTime_define; |
e464aaa4730f
Adding timing based debounce code
Jacob Alexander <haata@kiibohd.com>
parents:
299
diff
changeset
|
40 MinDebounceTime = 5; # 5 ms |
e464aaa4730f
Adding timing based debounce code
Jacob Alexander <haata@kiibohd.com>
parents:
299
diff
changeset
|
41 |