|
123 | 123 | _BIT_POS_CONTROL_PGAIN = const(2)
|
124 | 124 | _BIT_MASK_CONTROL_PGAIN = const(0x0C)
|
125 | 125 |
|
| 126 | +_BIT_POS_GCONF2_GGAIN = const(5) |
| 127 | +_BIT_MASK_GCONF2_GGAIN = const(0x60) |
126 | 128 |
|
127 | 129 | # pylint: disable-msg=too-many-instance-attributes
|
128 | 130 | class APDS9960:
|
@@ -224,7 +226,7 @@ def __init__(
|
224 | 226 | self._write8(_APDS9960_GEXTH, 0x1E)
|
225 | 227 | # GEXPERS: 2 (4 cycles), GEXMSK: 0 (default) GFIFOTH: 2 (8 datasets)
|
226 | 228 | self._write8(_APDS9960_GCONF1, 0x82)
|
227 |
| - # GGAIN: 2 (4x), GLDRIVE: 100 mA (default), GGAIN: 1 (2x) |
| 229 | + # GGAIN: 2 (4x), GLDRIVE: 100 mA (default), GWTIME: 1 (2.8ms) |
228 | 230 | self._write8(_APDS9960_GCONF2, 0x41)
|
229 | 231 | # GPULSE: 5 (6 pulses), GPLEN: 2 (16 us)
|
230 | 232 | self._write8(_APDS9960_GPULSE, 0x85)
|
@@ -423,6 +425,30 @@ def enable_gesture(self) -> bool:
|
423 | 425 | def enable_gesture(self, value: bool) -> None:
|
424 | 426 | self._set_bit(_APDS9960_ENABLE, _BIT_MASK_ENABLE_GESTURE, value)
|
425 | 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 | + |
426 | 452 | @property
|
427 | 453 | def rotation(self) -> int:
|
428 | 454 | """Clock-wise offset to apply to gesture results.
|
|
0 commit comments