Skip to content

Commit f67db29

Browse files
authored
Merge pull request #2541 from makermelissa/main
Update dreidel game code to work with I2S Audio for MatrixPortal S3
2 parents 16c63d9 + 644f451 commit f67db29

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

RGB_Matrix_Dreidel_Game/code.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@
99
import displayio
1010
import adafruit_imageload
1111
from audiocore import WaveFile
12-
from audioio import AudioOut
1312
from adafruit_motor import servo
1413
from digitalio import DigitalInOut, Direction, Pull
1514
from adafruit_matrixportal.matrix import Matrix
1615

16+
I2S_VERSION = False # set to True if using I2S audio out
17+
18+
# import the appropriate audio module
19+
if I2S_VERSION:
20+
from audiobusio import I2SOut
21+
else:
22+
from audioio import AudioOut
23+
1724
# setup for down button on matrixportal
1825
switch = DigitalInOut(board.BUTTON_DOWN)
1926
switch.direction = Direction.INPUT
@@ -36,7 +43,10 @@
3643
wave = WaveFile(wave_file)
3744

3845
# setup for audio out
39-
audio = AudioOut(board.A0)
46+
if I2S_VERSION:
47+
audio = I2SOut(board.A2, board.A3, board.TX)
48+
else:
49+
audio = AudioOut(board.A0)
4050

4151
# setup for matrix display
4252
matrix = Matrix(width=32, height=32)

0 commit comments

Comments
 (0)