Skip to content

Commit 172d6a0

Browse files
Merge branch 'python-goggles' of https://github.com/adafruit/Adafruit_Learning_System_Guides into python-goggles
2 parents 4753c46 + 99fc01e commit 172d6a0

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

CPX_Walking_Stick/code.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,27 @@
77
# Set the tap type: 1=single, 2=double
88
cpx.detect_taps = 1
99

10-
# NeoPixel settings
10+
# NeoPixel colors used
1111
RED = (90, 0, 0)
1212
BLACK = (0, 0, 0)
13-
step_col = [RED]
1413

1514
cpx.pixels.brightness = 0.1 # set brightness value
1615

1716
# The audio file assigned to the touchpad
18-
audio_file = ["imperial_march.wav"]
17+
audio_file = "imperial_march.wav"
1918

20-
def play_it(index):
21-
cpx.pixels.fill(step_col[index]) # Light neopixels
22-
cpx.play_file(audio_file[index]) # play audio clip
23-
print("playing file " + audio_file[index])
19+
def play_it():
20+
cpx.pixels.fill(RED) # Light neopixels
21+
cpx.play_file(audio_file) # play audio clip
22+
print("playing file ", audio_file)
2423
cpx.pixels.fill(BLACK) # unlight lights
2524

2625
while True:
2726
# playback mode. Use the slide switch to change between
2827
# trigger via touch or via single tap
2928
if cpx.switch:
3029
if cpx.touch_A1:
31-
play_it(0)
30+
play_it()
3231
else:
3332
if cpx.tapped:
34-
play_it(0)
33+
play_it()

0 commit comments

Comments
 (0)