120120_BIT_POS_CONTROL_AGAIN = const (0 )
121121_BIT_MASK_CONTROL_AGAIN = const (3 )
122122
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+
123129# pylint: disable-msg=too-many-instance-attributes
124130class APDS9960 :
125131 """
@@ -195,7 +201,7 @@ def __init__(
195201 self ._write8 (_APDS9960_GCONF4 , 0 )
196202 self ._write8 (_APDS9960_GPULSE , 0 )
197203 self ._write8 (_APDS9960_ATIME , 255 )
198- self ._write8 (_APDS9960_CONTROL , 1 )
204+ self ._write8 (_APDS9960_CONTROL , 0 )
199205
200206 # Clear all non-gesture interrupts
201207 self .clear_interrupt ()
@@ -220,7 +226,7 @@ def __init__(
220226 self ._write8 (_APDS9960_GEXTH , 0x1E )
221227 # GEXPERS: 2 (4 cycles), GEXMSK: 0 (default) GFIFOTH: 2 (8 datasets)
222228 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 )
224230 self ._write8 (_APDS9960_GCONF2 , 0x41 )
225231 # GPULSE: 5 (6 pulses), GPLEN: 2 (16 us)
226232 self ._write8 (_APDS9960_GPULSE , 0x85 )
@@ -370,6 +376,30 @@ def proximity_interrupt_threshold(self, setting_tuple: Tuple[int, ...]) -> None:
370376 _APDS9960_PERS , _BIT_POS_PERS_PPERS , _BIT_MASK_PERS_PPERS , persist
371377 )
372378
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+
373403 def clear_interrupt (self ) -> None :
374404 """Clears all non-gesture interrupts.
375405
@@ -395,6 +425,30 @@ def enable_gesture(self) -> bool:
395425 def enable_gesture (self , value : bool ) -> None :
396426 self ._set_bit (_APDS9960_ENABLE , _BIT_MASK_ENABLE_GESTURE , value )
397427
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+
398452 @property
399453 def rotation (self ) -> int :
400454 """Clock-wise offset to apply to gesture results.
0 commit comments