Skip to content

Class daisy::Apds9960

template <typename Transport>

ClassList > daisy > Apds9960

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

  • #include <apds9960.h>

Classes

Type Name
struct Config

Public Types

Type Name
enum Result

Public Functions

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

Detailed Description

Author:

beserge

Date:

December 2021

Public Types Documentation

enum Result

enum daisy::Apds9960::Result {
    OK = 0,
    ERR
};

Public Functions Documentation

function Apds9960

inline daisy::Apds9960::Apds9960 () 

function CalculateColorTemperature

inline uint16_t daisy::Apds9960::CalculateColorTemperature (
    uint16_t r,
    uint16_t g,
    uint16_t b
) 

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

Parameters:

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

Returns:

Color temperature


function CalculateLux

inline uint16_t daisy::Apds9960::CalculateLux (
    uint16_t r,
    uint16_t g,
    uint16_t b
) 

Calculate ambient light values

Parameters:

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

Returns:

LUX value


function ClearInterrupt

inline void daisy::Apds9960::ClearInterrupt () 

Clears interrupt


function ColorDataReady

inline bool daisy::Apds9960::ColorDataReady () 

Returns status of color data

Returns:

True if color data ready, False otherwise


function Enable

inline void daisy::Apds9960::Enable (
    bool en
) 

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

Parameters:

  • en Enable

function EnableColor

inline void daisy::Apds9960::EnableColor (
    bool en
) 

Enable color readings

Parameters:

  • en Enable

function EnableGesture

inline void daisy::Apds9960::EnableGesture (
    bool en
) 

Enable gesture readings

Parameters:

  • en Enable

function EnableProximity

inline void daisy::Apds9960::EnableProximity (
    bool en
) 

Enable proximity readings

Parameters:

  • en Enable

function GestureValid

inline bool daisy::Apds9960::GestureValid () 

Returns validity status of a gesture

Returns:

Status (True/False)


function GetADCIntegrationTime

inline float daisy::Apds9960::GetADCIntegrationTime () 

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

Returns:

Integration time


function GetColorData

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

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

Parameters:

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

function GetColorDataBlue

inline uint16_t daisy::Apds9960::GetColorDataBlue () 

Reads the raw blue channel value

Returns:

Blue channel value


function GetColorDataClear

inline uint16_t daisy::Apds9960::GetColorDataClear () 

Reads the raw clear channel value

Returns:

Clear channel value


function GetColorDataGreen

inline uint16_t daisy::Apds9960::GetColorDataGreen () 

Reads the raw green channel value

Returns:

Green channel value


function GetColorDataRed

inline uint16_t daisy::Apds9960::GetColorDataRed () 

Reads the raw red channel value

Returns:

Red channel value


function GetProxGain

inline uint8_t daisy::Apds9960::GetProxGain () 

Returns the Proximity gain on the APDS9960

Returns:

Proxmity gain


function Init

inline Result daisy::Apds9960::Init (
    Config config
) 

Initialize the APDS9960 device

Parameters:

  • config Configuration settings

function Read16R

inline uint16_t daisy::Apds9960::Read16R (
    uint8_t reg
) 

function Read8

inline uint8_t daisy::Apds9960::Read8 (
    uint8_t reg
) 

function ReadGesture

inline uint8_t daisy::Apds9960::ReadGesture () 

Reads gesture

Returns:

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


function ReadProximity

inline uint8_t daisy::Apds9960::ReadProximity () 

Read proximity data

Returns:

Proximity


function ResetCounts

inline void daisy::Apds9960::ResetCounts () 

Resets gesture counts


function SetADCGain

inline void daisy::Apds9960::SetADCGain (
    uint8_t aGain
) 

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

Parameters:

  • aGain Gain

function SetADCIntegrationTime

inline void daisy::Apds9960::SetADCIntegrationTime (
    uint16_t iTimeMS
) 

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

Parameters:

  • iTimeMS Integration time

function SetColorInterrupt

inline void daisy::Apds9960::SetColorInterrupt (
    bool en
) 

Enables/disables color interrupt

Parameters:

  • en Enable / disable

function SetGestureDimensions

inline void daisy::Apds9960::SetGestureDimensions (
    uint8_t dims
) 

Sets gesture dimensions

Parameters:

  • dims Dimensions

function SetGestureFIFOThreshold

inline void daisy::Apds9960::SetGestureFIFOThreshold (
    uint8_t thresh
) 

Sets gesture FIFO Threshold

Parameters:

  • thresh Threshold

function SetGestureGain

inline void daisy::Apds9960::SetGestureGain (
    uint8_t gain
) 

Sets gesture sensor gain

Parameters:

  • gain Gain

function SetGestureOffset

inline void daisy::Apds9960::SetGestureOffset (
    uint8_t offset_up,
    uint8_t offset_down,
    uint8_t offset_left,
    uint8_t offset_right
) 

Sets gesture sensor offset

Parameters:

  • offset_up Up offset

  • offset_down Down offset

  • offset_left Left offset
  • offset_right Right offset

function SetGestureProximityThreshold

inline void daisy::Apds9960::SetGestureProximityThreshold (
    uint8_t thresh
) 

Sets gesture sensor threshold

Parameters:

  • thresh Threshold

function SetIntLimits

inline void daisy::Apds9960::SetIntLimits (
    uint16_t low,
    uint16_t high
) 

Sets interrupt limits

Parameters:

  • low Low limit
  • high High limit

function SetLED

inline void daisy::Apds9960::SetLED (
    uint8_t drive,
    uint8_t boost
) 

Set LED brightness for proximity/gesture

Parameters:

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

function SetProxGain

inline void daisy::Apds9960::SetProxGain (
    uint8_t pGain
) 

Adjusts the Proximity gain on the APDS9960

Parameters:

  • pGain Gain

function SetProxPulse

inline void daisy::Apds9960::SetProxPulse (
    uint8_t pLen,
    uint8_t pulses
) 

Sets number of proxmity pulses

Parameters:

  • pLen Pulse Length
  • pulses Number of pulses

function SetProximityInterrupt

inline void daisy::Apds9960::SetProximityInterrupt (
    bool en
) 

Enables / Disables color interrupt

Parameters:

  • en Enable / disable

function Write8

inline void daisy::Apds9960::Write8 (
    uint8_t reg,
    uint8_t data
) 

function enable

void daisy::Apds9960::enable (
    bool en=true
) 

function ~Apds9960

inline daisy::Apds9960::~Apds9960 () 


The documentation for this class was generated from the following file external-docs/libDaisy/src/dev/apds9960.h