Skip to content

Commit a4a439c

Browse files
committed
examples/button_reaction: Update for time_pulse_us() no longer raising exc.
1 parent d5e9ab6 commit a4a439c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/hwapi/button_reaction.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
""")
1212

1313
while 1:
14-
try:
15-
delay = machine.time_pulse_us(BUTTON, 1, 10*1000*1000)
16-
print("You are as slow as %d microseconds!" % delay)
17-
except OSError:
14+
delay = machine.time_pulse_us(BUTTON, 1, 10*1000*1000)
15+
if delay < 0:
1816
print("Well, you're *really* slow")
17+
else:
18+
print("You are as slow as %d microseconds!" % delay)
1919
utime.sleep_ms(10)

0 commit comments

Comments
 (0)