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, *, interrupt_pin=None, address=57, integration_time=1, gain=1, rotation=0)[source]

APDS9900 provide basic driver services for the ASDS9960 breakout board

Parameters:
  • i2c (I2C) – The I2C bus the BME280 is connected to
  • interrupt_pin (Pin) – Interrupt pin. Defaults to None
  • 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()[source]

Clear all interrupts

color_data

Tuple containing r, g, b, c values

color_data_ready

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

enable_gesture

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()[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

gesture_dimensions

Gesture dimension value: range 0-3

gesture_fifo_threshold

Gesture fifo threshold value: range 0-3

gesture_gain

Gesture gain value: range 0-3

gesture_proximity_threshold

Proximity threshold value: range 0-255

integration_time

Proximity integration time: range 0-255

proximity

Proximity value: range 0-255

proximity_interrupt_threshold

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)[source]

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

rotation

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, g, b)[source]

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

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

Calculate ambient light values