File tree Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -166,26 +166,25 @@ def __init__( # noqa: PLR0913, PLR0912
166166
167167 if i2c is None :
168168 i2c = board .I2C ()
169- if i2c is not False :
169+ if i2c is False :
170+ self ._dac = None
171+ else :
170172 while not i2c .try_lock ():
171173 time .sleep (0.01 )
172174 dac_present = 0x18 in i2c .scan ()
173175 i2c .unlock ()
174176
175- if i2c is not False and dac_present :
176- self ._dac = adafruit_tlv320 .TLV320DAC3100 (i2c )
177-
178- # set sample rate & bit depth
179- self ._dac .configure_clocks (sample_rate = sample_rate , bit_depth = bit_depth )
180-
181- self ._audio = (
182- audiobusio .I2SOut (board .I2S_BCLK , board .I2S_WS , board .I2S_DIN )
183- if "I2S_BCLK" in dir (board )
184- else None
185- )
177+ if dac_present :
178+ self ._dac = adafruit_tlv320 .TLV320DAC3100 (i2c )
179+ self ._dac .configure_clocks ( # set sample rate & bit depth
180+ sample_rate = sample_rate , bit_depth = bit_depth
181+ )
182+ else :
183+ self ._dac = None
186184
185+ if "I2S_BCLK" in dir (board ) and "I2S_WS" in dir (board ) and "I2S_DIN" in dir (board ):
186+ self ._audio = audiobusio .I2SOut (board .I2S_BCLK , board .I2S_WS , board .I2S_DIN )
187187 else :
188- self ._dac = None
189188 self ._audio = None
190189
191190 if safe_volume_limit < 1 or safe_volume_limit > 20 :
You can’t perform that action at this time.
0 commit comments