This commit is contained in:
RetiredWizard 2025-08-29 05:14:46 +00:00 committed by GitHub
commit 8a295b4257
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 31 deletions

View file

@ -226,7 +226,7 @@ def PyDOS():
if "_display" not in envVars.keys(): if "_display" not in envVars.keys():
if "display" in dir(Pydos_ui): if "display" in dir(Pydos_ui):
envVars["_display"] = Pydos_ui.display envVars["_display"] = Pydos_ui.display
elif "display" in dir(runtime): elif "display" in dir(runtime) and runtime.display is not None:
envVars["_display"] = runtime.display envVars["_display"] = runtime.display
elif "display" in dir(board): elif "display" in dir(board):
envVars["_display"] = board.display envVars["_display"] = board.display
@ -237,6 +237,10 @@ def PyDOS():
if envVars["_display"].root_group != displayio.CIRCUITPYTHON_TERMINAL: if envVars["_display"].root_group != displayio.CIRCUITPYTHON_TERMINAL:
envVars["_display"].root_group = displayio.CIRCUITPYTHON_TERMINAL envVars["_display"].root_group = displayio.CIRCUITPYTHON_TERMINAL
envVars["_display"].auto_refresh = True
envVars["_scrHeight"] = envVars["_display"].root_group[0].height
envVars["_scrWidth"] = envVars["_display"].root_group[0].width - 1
return return

View file

@ -1,7 +1,6 @@
# SPDX-FileCopyrightText: 2025 Tim Cocks for Adafruit Industries # SPDX-FileCopyrightText: 2025 Tim Cocks for Adafruit Industries
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import gc
import json import json
import board import board
@ -10,10 +9,8 @@ from displayio import TileGrid, Group
import adafruit_imageload import adafruit_imageload
import time import time
import math import math
import adafruit_tlv320
from audiocore import WaveFile
import audiobusio
import adafruit_pathlib as pathlib import adafruit_pathlib as pathlib
import adafruit_fruitjam
launcher_config = {} launcher_config = {}
if pathlib.Path("launcher.conf.json").exists(): if pathlib.Path("launcher.conf.json").exists():
@ -31,34 +28,22 @@ i2c = board.I2C()
while not i2c.try_lock(): while not i2c.try_lock():
time.sleep(0.01) time.sleep(0.01)
if 0x18 in i2c.scan(): if 0x18 in i2c.scan():
ltv320_present = True tlv320_present = True
else: else:
ltv320_present = False tlv320_present = False
i2c.unlock() i2c.unlock()
if ltv320_present: if tlv320_present:
dac = adafruit_tlv320.TLV320DAC3100(i2c) fjPeriphs = adafruit_fruitjam.peripherals.Peripherals()
# set sample rate & bit depth if "tlv320" in launcher_config:
dac.configure_clocks(sample_rate=11030, bit_depth=16) if launcher_config["tlv320"].get("output") == "speaker":
if "sound" in launcher_config:
if launcher_config["sound"] == "speaker":
# use speaker # use speaker
dac.speaker_output = True fjPeriphs.audio_output = "speaker"
dac.speaker_volume = -40 if "volume" in launcher_config["tlv320"]:
else: fjPeriphs.volume = launcher_config["tlv320"]["volume"]
# use headphones
dac.headphone_output = True
dac.headphone_volume = -15 # dB
else:
# default to headphones
dac.headphone_output = True
dac.headphone_volume = -15 # dB
wave_file = open("/boot_animation/ada_fruitjam_boot_jingle.wav", "rb") wave_file = "/boot_animation/ada_fruitjam_boot_jingle.wav"
wave = WaveFile(wave_file)
audio = audiobusio.I2SOut(board.I2S_BCLK, board.I2S_WS, board.I2S_DIN)
class OvershootAnimator: class OvershootAnimator:
@ -648,8 +633,8 @@ display.root_group = main_group
start_time = time.monotonic() start_time = time.monotonic()
if ltv320_present: if tlv320_present:
audio.play(wave) fjPeriphs.play_file(wave_file,False)
while True: while True:
now = time.monotonic() now = time.monotonic()
@ -696,8 +681,8 @@ while True:
if not still_going: if not still_going:
break break
if ltv320_present: if tlv320_present:
while audio.playing: while fjPeriphs.audio.playing:
pass pass
supervisor.set_next_code_file("code.py") supervisor.set_next_code_file("code.py")