36
36
#include "supervisor/port.h"
37
37
#include "supervisor/shared/tick.h"
38
38
39
+ static void keypad_shiftregisterkeys_scan_now (keypad_shiftregisterkeys_obj_t * self , uint64_t now );
40
+
39
41
void common_hal_keypad_shiftregisterkeys_construct (keypad_shiftregisterkeys_obj_t * self , const mcu_pin_obj_t * clock_pin , const mcu_pin_obj_t * data_pin , const mcu_pin_obj_t * latch_pin , bool value_to_latch , size_t key_count , bool value_when_pressed , mp_float_t interval , size_t max_events ) {
40
42
41
43
digitalio_digitalinout_obj_t * clock = m_new_obj (digitalio_digitalinout_obj_t );
@@ -63,7 +65,6 @@ void common_hal_keypad_shiftregisterkeys_construct(keypad_shiftregisterkeys_obj_
63
65
self -> key_count = key_count ;
64
66
65
67
self -> interval_ticks = (mp_uint_t )(interval * 1024 ); // interval * 1000 * (1024/1000)
66
- self -> last_scan_ticks = port_get_raw_ticks (NULL );
67
68
68
69
keypad_eventqueue_obj_t * events = m_new_obj (keypad_eventqueue_obj_t );
69
70
events -> base .type = & keypad_eventqueue_type ;
@@ -72,6 +73,7 @@ void common_hal_keypad_shiftregisterkeys_construct(keypad_shiftregisterkeys_obj_
72
73
73
74
// Add self to the list of active keypad scanners.
74
75
keypad_register_scanner ((keypad_scanner_obj_t * )self );
76
+ keypad_shiftregisterkeys_scan_now (self , port_get_raw_ticks (NULL ));
75
77
}
76
78
77
79
void common_hal_keypad_shiftregisterkeys_deinit (keypad_shiftregisterkeys_obj_t * self ) {
@@ -108,10 +110,9 @@ mp_obj_t common_hal_keypad_shiftregisterkeys_get_events(keypad_shiftregisterkeys
108
110
void common_hal_keypad_shiftregisterkeys_reset (keypad_shiftregisterkeys_obj_t * self ) {
109
111
const size_t key_count = common_hal_keypad_shiftregisterkeys_get_key_count (self );
110
112
111
- supervisor_acquire_lock (& keypad_scanners_linked_list_lock );
112
113
memset (self -> previously_pressed , false, key_count );
113
114
memset (self -> currently_pressed , false, key_count );
114
- supervisor_release_lock ( & keypad_scanners_linked_list_lock );
115
+ keypad_shiftregisterkeys_scan_now ( self , port_get_raw_ticks ( NULL ) );
115
116
}
116
117
117
118
void keypad_shiftregisterkeys_scan (keypad_shiftregisterkeys_obj_t * self ) {
@@ -121,6 +122,10 @@ void keypad_shiftregisterkeys_scan(keypad_shiftregisterkeys_obj_t *self) {
121
122
return ;
122
123
}
123
124
125
+ keypad_shiftregisterkeys_scan_now (self , now );
126
+ }
127
+
128
+ static void keypad_shiftregisterkeys_scan_now (keypad_shiftregisterkeys_obj_t * self , uint64_t now ) {
124
129
self -> last_scan_ticks = now ;
125
130
126
131
mp_obj_t timestamp = supervisor_ticks_ms ();
0 commit comments