From 447cd1e02ba3b05566e0b4336b0aed1039d2a5a5 Mon Sep 17 00:00:00 2001 From: "Sean D. Cline" Date: Thu, 26 Sep 2024 09:21:13 -0400 Subject: [PATCH 1/2] Add a delay to KeyMatrix scan. This gives the matrix columns time to discharge and settle down to their resting state. --- shared-module/keypad/KeyMatrix.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shared-module/keypad/KeyMatrix.c b/shared-module/keypad/KeyMatrix.c index 7706e335af82..9d31b49bc515 100644 --- a/shared-module/keypad/KeyMatrix.c +++ b/shared-module/keypad/KeyMatrix.c @@ -7,6 +7,7 @@ #include #include "py/gc.h" +#include "py/mphal.h" #include "py/runtime.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/keypad/EventQueue.h" @@ -133,6 +134,10 @@ static void keymatrix_scan_now(void *self_in, mp_obj_t timestamp) { // to switch values. Just switching to an input with a (relatively weak) pullup/pulldown // causes a slight delay in the output changing, which can cause false readings. common_hal_digitalio_digitalinout_set_value(row_dio, self->columns_to_anodes); + + // Wait a moment to let the columns settle. + mp_hal_delay_us(1); + // Switch the row back to an input, pulled appropriately common_hal_digitalio_digitalinout_switch_to_input( row_dio, self->columns_to_anodes ? PULL_UP : PULL_DOWN); From dc52fe3062b50c4d9d51b4f91d170cea31fa1b69 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 26 Sep 2024 18:42:35 -0400 Subject: [PATCH 2/2] Update KeyMatrix.c: remove trailing spaces --- shared-module/keypad/KeyMatrix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-module/keypad/KeyMatrix.c b/shared-module/keypad/KeyMatrix.c index 9d31b49bc515..67a554685355 100644 --- a/shared-module/keypad/KeyMatrix.c +++ b/shared-module/keypad/KeyMatrix.c @@ -134,10 +134,10 @@ static void keymatrix_scan_now(void *self_in, mp_obj_t timestamp) { // to switch values. Just switching to an input with a (relatively weak) pullup/pulldown // causes a slight delay in the output changing, which can cause false readings. common_hal_digitalio_digitalinout_set_value(row_dio, self->columns_to_anodes); - + // Wait a moment to let the columns settle. mp_hal_delay_us(1); - + // Switch the row back to an input, pulled appropriately common_hal_digitalio_digitalinout_switch_to_input( row_dio, self->columns_to_anodes ? PULL_UP : PULL_DOWN);