Skip to content

Commit c510c6d

Browse files
committed
2 parents d8a35f2 + 3413378 commit c510c6d

File tree

11 files changed

+171
-1
lines changed

11 files changed

+171
-1
lines changed

CLUE_Altimeter/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
# background
4848
bg_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
)
5151
for i, color in enumerate(bg_pal):
5252
if color == 0xFF0000:
File renamed without changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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)
Binary file not shown.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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!")

Metro_M7_Examples/I2S_Tone/code.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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)
413 KB
Binary file not shown.

Metro_M7_Examples/I2S_Wav/code.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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!")

Metro_M7_Examples/PWM_Tone/code.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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)
413 KB
Binary file not shown.

0 commit comments

Comments
 (0)