From 33eceaf3fa353d770a03099c71cd7fb36bed0f37 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Fri, 15 Aug 2025 18:29:55 -0400 Subject: [PATCH] remove guard against missing DAC --- Fruit_Jam/Larsio_Paint_Music/sound_manager.py | 57 +++++++------------ 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/Fruit_Jam/Larsio_Paint_Music/sound_manager.py b/Fruit_Jam/Larsio_Paint_Music/sound_manager.py index 1702d5b29..5a11be571 100755 --- a/Fruit_Jam/Larsio_Paint_Music/sound_manager.py +++ b/Fruit_Jam/Larsio_Paint_Music/sound_manager.py @@ -108,51 +108,34 @@ class SoundManager: wsel_pin = board.I2S_WS din_pin = board.I2S_DIN - # Check if DAC is connected - for i in range(500): # try for 5 seconds - if i2c.try_lock(): - break - time.sleep(0.01) - if 0x18 in i2c.scan(): - ltv320_present = True - else: - ltv320_present = False - i2c.unlock() - # Initialize TLV320 - if ltv320_present: - self.tlv = adafruit_tlv320.TLV320DAC3100(i2c) + self.tlv = adafruit_tlv320.TLV320DAC3100(i2c) - # set sample rate & bit depth - self.tlv.configure_clocks(sample_rate=11025, bit_depth=16) + # set sample rate & bit depth + self.tlv.configure_clocks(sample_rate=11025, bit_depth=16) - if "sound" in launcher_config: - if launcher_config["sound"] == "speaker": - # use speaker - self.tlv.speaker_output = True - self.tlv.speaker_volume = -60 - else: - # use headphones - self.tlv.headphone_output = True - self.tlv.headphone_volume = -15 # dB + if "sound" in launcher_config: + if launcher_config["sound"] == "speaker": + # use speaker + self.tlv.speaker_output = True + self.tlv.speaker_volume = -60 else: - # default to headphones + # use headphones self.tlv.headphone_output = True self.tlv.headphone_volume = -15 # dB - - # Setup I2S audio output - important to do this AFTER configuring the DAC - self.audio = audiobusio.I2SOut( - bit_clock=bclck_pin, - word_select=wsel_pin, - data=din_pin - ) - - print("TLV320 I2S DAC initialized successfully") - else: - print("TLV320 DAC not found, falling back to PWM audio output") - self.audio = audiopwmio.PWMAudioOut(board.D10) + # default to headphones + self.tlv.headphone_output = True + self.tlv.headphone_volume = -15 # dB + # Setup I2S audio output - important to do this AFTER configuring the DAC + self.audio = audiobusio.I2SOut( + bit_clock=bclck_pin, + word_select=wsel_pin, + data=din_pin + ) + + print("TLV320 I2S DAC initialized successfully") except Exception as e: print(f"Error initializing TLV320 DAC: {e}") print("Falling back to PWM audio output")