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" in dir(Pydos_ui):
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
elif "display" in dir(board):
envVars["_display"] = board.display
@ -238,6 +238,10 @@ def PyDOS():
if 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
def chkPath(tstPath):

View file

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