File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 69
69
_TSL2591_LUX_COEFB = 1.64
70
70
_TSL2591_LUX_COEFC = 0.59
71
71
_TSL2591_LUX_COEFD = 0.86
72
+ _TSL2591_MAX_COUNT_100MS = const (36863 ) # 0x8FFF
73
+ _TSL2591_MAX_COUNT = const (65535 ) # 0xFFFF
72
74
73
75
# User-facing constants:
74
76
GAIN_LOW = 0x00 # low gain (1x)
@@ -248,12 +250,21 @@ def lux(self):
248
250
and visible light channels.
249
251
"""
250
252
channel_0 , channel_1 = self .raw_luminosity
253
+
254
+ # Compute the atime in milliseconds
255
+ atime = 100.0 * self ._integration_time + 100.0
256
+
257
+ # Set the maximum sensor counts based on the integration time (atime) setting
258
+ if self ._integration_time == INTEGRATIONTIME_100MS :
259
+ max_counts = _TSL2591_MAX_COUNT_100MS
260
+ else :
261
+ max_counts = _TSL2591_MAX_COUNT
262
+
251
263
# Handle overflow.
252
- if channel_0 == 0xFFFF or channel_1 == 0xFFFF :
264
+ if channel_0 >= max_counts or channel_1 >= max_counts :
253
265
raise RuntimeError ('Overflow reading light channels!' )
254
266
# Calculate lux using same equation as Arduino library:
255
267
# https://github.com/adafruit/Adafruit_TSL2591_Library/blob/master/Adafruit_TSL2591.cpp
256
- atime = 100.0 * self ._integration_time + 100.0
257
268
again = 1.0
258
269
if self ._gain == GAIN_MED :
259
270
again = 25.0
You can’t perform that action at this time.
0 commit comments