def button_select_click(channel): global current_mode, ready_to_shutdown, automatic_mode automatic_mode = True if current_mode == MODE_STOP: if not ready_to_shutdown: display("STP?") ready_to_shutdown = True else: display("SHUT") if not (EXTERNAL_DEBUG_MODE): GPIO.cleanup() os.system("sudo shutdown now -h") else: print("DEBUG : SHUTDOWN BUTTON CLICKED") exit else: if not (_current is None): _current.onSelect()
def button_select_click(channel): global current_mode, ready_to_shutdown, automatic_mode automatic_mode = True if current_mode == MODE_STOP: if not ready_to_shutdown : display("STP?") ready_to_shutdown = True else : display("SHUT") if not(EXTERNAL_DEBUG_MODE): GPIO.cleanup() os.system("sudo shutdown now -h") else: print("DEBUG : SHUTDOWN BUTTON CLICKED") exit else : if not(_current is None): _current.onSelect()
else: _ledComm.sendLedReset() print "LED Reset" delta = (datetime.now() - timer_current) sleepduration = (delta.total_seconds() + delta.microseconds / 1000000) if sleepduration < TOTAL_SLEEP: print "Sleep : " + str(TOTAL_SLEEP - sleepduration) time.sleep(TOTAL_SLEEP - sleepduration) else: print "No sleep" timer_lastloop = timer_current #except: try: if not (_current is None): _current.onStop() display("ERR") # 3 attempts to light off the led strip _ledComm.sendLedReset() time.sleep(2) _ledComm.sendLedReset() time.sleep(2) _ledComm.sendLedReset() except: pass GPIO.cleanup()
print "Sent to LED" else: _ledComm.sendLedReset() print "LED Reset" delta = (datetime.now() - timer_current) sleepduration = (delta.total_seconds() + delta.microseconds / 1000000) if sleepduration < TOTAL_SLEEP: print "Sleep : " + str(TOTAL_SLEEP - sleepduration) time.sleep(TOTAL_SLEEP - sleepduration) else: print "No sleep" timer_lastloop = timer_current #except: try: if not(_current is None): _current.onStop() display("ERR") # 3 attempts to light off the led strip _ledComm.sendLedReset() sleep(2) _ledComm.sendLedReset() sleep(2) _ledComm.sendLedReset() except: pass GPIO.cleanup()