Skip to content

Commit

Permalink
Merge pull request #9819 from dhalbert/keys-generic-reset-fix
Browse files Browse the repository at this point in the history
Fix regression of keypad.*.reset() behavior: send key_pressed events
  • Loading branch information
dhalbert authored Nov 20, 2024
2 parents 4838af5 + d08cecf commit 17d40f5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions shared-bindings/keypad/KeyMatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ static void check_for_deinit(keypad_keymatrix_obj_t *self) {
//| """Reset the internal state of the scanner to assume that all keys are now released.
//| Any key that is already pressed at the time of this call will therefore immediately cause
//| a new key-pressed event to occur.
//| For instance, if you call `reset()` immediately after creating a `KeyMatrix` object
//| at the beginning of your program, the events it generates will let you determine which keys
//| were being held down at program start.
//| """
//| ...

Expand Down
3 changes: 3 additions & 0 deletions shared-bindings/keypad/Keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(keypad_keys___exit___obj, 4, 4, keypa
//| """Reset the internal state of the scanner to assume that all keys are now released.
//| Any key that is already pressed at the time of this call will therefore immediately cause
//| a new key-pressed event to occur.
//| For instance, if you call `reset()` immediately after creating a `Keys` object
//| at the beginning of your program, the events it generates will let you determine which keys
//| were being held down at program start.
//| """
//| ...

Expand Down
3 changes: 3 additions & 0 deletions shared-bindings/keypad/ShiftRegisterKeys.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(keypad_shiftregisterkeys___exit___obj
//| """Reset the internal state of the scanner to assume that all keys are now released.
//| Any key that is already pressed at the time of this call will therefore immediately cause
//| a new key-pressed event to occur.
//| For instance, if you call `reset()` immediately after creating a `ShiftRegisterKeys` object
//| at the beginning of your program, the events it generates will let you determine which keys
//| were being held down at program start.
//| """
//| ...

Expand Down
3 changes: 3 additions & 0 deletions shared-bindings/keypad_demux/DemuxKeyMatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ static void check_for_deinit(keypad_demux_demuxkeymatrix_obj_t *self) {
//| """Reset the internal state of the scanner to assume that all keys are now released.
//| Any key that is already pressed at the time of this call will therefore immediately cause
//| a new key-pressed event to occur.
//| For instance, if you call `reset()` immediately after creating a `DemuxKeyMatrix` object
//| at the beginning of your program, the events it generates will let you determine which keys
//| were being held down at program start.
//| """
//| ...

Expand Down
2 changes: 1 addition & 1 deletion shared-module/keypad/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void keypad_never_reset(keypad_scanner_obj_t *self) {
void common_hal_keypad_generic_reset(void *self_in) {
keypad_scanner_obj_t *self = self_in;
size_t key_count = common_hal_keypad_generic_get_key_count(self);
memset(self->debounce_counter, self->debounce_threshold, key_count);
memset(self->debounce_counter, -self->debounce_threshold, key_count);
keypad_scan_now(self, port_get_raw_ticks(NULL));
}

Expand Down

0 comments on commit 17d40f5

Please sign in to comment.