Basic library for the TCS34725, based off of several example programs and the Adafruit Arduino library
Dependents: MF_FUJIKO_BASE STEM_2019 STEM_2020
Revision 4:41f1acad69e5, committed 2017-03-22
- Comitter:
- mwilkens241
- Date:
- Wed Mar 22 20:54:37 2017 +0000
- Parent:
- 3:afb107db7994
- Commit message:
- color sensor testing
Changed in this revision
| TCS34725.cpp | Show annotated file Show diff for this revision Revisions of this file |
| TCS34725.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/TCS34725.cpp Wed Jan 25 20:17:57 2017 +0000
+++ b/TCS34725.cpp Wed Mar 22 20:54:37 2017 +0000
@@ -47,11 +47,11 @@
init(intTime,gain);
}
-void TCS34725::getColor(uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *c){
- *c = i2cRead16(SENSOR_ADDR, TCS34725_CDATAL);
- *r = i2cRead16(SENSOR_ADDR, TCS34725_RDATAL);
- *g = i2cRead16(SENSOR_ADDR, TCS34725_GDATAL);
- *b = i2cRead16(SENSOR_ADDR, TCS34725_BDATAL);
+void TCS34725::getColor(uint16_t &r, uint16_t &g, uint16_t &b, uint16_t &c){
+ c = i2cRead16(SENSOR_ADDR, TCS34725_CDATAL);
+ r = i2cRead16(SENSOR_ADDR, TCS34725_RDATAL);
+ g = i2cRead16(SENSOR_ADDR, TCS34725_GDATAL);
+ b = i2cRead16(SENSOR_ADDR, TCS34725_BDATAL);
switch(t_intTime){
case TCS34725_INTEGRATIONTIME_2_4MS:
wait(0.003);
--- a/TCS34725.h Wed Jan 25 20:17:57 2017 +0000
+++ b/TCS34725.h Wed Mar 22 20:54:37 2017 +0000
@@ -62,7 +62,7 @@
* }
*
* while(1) {
- colorSens.getColor(&r,&g,&b,&c); //pass variables by reference...
+ 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);
* }
@@ -113,7 +113,7 @@
* @param b Blue value (passed by reference)
* @param c Clear value (all wavelengths - essentially shade) (passed by reference)
*/
- void getColor(uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *c);
+ void getColor(uint16_t &r, uint16_t &g, uint16_t &b, uint16_t &c);
/** Debug function... probably not useful unless youre debugging your i2c line
*