@@ -131,11 +131,15 @@ def current_duration(self):
131
131
132
132
class Button (Debouncer ):
133
133
"""Debounce counter"""
134
- def __init__ (self , pin ,
135
- short_duration_ms = 200 ,
136
- long_duration_ms = 500 ,
137
- active_down = True ,
138
- ** kwargs ):
134
+
135
+ def __init__ (
136
+ self ,
137
+ pin ,
138
+ short_duration_ms = 200 ,
139
+ long_duration_ms = 500 ,
140
+ active_down = True ,
141
+ ** kwargs
142
+ ):
139
143
self .short_duration_ms = short_duration_ms
140
144
self .long_duration_ms = long_duration_ms
141
145
self .active_down = active_down
@@ -147,12 +151,14 @@ def __init__(self, pin,
147
151
super ().__init__ (pin , ** kwargs )
148
152
149
153
def _pushed (self ):
150
- return (self .active_down and super ().fell ) or \
151
- (not self .active_down and super ().rose )
154
+ return (self .active_down and super ().fell ) or (
155
+ not self .active_down and super ().rose
156
+ )
152
157
153
158
def _released (self ):
154
- return (self .active_down and super ().rose ) or \
155
- (not self .active_down and super ().fell )
159
+ return (self .active_down and super ().rose ) or (
160
+ not self .active_down and super ().fell
161
+ )
156
162
157
163
def update (self ):
158
164
super ().update ()
@@ -166,15 +172,19 @@ def update(self):
166
172
self .long_showed = False
167
173
else :
168
174
duration = ticks_diff (ticks_ms (), self .last_change_ms )
169
- if not self .long_registered and \
170
- self .value != self .active_down and \
171
- duration > self .long_duration_ms :
175
+ if (
176
+ not self .long_registered
177
+ and self .value != self .active_down
178
+ and duration > self .long_duration_ms
179
+ ):
172
180
self .long_registered = True
173
181
self .short_to_show = self .short_counter - 1
174
182
self .short_counter = 0
175
- elif self .short_counter > 0 and \
176
- self .value == self .active_down and \
177
- duration > self .short_duration_ms :
183
+ elif (
184
+ self .short_counter > 0
185
+ and self .value == self .active_down
186
+ and duration > self .short_duration_ms
187
+ ):
178
188
self .short_to_show = self .short_counter
179
189
self .short_counter = 0
180
190
0 commit comments