Skip to content

Commit 447cd1e

Browse files
committed
Add a delay to KeyMatrix scan.
This gives the matrix columns time to discharge and settle down to their resting state.
1 parent 4ef4f50 commit 447cd1e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

shared-module/keypad/KeyMatrix.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <string.h>
88

99
#include "py/gc.h"
10+
#include "py/mphal.h"
1011
#include "py/runtime.h"
1112
#include "shared-bindings/digitalio/DigitalInOut.h"
1213
#include "shared-bindings/keypad/EventQueue.h"
@@ -133,6 +134,10 @@ static void keymatrix_scan_now(void *self_in, mp_obj_t timestamp) {
133134
// to switch values. Just switching to an input with a (relatively weak) pullup/pulldown
134135
// causes a slight delay in the output changing, which can cause false readings.
135136
common_hal_digitalio_digitalinout_set_value(row_dio, self->columns_to_anodes);
137+
138+
// Wait a moment to let the columns settle.
139+
mp_hal_delay_us(1);
140+
136141
// Switch the row back to an input, pulled appropriately
137142
common_hal_digitalio_digitalinout_switch_to_input(
138143
row_dio, self->columns_to_anodes ? PULL_UP : PULL_DOWN);

0 commit comments

Comments
 (0)