mirror of
https://github.com/supleed2/ELEC60013-ES-CW1.git
synced 2024-11-10 01:35:50 +00:00
Update lis3dh.py
This commit is contained in:
parent
898cd451db
commit
65bddab7f5
11
lis3dh.py
11
lis3dh.py
|
@ -100,7 +100,14 @@ class lis3dh:
|
|||
X = int.from_bytes(x.buf[0],"big")
|
||||
Y = int.from_bytes(y.buf[0],"big")
|
||||
Z = int.from_bytes(z.buf[0],"big")
|
||||
# TODO: Need to format this so that it returns values in g
|
||||
return [X,Y,Z]
|
||||
new_values = []
|
||||
for D in [X,Y,Z]:
|
||||
MSB = D >> 7
|
||||
if MSB == 1:
|
||||
res = -128 + (D - 128)
|
||||
else:
|
||||
res = D
|
||||
new_values.append(res)
|
||||
return new_values
|
||||
else:
|
||||
return None # Should never get here lol
|
Loading…
Reference in a new issue