diff --git a/docs/en/scanners.md b/docs/en/scanners.md index b0122add8..7576b557a 100644 --- a/docs/en/scanners.md +++ b/docs/en/scanners.md @@ -11,7 +11,11 @@ need to swap it out with an alternative scanner. ## Keypad Scanners The scanners in `kmk.scanners.keypad` wrap the `keypad` module that ships with CircuitPython and support the same configuration and tuning options as their -upstream. You can find out more in the [CircuitPython +upstream. + +**Some users may need to tweak debounce parameters**, `interval=0.01,debounce_threshold=5` is a good starting point. `debounce_threshold` is only applicable for CircuitPython >= 9.2.0 + +You can find out more in the [CircuitPython documentation](https://docs.circuitpython.org/en/latest/shared-bindings/keypad/index.html). ### keypad MatrixScanner @@ -30,7 +34,8 @@ class MyKeyboard(KMKKeyboard): row_pins=self.row_pins, # optional arguments with defaults: columns_to_anodes=DiodeOrientation.COL2ROW, - interval=0.02, # Debounce time in floating point seconds + interval=0.02, # Matrix sampling interval in ms + debounce_threshold=None, # Number of samples needed to change state, values greater than 1 enable debouncing. Only applicable for CircuitPython >= 9.2.0 max_events=64 ) @@ -68,7 +73,8 @@ class MyKeyboard(KMKKeyboard): # optional arguments with defaults: value_when_pressed=False, pull=True, - interval=0.02, # Debounce time in floating point seconds + interval=0.02, # Matrix sampling interval in ms + debounce_threshold=None, # Number of samples needed to change state, values greater than 1 enable debouncing. Only applicable for CircuitPython >= 9.2.0 max_events=64 ) ``` @@ -94,7 +100,8 @@ class MyKeyboard(KMKKeyboard): # optional arguments with defaults: value_to_latch=True, # 74HC165: True, CD4021: False value_when_pressed=False, - interval=0.02, # Debounce time in floating point seconds + interval=0.02, # Matrix sampling interval in ms + debounce_threshold=None, # Number of samples needed to change state, values greater than 1 enable debouncing. Only applicable for CircuitPython >= 9.2.0 max_events=64 ) ``` diff --git a/kmk/scanners/keypad.py b/kmk/scanners/keypad.py index c6b007aea..9979142cd 100644 --- a/kmk/scanners/keypad.py +++ b/kmk/scanners/keypad.py @@ -1,6 +1,6 @@ import keypad -from kmk.scanners import DiodeOrientation, Scanner +from kmk.scanners import Scanner class KeypadScanner(Scanner): @@ -36,22 +36,8 @@ class MatrixScanner(KeypadScanner): :param direction: The diode orientation of the matrix. ''' - def __init__( - self, - row_pins, - column_pins, - *, - columns_to_anodes=DiodeOrientation.COL2ROW, - interval=0.02, - max_events=64, - ): - self.keypad = keypad.KeyMatrix( - row_pins, - column_pins, - columns_to_anodes=(columns_to_anodes == DiodeOrientation.COL2ROW), - interval=interval, - max_events=max_events, - ) + def __init__(self, *args, **kwargs): + self.keypad = keypad.Keys(*args, **kwargs) super().__init__() @@ -62,46 +48,12 @@ class KeysScanner(KeypadScanner): :param pins: An array of arrays of CircuitPython Pin objects, such that pins[r][c] is the pin for row r, column c. ''' - def __init__( - self, - pins, - *, - value_when_pressed=False, - pull=True, - interval=0.02, - max_events=64, - ): - self.keypad = keypad.Keys( - pins, - value_when_pressed=value_when_pressed, - pull=pull, - interval=interval, - max_events=max_events, - ) + def __init__(self, *args, **kwargs): + self.keypad = keypad.Keys(*args, **kwargs) super().__init__() class ShiftRegisterKeys(KeypadScanner): - def __init__( - self, - *, - clock, - data, - latch, - value_to_latch=True, - key_count, - value_when_pressed=False, - interval=0.02, - max_events=64, - ): - self.keypad = keypad.ShiftRegisterKeys( - clock=clock, - data=data, - latch=latch, - value_to_latch=value_to_latch, - key_count=key_count, - value_when_pressed=value_when_pressed, - interval=interval, - max_events=max_events, - ) + def __init__(self, *args, **kwargs): + self.keypad = keypad.Keys(*args, **kwargs) super().__init__() diff --git a/util/aspell.en.pws b/util/aspell.en.pws index f2ee422b2..379d18ad7 100644 --- a/util/aspell.en.pws +++ b/util/aspell.en.pws @@ -33,6 +33,7 @@ Crkbd Crowboard Ctrl Cygwin +debounce DFU DISCOVERABLE DIY