Skip to content

daisy::Apds9960

Module: External

Device support for APDS9960 gesture / RGB / proximity sensor. More...

#include <apds9960.h>

Public Classes

Name
struct Config

Public Types

Name
enum Result

Public Functions

Name
Apds9960()
~Apds9960()
void enable(bool en =true)
Result Init(Config config)
void SetADCIntegrationTime(uint16_t iTimeMS)
float GetADCIntegrationTime()
void SetADCGain(uint8_t aGain)
void SetGestureOffset(uint8_t offset_up, uint8_t offset_down, uint8_t offset_left, uint8_t offset_right)
void SetGestureDimensions(uint8_t dims)
void SetGestureFIFOThreshold(uint8_t thresh)
void SetGestureGain(uint8_t gain)
void SetGestureProximityThreshold(uint8_t thresh)
void Enable(bool en)
void EnableGesture(bool en)
void EnableProximity(bool en)
void EnableColor(bool en)
void SetColorInterrupt(bool en)
void SetProximityInterrupt(bool en)
void ClearInterrupt()
void ResetCounts()
void Write8(uint8_t reg, uint8_t data)
uint8_t Read8(uint8_t reg)
uint16_t Read16R(uint8_t reg)
uint8_t ReadProximity()
void SetProxGain(uint8_t pGain)
uint8_t GetProxGain()
void SetProxPulse(uint8_t pLen, uint8_t pulses)
bool GestureValid()
uint8_t ReadGesture()
void SetLED(uint8_t drive, uint8_t boost)
uint16_t CalculateColorTemperature(uint16_t r, uint16_t g, uint16_t b)
uint16_t CalculateLux(uint16_t r, uint16_t g, uint16_t b)
void SetIntLimits(uint16_t low, uint16_t high)
bool ColorDataReady()
uint16_t GetColorDataRed()
uint16_t GetColorDataGreen()
uint16_t GetColorDataBlue()
uint16_t GetColorDataClear()
void GetColorData(uint16_t * r, uint16_t * g, uint16_t * b, uint16_t * c)

Detailed Description

template <typename Transport >
class daisy::Apds9960;

Device support for APDS9960 gesture / RGB / proximity sensor.

Author: beserge

Date: December 2021

Public Types Documentation

enum Result

Enumerator Value Description
OK 0
ERR

Public Functions Documentation

function Apds9960

inline Apds9960()

function ~Apds9960

inline ~Apds9960()

function enable

void enable(
    bool en =true
)

function Init

inline Result Init(
    Config config
)

Parameters:

  • config Configuration settings

Initialize the APDS9960 device


function SetADCIntegrationTime

inline void SetADCIntegrationTime(
    uint16_t iTimeMS
)

Parameters:

  • iTimeMS Integration time

Sets the integration time for the ADC of the APDS9960, in millis


function GetADCIntegrationTime

inline float GetADCIntegrationTime()

Return: Integration time

Returns the integration time for the ADC of the APDS9960, in millis


function SetADCGain

inline void SetADCGain(
    uint8_t aGain
)

Parameters:

  • aGain Gain

Adjusts the color/ALS gain on the APDS9960 (adjusts the sensitivity to light)


function SetGestureOffset

inline void SetGestureOffset(
    uint8_t offset_up,
    uint8_t offset_down,
    uint8_t offset_left,
    uint8_t offset_right
)

Parameters:

  • offset_up Up offset
  • offset_down Down offset
  • offset_left Left offset
  • offset_right Right offset

Sets gesture sensor offset


function SetGestureDimensions

inline void SetGestureDimensions(
    uint8_t dims
)

Parameters:

  • dims Dimensions

Sets gesture dimensions


function SetGestureFIFOThreshold

inline void SetGestureFIFOThreshold(
    uint8_t thresh
)

Parameters:

  • thresh Threshold

Sets gesture FIFO Threshold


function SetGestureGain

inline void SetGestureGain(
    uint8_t gain
)

Parameters:

  • gain Gain

Sets gesture sensor gain


function SetGestureProximityThreshold

inline void SetGestureProximityThreshold(
    uint8_t thresh
)

Parameters:

  • thresh Threshold

Sets gesture sensor threshold


function Enable

inline void Enable(
    bool en
)

Parameters:

  • en Enable

Enables the device / Disables the device (putting it in lower power sleep mode)


function EnableGesture

inline void EnableGesture(
    bool en
)

Parameters:

  • en Enable

Enable gesture readings


function EnableProximity

inline void EnableProximity(
    bool en
)

Parameters:

  • en Enable

Enable proximity readings


function EnableColor

inline void EnableColor(
    bool en
)

Parameters:

  • en Enable

Enable color readings


function SetColorInterrupt

inline void SetColorInterrupt(
    bool en
)

Parameters:

  • en Enable / disable

Enables/disables color interrupt


function SetProximityInterrupt

inline void SetProximityInterrupt(
    bool en
)

Parameters:

  • en Enable / disable

Enables / Disables color interrupt


function ClearInterrupt

inline void ClearInterrupt()

Clears interrupt


function ResetCounts

inline void ResetCounts()

Resets gesture counts


function Write8

inline void Write8(
    uint8_t reg,
    uint8_t data
)

function Read8

inline uint8_t Read8(
    uint8_t reg
)

function Read16R

inline uint16_t Read16R(
    uint8_t reg
)

function ReadProximity

inline uint8_t ReadProximity()

Return: Proximity

Read proximity data


function SetProxGain

inline void SetProxGain(
    uint8_t pGain
)

Parameters:

  • pGain Gain

Adjusts the Proximity gain on the APDS9960


function GetProxGain

inline uint8_t GetProxGain()

Return: Proxmity gain

Returns the Proximity gain on the APDS9960


function SetProxPulse

inline void SetProxPulse(
    uint8_t pLen,
    uint8_t pulses
)

Parameters:

  • pLen Pulse Length
  • pulses Number of pulses

Sets number of proxmity pulses


function GestureValid

inline bool GestureValid()

Return: Status (True/False)

Returns validity status of a gesture


function ReadGesture

inline uint8_t ReadGesture()

Return: Received gesture (1,4) -> {UP, DOWN, LEFT, RIGHT}

Reads gesture

< Gesture Up

< Gesture Down

< Gesture Left

< Gesture Right


function SetLED

inline void SetLED(
    uint8_t drive,
    uint8_t boost
)

Parameters:

  • drive LED Drive (0,3) -> {100mA, 50mA, 25mA, 12.5mA}
  • boost LED Boost (0,3) -> {100%, 150%, 200%, 300%}

Set LED brightness for proximity/gesture


function CalculateColorTemperature

inline uint16_t CalculateColorTemperature(
    uint16_t r,
    uint16_t g,
    uint16_t b
)

Parameters:

  • r Red value
  • g Green value
  • b Blue value

Return: Color temperature

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


function CalculateLux

inline uint16_t CalculateLux(
    uint16_t r,
    uint16_t g,
    uint16_t b
)

Parameters:

  • r Red value
  • g Green value
  • b Blue value

Return: LUX value

Calculate ambient light values


function SetIntLimits

inline void SetIntLimits(
    uint16_t low,
    uint16_t high
)

Parameters:

  • low Low limit
  • high High limit

Sets interrupt limits


function ColorDataReady

inline bool ColorDataReady()

Return: True if color data ready, False otherwise

Returns status of color data


function GetColorDataRed

inline uint16_t GetColorDataRed()

Return: Red channel value

Reads the raw red channel value


function GetColorDataGreen

inline uint16_t GetColorDataGreen()

Return: Green channel value

Reads the raw green channel value


function GetColorDataBlue

inline uint16_t GetColorDataBlue()

Return: Blue channel value

Reads the raw blue channel value


function GetColorDataClear

inline uint16_t GetColorDataClear()

Return: Clear channel value

Reads the raw clear channel value


function GetColorData

inline void GetColorData(
    uint16_t * r,
    uint16_t * g,
    uint16_t * b,
    uint16_t * c
)

Parameters:

  • ***r** Red value
  • ***g** Green value
  • ***b** Blue value
  • ***c** Clear channel value

Reads the raw red, green, blue and clear channel values

---

Updated on 2024-01-03 at 19:41:01 +0000