def powerSwitch(channel):
#Checking for LED bounce for the duration of the Power Timeout
for bounceSample in range(1, int(round(powerTimeout / sampleRate))):
time.sleep(sampleRate)
if GPIO.input(powerGPIO) is 0:
break
if bounceSample is int(round(powerTimeout / sampleRate)) - 1:
#When the Power Switch is placed in the off position with no bounce for the duration of the Power Timeout, we immediately shutdown
os.system("sudo shutdown -h now")
try:
sys.stdout.close()
except:
pass
try:
sys.stderr.close()
except:
pass
sys.exit(0)
评论列表
文章目录