|
|
|
@ -2,26 +2,34 @@
|
|
|
|
|
|
|
|
|
|
Adafruit_APDS9960 _sensor_apds9960;
|
|
|
|
|
|
|
|
|
|
bool sensor_apds9960_begin() {
|
|
|
|
|
bool sensor_apds9960_begin()
|
|
|
|
|
{
|
|
|
|
|
bool status = _sensor_apds9960.begin();
|
|
|
|
|
if (status) {
|
|
|
|
|
|
|
|
|
|
if (status)
|
|
|
|
|
{
|
|
|
|
|
_sensor_apds9960.enableColor(true);
|
|
|
|
|
debug("APDS9960 Connected");
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
debug("Could not find a valid APDS9960 sensor, check wiring!");
|
|
|
|
|
}
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float apds9960_light() {
|
|
|
|
|
float apds9960_light()
|
|
|
|
|
{
|
|
|
|
|
uint16_t red, green, blue, white, lux;
|
|
|
|
|
|
|
|
|
|
while(!_sensor_apds9960.colorDataReady()) {
|
|
|
|
|
while(!_sensor_apds9960.colorDataReady())
|
|
|
|
|
{
|
|
|
|
|
delay(5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_sensor_apds9960.getColorData(&red, &green, &blue, &white);
|
|
|
|
|
|
|
|
|
|
//calculate lux
|
|
|
|
|
lux = _sensor_apds9960.calculateLux(red, green, blue);
|
|
|
|
|
|
|
|
|
|
return lux * LIGHT_FACTOR;
|
|
|
|
|
}
|
|
|
|
|