Skip to content

Commit 180b8c6

Browse files
committed
add setter/getter for proximity-gain
1 parent fc31dc2 commit 180b8c6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

adafruit_apds9960/apds9960.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@
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+
123127
# pylint: disable-msg=too-many-instance-attributes
124128
class APDS9960:
125129
"""
@@ -370,6 +374,30 @@ def proximity_interrupt_threshold(self, setting_tuple: Tuple[int, ...]) -> None:
370374
_APDS9960_PERS, _BIT_POS_PERS_PPERS, _BIT_MASK_PERS_PPERS, persist
371375
)
372376

377+
@property
378+
def proximity_gain(self) -> int:
379+
"""Proximity sensor gain value.
380+
381+
This sets the gain multiplier for the ADC during proximity engine operations.
382+
383+
.. csv-table::
384+
:header: "``proximity_gain``", "Gain Multiplier", "Note"
385+
386+
0, "1x", "Power-on Default"
387+
1, "2x", ""
388+
2, "4x", ""
389+
3, "8x", ""
390+
"""
391+
return self._get_bits(
392+
_APDS9960_CONTROL, _BIT_POS_CONTROL_PGAIN, _BIT_MASK_CONTROL_PGAIN
393+
)
394+
395+
@proximity_gain.setter
396+
def proximity_gain(self, value: int) -> None:
397+
self._set_bits(
398+
_APDS9960_CONTROL, _BIT_POS_CONTROL_PGAIN, _BIT_MASK_CONTROL_PGAIN, value
399+
)
400+
373401
def clear_interrupt(self) -> None:
374402
"""Clears all non-gesture interrupts.
375403

0 commit comments

Comments
 (0)