Added the call for opening the fridge

master
Jared 8 years ago
parent a19eb64b3e
commit 1bfb5f5b35

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

Loading…
Cancel
Save