mirror of
https://github.com/supleed2/ELEC60013-ES-CW1.git
synced 2024-11-10 01:35:50 +00:00
Tweaking
This commit is contained in:
parent
ac5f883981
commit
4c10e5de06
|
@ -100,6 +100,8 @@ class lis3dh:
|
||||||
X = int.from_bytes(x.buf[0],"big")
|
X = int.from_bytes(x.buf[0],"big")
|
||||||
Y = int.from_bytes(y.buf[0],"big")
|
Y = int.from_bytes(y.buf[0],"big")
|
||||||
Z = int.from_bytes(z.buf[0],"big")
|
Z = int.from_bytes(z.buf[0],"big")
|
||||||
|
|
||||||
|
# Convert from binary 2s complement to useful data
|
||||||
new_values = []
|
new_values = []
|
||||||
for D in [X,Y,Z]:
|
for D in [X,Y,Z]:
|
||||||
MSB = D >> 7
|
MSB = D >> 7
|
||||||
|
@ -108,6 +110,7 @@ class lis3dh:
|
||||||
else:
|
else:
|
||||||
res = (D*self.resolution)/128
|
res = (D*self.resolution)/128
|
||||||
new_values.append(res)
|
new_values.append(res)
|
||||||
|
|
||||||
return new_values
|
return new_values
|
||||||
else:
|
else:
|
||||||
return None # Should never get here lol
|
return None # Should never get here lol
|
2
main.py
2
main.py
|
@ -3,7 +3,7 @@ from datetime import datetime
|
||||||
|
|
||||||
print("Raspberry Pi Zero W, up and running!")
|
print("Raspberry Pi Zero W, up and running!")
|
||||||
bus = smbus2.SMBus(1)
|
bus = smbus2.SMBus(1)
|
||||||
accel = lis3dh(bus,2,10)
|
accel = lis3dh(bus,2,1)
|
||||||
|
|
||||||
print("LIS3DH initiated successfully!")
|
print("LIS3DH initiated successfully!")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue