doors: Blink LEDs when exceptions are thrown
This gives visual feedback that something has gone horribly, horribly wrong. Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
parent
c877f6db00
commit
ff4bd7fcbd
25
doors.py
25
doors.py
|
@ -70,8 +70,19 @@ def close_door():
|
||||||
GPIO.output(GREEN_LED, OFF)
|
GPIO.output(GREEN_LED, OFF)
|
||||||
GPIO.output(YELLOW_LED, OFF);
|
GPIO.output(YELLOW_LED, OFF);
|
||||||
|
|
||||||
|
# Turn all LEDs on
|
||||||
|
def leds_on():
|
||||||
|
GPIO.output(RED_LED, ON)
|
||||||
|
GPIO.output(GREEN_LED, ON)
|
||||||
|
GPIO.output(YELLOW_LED, ON)
|
||||||
|
|
||||||
|
# Turn all LEDs off
|
||||||
|
def leds_off():
|
||||||
|
GPIO.output(RED_LED, OFF)
|
||||||
|
GPIO.output(GREEN_LED, OFF)
|
||||||
|
GPIO.output(YELLOW_LED, OFF)
|
||||||
|
|
||||||
close_door()
|
close_door()
|
||||||
GPIO.output(YELLOW_LED, OFF)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,14 +128,24 @@ def read_rfid():
|
||||||
RFID_SERIAL.flushInput() # ignore errors, no data
|
RFID_SERIAL.flushInput() # ignore errors, no data
|
||||||
|
|
||||||
|
|
||||||
|
def blink_leds():
|
||||||
|
for i in range(5):
|
||||||
|
if (i % 2) == 0:
|
||||||
|
leds_on()
|
||||||
|
else:
|
||||||
|
leds_off()
|
||||||
|
time.sleep(1)
|
||||||
|
close_door()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
read_rfid()
|
read_rfid()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
door_close()
|
|
||||||
print(e)
|
print(e)
|
||||||
|
close_door()
|
||||||
|
blink_leds()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__": main()
|
if __name__ == "__main__": main()
|
||||||
|
|
Loading…
Reference in New Issue