mirror of
https://github.com/adafruit/Adafruit_TSL2561.git
synced 2025-07-30 17:07:14 +02:00
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:
@ -385,10 +385,10 @@ uint32_t Adafruit_TSL2561_Unified::calculateLux(uint16_t broadband, uint16_t ir)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return 0 lux if the sensor is saturated */
|
/* Return 65536 lux if the sensor is saturated */
|
||||||
if ((broadband > clipThreshold) || (ir > clipThreshold))
|
if ((broadband > clipThreshold) || (ir > clipThreshold))
|
||||||
{
|
{
|
||||||
return 0;
|
return 65536;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the correct scale depending on the intergration time */
|
/* 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
|
@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)
|
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);
|
getLuminosity(&broadband, &ir);
|
||||||
event->light = calculateLux(broadband, ir);
|
event->light = calculateLux(broadband, ir);
|
||||||
|
|
||||||
|
if (event->light == 65536) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user