mirror of
https://github.com/supleed2/ELEC60013-ES-CW1.git
synced 2024-11-10 01:35:50 +00:00
Bugfixes
This commit is contained in:
parent
4db2a4d34d
commit
d6e996bad8
|
@ -82,7 +82,7 @@ class LIS3DH:
|
||||||
int1_src_loc = smbus2.i2c_msg.write(self.addr, [0x31])
|
int1_src_loc = smbus2.i2c_msg.write(self.addr, [0x31])
|
||||||
read_int1_src = smbus2.i2c_msg.read(self.addr, 1)
|
read_int1_src = smbus2.i2c_msg.read(self.addr, 1)
|
||||||
self.i2c.i2c_rdwr(int1_src_loc,read_int1_src)
|
self.i2c.i2c_rdwr(int1_src_loc,read_int1_src)
|
||||||
if read_int1_src.bug[0] != None:
|
if read_int1_src.buf[0] != None:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
@ -92,7 +92,7 @@ class LIS3DH:
|
||||||
int2_src_loc = smbus2.i2c_msg.write(self.addr, [0x35])
|
int2_src_loc = smbus2.i2c_msg.write(self.addr, [0x35])
|
||||||
read_int2_src = smbus2.i2c_msg.read(self.addr, 1)
|
read_int2_src = smbus2.i2c_msg.read(self.addr, 1)
|
||||||
self.i2c.i2c_rdwr(int2_src_loc,read_int2_src)
|
self.i2c.i2c_rdwr(int2_src_loc,read_int2_src)
|
||||||
if read_int2_src.bug[0] != None:
|
if read_int2_src.buf[0] != None:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
10
main.py
10
main.py
|
@ -1,6 +1,6 @@
|
||||||
import os, sys
|
import os, sys
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from strictyaml import load, Map, Str, YAMLError
|
import yaml
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
import json, smbus2, si7201, tmp006, lis3dh, hci, gpiozero
|
import json, smbus2, si7201, tmp006, lis3dh, hci, gpiozero
|
||||||
|
|
||||||
|
@ -29,15 +29,15 @@ irtemp.active = 1 # turn on TMP006
|
||||||
|
|
||||||
accel = lis3dh.LIS3DH(bus, 10, 0x18) # set up LIS3DH sensor
|
accel = lis3dh.LIS3DH(bus, 10, 0x18) # set up LIS3DH sensor
|
||||||
fall = gpiozero.Button(18, pull_up = False) # GPIO17: Freefall Interrupt (INT1)
|
fall = gpiozero.Button(18, pull_up = False) # GPIO17: Freefall Interrupt (INT1)
|
||||||
fall.when_activated = setFallen(fall, accel) # set fallen to True when Freefall Interrupt (INT1) is triggered
|
fall.when_activated = lambda: setFallen(fall, accel) # set fallen to True when Freefall Interrupt (INT1) is triggered
|
||||||
step = gpiozero.Button(17, pull_up = False) # GPIO18: Step Counter Interrupt (INT2)
|
step = gpiozero.Button(17, pull_up = False) # GPIO18: Step Counter Interrupt (INT2)
|
||||||
step.when_activated = incrementStepCount(step, accel) # increment step count when Step Counter Interrupt (INT2) is triggered
|
step.when_activated = lambda: incrementStepCount(step, accel) # increment step count when Step Counter Interrupt (INT2) is triggered
|
||||||
|
|
||||||
with open(".secrets.yml", "r") as secrets:
|
with open(".secrets.yml", "r") as secrets:
|
||||||
try:
|
try:
|
||||||
secrets = load(secrets, schema = Map({"key": Str()}))
|
secrets = yaml.load(secrets, Loader = yaml.SafeLoader)
|
||||||
key = secrets["key"] # Get Base64 encoded device public key from secrets file
|
key = secrets["key"] # Get Base64 encoded device public key from secrets file
|
||||||
except YAMLError as exc:
|
except ImportError as exc:
|
||||||
print(exc)
|
print(exc)
|
||||||
sleep(60) # 60s delay before restarting
|
sleep(60) # 60s delay before restarting
|
||||||
os.execl(sys.executable, os.path.abspath(__file__), *sys.argv) # Restart propgram
|
os.execl(sys.executable, os.path.abspath(__file__), *sys.argv) # Restart propgram
|
||||||
|
|
|
@ -2,6 +2,7 @@ colorzero==2.0
|
||||||
gpiozero==1.6.2
|
gpiozero==1.6.2
|
||||||
paho-mqtt==1.6.1
|
paho-mqtt==1.6.1
|
||||||
python-dateutil==2.8.2
|
python-dateutil==2.8.2
|
||||||
|
PyYAML==6.0
|
||||||
|
RPi.GPIO==0.7.1
|
||||||
six==1.16.0
|
six==1.16.0
|
||||||
smbus2==0.4.1
|
smbus2==0.4.1
|
||||||
strictyaml==1.6.1
|
|
||||||
|
|
Loading…
Reference in a new issue