Skip to content

Commit 33ba756

Browse files
committed
Nicer names and some comments
1 parent 741932c commit 33ba756

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

adafruit_debouncer.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,14 @@
6363
_UNSTABLE_STATE = const(0x02)
6464
_CHANGED_STATE = const(0x04)
6565

66+
67+
# Find out whether the current CircuitPython supports time.monotonic_ns(),
68+
# which doesn't have the accuracy limitation.
6669
if hasattr(time, 'monotonic_ns'):
67-
INTERVAL_FACTOR = 1_000_000_000
70+
MONOTONIC_UNITS_PER_SEC = 1_000_000_000
6871
MONOTONIC_TIME = time.monotonic_ns
6972
else:
70-
INTERVAL_FACTOR = 1
73+
MONOTONIC_UNITS_PER_SEC = 1
7174
MONOTONIC_TIME = time.monotonic
7275

7376

@@ -123,12 +126,13 @@ def update(self):
123126

124127
@property
125128
def interval(self):
126-
return self._interval / INTERVAL_FACTOR
129+
"""The debounce delay, in seconds"""
130+
return self._interval / MONOTONIC_UNITS_PER_SEC
127131

128132

129133
@interval.setter
130134
def interval(self, new_interval_s):
131-
self._interval = new_interval_s * INTERVAL_FACTOR
135+
self._interval = new_interval_s * MONOTONIC_UNITS_PER_SEC
132136

133137

134138
@property

0 commit comments

Comments
 (0)