adafruit / Adafruit_TSL2591_Library

This is an Arduino library for the TSL2591 digital luminosity (light) sensors.
58 stars 48 forks source link

lowlight bugfix in getLuminosity(TSL2591_VISIBLE) when there are low … #42

Open smnmsr opened 3 years ago

smnmsr commented 3 years ago

in low light situations, it is possible, that the ir photodiode returns a higher value than the fullspectrum photodiode. if that happens, the calculated result was a low negative number which results in a high positive number if returned as an uint.

e.g. if the fullspec diode returns 0 and the ir diode returns 1, the calculated result for the visible value was -1. if -1 is stored in an uint16_t it results as an 0xFFFE.

The Scope of the change is to prevent the getLuminosity(TSL2591_VISIBLE) method to return 0xFFFF or 0xFFFE in low light situations, when the IR diode can return values greater then the ones from the fullspec diode.

Describe any known limitations with your change. There are no known limitations.

smnmsr commented 3 years ago

I'm not sure why the checks have failed. I've double-checked the code again and I cannot see any issue. Furthermore my code is running fine on my installation.

smnmsr commented 3 years ago

I've changed one more thing

There is an open issue about negative Lux values. Therefore the method first checks if the full value is greater than the ir value and if the full value isn't zero. this should fix that issue.

https://github.com/adafruit/Adafruit_TSL2591_Library/issues/24

smnmsr commented 3 years ago

@ladyada have you had a chance to look into this yet?

ladyada commented 3 years ago

nope! we wouldn't review until there are no merge conflicts and the actions CI passes this guide has hints on how to make sure the library can pass CI! https://learn.adafruit.com/contribute-to-arduino-with-git-and-github

smnmsr commented 3 years ago

What about now?