File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4646
4747# background
4848bg_bmp , bg_pal = adafruit_imageload .load (
49- "/network23.bmp" , bitmap = displayio .Bitmap , palette = displayio .Palette
49+ "images /network23.bmp" , bitmap = displayio .Bitmap , palette = displayio .Palette
5050)
5151for i , color in enumerate (bg_pal ):
5252 if color == 0xFF0000 :
File renamed without changes.
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
2+ #
3+ # SPDX-License-Identifier: MIT
4+
5+ """
6+ CircuitPython PWM Audio Out tone example
7+ Plays a tone for one second on, one
8+ second off, in a loop.
9+
10+ Remove this line and all of the following docstring content before submitting to the Learn repo.
11+
12+ Update the audio out pin to match the wiring chosen for the microcontroller.
13+ Update the following pin name to a viable pin:
14+ * AUDIO_OUTPUT_PIN
15+ """
16+ import time
17+ import array
18+ import math
19+ import board
20+ from audiocore import RawSample
21+ from audiopwmio import PWMAudioOut as AudioOut
22+
23+ audio = AudioOut (board .AUDIO_OUTPUT_PIN )
24+
25+ tone_volume = 0.1 # Increase this to increase the volume of the tone.
26+ frequency = 440 # Set this to the Hz of the tone you want to generate.
27+ length = 8000 // frequency
28+ sine_wave = array .array ("H" , [0 ] * length )
29+ for i in range (length ):
30+ sine_wave [i ] = int ((1 + math .sin (math .pi * 2 * i / length )) * tone_volume * (2 ** 15 - 1 ))
31+
32+ sine_wave_sample = RawSample (sine_wave )
33+
34+ while True :
35+ audio .play (sine_wave_sample , loop = True )
36+ time .sleep (1 )
37+ audio .stop ()
38+ time .sleep (1 )
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
2+ #
3+ # SPDX-License-Identifier: MIT
4+
5+ """
6+ CircuitPython PWM Audio Out WAV example
7+ Play a WAV file once.
8+
9+ Remove this line and all of the following docstring content before submitting to the Learn repo.
10+
11+ Update the audio out pin to match the wiring chosen for the microcontroller.
12+ Update the following pin name to a viable pin:
13+ * AUDIO_OUTPUT_PIN
14+ """
15+ import board
16+ from audiocore import WaveFile
17+ from audiopwmio import PWMAudioOut as AudioOut
18+
19+ audio = AudioOut (board .AUDIO_OUTPUT_PIN )
20+
21+ with open ("StreetChicken.wav" , "rb" ) as wave_file :
22+ wave = WaveFile (wave_file )
23+ print ("Playing wav file!" )
24+ audio .play (wave )
25+ while audio .playing :
26+ pass
27+
28+ print ("Done!" )
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2+ # SPDX-License-Identifier: MIT
3+ """
4+ CircuitPython I2S Tone playback example.
5+ Plays a tone for one second on, one
6+ second off, in a loop.
7+ """
8+ import time
9+ import array
10+ import math
11+ import audiocore
12+ import board
13+ import audiobusio
14+
15+ audio = audiobusio .I2SOut (board .D10 , board .D9 , board .D12 )
16+
17+ tone_volume = 0.1 # Increase this to increase the volume of the tone.
18+ frequency = 440 # Set this to the Hz of the tone you want to generate.
19+ length = 8000 // frequency
20+ sine_wave = array .array ("h" , [0 ] * length )
21+ for i in range (length ):
22+ sine_wave [i ] = int ((math .sin (math .pi * 2 * i / length )) * tone_volume * (2 ** 15 - 1 ))
23+ sine_wave_sample = audiocore .RawSample (sine_wave )
24+
25+ while True :
26+ audio .play (sine_wave_sample , loop = True )
27+ time .sleep (1 )
28+ audio .stop ()
29+ time .sleep (1 )
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2+ # SPDX-License-Identifier: MIT
3+ """
4+ CircuitPython I2S WAV file playback.
5+ Plays a WAV file once.
6+ """
7+ import audiocore
8+ import board
9+ import audiobusio
10+
11+ audio = audiobusio .I2SOut (board .D10 , board .D9 , board .D12 )
12+
13+ with open ("StreetChicken.wav" , "rb" ) as wave_file :
14+ wav = audiocore .WaveFile (wave_file )
15+
16+ print ("Playing wav file!" )
17+ audio .play (wav )
18+ while audio .playing :
19+ pass
20+
21+ print ("Done!" )
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
2+ #
3+ # SPDX-License-Identifier: MIT
4+
5+ """
6+ CircuitPython PWM Audio Out tone example
7+ Plays a tone for one second on, one
8+ second off, in a loop.
9+ """
10+ import time
11+ import array
12+ import math
13+ import board
14+ from audiocore import RawSample
15+ from audiopwmio import PWMAudioOut as AudioOut
16+
17+ audio = AudioOut (board .A1 )
18+
19+ tone_volume = 0.1 # Increase this to increase the volume of the tone.
20+ frequency = 440 # Set this to the Hz of the tone you want to generate.
21+ length = 8000 // frequency
22+ sine_wave = array .array ("H" , [0 ] * length )
23+ for i in range (length ):
24+ sine_wave [i ] = int ((1 + math .sin (math .pi * 2 * i / length )) * tone_volume * (2 ** 15 - 1 ))
25+
26+ sine_wave_sample = RawSample (sine_wave )
27+
28+ while True :
29+ audio .play (sine_wave_sample , loop = True )
30+ time .sleep (1 )
31+ audio .stop ()
32+ time .sleep (1 )
You can’t perform that action at this time.
0 commit comments