Skip to content

Commit 17d40f5

Browse files
authored
Merge pull request #9819 from dhalbert/keys-generic-reset-fix
Fix regression of keypad.*.reset() behavior: send key_pressed events
2 parents 4838af5 + d08cecf commit 17d40f5

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

shared-bindings/keypad/KeyMatrix.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ static void check_for_deinit(keypad_keymatrix_obj_t *self) {
159159
//| """Reset the internal state of the scanner to assume that all keys are now released.
160160
//| Any key that is already pressed at the time of this call will therefore immediately cause
161161
//| a new key-pressed event to occur.
162+
//| For instance, if you call `reset()` immediately after creating a `KeyMatrix` object
163+
//| at the beginning of your program, the events it generates will let you determine which keys
164+
//| were being held down at program start.
162165
//| """
163166
//| ...
164167

shared-bindings/keypad/Keys.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(keypad_keys___exit___obj, 4, 4, keypa
147147
//| """Reset the internal state of the scanner to assume that all keys are now released.
148148
//| Any key that is already pressed at the time of this call will therefore immediately cause
149149
//| a new key-pressed event to occur.
150+
//| For instance, if you call `reset()` immediately after creating a `Keys` object
151+
//| at the beginning of your program, the events it generates will let you determine which keys
152+
//| were being held down at program start.
150153
//| """
151154
//| ...
152155

shared-bindings/keypad/ShiftRegisterKeys.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(keypad_shiftregisterkeys___exit___obj
201201
//| """Reset the internal state of the scanner to assume that all keys are now released.
202202
//| Any key that is already pressed at the time of this call will therefore immediately cause
203203
//| a new key-pressed event to occur.
204+
//| For instance, if you call `reset()` immediately after creating a `ShiftRegisterKeys` object
205+
//| at the beginning of your program, the events it generates will let you determine which keys
206+
//| were being held down at program start.
204207
//| """
205208
//| ...
206209

shared-bindings/keypad_demux/DemuxKeyMatrix.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ static void check_for_deinit(keypad_demux_demuxkeymatrix_obj_t *self) {
147147
//| """Reset the internal state of the scanner to assume that all keys are now released.
148148
//| Any key that is already pressed at the time of this call will therefore immediately cause
149149
//| a new key-pressed event to occur.
150+
//| For instance, if you call `reset()` immediately after creating a `DemuxKeyMatrix` object
151+
//| at the beginning of your program, the events it generates will let you determine which keys
152+
//| were being held down at program start.
150153
//| """
151154
//| ...
152155

shared-module/keypad/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void keypad_never_reset(keypad_scanner_obj_t *self) {
140140
void common_hal_keypad_generic_reset(void *self_in) {
141141
keypad_scanner_obj_t *self = self_in;
142142
size_t key_count = common_hal_keypad_generic_get_key_count(self);
143-
memset(self->debounce_counter, self->debounce_threshold, key_count);
143+
memset(self->debounce_counter, -self->debounce_threshold, key_count);
144144
keypad_scan_now(self, port_get_raw_ticks(NULL));
145145
}
146146

0 commit comments

Comments
 (0)