Skip to content

Fixes for temperature conversion bugs issue #15. #16

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

Merged
merged 1 commit into from
May 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions adafruit_amg88xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
# Operating Modes
# pylint: disable=bad-whitespace
_NORMAL_MODE = const(0x00)
_SLEEP_MODE = const(0x01)
_SLEEP_MODE = const(0x10)
_STAND_BY_60 = const(0x20)
_STAND_BY_10 = const(0x21)

Expand Down Expand Up @@ -86,10 +86,16 @@
def _signed_12bit_to_float(val):
#take first 11 bits as absolute val
abs_val = (val & 0x7FF)
if val & 0x8000:
if val & 0x800:
return 0 - float(abs_val)
return float(abs_val)

def _twos_comp_to_float(val):
val &= 0xfff
if val & 0x800:
val -= 0x1000
return float(val)

class AMG88XX:
"""Driver for the AMG88xx GRID-Eye IR 8x8 thermal camera."""

Expand Down Expand Up @@ -161,6 +167,6 @@ def pixels(self):
i2c.readinto(buf, start=1)

raw = (buf[2] << 8) | buf[1]
retbuf[row][col] = _signed_12bit_to_float(raw) * _PIXEL_TEMP_CONVERSION
retbuf[row][col] = _twos_comp_to_float(raw) * _PIXEL_TEMP_CONVERSION

return retbuf