Changed return value of getEvent

value of 0 could be a valid value in darkness, better to return a value > 65535 to report saturation and return false from getEvent in that case!
This commit is contained in:
Bernd Giesecke
2016-01-09 23:43:37 +08:00
parent d087310e6a
commit bcb5729944

View File

@ -385,10 +385,10 @@ uint32_t Adafruit_TSL2561_Unified::calculateLux(uint16_t broadband, uint16_t ir)
break;
}
/* Return 0 lux if the sensor is saturated */
/* Return 65536 lux if the sensor is saturated */
if ((broadband > clipThreshold) || (ir > clipThreshold))
{
return 0;
return 65536;
}
/* Get the correct scale depending on the intergration time */
@ -476,6 +476,8 @@ uint32_t Adafruit_TSL2561_Unified::calculateLux(uint16_t broadband, uint16_t ir)
/**************************************************************************/
/*!
@brief Gets the most recent sensor event
returns true if sensor reading is between 0 and 65535 lux
returns false if sensor is saturated
*/
/**************************************************************************/
bool Adafruit_TSL2561_Unified::getEvent(sensors_event_t *event)
@ -494,6 +496,9 @@ bool Adafruit_TSL2561_Unified::getEvent(sensors_event_t *event)
getLuminosity(&broadband, &ir);
event->light = calculateLux(broadband, ir);
if (event->light == 65536) {
return false;
}
return true;
}