@@ -95,6 +95,8 @@ def __init__(self, i2c, address=0x29):
95
95
self ._device = i2c_device .I2CDevice (i2c , address )
96
96
self ._active = False
97
97
self .integration_time = 2.4
98
+ self ._glass_attenuation = None
99
+ self .glass_attenuation = 1.0
98
100
# Check sensor ID is expectd value.
99
101
sensor_id = self ._read_u8 (_REGISTER_SENSORID )
100
102
if sensor_id not in (0x44 , 0x10 ):
@@ -247,13 +249,13 @@ def _temperature_and_lux_dn40(self):
247
249
R , G , B , C = self .color_raw
248
250
249
251
# Device specific values (DN40 Table 1 in Appendix I)
250
- GA = 1.0 # Glass Attenuation Factor
251
- DF = 310.0 # Device Factor
252
- R_Coef = 0.136 # |
253
- G_Coef = 1.0 # | used in lux computation
254
- B_Coef = - 0.444 # |
255
- CT_Coef = 3810 # Color Temperature Coefficient
256
- CT_Offset = 1391 # Color Temperatuer Offset
252
+ GA = self . glass_attenuation # Glass Attenuation Factor
253
+ DF = 310.0 # Device Factor
254
+ R_Coef = 0.136 # |
255
+ G_Coef = 1.0 # | used in lux computation
256
+ B_Coef = - 0.444 # |
257
+ CT_Coef = 3810 # Color Temperature Coefficient
258
+ CT_Offset = 1391 # Color Temperatuer Offset
257
259
258
260
# Analog/Digital saturation (DN40 3.5)
259
261
SATURATION = 65535 if 256 - ATIME > 63 else 1024 * (256 - ATIME )
@@ -282,6 +284,23 @@ def _temperature_and_lux_dn40(self):
282
284
283
285
return lux , CT
284
286
287
+ @property
288
+ def glass_attenuation (self ):
289
+ """The Glass Attenuation (FA) factor used to compensate for lower light
290
+ levels at the device due to the possible presence of glass. The GA is
291
+ the inverse of the glass transmissivity (T), so GA = 1/T. A transmissivity
292
+ of 50% gives GA = 1 / 0.50 = 2. If no glass is present, use GA = 1.
293
+ See Application Note: DN40-Rev 1.0 – Lux and CCT Calculations using
294
+ ams Color Sensors for more details.
295
+ """
296
+ return self ._glass_attenuation
297
+
298
+ @glass_attenuation .setter
299
+ def glass_attenuation (self , value ):
300
+ if value < 1 :
301
+ raise ValueError ("Glass attenuation factor must be at least 1." )
302
+ self ._glass_attenuation = value
303
+
285
304
def _valid (self ):
286
305
# Check if the status bit is set and the chip is ready.
287
306
return bool (self ._read_u8 (_REGISTER_STATUS ) & 0x01 )
0 commit comments