diff --git a/counter.py b/counter.py index c858539..d1cd731 100644 --- a/counter.py +++ b/counter.py @@ -30,13 +30,11 @@ class ButtonHandler(): def handler(self, pin): global idx - now = time.ticks_ms() - if time.ticks_diff(now, self.last) < 150: - print("Debouncing") - else: - print(f"Changing by {self.change}") + pin.irq(None) + time.sleep(0.02) + if pin.value() == 1: idx += self.change - self.last = now + pin.irq(self.handler, trigger=Pin.IRQ_RISING) button_fwd.irq(ButtonHandler(+1).handler, trigger=Pin.IRQ_RISING)