42 #include <Adafruit_I2CDevice.h> 44 #define TCS34725_ADDRESS (0x29) 45 #define TCS34725_COMMAND_BIT (0x80) 46 #define TCS34725_ENABLE (0x00) 47 #define TCS34725_ENABLE_AIEN (0x10) 48 #define TCS34725_ENABLE_WEN \ 50 #define TCS34725_ENABLE_AEN \ 52 #define TCS34725_ENABLE_PON \ 55 #define TCS34725_ATIME (0x01) 56 #define TCS34725_WTIME \ 58 #define TCS34725_WTIME_2_4MS (0xFF) 59 #define TCS34725_WTIME_204MS (0xAB) 60 #define TCS34725_WTIME_614MS (0x00) 61 #define TCS34725_AILTL \ 63 #define TCS34725_AILTH \ 65 #define TCS34725_AIHTL \ 67 #define TCS34725_AIHTH \ 69 #define TCS34725_PERS \ 72 #define TCS34725_PERS_NONE \ 74 #define TCS34725_PERS_1_CYCLE \ 77 #define TCS34725_PERS_2_CYCLE \ 80 #define TCS34725_PERS_3_CYCLE \ 83 #define TCS34725_PERS_5_CYCLE \ 86 #define TCS34725_PERS_10_CYCLE \ 89 #define TCS34725_PERS_15_CYCLE \ 92 #define TCS34725_PERS_20_CYCLE \ 95 #define TCS34725_PERS_25_CYCLE \ 98 #define TCS34725_PERS_30_CYCLE \ 101 #define TCS34725_PERS_35_CYCLE \ 104 #define TCS34725_PERS_40_CYCLE \ 107 #define TCS34725_PERS_45_CYCLE \ 110 #define TCS34725_PERS_50_CYCLE \ 113 #define TCS34725_PERS_55_CYCLE \ 116 #define TCS34725_PERS_60_CYCLE \ 119 #define TCS34725_CONFIG (0x0D) 120 #define TCS34725_CONFIG_WLONG \ 123 #define TCS34725_CONTROL (0x0F) 124 #define TCS34725_ID \ 126 #define TCS34725_STATUS (0x13) 127 #define TCS34725_STATUS_AINT (0x10) 128 #define TCS34725_STATUS_AVALID \ 131 #define TCS34725_CDATAL (0x14) 132 #define TCS34725_CDATAH (0x15) 133 #define TCS34725_RDATAL (0x16) 134 #define TCS34725_RDATAH (0x17) 135 #define TCS34725_GDATAL (0x18) 136 #define TCS34725_GDATAH (0x19) 137 #define TCS34725_BDATAL (0x1A) 138 #define TCS34725_BDATAH (0x1B) 145 #define TCS34725_INTEGRATIONTIME_2_4MS \ 147 #define TCS34725_INTEGRATIONTIME_24MS \ 149 #define TCS34725_INTEGRATIONTIME_50MS \ 151 #define TCS34725_INTEGRATIONTIME_60MS \ 153 #define TCS34725_INTEGRATIONTIME_101MS \ 155 #define TCS34725_INTEGRATIONTIME_120MS \ 157 #define TCS34725_INTEGRATIONTIME_154MS \ 159 #define TCS34725_INTEGRATIONTIME_180MS \ 161 #define TCS34725_INTEGRATIONTIME_199MS \ 163 #define TCS34725_INTEGRATIONTIME_240MS \ 165 #define TCS34725_INTEGRATIONTIME_300MS \ 167 #define TCS34725_INTEGRATIONTIME_360MS \ 169 #define TCS34725_INTEGRATIONTIME_401MS \ 171 #define TCS34725_INTEGRATIONTIME_420MS \ 173 #define TCS34725_INTEGRATIONTIME_480MS \ 175 #define TCS34725_INTEGRATIONTIME_499MS \ 177 #define TCS34725_INTEGRATIONTIME_540MS \ 179 #define TCS34725_INTEGRATIONTIME_600MS \ 181 #define TCS34725_INTEGRATIONTIME_614MS \ 206 void getRawData(uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *c);
207 void getRGB(
float *r,
float *g,
float *b);
212 uint16_t
calculateLux(uint16_t r, uint16_t g, uint16_t b);
213 void write8(uint8_t reg, uint8_t value);
214 uint8_t
read8(uint8_t reg);
223 Adafruit_I2CDevice *i2c_dev = NULL;
224 boolean _tcs34725Initialised;
226 uint8_t _tcs34725IntegrationTime;
uint16_t read16(uint8_t reg)
Reads a 16 bit values over I2C.
Definition: Adafruit_TCS34725.cpp:72
void getRGB(float *r, float *g, float *b)
Read the RGB color detected by the sensor.
Definition: Adafruit_TCS34725.cpp:249
uint8_t read8(uint8_t reg)
Reads an 8 bit value over I2C.
Definition: Adafruit_TCS34725.cpp:61
Adafruit_TCS34725(uint8_t=TCS34725_INTEGRATIONTIME_2_4MS, tcs34725Gain_t=TCS34725_GAIN_1X)
Constructor.
Definition: Adafruit_TCS34725.cpp:112
void setInterrupt(boolean flag)
Sets interrupt for TCS34725.
Definition: Adafruit_TCS34725.cpp:427
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...
Definition: Adafruit_TCS34725.cpp:322
uint16_t calculateLux(uint16_t r, uint16_t g, uint16_t b)
Converts the raw R/G/B values to lux.
Definition: Adafruit_TCS34725.cpp:412
tcs34725Gain_t
Definition: Adafruit_TCS34725.h:204
void clearInterrupt()
Clears inerrupt for TCS34725.
Definition: Adafruit_TCS34725.cpp:440
void write8(uint8_t reg, uint8_t value)
Writes a register and an 8 bit value over I2C.
Definition: Adafruit_TCS34725.cpp:51
void setGain(tcs34725Gain_t gain)
Adjusts the gain on the TCS34725.
Definition: Adafruit_TCS34725.cpp:180
void disable()
Disables the device (putting it in lower power sleep mode)
Definition: Adafruit_TCS34725.cpp:98
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.
Definition: Adafruit_TCS34725.cpp:275
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...
Definition: Adafruit_TCS34725.cpp:230
#define TCS34725_ADDRESS
Definition: Adafruit_TCS34725.h:44
void enable()
Enables the device.
Definition: Adafruit_TCS34725.cpp:81
Definition: Adafruit_TCS34725.h:207
boolean begin(uint8_t addr=TCS34725_ADDRESS, TwoWire *theWire=&Wire)
Initializes I2C and configures the sensor.
Definition: Adafruit_TCS34725.cpp:126
Definition: Adafruit_TCS34725.h:208
Class that stores state and functions for interacting with TCS34725 Color Sensor. ...
Definition: Adafruit_TCS34725.h:215
boolean init()
Part of begin.
Definition: Adafruit_TCS34725.cpp:138
Definition: Adafruit_TCS34725.h:205
void setIntLimits(uint16_t l, uint16_t h)
Sets inerrupt limits.
Definition: Adafruit_TCS34725.cpp:452
Definition: Adafruit_TCS34725.h:206
void setIntegrationTime(uint8_t it)
Sets the integration time for the TC34725.
Definition: Adafruit_TCS34725.cpp:164
#define TCS34725_INTEGRATIONTIME_2_4MS
Definition: Adafruit_TCS34725.h:164
void getRawData(uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *c)
Reads the raw red, green, blue and clear channel values.
Definition: Adafruit_TCS34725.cpp:202