upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions

API for the TCS37727 Color Light-To-Digital Converter. More...

Detailed Description

Description in web-link above: The TCS3772 device family provides red, green, blue, and clear (RGBC) light sensing and, when coupled with an external IR LED, proximity detection. These devices detect light intensity under a variety of lighting conditions and through a variety of attenuation materials, including dark glass. The proximity detection feature allows a large dynamic range of operation for accurate short distance detection, such as in a cell phone, for detecting when the user positions the phone close to their ear. An internal state machine provides the ability to put the device into a low power state in between proximity and RGBC measurements providing very low average power consumption.

std::cout << "Initializing test-application..." << std::endl;
// Instantiate an TCS37727 instance on bus 1
upm::TCS37727 mySensor(1);
// activate periodic measurements
mySensor.setActive();
// update and print available values every second
while (run) {
mySensor.getData(&data, true);
std::cout << "Red: " << (int) data.red << std::endl
<< "Green: " << (int) data.green << std::endl
<< "Blue: " << (int) data.blue << std::endl
<< "Clear: " << (int) data.clear << std::endl
<< "Lux: " << (int) data.lux << std::endl
<< "Color temperature: " << (int) data.ct << std::endl;
std::cout << std::endl;
upm_delay(1);
}
std::cout << "Exiting test-application..." << std::endl;

Public Member Functions

 TCS37727 (int bus, int atime_us=TCS37727_ATIME_DEFAULT, int devAddr=TCS37727_I2C_ADDRESS)
 
int checkID (void)
 
int setActive (void)
 
int setStandby (void)
 
uint8_t trimGain (int rawc)
 
int sampleData (void)
 
uint32_t getChannelRed (int bSampleData=0)
 
uint32_t getChannelGreen (int bSampleData=0)
 
uint32_t getChannelBlue (int bSampleData=0)
 
uint32_t getChannelClear (int bSampleData=0)
 
uint32_t getLux (int bSampleData=0)
 
uint32_t getColorTemperature (int bSampleData=0)
 
int getData (tcs37727_data_t *data, int bSampleData=0)
 

Constructor & Destructor Documentation

TCS37727 ( int  bus,
int  atime_us = TCS37727_ATIME_DEFAULT,
int  devAddr = TCS37727_I2C_ADDRESS 
)

Instantiates an TCS37727 object Settings: Gain 4x, Proximity Detection off

Parameters
busNumber of the used bus
atime_usRGBC integration time
devAddrAddress of the used I2C device

Here is the call graph for this function:

Member Function Documentation

int checkID ( void  )

Check device_id of sensor

Returns
0 on success -1 on error

Here is the caller graph for this function:

int setActive ( void  )

Set active mode, this enables periodic RGBC measurements

Returns
0 on success -1 on error
int setStandby ( void  )

Set standby mode, this disables periodic RGBC measurements Also turns off the sensor when proximity measurement is disabled

Returns
0 on success -1 on error
int sampleData ( void  )

Read out data of regs and call further function Also saves converted values to variables

Returns
0 on success -1 on error

Here is the caller graph for this function:

uint32_t getChannelRed ( int  bSampleData = 0)

Get the calculated channel red color

Parameters
bSampleDataFlag to read sensor
Returns
The channel red color on success 999 on error

Here is the call graph for this function:

uint32_t getChannelGreen ( int  bSampleData = 0)

Get the calculated channel green color

Parameters
bSampleDataFlag to read sensor
Returns
The channel green color on success 999 on error

Here is the call graph for this function:

uint32_t getChannelBlue ( int  bSampleData = 0)

Get the calculated channel blue color

Parameters
bSampleDataFlag to read sensor
Returns
The channel blue color on success 999 on error

Here is the call graph for this function:

uint32_t getChannelClear ( int  bSampleData = 0)

Get the calculated channel clear color

Parameters
bSampleDataFlag to read sensor
Returns
The channel clear color on success 999 on error

Here is the call graph for this function:

uint32_t getLux ( int  bSampleData = 0)

Get the calculated lux value

Parameters
bSampleDataFlag to read sensor
Returns
The lux value on success 999 on error

Here is the call graph for this function:

uint32_t getColorTemperature ( int  bSampleData = 0)

Get the calculated color temperature

Parameters
bSampleDataFlag to read sensor
Returns
The color temperature on success 999 on error

Here is the call graph for this function:

int getData ( tcs37727_data_t data,
int  bSampleData = 0 
)

Get calculated sensor values

Parameters
dataCalculated sensor values
bSampleDataFlag to read sensor
Returns
0 on success -1 on error

Here is the call graph for this function:


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