Merge pull request #40 from RetiredWizard/fruitjamaudio

Skip audio output if DAC not attached
This commit is contained in:
foamyguy 2025-08-04 10:37:44 -05:00 committed by GitHub
commit f3e9e23c47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,6 +20,16 @@ display = supervisor.runtime.display
display.auto_refresh = False
i2c = board.I2C()
# Check if DAC is connected
while not i2c.try_lock():
time.sleep(0.01)
if 0x18 in i2c.scan():
ltv320_present = True
else:
ltv320_present = False
i2c.unlock()
if ltv320_present:
dac = adafruit_tlv320.TLV320DAC3100(i2c)
# set sample rate & bit depth
@ -621,6 +631,7 @@ display.root_group = main_group
start_time = time.monotonic()
if ltv320_present:
audio.play(wave)
while True:
@ -668,6 +679,7 @@ while True:
if not still_going:
break
if ltv320_present:
while audio.playing:
pass