Skip to content

Commit 7b144ce

Browse files
ladyadatannewt
authored andcommitted
fix for gemma/trinket and other non-audio boards
1 parent 4b389e6 commit 7b144ce

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

simpleio.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
2626
The `simpleio` module contains classes to provide simple access to IO.
2727
"""
28-
import audioio
28+
try:
29+
import audioio
30+
except ImportError:
31+
pass # not always supported by every board!
2932
import array
3033
import digitalio
3134
import pulseio
@@ -53,7 +56,7 @@ def tone(pin, frequency, duration = 1):
5356
waveform.play(loop=True)
5457
time.sleep(duration)
5558
waveform.stop()
56-
except ValueError:
59+
except (NameError, ValueError):
5760
with pulseio.PWMOut(pin, frequency = frequency, variable_frequency = False) as pwm:
5861
pwm.duty_cycle = 0x8000
5962
time.sleep(duration)

0 commit comments

Comments
 (0)