Remove interrupt config/rely on pin set

If the interrupt pin is set, use the interrupt code, else poll.

This change results in a slightly larger executable in both cases,
with unreachable code. More so in the case of polling, bet the
difference is not great.
This commit is contained in:
HookyKB 2023-03-22 06:55:22 +00:00 committed by Peter Johanson
parent 087774c783
commit 48dfbaf48f
4 changed files with 16 additions and 18 deletions

View file

@ -1,4 +1,4 @@
# Copyright (c) 2020 The ZMK Contributors # Copyright (c) 2020-2023 The ZMK Contributors
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
zephyr_library_amend() zephyr_library_amend()

View file

@ -66,7 +66,7 @@ endif # ZMK_KSCAN_GPIO_MATRIX
if ZMK_KSCAN_GPIO_CHARLIPLEX if ZMK_KSCAN_GPIO_CHARLIPLEX
config ZMK_KSCAN_MATRIX_WAIT_BEFORE_INPUTS config ZMK_KSCAN_CHARLIPLEX_WAIT_BEFORE_INPUTS
int "Ticks to wait before reading inputs after an output set active" int "Ticks to wait before reading inputs after an output set active"
default 0 default 0
help help
@ -97,9 +97,6 @@ if ZMK_KSCAN_GPIO_DRIVER
config ZMK_KSCAN_MATRIX_POLLING config ZMK_KSCAN_MATRIX_POLLING
bool "Poll for key event triggers instead of using interrupts on matrix boards." bool "Poll for key event triggers instead of using interrupts on matrix boards."
config ZMK_KSCAN_CHARLIPLEX_POLLING
bool "Poll for key event triggers instead of using interrupts on multiplex boards."
config ZMK_KSCAN_DIRECT_POLLING config ZMK_KSCAN_DIRECT_POLLING
bool "Poll for key event triggers instead of using interrupts on direct wired boards." bool "Poll for key event triggers instead of using interrupts on direct wired boards."

View file

@ -1,4 +1,4 @@
# Copyright (c) 2022 The ZMK Contributors # Copyright (c) 2023 The ZMK Contributors
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
description: GPIO keyboard charliplex matrix controller description: GPIO keyboard charliplex matrix controller
@ -13,7 +13,6 @@ properties:
required: true required: true
interrupt-gpios: interrupt-gpios:
type: phandle-array type: phandle-array
required: true
debounce-press-ms: debounce-press-ms:
type: int type: int
default: 5 default: 5

View file

@ -151,13 +151,15 @@ The output pins (e.g. columns for `col2row`) should have the flag `GPIO_ACTIVE_H
## Charliplex Driver ## Charliplex Driver
Keyboard scan driver where keys are arranged on a matrix with each GPIO used as both input and output. This driver enables n pins to drive up to n\*(n-1) keys. Keyboard scan driver where keys are arranged on a matrix with each GPIO used as both input and output.
- With `interrupt-gpios` unset, this allows n pins to drive n\*(n-1) keys.
- With `interrupt-gpios` set, n pins will drive (n-1)\*(n-2) keys, but provide much improved power handling.
Definition file: [zmk/app/drivers/kscan/Kconfig](https://github.com/zmkfirmware/zmk/blob/main/app/drivers/kscan/Kconfig) Definition file: [zmk/app/drivers/kscan/Kconfig](https://github.com/zmkfirmware/zmk/blob/main/app/drivers/kscan/Kconfig)
| Config | Type | Description | Default | | Config | Type | Description | Default |
| --------------------------------------------------- | ----------- | ------------------------------------------------------------------------- | ------- | | --------------------------------------------------- | ----------- | ------------------------------------------------------------------------- | ------- |
| `CONFIG_ZMK_KSCAN_CHARLIPLEX_POLLING` | bool | Poll for key presses instead of using interrupts | n |
| `CONFIG_ZMK_KSCAN_CHARLIPLEX_WAIT_BEFORE_INPUTS` | int (ticks) | How long to wait before reading input pins after setting output active | 0 | | `CONFIG_ZMK_KSCAN_CHARLIPLEX_WAIT_BEFORE_INPUTS` | int (ticks) | How long to wait before reading input pins after setting output active | 0 |
| `CONFIG_ZMK_KSCAN_CHARLIPLEX_WAIT_BETWEEN_OUTPUTS` | int (ticks) | How long to wait between each output to allow previous output to "settle" | 0 | | `CONFIG_ZMK_KSCAN_CHARLIPLEX_WAIT_BETWEEN_OUTPUTS` | int (ticks) | How long to wait between each output to allow previous output to "settle" | 0 |
@ -171,14 +173,14 @@ Applies to: `compatible = "zmk,kscan-gpio-charliplex"`
Definition file: [zmk/app/drivers/zephyr/dts/bindings/kscan/zmk,kscan-gpio-charliplex.yaml](https://github.com/zmkfirmware/zmk/blob/main/app/drivers/zephyr/dts/bindings/kscan/zmk%2Ckscan-gpio-charliplex.yaml) Definition file: [zmk/app/drivers/zephyr/dts/bindings/kscan/zmk,kscan-gpio-charliplex.yaml](https://github.com/zmkfirmware/zmk/blob/main/app/drivers/zephyr/dts/bindings/kscan/zmk%2Ckscan-gpio-charliplex.yaml)
| Property | Type | Description | Default | | Property | Type | Description | Default |
| ------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------- | ------- | | ------------------------- | ---------- | ------------------------------------------------------------------------------------------- | ------- |
| `label` | string | Unique label for the node | | | `label` | string | Unique label for the node. | |
| `gpios` | GPIO array | GPIOs used, listed in order | | | `gpios` | GPIO array | GPIOs used, listed in order. | |
| `interrupt-gpios` | GPIO array | A single GPIO to use for interrupt | | | `interrupt-gpios` | GPIO array | A single GPIO to use for interrupt. Leaving this empty will enable continuous polling. | |
| `debounce-press-ms` | int | Debounce time for key press in milliseconds. Use 0 for eager debouncing. | 5 | | `debounce-press-ms` | int | Debounce time for key press in milliseconds. Use 0 for eager debouncing. | 5 |
| `debounce-release-ms` | int | Debounce time for key release in milliseconds. | 5 | | `debounce-release-ms` | int | Debounce time for key release in milliseconds. | 5 |
| `debounce-scan-period-ms` | int | Time between reads in milliseconds when any key is pressed. | 1 | | `debounce-scan-period-ms` | int | Time between reads in milliseconds when any key is pressed. | 1 |
| `poll-period-ms` | int | Time between reads in milliseconds when no key is pressed and `CONFIG_ZMK_KSCAN_MATRIX_POLLING` is enabled. | 10 | | `poll-period-ms` | int | Time between reads in milliseconds when no key is pressed and `interrupt-gpois` is not set. | 10 |
Define the transform with a [matrix transform](#matrix-transform). The row is always the driven pin, and the column always the receiving pin (input to the controller). Define the transform with a [matrix transform](#matrix-transform). The row is always the driven pin, and the column always the receiving pin (input to the controller).
For example, in `RC(5,0)` power flows from the 6th pin in `gpios` to the 1st pin in `gpios`. For example, in `RC(5,0)` power flows from the 6th pin in `gpios` to the 1st pin in `gpios`.