feature(drivers): Option for read wait on matrix.
* Add a new Kconfig option, `ZMK_KSCAN_MATRIX_WAIT_BEFORE_INPUTS` to delay reading inputs after setting an output active.
This commit is contained in:
parent
0b39bf4336
commit
9782518397
2 changed files with 15 additions and 1 deletions
|
@ -32,6 +32,16 @@ config ZMK_KSCAN_GPIO_MATRIX
|
||||||
|
|
||||||
if ZMK_KSCAN_GPIO_MATRIX
|
if ZMK_KSCAN_GPIO_MATRIX
|
||||||
|
|
||||||
|
config ZMK_KSCAN_MATRIX_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_MATRIX_WAIT_BETWEEN_OUTPUTS
|
config ZMK_KSCAN_MATRIX_WAIT_BETWEEN_OUTPUTS
|
||||||
int "Ticks to wait between each output when scanning"
|
int "Ticks to wait between each output when scanning"
|
||||||
default 0
|
default 0
|
||||||
|
@ -40,7 +50,7 @@ config ZMK_KSCAN_MATRIX_WAIT_BETWEEN_OUTPUTS
|
||||||
inactive again, some boards may take time for the previous output to
|
inactive again, some boards may take time for the previous output to
|
||||||
"settle" before reading inputs for the next active output column. In that
|
"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
|
scenario, set this value to a positive value to configure the number of
|
||||||
usecs to wait after reading each column of keys.
|
ticks to wait after reading each column of keys.
|
||||||
|
|
||||||
endif # ZMK_KSCAN_GPIO_MATRIX
|
endif # ZMK_KSCAN_GPIO_MATRIX
|
||||||
|
|
||||||
|
|
|
@ -235,6 +235,10 @@ static int kscan_matrix_read(const struct device *dev) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_ZMK_KSCAN_MATRIX_WAIT_BEFORE_INPUTS > 0
|
||||||
|
k_busy_wait(CONFIG_ZMK_KSCAN_MATRIX_WAIT_BEFORE_INPUTS);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < config->inputs.len; i++) {
|
for (int i = 0; i < config->inputs.len; i++) {
|
||||||
const struct gpio_dt_spec *in_gpio = &config->inputs.gpios[i];
|
const struct gpio_dt_spec *in_gpio = &config->inputs.gpios[i];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue