120
120
_BIT_POS_CONTROL_AGAIN = const (0 )
121
121
_BIT_MASK_CONTROL_AGAIN = const (3 )
122
122
123
+ _BIT_POS_CONTROL_PGAIN = const (2 )
124
+ _BIT_MASK_CONTROL_PGAIN = const (0x0C )
125
+
126
+ _BIT_POS_GCONF2_GGAIN = const (5 )
127
+ _BIT_MASK_GCONF2_GGAIN = const (0x60 )
128
+
123
129
# pylint: disable-msg=too-many-instance-attributes
124
130
class APDS9960 :
125
131
"""
@@ -195,7 +201,7 @@ def __init__(
195
201
self ._write8 (_APDS9960_GCONF4 , 0 )
196
202
self ._write8 (_APDS9960_GPULSE , 0 )
197
203
self ._write8 (_APDS9960_ATIME , 255 )
198
- self ._write8 (_APDS9960_CONTROL , 1 )
204
+ self ._write8 (_APDS9960_CONTROL , 0 )
199
205
200
206
# Clear all non-gesture interrupts
201
207
self .clear_interrupt ()
@@ -220,7 +226,7 @@ def __init__(
220
226
self ._write8 (_APDS9960_GEXTH , 0x1E )
221
227
# GEXPERS: 2 (4 cycles), GEXMSK: 0 (default) GFIFOTH: 2 (8 datasets)
222
228
self ._write8 (_APDS9960_GCONF1 , 0x82 )
223
- # GGAIN: 2 (4x), GLDRIVE: 100 mA (default), GGAIN : 1 (2x )
229
+ # GGAIN: 2 (4x), GLDRIVE: 100 mA (default), GWTIME : 1 (2.8ms )
224
230
self ._write8 (_APDS9960_GCONF2 , 0x41 )
225
231
# GPULSE: 5 (6 pulses), GPLEN: 2 (16 us)
226
232
self ._write8 (_APDS9960_GPULSE , 0x85 )
@@ -370,6 +376,30 @@ def proximity_interrupt_threshold(self, setting_tuple: Tuple[int, ...]) -> None:
370
376
_APDS9960_PERS , _BIT_POS_PERS_PPERS , _BIT_MASK_PERS_PPERS , persist
371
377
)
372
378
379
+ @property
380
+ def proximity_gain (self ) -> int :
381
+ """Proximity sensor gain value.
382
+
383
+ This sets the gain multiplier for the ADC during proximity engine operations.
384
+
385
+ .. csv-table::
386
+ :header: "``proximity_gain``", "Gain Multiplier", "Note"
387
+
388
+ 0, "1x", "Power-on Default"
389
+ 1, "2x", ""
390
+ 2, "4x", ""
391
+ 3, "8x", ""
392
+ """
393
+ return self ._get_bits (
394
+ _APDS9960_CONTROL , _BIT_POS_CONTROL_PGAIN , _BIT_MASK_CONTROL_PGAIN
395
+ )
396
+
397
+ @proximity_gain .setter
398
+ def proximity_gain (self , value : int ) -> None :
399
+ self ._set_bits (
400
+ _APDS9960_CONTROL , _BIT_POS_CONTROL_PGAIN , _BIT_MASK_CONTROL_PGAIN , value
401
+ )
402
+
373
403
def clear_interrupt (self ) -> None :
374
404
"""Clears all non-gesture interrupts.
375
405
@@ -395,6 +425,30 @@ def enable_gesture(self) -> bool:
395
425
def enable_gesture (self , value : bool ) -> None :
396
426
self ._set_bit (_APDS9960_ENABLE , _BIT_MASK_ENABLE_GESTURE , value )
397
427
428
+ @property
429
+ def gesture_gain (self ) -> int :
430
+ """Gesture mode gain value.
431
+
432
+ This sets the gain multiplier for the ADC during gesture engine operations.
433
+
434
+ .. csv-table::
435
+ :header: "``gesture_gain``", "Gain Multiplier", "Note"
436
+
437
+ 0, "1x", "Power-on Default"
438
+ 1, "2x", ""
439
+ 2, "4x", "Driver Default"
440
+ 3, "8x", ""
441
+ """
442
+ return self ._get_bits (
443
+ _APDS9960_GCONF2 , _BIT_POS_GCONF2_GGAIN , _BIT_MASK_GCONF2_GGAIN
444
+ )
445
+
446
+ @gesture_gain .setter
447
+ def gesture_gain (self , value : int ) -> None :
448
+ self ._set_bits (
449
+ _APDS9960_GCONF2 , _BIT_POS_GCONF2_GGAIN , _BIT_MASK_GCONF2_GGAIN , value
450
+ )
451
+
398
452
@property
399
453
def rotation (self ) -> int :
400
454
"""Clock-wise offset to apply to gesture results.
0 commit comments