Skip to content

Commit 347d60c

Browse files
committed
Simplified fixes for Slideshow_Soundtrack
1 parent 1bf4d91 commit 347d60c

1 file changed

Lines changed: 13 additions & 24 deletions

File tree

Slideshows_Soundtrack/slideshows_soundtrack.py

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,24 @@
1111
back_pin = board.TOUCH1
1212
forward_pin = board.TOUCH4
1313

14-
# Detect if this is the HalloWing M4 or M0
15-
is_hallowing_m4 = False
14+
# Perform a couple extra steps for the HalloWing M4
1615
try:
1716
if getattr(board, "CAP_PIN"):
18-
is_hallowing_m4 = True
17+
# Create digitalio objects and pull low for HalloWing M4
18+
cap_pin = digitalio.DigitalInOut(board.CAP_PIN)
19+
cap_pin.direction = digitalio.Direction.OUTPUT
20+
cap_pin.value = False
21+
if getattr(board, "SPEAKER_ENABLE"):
22+
# Enable the Speaker
23+
speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
24+
speaker_enable.direction = digitalio.Direction.OUTPUT
25+
speaker_enable.value = True
1926
except AttributeError:
2027
pass
2128

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)
29+
# Create the touchio objects for HalloWing M0
30+
back_button = touchio.TouchIn(back_pin)
31+
forward_button = touchio.TouchIn(forward_pin)
4332

4433
# Setup the speaker output
4534
a = audioio.AudioOut(board.SPEAKER)

0 commit comments

Comments
 (0)