use agc wrapper class for tcs34725
This commit is contained in:
parent
e2005bbf84
commit
ff8582fa1e
26
src/main.cpp
26
src/main.cpp
|
@ -172,14 +172,18 @@ struct sensordata
|
|||
#endif
|
||||
|
||||
#ifdef SENSOR_TCS34725
|
||||
#include "Adafruit_TCS34725.h"
|
||||
//#include "Adafruit_TCS34725.h"
|
||||
#include "tcs34725_agc.h" //class code from example https://github.com/adafruit/Adafruit_TCS34725/blob/master/examples/tcs34725autorange/tcs34725autorange.ino
|
||||
//Connect SCL to D1, SDA to D2, GND and 3v3
|
||||
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X);
|
||||
//Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X); //initializer from standart class
|
||||
tcs34725 tcs; //wrapper class with agc
|
||||
bool tcs34725init_ok=false;
|
||||
struct sensordata dataTCS34725_lux;
|
||||
struct sensordata dataTCS34725_colortemp;
|
||||
uint16_t value_colortemp, value_tcs_lux, value_tcs_r,value_tcs_g,value_tcs_b,value_tcs_c;
|
||||
unsigned long lastread_tcs34725=0;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SENSOR_ANEMOMETER
|
||||
|
@ -846,9 +850,14 @@ void loop_TCS34725_lux()
|
|||
bool _changed=false;
|
||||
if (millis() >= (d.lastreadtime+d.readdelay)) {
|
||||
if (millis() >= (lastread_tcs34725+d.readdelay)) {
|
||||
tcs.getRawData(&value_tcs_r, &value_tcs_g, &value_tcs_b, &value_tcs_c);
|
||||
//tcs.getRawData(&value_tcs_r, &value_tcs_g, &value_tcs_b, &value_tcs_c);
|
||||
tcs.getData();
|
||||
if (tcs.isSaturated){
|
||||
Serial.println("Warning: tcs34725 is saturated");
|
||||
}
|
||||
value_tcs_lux = tcs.calculateLux(value_tcs_r, value_tcs_g, value_tcs_b);
|
||||
}
|
||||
//value_tcs_lux = tcs.calculateLux(value_tcs_r, value_tcs_g, value_tcs_b);
|
||||
value_tcs_lux = tcs.lux;
|
||||
|
||||
if (abs((int)d.lastsentvalue-value_tcs_lux)>=d.minchange){ //int abs
|
||||
_changed=true;
|
||||
|
@ -880,10 +889,15 @@ void loop_TCS34725_colortemp()
|
|||
bool _changed=false;
|
||||
if (millis() >= (d.lastreadtime+d.readdelay)) {
|
||||
if (millis() >= (lastread_tcs34725+d.readdelay)) {
|
||||
tcs.getRawData(&value_tcs_r, &value_tcs_g, &value_tcs_b, &value_tcs_c);
|
||||
//tcs.getRawData(&value_tcs_r, &value_tcs_g, &value_tcs_b, &value_tcs_c);
|
||||
tcs.getData();
|
||||
if (tcs.isSaturated){
|
||||
Serial.println("Warning: tcs34725 is saturated");
|
||||
}
|
||||
}
|
||||
// colorTemp = tcs.calculateColorTemperature(r, g, b);
|
||||
value_colortemp = tcs.calculateColorTemperature_dn40(value_tcs_r, value_tcs_g, value_tcs_b, value_tcs_c);
|
||||
//value_colortemp = tcs.calculateColorTemperature_dn40(value_tcs_r, value_tcs_g, value_tcs_b, value_tcs_c);
|
||||
value_colortemp = tcs.ct; //with agc
|
||||
|
||||
|
||||
if (abs((int)d.lastsentvalue-value_colortemp)>=d.minchange){ //int abs
|
||||
|
|
Loading…
Reference in New Issue