rat.post_log("Shutdown Button Started") while True: if not pressed and GPIO.input(17)==0: pressed = time.time() elif pressed and GPIO.input(17)==0: #print "pressed for {0}".format(time.time()-pressed) counter = int((time.time()-pressed)*10) inv_counter = 50-counter if inv_counter>=10: if counter%(inv_counter/10) == 0: RED_LED = not RED_LED rat.set_red_led(RED_LED) elif inv_counter<10: RED_LED = True rat.set_red_led(RED_LED) if counter>60: rat.set_green_led(True) rat.post_log("shutdown system") p = subprocess.Popen("shutdown -P -h now", shell=True) p.communicate() exit(0) elif pressed and GPIO.input(17)==1: RED_LED = False rat.set_red_led(RED_LED) pressed = False RED_LED = False time.sleep(0.1)
import io import Queue import threading import traceback import RPi.GPIO as GPIO skip = False if len(sys.argv)>1: if sys.argv[1]=='skip': skip = True if not skip: for _ in xrange(0,5): rat.set_red_led(True) rat.set_green_led(False) time.sleep(1) rat.set_red_led(False) rat.set_green_led(True) time.sleep(1) def log(msg): sys.stdout.write("[camera] "+str(msg)+"\n") sys.stdout.flush() rat.set_red_led(False) rat.set_green_led(False) GPIO.setmode(GPIO.BCM) GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)