File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 54
54
# Operating Modes
55
55
# pylint: disable=bad-whitespace
56
56
_NORMAL_MODE = const (0x00 )
57
- _SLEEP_MODE = const (0x01 )
57
+ _SLEEP_MODE = const (0x10 )
58
58
_STAND_BY_60 = const (0x20 )
59
59
_STAND_BY_10 = const (0x21 )
60
60
86
86
def _signed_12bit_to_float (val ):
87
87
#take first 11 bits as absolute val
88
88
abs_val = (val & 0x7FF )
89
- if val & 0x8000 :
89
+ if val & 0x800 :
90
90
return 0 - float (abs_val )
91
91
return float (abs_val )
92
92
93
+ def _twos_comp_to_float (val ):
94
+ val &= 0xfff
95
+ if val & 0x800 :
96
+ val -= 0x1000
97
+ return float (val )
98
+
93
99
class AMG88XX :
94
100
"""Driver for the AMG88xx GRID-Eye IR 8x8 thermal camera."""
95
101
@@ -161,6 +167,6 @@ def pixels(self):
161
167
i2c .readinto (buf , start = 1 )
162
168
163
169
raw = (buf [2 ] << 8 ) | buf [1 ]
164
- retbuf [row ][col ] = _signed_12bit_to_float (raw ) * _PIXEL_TEMP_CONVERSION
170
+ retbuf [row ][col ] = _twos_comp_to_float (raw ) * _PIXEL_TEMP_CONVERSION
165
171
166
172
return retbuf
You can’t perform that action at this time.
0 commit comments