Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporate Dan Halbert's suggestions #6

Merged
merged 2 commits into from
Jan 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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