-
Notifications
You must be signed in to change notification settings - Fork 22
ZeroDivisionError: division by zero on adafruit_tcs34725.py #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@ladyada This is touching on the same part of the code that I stumbled upon in #10. Do you happen to have any insight as to where that math is coming from and/or what it's trying to do? |
@microbuilder knows this best! |
Weird ... I know this chip fairly well and off the top of my head, I don't know what that code with the pow and 2.5 is doing! I'll have to dig into this a bit. The div by zero check is valid in any case, though, and I can add that in ... but need to understand what's going on in that function first. That was part of the original commit from TonyD, and it's not obvious to me what the logic was. |
Thanks for confirming weirdness! I read the datasheet and several ap notes and did not find anything with this math. If you figure out what's it's about, great. Otherwise, may not matter as it will likely go away with updated algorithm suggested by #15. |
Fixed with #16 |
On /usr/local/lib/python3.5/dist-packages/adafruit_tcs34725.py the function
def color_rgb_bytes(self)
should check if rgb values are greater than zero to avoid the division by zero exceptionFile "/usr/local/lib/python3.5/dist-packages/adafruit_tcs34725.py", line 240, in color_rgb_bytes
red = int(pow((int((r/clear) * 256) / 255), 2.5) * 255)
ZeroDivisionError: division by zero
The text was updated successfully, but these errors were encountered: