Skip to content

Commit 1bf4d91

Browse files
committed
Updated Slideshow_Soundtrack to run on both HalloWing M0 and M4
1 parent aed3311 commit 1bf4d91

1 file changed

Lines changed: 34 additions & 4 deletions

File tree

Slideshows_Soundtrack/slideshows_soundtrack.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,49 @@
11
import board
22
from adafruit_slideshow import SlideShow, PlayBackDirection
33
import audioio
4+
import digitalio
45
import touchio
56

67
# Create the slideshow object that plays through once alphabetically.
78
slideshow = SlideShow(board.DISPLAY)
89

9-
# Create the touch objects on the first and last teeth
10-
back_button = touchio.TouchIn(board.TOUCH1)
11-
forward_button = touchio.TouchIn(board.TOUCH4)
10+
# Set the touch objects to the first and last teeth
11+
back_pin = board.TOUCH1
12+
forward_pin = board.TOUCH4
13+
14+
# Detect if this is the HalloWing M4 or M0
15+
is_hallowing_m4 = False
16+
try:
17+
if getattr(board, "CAP_PIN"):
18+
is_hallowing_m4 = True
19+
except AttributeError:
20+
pass
21+
22+
# Initialize the Buttons and Speaker
23+
if is_hallowing_m4:
24+
# Enable the Speaker
25+
speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
26+
speaker_enable.direction = digitalio.Direction.OUTPUT
27+
speaker_enable.value = True
28+
29+
# Create digitalio objects and pull low for HalloWing M4
30+
back_button = digitalio.DigitalInOut(back_pin)
31+
back_button.direction = digitalio.Direction.OUTPUT
32+
back_button.value = False
33+
back_button.direction = digitalio.Direction.INPUT
34+
35+
forward_button = digitalio.DigitalInOut(forward_pin)
36+
forward_button.direction = digitalio.Direction.OUTPUT
37+
forward_button.value = False
38+
forward_button.direction = digitalio.Direction.INPUT
39+
else:
40+
# Create the touchio objects for HalloWing M0
41+
back_button = touchio.TouchIn(back_pin)
42+
forward_button = touchio.TouchIn(forward_pin)
1243

1344
# Setup the speaker output
1445
a = audioio.AudioOut(board.SPEAKER)
1546

16-
1747
# Helper function that takes in the file name string, splits it at the period, and keeps only the
1848
# beginning of the string. i.e. kitten.bmp becomes kitten.
1949
def basename(file_name):

0 commit comments

Comments
 (0)