Adafruit TCS34725 Library
Public Member Functions | List of all members
Adafruit_TCS34725 Class Reference

Class that stores state and functions for interacting with TCS34725 Color Sensor. More...

#include <Adafruit_TCS34725.h>

Public Member Functions

 Adafruit_TCS34725 (uint8_t=TCS34725_INTEGRATIONTIME_2_4MS, tcs34725Gain_t=TCS34725_GAIN_1X)
 Constructor. More...
 
boolean begin (uint8_t addr=TCS34725_ADDRESS, TwoWire *theWire=&Wire)
 Initializes I2C and configures the sensor. More...
 
boolean init ()
 Part of begin. More...
 
void setIntegrationTime (uint8_t it)
 Sets the integration time for the TC34725. More...
 
void setGain (tcs34725Gain_t gain)
 Adjusts the gain on the TCS34725. More...
 
void getRawData (uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *c)
 Reads the raw red, green, blue and clear channel values. More...
 
void getRGB (float *r, float *g, float *b)
 Read the RGB color detected by the sensor. More...
 
void getRawDataOneShot (uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *c)
 Reads the raw red, green, blue and clear channel values in one-shot mode (e.g., wakes from sleep, takes measurement, enters sleep) More...
 
uint16_t calculateColorTemperature (uint16_t r, uint16_t g, uint16_t b)
 Converts the raw R/G/B values to color temperature in degrees Kelvin. More...
 
uint16_t calculateColorTemperature_dn40 (uint16_t r, uint16_t g, uint16_t b, uint16_t c)
 Converts the raw R/G/B values to color temperature in degrees Kelvin using the algorithm described in DN40 from Taos (now AMS). More...
 
uint16_t calculateLux (uint16_t r, uint16_t g, uint16_t b)
 Converts the raw R/G/B values to lux. More...
 
void write8 (uint8_t reg, uint8_t value)
 Writes a register and an 8 bit value over I2C. More...
 
uint8_t read8 (uint8_t reg)
 Reads an 8 bit value over I2C. More...
 
uint16_t read16 (uint8_t reg)
 Reads a 16 bit values over I2C. More...
 
void setInterrupt (boolean flag)
 Sets interrupt for TCS34725. More...
 
void clearInterrupt ()
 Clears inerrupt for TCS34725.
 
void setIntLimits (uint16_t l, uint16_t h)
 Sets inerrupt limits. More...
 
void enable ()
 Enables the device.
 
void disable ()
 Disables the device (putting it in lower power sleep mode)
 

Detailed Description

Class that stores state and functions for interacting with TCS34725 Color Sensor.

Constructor & Destructor Documentation

◆ Adafruit_TCS34725()

Adafruit_TCS34725::Adafruit_TCS34725 ( uint8_t  it = TCS34725_INTEGRATIONTIME_2_4MS,
tcs34725Gain_t  gain = TCS34725_GAIN_1X 
)

Constructor.

Parameters
itIntegration Time
gainGain

Member Function Documentation

◆ begin()

boolean Adafruit_TCS34725::begin ( uint8_t  addr = TCS34725_ADDRESS,
TwoWire *  theWire = &Wire 
)

Initializes I2C and configures the sensor.

Parameters
addri2c address
*theWireThe Wire object
Returns
True if initialization was successful, otherwise false.

◆ init()

boolean Adafruit_TCS34725::init ( )

Part of begin.

Returns
True if initialization was successful, otherwise false.

◆ setIntegrationTime()

void Adafruit_TCS34725::setIntegrationTime ( uint8_t  it)

Sets the integration time for the TC34725.

Parameters
itIntegration Time

◆ setGain()

void Adafruit_TCS34725::setGain ( tcs34725Gain_t  gain)

Adjusts the gain on the TCS34725.

Parameters
gainGain (sensitivity to light)

◆ getRawData()

void Adafruit_TCS34725::getRawData ( uint16_t *  r,
uint16_t *  g,
uint16_t *  b,
uint16_t *  c 
)

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

Parameters
*rRed value
*gGreen value
*bBlue value
*cClear channel value

◆ getRGB()

void Adafruit_TCS34725::getRGB ( float *  r,
float *  g,
float *  b 
)

Read the RGB color detected by the sensor.

Parameters
*rRed value normalized to 0-255
*gGreen value normalized to 0-255
*bBlue value normalized to 0-255

◆ getRawDataOneShot()

void Adafruit_TCS34725::getRawDataOneShot ( uint16_t *  r,
uint16_t *  g,
uint16_t *  b,
uint16_t *  c 
)

Reads the raw red, green, blue and clear channel values in one-shot mode (e.g., wakes from sleep, takes measurement, enters sleep)

Parameters
*rRed value
*gGreen value
*bBlue value
*cClear channel value

◆ calculateColorTemperature()

uint16_t Adafruit_TCS34725::calculateColorTemperature ( uint16_t  r,
uint16_t  g,
uint16_t  b 
)

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

Parameters
rRed value
gGreen value
bBlue value
Returns
Color temperature in degrees Kelvin

◆ calculateColorTemperature_dn40()

uint16_t Adafruit_TCS34725::calculateColorTemperature_dn40 ( uint16_t  r,
uint16_t  g,
uint16_t  b,
uint16_t  c 
)

Converts the raw R/G/B values to color temperature in degrees Kelvin using the algorithm described in DN40 from Taos (now AMS).

Parameters
rRed value
gGreen value
bBlue value
cClear channel value
Returns
Color temperature in degrees Kelvin

Color temp coefficient.

Color temp offset.

◆ calculateLux()

uint16_t Adafruit_TCS34725::calculateLux ( uint16_t  r,
uint16_t  g,
uint16_t  b 
)

Converts the raw R/G/B values to lux.

Parameters
rRed value
gGreen value
bBlue value
Returns
Lux value

◆ write8()

void Adafruit_TCS34725::write8 ( uint8_t  reg,
uint8_t  value 
)

Writes a register and an 8 bit value over I2C.

Parameters
reg
value

◆ read8()

uint8_t Adafruit_TCS34725::read8 ( uint8_t  reg)

Reads an 8 bit value over I2C.

Parameters
reg
Returns
value

◆ read16()

uint16_t Adafruit_TCS34725::read16 ( uint8_t  reg)

Reads a 16 bit values over I2C.

Parameters
reg
Returns
value

◆ setInterrupt()

void Adafruit_TCS34725::setInterrupt ( boolean  i)

Sets interrupt for TCS34725.

Parameters
iInterrupt (True/False)

◆ setIntLimits()

void Adafruit_TCS34725::setIntLimits ( uint16_t  low,
uint16_t  high 
)

Sets inerrupt limits.

Parameters
lowLow limit
highHigh limit

The documentation for this class was generated from the following files: