File tree Expand file tree Collapse file tree 2 files changed +26
-5
lines changed
Adafruit_Prop_Maker_FeatherWing
Prop_Maker_3W_LED_Simpletest
Prop_Maker_Audio_Simpletest Expand file tree Collapse file tree 2 files changed +26
-5
lines changed Original file line number Diff line number Diff line change 1
- # SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries
1
+ # SPDX-FileCopyrightText: 2019, 2023 Kattni Rembor for Adafruit Industries
2
2
#
3
3
# SPDX-License-Identifier: MIT
4
4
5
5
"""Simple rainbow swirl example for 3W LED"""
6
+ import time
6
7
import pwmio
7
8
import board
8
- from rainbowio import colorwheel
9
9
import digitalio
10
10
11
11
enable = digitalio .DigitalInOut (board .D10 )
12
12
enable .direction = digitalio .Direction .OUTPUT
13
13
enable .value = True
14
14
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
+
15
28
red = pwmio .PWMOut (board .D11 , duty_cycle = 0 , frequency = 20000 )
16
29
green = pwmio .PWMOut (board .D12 , duty_cycle = 0 , frequency = 20000 )
17
30
blue = pwmio .PWMOut (board .D13 , duty_cycle = 0 , frequency = 20000 )
22
35
red .duty_cycle = int (r * 65536 / 256 )
23
36
green .duty_cycle = int (g * 65536 / 256 )
24
37
blue .duty_cycle = int (b * 65536 / 256 )
38
+ time .sleep (0.05 )
Original file line number Diff line number Diff line change 1
- # SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries
1
+ # SPDX-FileCopyrightText: 2019, 2023 Kattni Rembor for Adafruit Industries
2
2
#
3
3
# SPDX-License-Identifier: MIT
4
4
5
5
"""Simple example to play a wave file"""
6
6
# This example only works on Feathers that have analog audio out!
7
7
import digitalio
8
8
import board
9
- import audioio
10
9
import audiocore
11
10
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
+
12
19
WAV_FILE_NAME = "StreetChicken.wav" # Change to the name of your wav file!
13
20
14
21
enable = digitalio .DigitalInOut (board .D10 )
15
22
enable .direction = digitalio .Direction .OUTPUT
16
23
enable .value = True
17
24
18
- with audioio . AudioOut (board .A0 ) as audio : # Speaker connector
25
+ with AudioOut (board .A0 ) as audio : # Speaker connector
19
26
wave_file = open (WAV_FILE_NAME , "rb" )
20
27
wave = audiocore .WaveFile (wave_file )
21
28
You can’t perform that action at this time.
0 commit comments