@@ -144,21 +144,24 @@ def update(self):
144144 # Check for press and release
145145 if (button_states_changed ):
146146
147- if (new_status [0 ] == 1 and previous_status [0 ] == 0 and self . _on_button_a_press ):
147+ if (new_status [0 ] == 1 and previous_status [0 ] == 0 ):
148148 self ._last_press_timestamps [0 ] = ticks_ms ()
149- self ._on_button_a_press ()
149+ if (self ._on_button_a_press ):
150+ self ._on_button_a_press ()
150151 elif (new_status [0 ] == 0 and previous_status [0 ] == 1 and self ._on_button_a_release ):
151152 self ._on_button_a_release ()
152153
153- if (new_status [1 ] == 1 and previous_status [1 ] == 0 and self . _on_button_b_press ):
154+ if (new_status [1 ] == 1 and previous_status [1 ] == 0 ):
154155 self ._last_press_timestamps [1 ] = ticks_ms ()
155- self ._on_button_b_press ()
156+ if (self ._on_button_b_press ):
157+ self ._on_button_b_press ()
156158 elif (new_status [1 ] == 0 and previous_status [1 ] == 1 and self ._on_button_b_release ):
157159 self ._on_button_b_release ()
158160
159- if (new_status [2 ] == 1 and previous_status [2 ] == 0 and self . _on_button_c_press ):
161+ if (new_status [2 ] == 1 and previous_status [2 ] == 0 ):
160162 self ._last_press_timestamps [2 ] = ticks_ms ()
161- self ._on_button_c_press ()
163+ if (self ._on_button_c_press ):
164+ self ._on_button_c_press ()
162165 elif (new_status [2 ] == 0 and previous_status [2 ] == 1 and self ._on_button_c_release ):
163166 self ._on_button_c_release ()
164167
0 commit comments