Skip to content

Commit 5c59c04

Browse files
committed
Add guard for boards without I2C defined
1 parent 118806a commit 5c59c04

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

Metro/Metro_RP2350_Chips_Challenge/definitions.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@
1818
launcher_config = json.load(f)
1919

2020
# Check if DAC is connected
21-
i2c = board.I2C()
22-
for i in range(500): # try for 5 seconds
23-
if i2c.try_lock():
24-
break
25-
time.sleep(0.01)
26-
if 0x18 in i2c.scan():
27-
ltv320_present = True
21+
if "I2C" in dir(board):
22+
i2c = board.I2C()
23+
for i in range(500): # try for 5 seconds
24+
if i2c.try_lock():
25+
break
26+
time.sleep(0.01)
27+
if 0x18 in i2c.scan():
28+
ltv320_present = True
29+
else:
30+
ltv320_present = False
31+
i2c.unlock()
2832
else:
2933
ltv320_present = False
30-
i2c.unlock()
3134

3235
if ltv320_present:
3336
dac = adafruit_tlv320.TLV320DAC3100(i2c)

0 commit comments

Comments
 (0)