-
Notifications
You must be signed in to change notification settings - Fork 26
Handling of negative pixel temperature values is incorrect #15
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
On further review there is also an error in _signed_12bit_to_float which will fail to handle negative thermistor temperatures. It should read def _signed_12bit_to_float(val):
#take first 11 bits as absolute val
abs_val = (val & 0x7FF)
if val & 0x800:
return 0 - float(abs_val)
return float(abs_val) i.e. the test for negative should be 0x800 not 0x8000. |
A further bug - which won't have effect because sleep mode is currently unused - is
The value should be 0x10 (datasheet page 9). |
ladyada
added a commit
that referenced
this issue
May 22, 2019
Fixes for temperature conversion bugs issue #15.
huzzah! thank you @peterhinch :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The _signed_12bit_to_float function is correct for thermistor temperature readings which are in sign bit/absolute data format (datasheet page 13).
However datasheet page 14 indicates that pixel values are in two's complement format. This requires different handling.
I have no hardware (yet) so am not in a position to offer a tested PR.
The text was updated successfully, but these errors were encountered: