Skip to content

Commit a0327ac

Browse files
authored
Merge pull request #12 from mikeysklar/headphone-speaker
headphone vs speaker usage
2 parents 3aebe8d + b8b1770 commit a0327ac

File tree

8 files changed

+63
-0
lines changed

8 files changed

+63
-0
lines changed

examples/fruitjam_headphone.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 Tim Cocks for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
import time
5+
6+
import adafruit_fruitjam
7+
8+
pobj = adafruit_fruitjam.peripherals.Peripherals()
9+
dac = pobj.dac # use Fruit Jam's codec
10+
11+
# Route once for headphones
12+
dac.headphone_output = True
13+
dac.speaker_output = False
14+
15+
FILES = ["beep.wav", "dip.wav", "rise.wav"]
16+
VOLUMES_DB = [12, 6, 0, -6, -12]
17+
18+
while True:
19+
print("\n=== Headphones Test ===")
20+
for vol in VOLUMES_DB:
21+
dac.dac_volume = vol
22+
print(f"Headphones volume: {vol} dB")
23+
for f in FILES:
24+
print(f" -> {f}")
25+
pobj.play_file(f)
26+
time.sleep(0.2)
27+
time.sleep(1.0)

examples/fruitjam_speaker.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 Tim Cocks for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
import time
5+
6+
import adafruit_fruitjam
7+
8+
pobj = adafruit_fruitjam.peripherals.Peripherals()
9+
dac = pobj.dac # use Fruit Jam's codec
10+
11+
# Route once for speaker
12+
dac.headphone_output = False
13+
dac.speaker_output = True
14+
15+
FILES = ["beep.wav", "dip.wav", "rise.wav"]
16+
VOLUMES_DB = [12, 6, 0, -6, -12]
17+
18+
while True:
19+
print("\n=== Speaker Test ===")
20+
for vol in VOLUMES_DB:
21+
dac.dac_volume = vol
22+
print(f"Speaker volume: {vol} dB")
23+
for f in FILES:
24+
print(f" -> {f}")
25+
pobj.play_file(f)
26+
time.sleep(0.2)
27+
time.sleep(1.0)

examples/wav/beep.wav

9.14 KB
Binary file not shown.

examples/wav/beep.wav.license

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: CC-BY-4.0

examples/wav/dip.wav

25.9 KB
Binary file not shown.

examples/wav/dip.wav.license

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: CC-BY-4.0

examples/wav/rise.wav

25.7 KB
Binary file not shown.

examples/wav/rise.wav.license

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: CC-BY-4.0

0 commit comments

Comments
 (0)