Skip to content

Commit b6a287e

Browse files
Merge pull request #15 from BrianPugh/master
Retry logic for initial enabling of device from light_shutdown.
2 parents d6116bf + 8f2f24e commit b6a287e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

adafruit_veml7700.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,14 @@ class VEML7700:
186186

187187
def __init__(self, i2c_bus, address=0x10):
188188
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, address)
189-
self.light_shutdown = False # Enable the ambient light sensor
189+
for _ in range(3):
190+
try:
191+
self.light_shutdown = False # Enable the ambient light sensor
192+
break
193+
except OSError:
194+
pass
195+
else:
196+
raise RuntimeError("Unable to enable VEML7700 device")
190197

191198
def integration_time_value(self):
192199
"""Integration time value in integer form. Used for calculating ``resolution``."""

0 commit comments

Comments
 (0)