Adafruit_TSL2591_Library icon indicating copy to clipboard operation
Adafruit_TSL2591_Library copied to clipboard

allow for 'non-blocking' read of values

Open s-light opened this issue 6 years ago • 0 comments

currently the library blocks on every reading of the sensor values:

uint32_t Adafruit_TSL2591::getFullLuminosity (void) {
  // ....
  // Wait x ms for ADC to complete
  for (uint8_t d=0; d<=_integration; d++)
  {
    delay(120);
  }
  // ....
}

(all specialized readings are calling the getFullLuminosity function)

this delay is needed because the lib enables the sensor for every interaction and disables it afterwards. but i think a ~100-600ms blocking delay just for getting a sensor reading is not a nice thing to do.. → if the sensor is left running you just can read a value and be happy ;-)

if you want to make sure you get a valid reading - first check the Status Register for AVALID. if the lib needs to make sure it always gets a new conversion value i think after the read we could disable only the AEN flag (Enable Register) and re enable it directly again. this should clear the AVALID flag.

i would try and create a pull-request - but i first need a ok/info for how to do this in line with the adafruit goals!

so the fix for this should also fix #12

s-light avatar Aug 07 '19 11:08 s-light