Skip to content
This repository was archived by the owner on Oct 29, 2019. It is now read-only.

Commit 38ab491

Browse files
authored
Removed erroneous 4-bit shift
Values are already 16-bits signed, with 12-bit data, so it can be returned as is. The datasheet isn't terribly clear here, but testing leads me to the conclusion that the code in this PR is the correct solution. The math makes sense for 12-bit values in a 16-bit signed wrapper, though not full 16-bit data. The DS states at +/-2g on the accel 1 lsb = 1mg, so at 12-bits we get 4096mg or +/-2g. The values seem the be returned already formed as 16-bit signed integers, though, so the right-shift is incorrect.
1 parent 2a299cb commit 38ab491

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

adafruit_lsm303.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ def raw_magnetic(self):
177177
"""
178178
self._read_bytes(self._mag_device, _REG_MAG_OUT_X_H_M, 6, self._BUFFER)
179179
raw_values = struct.unpack_from('>hhh', self._BUFFER[0:6])
180-
values = tuple([n >> 4 for n in raw_values])
181-
return (values[0], values[2], values[1])
180+
return (raw_values[0], raw_values[2], raw_values[1])
182181

183182
@property
184183
def magnetic(self):

0 commit comments

Comments
 (0)