|
|
@ -56,18 +56,23 @@ 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']:
|
|
|
|
locked = False
|
|
|
|
|
|
|
|
with open('locked_till.txt', 'rb') as f:
|
|
|
|
|
|
|
|
txt = f.read()
|
|
|
|
|
|
|
|
t = float(txt)
|
|
|
|
|
|
|
|
locked = time.time() < t
|
|
|
|
|
|
|
|
if data['secretTools'] and not locked:
|
|
|
|
GPIO.output(pin_config['tools_grn_LED'], GPIO.HIGH)
|
|
|
|
GPIO.output(pin_config['tools_grn_LED'], GPIO.HIGH)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
GPIO.output(pin_config['tools_red_LED'], GPIO.HIGH)
|
|
|
|
GPIO.output(pin_config['tools_red_LED'], GPIO.HIGH)
|
|
|
|
if data['fridge']:
|
|
|
|
if data['fridge'] and not locked:
|
|
|
|
GPIO.output(pin_config['fridge_grn_LED'], GPIO.HIGH)
|
|
|
|
GPIO.output(pin_config['fridge_grn_LED'], GPIO.HIGH)
|
|
|
|
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
|
|
|
|
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 and not locked:
|
|
|
|
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)
|
|
|
@ -76,7 +81,7 @@ if __name__ == '__main__':
|
|
|
|
wait = False
|
|
|
|
wait = False
|
|
|
|
# Open tools
|
|
|
|
# Open tools
|
|
|
|
subprocess.call("/home/pi/ELAB-RFID-I2C/RPi/i2c_challenge 0x30", shell=True)
|
|
|
|
subprocess.call("/home/pi/ELAB-RFID-I2C/RPi/i2c_challenge 0x30", shell=True)
|
|
|
|
if data['fridge'] and GPIO.input(pin_config['fridge_btn']) == 0:
|
|
|
|
if data['fridge'] and GPIO.input(pin_config['fridge_btn']) == 0 and not locked:
|
|
|
|
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)
|
|
|
|