mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-09-12 17:45:49 +00:00
[TSL2591] Perform async reading of sensor prevent blocking calls
This commit is contained in:
@@ -250,6 +250,29 @@ uint32_t Adafruit_TSL2591::calculateLux(uint16_t ch0, uint16_t ch1)
|
||||
return (uint32_t) calculateLuxf(ch0, ch1);
|
||||
}
|
||||
|
||||
uint32_t Adafruit_TSL2591::getFullLuminosity (bool& finished)
|
||||
{
|
||||
const uint8_t status = read8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_DEVICE_STATUS);
|
||||
|
||||
// ALS Valid. Indicates that the ADC channels have completed an
|
||||
// integration cycle since the AEN bit was asserted.
|
||||
finished = status & 0x01;
|
||||
if (!finished) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t x;
|
||||
uint16_t y = 0;
|
||||
y |= read16(TSL2591_COMMAND_BIT | TSL2591_REGISTER_CHAN0_LOW);
|
||||
x = read16(TSL2591_COMMAND_BIT | TSL2591_REGISTER_CHAN1_LOW);
|
||||
x <<= 16;
|
||||
x |= y;
|
||||
|
||||
disable();
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
uint32_t Adafruit_TSL2591::getFullLuminosity (void)
|
||||
{
|
||||
if (!_initialized)
|
||||
|
||||
@@ -163,6 +163,7 @@ class Adafruit_TSL2591 : public Adafruit_Sensor
|
||||
void setTiming ( tsl2591IntegrationTime_t integration );
|
||||
uint16_t getLuminosity (uint8_t channel );
|
||||
uint32_t getFullLuminosity ( );
|
||||
uint32_t getFullLuminosity (bool& finished);
|
||||
|
||||
tsl2591IntegrationTime_t getTiming();
|
||||
tsl2591Gain_t getGain();
|
||||
|
||||
Reference in New Issue
Block a user