Skip to content

Commit 3569774

Browse files
authored
Merge pull request #24 from dglaude/patch-1
Update adafruit_debouncer.py
2 parents 5e5e302 + 62eb982 commit 3569774

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

adafruit_debouncer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,13 @@
6262
_UNSTABLE_STATE = const(0x02)
6363
_CHANGED_STATE = const(0x04)
6464

65-
# Find out whether the current CircuitPython supports time.monotonic_ns(),
65+
# Find out whether the current CircuitPython really supports time.monotonic_ns(),
6666
# which doesn't have the accuracy limitation.
67-
if hasattr(time, "monotonic_ns"):
67+
try:
68+
time.monotonic_ns()
6869
TICKS_PER_SEC = 1_000_000_000
6970
MONOTONIC_TICKS = time.monotonic_ns
70-
else:
71+
except (AttributeError, NotImplementedError):
7172
TICKS_PER_SEC = 1
7273
MONOTONIC_TICKS = time.monotonic
7374

0 commit comments

Comments
 (0)