Skip to content

Commit 965fdd3

Browse files
authored
Merge pull request #64 from hexthat/patch-4
Update to support CP versions 3.0.0 to 5.0.0
2 parents fc735f8 + f8789a4 commit 965fdd3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

adafruit_circuitplayground/express.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
import adafruit_thermistor
5252
import analogio
5353
import audioio
54+
try:
55+
import audiocore
56+
except ImportError:
57+
audiocore = audioio
5458
import board
5559
import busio
5660
import digitalio
@@ -575,7 +579,7 @@ def _generate_sample(self, length=100):
575579
self._sine_wave = array.array("H", Express._sine_sample(length))
576580
if sys.implementation.version[0] >= 3:
577581
self._sample = audioio.AudioOut(board.SPEAKER)
578-
self._sine_wave_sample = audioio.RawSample(self._sine_wave)
582+
self._sine_wave_sample = audiocore.RawSample(self._sine_wave)
579583
else:
580584
raise NotImplementedError("Please use CircuitPython 3.0 or higher.")
581585

@@ -683,7 +687,7 @@ def play_file(self, file_name):
683687
self._speaker_enable.value = True
684688
if sys.implementation.version[0] >= 3:
685689
with audioio.AudioOut(board.SPEAKER) as audio:
686-
wavefile = audioio.WaveFile(open(file_name, "rb"))
690+
wavefile = audiocore.WaveFile(open(file_name, "rb"))
687691
audio.play(wavefile)
688692
while audio.playing:
689693
pass

0 commit comments

Comments
 (0)