We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 5e5e302 + 62eb982 commit 3569774Copy full SHA for 3569774
adafruit_debouncer.py
@@ -62,12 +62,13 @@
62
_UNSTABLE_STATE = const(0x02)
63
_CHANGED_STATE = const(0x04)
64
65
-# Find out whether the current CircuitPython supports time.monotonic_ns(),
+# Find out whether the current CircuitPython really supports time.monotonic_ns(),
66
# which doesn't have the accuracy limitation.
67
-if hasattr(time, "monotonic_ns"):
+try:
68
+ time.monotonic_ns()
69
TICKS_PER_SEC = 1_000_000_000
70
MONOTONIC_TICKS = time.monotonic_ns
-else:
71
+except (AttributeError, NotImplementedError):
72
TICKS_PER_SEC = 1
73
MONOTONIC_TICKS = time.monotonic
74
0 commit comments