Skip to content

Commit b5eb256

Browse files
authored
Merge pull request #2591 from kattni/propmaker-featherwing-updates
Update PropMaker FeatherWing examples.
2 parents d453e1f + 2c54497 commit b5eb256

File tree

2 files changed

+26
-5
lines changed
  • Adafruit_Prop_Maker_FeatherWing

2 files changed

+26
-5
lines changed

Adafruit_Prop_Maker_FeatherWing/Prop_Maker_3W_LED_Simpletest/code.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
1-
# SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries
1+
# SPDX-FileCopyrightText: 2019, 2023 Kattni Rembor for Adafruit Industries
22
#
33
# SPDX-License-Identifier: MIT
44

55
"""Simple rainbow swirl example for 3W LED"""
6+
import time
67
import pwmio
78
import board
8-
from rainbowio import colorwheel
99
import digitalio
1010

1111
enable = digitalio.DigitalInOut(board.D10)
1212
enable.direction = digitalio.Direction.OUTPUT
1313
enable.value = True
1414

15+
16+
def colorwheel(pos):
17+
if pos < 0 or pos > 255:
18+
return 0, 0, 0
19+
if pos < 85:
20+
return int(255 - pos * 3), int(pos * 3), 0
21+
if pos < 170:
22+
pos -= 85
23+
return 0, int(255 - pos * 3), int(pos * 3)
24+
pos -= 170
25+
return int(pos * 3), 0, int(255 - pos * 3)
26+
27+
1528
red = pwmio.PWMOut(board.D11, duty_cycle=0, frequency=20000)
1629
green = pwmio.PWMOut(board.D12, duty_cycle=0, frequency=20000)
1730
blue = pwmio.PWMOut(board.D13, duty_cycle=0, frequency=20000)
@@ -22,3 +35,4 @@
2235
red.duty_cycle = int(r * 65536 / 256)
2336
green.duty_cycle = int(g * 65536 / 256)
2437
blue.duty_cycle = int(b * 65536 / 256)
38+
time.sleep(0.05)

Adafruit_Prop_Maker_FeatherWing/Prop_Maker_Audio_Simpletest/code.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
# SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries
1+
# SPDX-FileCopyrightText: 2019, 2023 Kattni Rembor for Adafruit Industries
22
#
33
# SPDX-License-Identifier: MIT
44

55
"""Simple example to play a wave file"""
66
# This example only works on Feathers that have analog audio out!
77
import digitalio
88
import board
9-
import audioio
109
import audiocore
1110

11+
try:
12+
from audioio import AudioOut
13+
except ImportError:
14+
try:
15+
from audiopwmio import PWMAudioOut as AudioOut
16+
except ImportError:
17+
pass # not always supported by every board!
18+
1219
WAV_FILE_NAME = "StreetChicken.wav" # Change to the name of your wav file!
1320

1421
enable = digitalio.DigitalInOut(board.D10)
1522
enable.direction = digitalio.Direction.OUTPUT
1623
enable.value = True
1724

18-
with audioio.AudioOut(board.A0) as audio: # Speaker connector
25+
with AudioOut(board.A0) as audio: # Speaker connector
1926
wave_file = open(WAV_FILE_NAME, "rb")
2027
wave = audiocore.WaveFile(wave_file)
2128

0 commit comments

Comments
 (0)