Skip to content

Commit e427332

Browse files
committed
Modified for Issue adafruit#5 for the maxCounts to determine if the sensor overflowed
1 parent 0fa3c2e commit e427332

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

adafruit_tsl2591.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,15 @@ def lux(self):
248248
and visible light channels.
249249
"""
250250
channel_0, channel_1 = self.raw_luminosity
251+
252+
# Set the maximum sensor counts based on the atime setting
253+
if 100 == atime:
254+
maxCounts = 36863
255+
else:
256+
maxCounts = 0xFFFF
257+
251258
# Handle overflow.
252-
if channel_0 == 0xFFFF or channel_1 == 0xFFFF:
259+
if channel_0 == maxCounts or channel_1 == maxCounts:
253260
raise RuntimeError('Overflow reading light channels!')
254261
# Calculate lux using same equation as Arduino library:
255262
# https://github.com/adafruit/Adafruit_TSL2591_Library/blob/master/Adafruit_TSL2591.cpp

0 commit comments

Comments
 (0)