Detect additional key presses on the same output.
* Interrupts won't follow on additional keys pressed on an already "held" output pin, so queue additional reads while any keys are held.
This commit is contained in:
parent
092fa866af
commit
497049ff68
1 changed files with 13 additions and 3 deletions
|
@ -125,6 +125,7 @@ static int kscan_gpio_config_interrupts(struct device **devices,
|
|||
} \
|
||||
static int kscan_gpio_read_##n(struct device *dev) \
|
||||
{ \
|
||||
bool submit_follow_up_read = false; \
|
||||
struct kscan_gpio_data_##n *data = dev->driver_data; \
|
||||
static bool read_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \
|
||||
LOG_DBG("Scanning the matrix for updated state"); \
|
||||
|
@ -155,6 +156,8 @@ static int kscan_gpio_config_interrupts(struct device **devices,
|
|||
for (int c = 0; c < INST_MATRIX_COLS(n); c++) \
|
||||
{ \
|
||||
bool pressed = read_state[r][c]; \
|
||||
/* Follow up reads needed because further interrupts won't fire on already tripped input GPIO pins */ \
|
||||
submit_follow_up_read = (submit_follow_up_read || pressed); \
|
||||
if (pressed != data->matrix_state[r][c]) \
|
||||
{ \
|
||||
LOG_DBG("Sending event at %d,%d state %s", \
|
||||
|
@ -164,6 +167,13 @@ static int kscan_gpio_config_interrupts(struct device **devices,
|
|||
} \
|
||||
} \
|
||||
} \
|
||||
if (submit_follow_up_read) { \
|
||||
COND_CODE_0(DT_INST_PROP(n, debounce_period), \
|
||||
({ k_work_submit(&data->work); }), \
|
||||
({ \
|
||||
k_delayed_work_cancel(&data->work); \
|
||||
k_delayed_work_submit(&data->work, K_MSEC(1)); })) \
|
||||
} \
|
||||
return 0; \
|
||||
} \
|
||||
static void kscan_gpio_work_handler_##n(struct k_work *work) \
|
||||
|
|
Loading…
Reference in a new issue