|
109 | 109 | _BIT_MASK_ENABLE_PROX = const(0x04)
|
110 | 110 | _BIT_MASK_ENABLE_PROX_INT = const(0x20)
|
111 | 111 | _BIT_MASK_ENABLE_GESTURE = const(0x40)
|
| 112 | +_BIT_MASK_STATUS_AVALID = const(0x01) |
112 | 113 | _BIT_MASK_STATUS_GINT = const(0x04)
|
113 | 114 | _BIT_MASK_GSTATUS_GFOV = const(0x02)
|
114 | 115 | _BIT_MASK_GCONF4_GFIFO_CLR = const(0x04)
|
@@ -217,9 +218,9 @@ def __init__(
|
217 | 218 | self._write8(_APDS9960_GCONF2, 0x41)
|
218 | 219 | # GPULSE: 5 (6 pulses), GPLEN: 2 (16 us)
|
219 | 220 | self._write8(_APDS9960_GPULSE, 0x85)
|
220 |
| - # ATIME: 182 (200ms color integration time) |
221 |
| - self._write8(_APDS9960_ATIME, 0xB6) |
222 |
| - # AGAIN: 1 (4x color gain), PGAIN: 0 (1x) |
| 221 | + # ATIME: 255 (712ms color integration time, max count of 65535) |
| 222 | + self._write8(_APDS9960_ATIME, 0x00) |
| 223 | + # AGAIN: 1 (4x color gain), PGAIN: 0 (1x) (default), LDRIVE: 0 (100 mA) (default) |
223 | 224 | self._write8(_APDS9960_CONTROL, 0x01)
|
224 | 225 |
|
225 | 226 | ## BOARD
|
@@ -318,6 +319,15 @@ def enable_color(self, value: bool) -> None:
|
318 | 319 | """If true, the sensor's color/light engine is enabled"""
|
319 | 320 | self._set_bit(_APDS9960_ENABLE, _BIT_MASK_ENABLE_COLOR, value)
|
320 | 321 |
|
| 322 | + @property |
| 323 | + def color_data_ready(self) -> int: |
| 324 | + """Color data ready flag. |
| 325 | +
|
| 326 | + Returns ``0`` if no new data is ready, ``1`` if new data is ready. |
| 327 | +
|
| 328 | + This flag is reset when `color_data` is read.""" |
| 329 | + return self._get_bit(_APDS9960_STATUS, _BIT_MASK_STATUS_AVALID) |
| 330 | + |
321 | 331 | ## PROXIMITY
|
322 | 332 | @property
|
323 | 333 | def proximity(self) -> int:
|
@@ -480,14 +490,17 @@ def gesture(self) -> int:
|
480 | 490 | return gesture_found
|
481 | 491 |
|
482 | 492 | ## COLOR
|
483 |
| - @property |
484 |
| - def color_data_ready(self) -> int: |
485 |
| - """Color data ready flag. Zero if not ready, 1 if ready""" |
486 |
| - return self._read8(_APDS9960_STATUS) & 0x01 |
487 |
| - |
488 | 493 | @property
|
489 | 494 | def color_data(self) -> Tuple[int, int, int, int]:
|
490 |
| - """Tuple containing r, g, b, c values""" |
| 495 | + """Tuple containing red, green, blue, and clear light intensity values detected by the |
| 496 | + sensor during the latest color/light engine run. |
| 497 | +
|
| 498 | + Each value is a 16-bit integer with a possible value of ``0`` to ``65535``. |
| 499 | +
|
| 500 | + .. hint:: Testing with and tuning `color_gain` and `color_integration_time` values will |
| 501 | + likely be required to get useful color results. Optimum values for these will depend |
| 502 | + largely on the implementation details such as sensor positioning, illumination intensity |
| 503 | + and color temperature, reflectivity of the object(s) being measured, etc.""" |
491 | 504 | return (
|
492 | 505 | self._color_data16(_APDS9960_CDATAL + 2),
|
493 | 506 | self._color_data16(_APDS9960_CDATAL + 4),
|
|
0 commit comments