remove guard against missing DAC
This commit is contained in:
parent
5b726750db
commit
33eceaf3fa
1 changed files with 20 additions and 37 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in a new issue