feat(kscan): Add charlieplex keyscan driver

* Supports matrixes with and without additional interrupt pin use.

Co-authored-by: Peter Johanson <peter@peterjohanson.com>
This commit is contained in:
Hooky
2023-12-10 06:10:05 +08:00
committed by GitHub
parent b35a5e83c0
commit 2c50cff891
5 changed files with 563 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ DT_COMPAT_ZMK_KSCAN_COMPOSITE := zmk,kscan-composite
DT_COMPAT_ZMK_KSCAN_GPIO_DEMUX := zmk,kscan-gpio-demux
DT_COMPAT_ZMK_KSCAN_GPIO_DIRECT := zmk,kscan-gpio-direct
DT_COMPAT_ZMK_KSCAN_GPIO_MATRIX := zmk,kscan-gpio-matrix
DT_COMPAT_ZMK_KSCAN_GPIO_CHARLIEPLEX := zmk,kscan-gpio-charlieplex
DT_COMPAT_ZMK_KSCAN_MOCK := zmk,kscan-mock
if KSCAN
@@ -33,6 +34,11 @@ config ZMK_KSCAN_GPIO_MATRIX
default $(dt_compat_enabled,$(DT_COMPAT_ZMK_KSCAN_GPIO_MATRIX))
select ZMK_KSCAN_GPIO_DRIVER
config ZMK_KSCAN_GPIO_CHARLIEPLEX
bool
default $(dt_compat_enabled,$(DT_COMPAT_ZMK_KSCAN_GPIO_CHARLIEPLEX))
select ZMK_KSCAN_GPIO_DRIVER
if ZMK_KSCAN_GPIO_MATRIX
config ZMK_KSCAN_MATRIX_WAIT_BEFORE_INPUTS
@@ -58,6 +64,30 @@ config ZMK_KSCAN_MATRIX_WAIT_BETWEEN_OUTPUTS
endif # ZMK_KSCAN_GPIO_MATRIX
if ZMK_KSCAN_GPIO_CHARLIEPLEX
config ZMK_KSCAN_CHARLIEPLEX_WAIT_BEFORE_INPUTS
int "Ticks to wait before reading inputs after an output set active"
default 0
help
When iterating over each output to drive it active, read inputs, then set
inactive again, some boards may take time for output to propagate to the
inputs. In that scenario, set this value to a positive value to configure
the number of ticks to wait after setting an output active before reading
the inputs for their active state.
config ZMK_KSCAN_CHARLIEPLEX_WAIT_BETWEEN_OUTPUTS
int "Ticks to wait between each output when scanning charlieplex matrix"
default 0
help
When iterating over each output to drive it active, read inputs, then set
inactive again, some boards may take time for the previous output to
"settle" before reading inputs for the next active output column. In that
scenario, set this value to a positive value to configure the number of
usecs to wait after reading each column of keys.
endif # ZMK_KSCAN_GPIO_CHARLIEPLEX
config ZMK_KSCAN_MOCK_DRIVER
bool
default $(dt_compat_enabled,$(DT_COMPAT_ZMK_KSCAN_MOCK))