Skip to content

Commit 21311a6

Browse files
Fri3d Camp 2024 Board: add startup light and sound
1 parent f37337f commit 21311a6

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

internal_filesystem/lib/mpos/board/fri3d_2024.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,4 +318,64 @@ def adc_to_voltage(adc_value):
318318
LightsManager.init(neopixel_pin=12, num_leds=5)
319319

320320
print("Fri3d hardware: Audio and LEDs initialized")
321+
322+
# === STARTUP "WOW" EFFECT ===
323+
import time
324+
import _thread
325+
326+
def startup_wow_effect():
327+
"""
328+
Epic startup effect with rainbow LED chase and upbeat startup jingle.
329+
Runs in background thread to avoid blocking boot.
330+
"""
331+
try:
332+
# Startup jingle: Happy upbeat sequence (ascending scale with flourish)
333+
startup_jingle = "Startup:d=8,o=6,b=200:c,d,e,g,4c7,4e,4c7"
334+
335+
# Start the jingle
336+
AudioFlinger.play_rtttl(
337+
startup_jingle,
338+
stream_type=AudioFlinger.STREAM_NOTIFICATION,
339+
volume=60
340+
)
341+
342+
# Rainbow colors for the 5 LEDs
343+
rainbow = [
344+
(255, 0, 0), # Red
345+
(255, 128, 0), # Orange
346+
(255, 255, 0), # Yellow
347+
(0, 255, 0), # Green
348+
(0, 0, 255), # Blue
349+
]
350+
351+
# Rainbow sweep effect (3 passes, getting faster)
352+
for pass_num in range(3):
353+
for i in range(5):
354+
# Light up LEDs progressively
355+
for j in range(i + 1):
356+
LightsManager.set_led(j, *rainbow[j])
357+
LightsManager.write()
358+
time.sleep_ms(80 - pass_num * 20) # Speed up each pass
359+
360+
# Flash all LEDs bright white
361+
LightsManager.set_all(255, 255, 255)
362+
LightsManager.write()
363+
time.sleep_ms(150)
364+
365+
# Rainbow finale
366+
for i in range(5):
367+
LightsManager.set_led(i, *rainbow[i])
368+
LightsManager.write()
369+
time.sleep_ms(300)
370+
371+
# Fade out
372+
LightsManager.clear()
373+
LightsManager.write()
374+
375+
except Exception as e:
376+
print(f"Startup effect error: {e}")
377+
378+
_thread.stack_size(mpos.apps.good_stack_size())
379+
_thread.start_new_thread(startup_wow_effect, ())
380+
321381
print("boot.py finished")

0 commit comments

Comments
 (0)