APDS9960

Driver class for the APDS9960 board. Supports gesture, proximity, and color detection.

  • Author(s): Michael McWethy

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_apds9960.apds9960.APDS9960(i2c: busio.I2C, *, address: int = 57, integration_time: int = 1, gain: int = 1, rotation: int = 0)[source]

APDS9900 provide basic driver services for the ASDS9960 breakout board

Parameters
  • i2c (I2C) – The I2C bus the ASDS9960 is connected to

  • address (int) – The I2C device address. Defaults to 0x39

  • integration_time (int) – integration time. Defaults to 0x01

  • gain (int) – Device gain. Defaults to 0x01

  • rotation (int) – rotation of the device. Defaults to 0

Quickstart: Importing and using the APDS9960

Here is an example of using the APDS9960 class. First you will need to import the libraries to use the sensor

import board
from adafruit_apds9960.apds9960 import APDS9960

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()   # uses board.SCL and board.SDA
apds = APDS9960(i2c)

Now you have access to the sensor.proximity attribute

proximity = apds.proximity
clear_interrupt() None[source]

Clear all interrupts

property color_data: Tuple[int, int, int, int]

Tuple containing r, g, b, c values

property color_data_ready: int

Color data ready flag. zero if not ready, 1 is ready

color_gain

Color gain value

enable

Board enable. True to enable, False to disable

enable_color

Color detection enable flag. True when color detection is enabled, else False

property enable_gesture: bool

Gesture detection enable flag. True to enable, False to disable. Note that when disabled, gesture mode is turned off

enable_proximity

Enable of proximity mode

enable_proximity_interrupt

Proximity interrupt enable flag. True if enabled, False to disable

gesture() int[source]

Returns gesture code if detected. =0 if no gesture detected =1 if an UP, =2 if a DOWN, =3 if an LEFT, =4 if a RIGHT

property gesture_dimensions: int

Gesture dimension value: range 0-3

gesture_fifo_threshold

Gesture fifo threshold value: range 0-3

gesture_gain

Gesture gain value: range 0-3

property gesture_proximity_threshold: int

Proximity threshold value: range 0-255

property integration_time: int

Proximity integration time: range 0-255

property proximity: int

Proximity value: range 0-255

property proximity_interrupt_threshold: Tuple[int, int, int]

Tuple containing low and high threshold followed by the proximity interrupt persistance. When setting the proximity interrupt threshold values using a tuple of zero to three values: low threshold, high threshold, persistance. persistance defaults to 4 if not provided

rotated_gesture(original_gesture: int) int[source]

Applies rotation offset to the given gesture direction and returns the result

property rotation: int

Gesture rotation offset. Acceptable values are 0, 90, 180, 270.

colorutility

Helper functions for color calculations

  • Author(s): Michael McWethy

adafruit_apds9960.colorutility.calculate_color_temperature(r: int, g: int, b: int) float[source]

Converts the raw R/G/B values to color temperature in degrees Kelvin

adafruit_apds9960.colorutility.calculate_lux(r: int, g: int, b: int) float[source]

Calculate ambient light values