@@ -302,9 +302,9 @@ def threshold_low(self) -> int:
302
302
return th_low
303
303
304
304
@threshold_low .setter
305
- def threshold_low (self , value : int ) -> None :
306
- lower = value & 0xFF
307
- upper = (value >> 8 ) & 0xFF
305
+ def threshold_low (self , val : int ) -> None :
306
+ lower = val & 0xFF
307
+ upper = (val >> 8 ) & 0xFF
308
308
self ._write_u8 (_TSL2591_AILTL , lower )
309
309
self ._write_u8 (_TSL2591_AILTH , upper )
310
310
@@ -317,9 +317,9 @@ def threshold_high(self) -> int:
317
317
return th_high
318
318
319
319
@threshold_high .setter
320
- def threshold_high (self , value : int ) -> None :
321
- lower = value & 0xFF
322
- upper = (value >> 8 ) & 0xFF
320
+ def threshold_high (self , val : int ) -> None :
321
+ lower = val & 0xFF
322
+ upper = (val >> 8 ) & 0xFF
323
323
self ._write_u8 (_TSL2591_AIHTL , lower )
324
324
self ._write_u8 (_TSL2591_AIHTH , upper )
325
325
@@ -332,9 +332,9 @@ def nopersist_threshold_low(self) -> int:
332
332
return np_th_low
333
333
334
334
@nopersist_threshold_low .setter
335
- def nopersist_threshold_low (self , value : int ) -> None :
336
- lower = value & 0xFF
337
- upper = (value >> 8 ) & 0xFF
335
+ def nopersist_threshold_low (self , val : int ) -> None :
336
+ lower = val & 0xFF
337
+ upper = (val >> 8 ) & 0xFF
338
338
self ._write_u8 (_TSL2591_NPAILTL , lower )
339
339
self ._write_u8 (_TSL2591_NPAILTH , upper )
340
340
@@ -347,22 +347,43 @@ def nopersist_threshold_high(self) -> int:
347
347
return np_th_high
348
348
349
349
@nopersist_threshold_high .setter
350
- def nopersist_threshold_high (self , value : int ) -> None :
351
- lower = value & 0xFF
352
- upper = (value >> 8 ) & 0xFF
350
+ def nopersist_threshold_high (self , val : int ) -> None :
351
+ lower = val & 0xFF
352
+ upper = (val >> 8 ) & 0xFF
353
353
self ._write_u8 (_TSL2591_NPAIHTL , lower )
354
354
self ._write_u8 (_TSL2591_NPAIHTH , upper )
355
355
356
356
@property
357
357
def persist (self ) -> int :
358
358
"""Get and set the interrupt persist filter - the number of consecutive out-of-range
359
- ALS cycles necessary to generate an interrupt."""
359
+ ALS cycles necessary to generate an interrupt. Valid persist values are 0 - 15 (inclusive),
360
+ corresponding to a preset number of cycles. Only the 4 lower bits will be used to write
361
+ to the device.
362
+ Can be a value of:
363
+ - ``0 (0000)`` - Every ALS cycle generates an interrupt.
364
+ - ``1 (0001)`` - Any value outside of threshold range.
365
+ - ``2 (0010)`` - 2 consecutive values out of range.
366
+ - ``3 (0011)`` - 3 consecutive values out of range.
367
+ - ``4 (0100)`` - 5 consecutive values out of range.
368
+ - ``5 (0101)`` - 10 consecutive values out of range.
369
+ - ``6 (0110)`` - 15 consecutive values out of range.
370
+ - ``7 (0111)`` - 20 consecutive values out of range.
371
+ - ``8 (1000)`` - 25 consecutive values out of range.
372
+ - ``9 (1001)`` - 30 consecutive values out of range.
373
+ - ``10 (1010)`` - 35 consecutive values out of range.
374
+ - ``11 (1011)`` - 40 consecutive values out of range.
375
+ - ``12 (1100)`` - 45 consecutive values out of range.
376
+ - ``13 (1101)`` - 50 consecutive values out of range.
377
+ - ``14 (1110)`` - 55 consecutive values out of range.
378
+ - ``15 (1111)`` - 60 consecutive values out of range.
379
+ """
360
380
persist = self ._read_u8 (_TSL2591_PERSIST_FILTER )
361
381
return persist & 0x0F
362
382
363
383
@persist .setter
364
- def persist (self , value : int ) -> None :
365
- persist = value & 0x0F
384
+ def persist (self , val : int ) -> None :
385
+ assert 0 <= val <= 15
386
+ persist = val & 0x0F
366
387
self ._write_u8 (_TSL2591_PERSIST_FILTER , persist )
367
388
368
389
@property
0 commit comments