|
|
@ -1,7 +1,20 @@
|
|
|
|
import time
|
|
|
|
import time, json
|
|
|
|
import json
|
|
|
|
import RPi.GPIO as GPIO
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
pin_config = {}
|
|
|
|
|
|
|
|
with open('pin_config.json') as pin_config_stream:
|
|
|
|
|
|
|
|
pin_config = json.load(pin_config_stream)
|
|
|
|
|
|
|
|
if pin_config['mode'] == 'BOARD':
|
|
|
|
|
|
|
|
GPIO.setmode(GPIO.BOARD)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
GPIO.setmode(GPIO.BCM)
|
|
|
|
|
|
|
|
GPIO.setup(pin_config['frigde_btn'], GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
|
|
|
|
|
|
|
GPIO.setup(pin_config['tools_btn'], GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
|
|
|
|
|
|
|
GPIO.setup(pin_config['fridge_red_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_grn_LED'], GPIO.OUT)
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
cardID = raw_input("Enter card ID: ")
|
|
|
|
cardID = raw_input("Enter card ID: ")
|
|
|
|
event = {}
|
|
|
|
event = {}
|
|
|
@ -12,6 +25,36 @@ if __name__ == '__main__':
|
|
|
|
with open('cards/' + cardID + '.json') as card_data:
|
|
|
|
with open('cards/' + cardID + '.json') as card_data:
|
|
|
|
data = json.load(card_data)
|
|
|
|
data = json.load(card_data)
|
|
|
|
event["name"] = data['name']
|
|
|
|
event["name"] = data['name']
|
|
|
|
|
|
|
|
if data['secretTools']:
|
|
|
|
|
|
|
|
GPIO.output(pin_config['tools_grn_LED'], GPIO.HIGH)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
GPIO.output(pin_config['tools_red_LED'], GPIO.HIGH)
|
|
|
|
|
|
|
|
if data['fridge']:
|
|
|
|
|
|
|
|
GPIO.output(pin_config['fridge_grn_LED'], GPIO.HIGH)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
GPIO.output(pin_config['fridge_red_LED'], GPIO.HIGH)
|
|
|
|
|
|
|
|
timeout = time.time() + 5 # 5 seconds timeout
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
# Open tools
|
|
|
|
|
|
|
|
if data['fridge'] and GPIO.input(pin_config['fridge_btn']) == 0:
|
|
|
|
|
|
|
|
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 fridge
|
|
|
|
|
|
|
|
if time.time() > timeout:
|
|
|
|
|
|
|
|
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
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
print "Card not registered."
|
|
|
|
print "Card not registered."
|
|
|
|
history = []
|
|
|
|
history = []
|
|
|
|