|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
import time, json
|
|
|
|
|
import RPi.GPIO as GPIO
|
|
|
|
|
import keyboard
|
|
|
|
|
|
|
|
|
|
import subprocess
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
pin_config = []
|
|
|
|
|
with open('pin_config.json') as pin_config_stream:
|
|
|
|
@ -16,6 +16,12 @@ if __name__ == '__main__':
|
|
|
|
|
GPIO.setup(pin_config['fridge_grn_LED'], GPIO.OUT)
|
|
|
|
|
GPIO.setup(pin_config['tools_red_LED'], GPIO.OUT)
|
|
|
|
|
GPIO.setup(pin_config['tools_grn_LED'], GPIO.OUT)
|
|
|
|
|
|
|
|
|
|
GPIO.output(pin_config['fridge_grn_LED'], GPIO.LOW)
|
|
|
|
|
GPIO.output(pin_config['tools_grn_LED'], GPIO.LOW)
|
|
|
|
|
GPIO.output(pin_config['fridge_red_LED'], GPIO.LOW)
|
|
|
|
|
GPIO.output(pin_config['tools_red_LED'], GPIO.LOW)
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
print "Enter card ID:"
|
|
|
|
|
cardID_input = keyboard.record(until='enter')
|
|
|
|
@ -37,13 +43,14 @@ if __name__ == '__main__':
|
|
|
|
|
else:
|
|
|
|
|
GPIO.output(pin_config['fridge_red_LED'], GPIO.HIGH)
|
|
|
|
|
timeout = time.time() + 5 # 5 seconds timeout
|
|
|
|
|
wait = True
|
|
|
|
|
while wait:
|
|
|
|
|
if data['secretTools'] and GPIO.input(pin_config['tools_btn']) == 0:
|
|
|
|
|
wait = False
|
|
|
|
|
GPIO.output(pin_config['fridge_grn_LED'], GPIO.LOW)
|
|
|
|
|
GPIO.output(pin_config['tools_grn_LED'], GPIO.LOW)
|
|
|
|
|
GPIO.output(pin_config['fridge_red_LED'], GPIO.LOW)
|
|
|
|
|
GPIO.output(pin_config['tools_red_LED'], GPIO.LOW)
|
|
|
|
|
wait = False
|
|
|
|
|
# Open tools
|
|
|
|
|
if data['fridge'] and GPIO.input(pin_config['fridge_btn']) == 0:
|
|
|
|
|
GPIO.output(pin_config['fridge_grn_LED'], GPIO.LOW)
|
|
|
|
@ -52,6 +59,8 @@ if __name__ == '__main__':
|
|
|
|
|
GPIO.output(pin_config['tools_red_LED'], GPIO.LOW)
|
|
|
|
|
wait = False
|
|
|
|
|
# Open fridge
|
|
|
|
|
subprocess.call("/home/pi/ELAB-RFID-I2C/RPi/i2c_challenge", shell=True)
|
|
|
|
|
|
|
|
|
|
if time.time() > timeout:
|
|
|
|
|
GPIO.output(pin_config['fridge_grn_LED'], GPIO.LOW)
|
|
|
|
|
GPIO.output(pin_config['tools_grn_LED'], GPIO.LOW)
|
|
|
|
|