diff --git a/Adafruit_TSL2561_U.cpp b/Adafruit_TSL2561_U.cpp index 0111ef6..0517185 100644 --- a/Adafruit_TSL2561_U.cpp +++ b/Adafruit_TSL2561_U.cpp @@ -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; }