Skip to content

Commit

Permalink
Merge pull request #6 from dastels/Dans_suggestions
Browse files Browse the repository at this point in the history
Incorporate Dan Halbert's suggestions
  • Loading branch information
dhalbert committed Jan 8, 2019
2 parents c7a4a8e + 70cb1ca commit 867f2f8
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions adafruit_debouncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@

import time
import digitalio
from micropython import const

_DEBOUNCED_STATE = 0x01
_UNSTABLE_STATE = 0x02
_CHANGED_STATE = 0x04
_DEBOUNCED_STATE = const(0x01)
_UNSTABLE_STATE = const(0x02)
_CHANGED_STATE = const(0x04)

class Debouncer(object):
"""Debounce an input pin or an arbitrary predicate"""
Expand All @@ -68,10 +69,7 @@ def __init__(self, io_or_predicate, interval=0.010):
if self.function():
self._set_state(_DEBOUNCED_STATE | _UNSTABLE_STATE)
self.previous_time = 0
if interval is None:
self.interval = 0.010
else:
self.interval = interval
self.interval = interval


def _set_state(self, bits):
Expand Down

0 comments on commit 867f2f8

Please sign in to comment.