Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MF_FUJIKO_BASE STEM_2019 STEM_2020
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_sda SDA pin i2c_scl SCL 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:
-
intTime Integration time for reading (will delay accordingly) i2c_scl Gain 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:
-
deb Serial 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:
-
r Red value (passed by reference) g Green value (passed by reference) b Blue value (passed by reference) c Clear 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:
-
intTime Integration time for reading (will delay accordingly) i2c_scl Gain value
Definition at line 28 of file TCS34725.cpp.
Generated on Fri Jul 15 2022 15:32:01 by
1.7.2