Yingshan LIU / projet_embarque
Embed: (wiki syntax)

« Back to documentation index

TCS34725 Class Reference

TCS34725 Class Reference

TCS34725 control class. More...

#include <TCS34725.h>

Public Member Functions

 TCS34725 ()
 Initialize object with default i2c pins.
 TCS34725 (PinName i2c_sda, PinName i2c_scl)
 Initialize object with specific i2c pins.
bool init (char intTime, char gain)
 Boot up the sensor and checks if acking (see header for param defines)
void config (char intTime, char gain)
 Configure after initial boot (will restart sensor)
void getColor (uint16_t &r, uint16_t &g, uint16_t &b, uint16_t &c)
 Returns rgbc reading from the sensor.
void DEBUG (Serial *deb)
 Debug function...

Detailed Description

TCS34725 control class.

Example:

 //Send rgb data to the serial port
 #include "TCS34725.h"
 #include "mbed.h"

 TCS34725 colorSens(p9, p10); //I2C sda and scl
 Serial pc(USBTX, USBRX); //USB serial

 int main() {
   uint16_t r,g,b,c;
       
   if(!colorSens.init(TCS34725_INTEGRATIONTIME_101MS, TCS34725_GAIN_60X)){
       pc.printf("ERROR\n"); //check to see if i2c is responding
   }

   while(1) {
        colorSens.getColor(r,g,b,c); //pass variables by reference...
      pc.printf("DATA: r%d g%d b%d c%d", r, g, b, c);
      wait(0.5);
  }
 }

Definition at line 73 of file TCS34725.h.


Constructor & Destructor Documentation

TCS34725 (  )

Initialize object with default i2c pins.

Definition at line 3 of file TCS34725.cpp.

TCS34725 ( PinName  i2c_sda,
PinName  i2c_scl 
)

Initialize object with specific i2c pins.

Parameters:
i2c_sdaSDA pin
i2c_sclSCL pin

Definition at line 4 of file TCS34725.cpp.


Member Function Documentation

void config ( char  intTime,
char  gain 
)

Configure after initial boot (will restart sensor)

Parameters:
intTimeIntegration time for reading (will delay accordingly)
i2c_sclGain value
Returns:
1 if failed ` 0 if successful

Definition at line 44 of file TCS34725.cpp.

void DEBUG ( Serial *  deb )

Debug function...

probably not useful unless youre debugging your i2c line

Parameters:
debSerial object for debugging (passed by reference)

Definition at line 77 of file TCS34725.cpp.

void getColor ( uint16_t &  r,
uint16_t &  g,
uint16_t &  b,
uint16_t &  c 
)

Returns rgbc reading from the sensor.

Parameters:
rRed value (passed by reference)
gGreen value (passed by reference)
bBlue value (passed by reference)
cClear value (all wavelengths - essentially shade) (passed by reference)

Definition at line 50 of file TCS34725.cpp.

bool init ( char  intTime,
char  gain 
)

Boot up the sensor and checks if acking (see header for param defines)

Parameters:
intTimeIntegration time for reading (will delay accordingly)
i2c_sclGain value

Definition at line 28 of file TCS34725.cpp.