File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -73,11 +73,14 @@ def _toggle_state(self, bits):
73
73
def _get_state (self , bits ):
74
74
return (self .state & bits ) != 0
75
75
76
- def update (self ):
76
+ def update (self , new_state = None ):
77
77
"""Update the debouncer state. MUST be called frequently"""
78
78
now_ticks = ticks_ms ()
79
79
self ._unset_state (_CHANGED_STATE )
80
- current_state = self .function ()
80
+ if new_state is None :
81
+ current_state = self .function ()
82
+ else :
83
+ current_state = bool (new_state )
81
84
if current_state != self ._get_state (_UNSTABLE_STATE ):
82
85
self ._last_bounce_ticks = now_ticks
83
86
self ._toggle_state (_UNSTABLE_STATE )
@@ -160,8 +163,8 @@ def _released(self):
160
163
not self .active_down and super ().fell
161
164
)
162
165
163
- def update (self ):
164
- super ().update ()
166
+ def update (self , new_state = None ):
167
+ super ().update (new_state )
165
168
if self ._pushed ():
166
169
self .last_change_ms = ticks_ms ()
167
170
self .short_counter = self .short_counter + 1
You can’t perform that action at this time.
0 commit comments