Skip to content

Commit 5b72675

Browse files
committed
Replace possible infinite loops with 5 second max
1 parent 986f736 commit 5b72675

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Fruit_Jam/Larsio_Paint_Music/sound_manager.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ def __init__(self, audio_output="pwm", seconds_per_eighth=0.25):
109109
din_pin = board.I2S_DIN
110110

111111
# Check if DAC is connected
112-
while not i2c.try_lock():
112+
for i in range(500): # try for 5 seconds
113+
if i2c.try_lock():
114+
break
113115
time.sleep(0.01)
114116
if 0x18 in i2c.scan():
115117
ltv320_present = True

Metro/Metro_RP2350_Chips_Challenge/definitions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020
# Check if DAC is connected
2121
i2c = board.I2C()
22-
while not i2c.try_lock():
22+
for i in range(500): # try for 5 seconds
23+
if i2c.try_lock():
24+
break
2325
time.sleep(0.01)
2426
if 0x18 in i2c.scan():
2527
ltv320_present = True

0 commit comments

Comments
 (0)