Skip to content

Commit dfa5009

Browse files
authored
Merge pull request #3121 from RetiredWizard/fruitjamappssnd
new float volume setting and don't set volume to override
2 parents ad3f5a6 + a2514c6 commit dfa5009

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

Fruit_Jam/Fruit_Jam_Spell_Jam/code.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
# initialize Fruit Jam built-in hardware
4343
fj = FruitJam()
4444
fj.neopixels.brightness = 0.1
45-
fj.peripherals.volume = 9
45+
fj.peripherals.volume = 0.5
46+
vol_int = 50
4647

4748
# AWS auth requires us to have accurate date/time
4849
now = fj.sync_time()
@@ -119,13 +120,13 @@ def say_and_spell_lastword():
119120
say_and_spell_lastword()
120121
elif c.encode("utf-8") == b"\x1b[B":
121122
# down arrow
122-
fj.peripherals.volume = max(1, fj.peripherals.volume - 1)
123+
vol_int = max(0, vol_int - 5)
124+
fj.peripherals.volume = vol_int / 100
123125
print(f"Volume: {fj.peripherals.volume}")
124126
elif c.encode("utf-8") == b"\x1b[A":
125127
# up arrow
126-
fj.peripherals.volume = min(
127-
fj.peripherals.safe_volume_limit, fj.peripherals.volume + 1
128-
)
128+
vol_int = min(fj.peripherals.safe_volume_limit * 100, vol_int + 5)
129+
fj.peripherals.volume = vol_int / 100
129130
print(f"Volume: {fj.peripherals.volume}")
130131
else:
131132
print(f"unused key: {c.encode('utf-8')}")

Fruit_Jam/Larsio_Paint_Music/sound_manager.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def __init__(self, audio_output="pwm", seconds_per_eighth=0.25):
8383
# Initialize TLV320
8484
fjPeriphs = adafruit_fruitjam.Peripherals(
8585
audio_output=launcher_config["audio"].get("output", "headphone"),
86-
safe_volume_limit=launcher_config["audio"].get("volume_override_danger",12),
86+
safe_volume_limit=
87+
launcher_config["audio"].get("volume_override_danger",.75),
8788
sample_rate=11025,
8889
bit_depth=16,
8990
i2c=board.STEMMA_I2C()
@@ -103,7 +104,8 @@ def __init__(self, audio_output="pwm", seconds_per_eighth=0.25):
103104
# Initialize TLV320
104105
fjPeriphs = adafruit_fruitjam.Peripherals(
105106
audio_output=launcher_config["audio"].get("output", "headphone"),
106-
safe_volume_limit=launcher_config["audio"].get("volume_override_danger",12),
107+
safe_volume_limit=
108+
launcher_config["audio"].get("volume_override_danger",.75),
107109
sample_rate=11025,
108110
bit_depth=16,
109111
i2c=board.I2C()
@@ -112,10 +114,8 @@ def __init__(self, audio_output="pwm", seconds_per_eighth=0.25):
112114
self.tlv = fjPeriphs.dac
113115

114116
# If volume was specified use it, otherwise use the fruitjam library default
115-
if "volume_override_danger" in launcher_config["audio"]:
116-
fjPeriphs.volume = launcher_config["audio"]["volume_override_danger"]
117-
elif "volume" in launcher_config["audio"]:
118-
fjPeriphs.volume = launcher_config["audio"]["volume"] # FruitJam vol (1-20)
117+
if "volume" in launcher_config["audio"]:
118+
fjPeriphs.volume = launcher_config["audio"]["volume"] # FruitJam vol 0.0-1.0
119119

120120
# Setup I2S audio output - important to do this AFTER configuring the DAC
121121
# Fruitjam library actually does this before we modify the configuration

Metro/Metro_RP2350_Chips_Challenge/code.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
fjPeriphs = adafruit_fruitjam.Peripherals.Peripherals(
5252
audio_output=launcher_config["audio"].get("output", "headphone"),
53-
safe_volume_limit=launcher_config["audio"].get("volume_override_danger",12),
53+
safe_volume_limit=launcher_config["audio"].get("volume_override_danger",.75),
5454
sample_rate=44100,
5555
bit_depth=16,
5656
i2c=board.I2C()
@@ -61,10 +61,8 @@
6161
fjPeriphs.audio = audiobusio.I2SOut(board.D9, board.D10, board.D11)
6262

6363
# If volume was specified use it, otherwise use the fruitjam library default
64-
if "volume_override_danger" in launcher_config["audio"]:
65-
fjPeriphs.volume = launcher_config["audio"]["volume_override_danger"]
66-
elif "volume" in launcher_config["audio"]:
67-
fjPeriphs.volume = launcher_config["audio"]["volume"] # FruitJam vol (1-20)
64+
if "volume" in launcher_config["audio"]:
65+
fjPeriphs.volume = launcher_config["audio"]["volume"] # FruitJam vol 0.0-1.0
6866

6967
if fjPeriphs.audio is not None:
7068
audio = Audio(fjPeriphs.audio, SOUND_EFFECTS)

0 commit comments

Comments
 (0)