Skip to content

Commit 05b5c27

Browse files
committed
Use None as default value and allow False to disable
1 parent bb87708 commit 05b5c27

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

adafruit_fruitjam/peripherals.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class Peripherals:
140140
Using higher values can damage some speakers, change at your own risk.
141141
:param sample_rate: The sample rate to play back audio data in hertz. Default is 11025.
142142
:param bit_depth: The bits per sample of the audio data. Supports 8 and 16 bits. Default is 16.
143-
:param i2c: The I2C bus the audio DAC is connected to. Set as None to disable audio.
143+
:param i2c: The I2C bus the audio DAC is connected to. Set as False to disable audio.
144144
145145
Attributes:
146146
neopixels (NeoPxiels): The NeoPixels on the Fruit Jam board.
@@ -153,7 +153,7 @@ def __init__( # noqa: PLR0913
153153
safe_volume_limit: int = 12,
154154
sample_rate: int = 11025,
155155
bit_depth: int = 16,
156-
i2c: busio.I2C = board.I2C(),
156+
i2c: busio.I2C = None,
157157
):
158158
self.neopixels = NeoPixel(board.NEOPIXEL, 5)
159159

@@ -164,13 +164,15 @@ def __init__( # noqa: PLR0913
164164
switch.pull = Pull.UP
165165
self._buttons.append(switch)
166166

167-
if i2c is not None:
167+
if i2c is None:
168+
i2c = board.I2C()
169+
if i2c is not False:
168170
while not i2c.try_lock():
169171
time.sleep(0.01)
170172
dac_present = 0x18 in i2c.scan()
171173
i2c.unlock()
172174

173-
if i2c is not None and dac_present:
175+
if i2c is not False and dac_present:
174176
self._dac = adafruit_tlv320.TLV320DAC3100(i2c)
175177

176178
# set sample rate & bit depth

0 commit comments

Comments
 (0)