Skip to content

Commit 33eceaf

Browse files
committed
remove guard against missing DAC
1 parent 5b72675 commit 33eceaf

File tree

1 file changed

+23
-40
lines changed

1 file changed

+23
-40
lines changed

Fruit_Jam/Larsio_Paint_Music/sound_manager.py

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -108,51 +108,34 @@ def __init__(self, audio_output="pwm", seconds_per_eighth=0.25):
108108
wsel_pin = board.I2S_WS
109109
din_pin = board.I2S_DIN
110110

111-
# Check if DAC is connected
112-
for i in range(500): # try for 5 seconds
113-
if i2c.try_lock():
114-
break
115-
time.sleep(0.01)
116-
if 0x18 in i2c.scan():
117-
ltv320_present = True
118-
else:
119-
ltv320_present = False
120-
i2c.unlock()
121-
122111
# Initialize TLV320
123-
if ltv320_present:
124-
self.tlv = adafruit_tlv320.TLV320DAC3100(i2c)
125-
126-
# set sample rate & bit depth
127-
self.tlv.configure_clocks(sample_rate=11025, bit_depth=16)
128-
129-
if "sound" in launcher_config:
130-
if launcher_config["sound"] == "speaker":
131-
# use speaker
132-
self.tlv.speaker_output = True
133-
self.tlv.speaker_volume = -60
134-
else:
135-
# use headphones
136-
self.tlv.headphone_output = True
137-
self.tlv.headphone_volume = -15 # dB
112+
self.tlv = adafruit_tlv320.TLV320DAC3100(i2c)
113+
114+
# set sample rate & bit depth
115+
self.tlv.configure_clocks(sample_rate=11025, bit_depth=16)
116+
117+
if "sound" in launcher_config:
118+
if launcher_config["sound"] == "speaker":
119+
# use speaker
120+
self.tlv.speaker_output = True
121+
self.tlv.speaker_volume = -60
138122
else:
139-
# default to headphones
123+
# use headphones
140124
self.tlv.headphone_output = True
141125
self.tlv.headphone_volume = -15 # dB
142-
143-
# Setup I2S audio output - important to do this AFTER configuring the DAC
144-
self.audio = audiobusio.I2SOut(
145-
bit_clock=bclck_pin,
146-
word_select=wsel_pin,
147-
data=din_pin
148-
)
149-
150-
print("TLV320 I2S DAC initialized successfully")
151-
152126
else:
153-
print("TLV320 DAC not found, falling back to PWM audio output")
154-
self.audio = audiopwmio.PWMAudioOut(board.D10)
155-
127+
# default to headphones
128+
self.tlv.headphone_output = True
129+
self.tlv.headphone_volume = -15 # dB
130+
131+
# Setup I2S audio output - important to do this AFTER configuring the DAC
132+
self.audio = audiobusio.I2SOut(
133+
bit_clock=bclck_pin,
134+
word_select=wsel_pin,
135+
data=din_pin
136+
)
137+
138+
print("TLV320 I2S DAC initialized successfully")
156139
except Exception as e:
157140
print(f"Error initializing TLV320 DAC: {e}")
158141
print("Falling back to PWM audio output")

0 commit comments

Comments
 (0)