Skip to content

Commit a2514c6

Browse files
committed
use new volume API in spell jam
1 parent 6964278 commit a2514c6

File tree

1 file changed

+6
-5
lines changed
  • Fruit_Jam/Fruit_Jam_Spell_Jam

1 file changed

+6
-5
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')}")

0 commit comments

Comments
 (0)