2016-04-01 00:37:54 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2015-05-08 21:27:28 +02:00
|
|
|
buttonpin=24
|
|
|
|
import RPi.GPIO as GPIO
|
|
|
|
import time
|
|
|
|
import os
|
|
|
|
|
2016-03-10 20:25:13 +01:00
|
|
|
|
2015-05-08 21:27:28 +02:00
|
|
|
GPIO.setmode(GPIO.BCM)
|
|
|
|
|
|
|
|
GPIO.setup(buttonpin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
2016-05-06 20:23:01 +02:00
|
|
|
exit
|
2015-05-08 21:27:28 +02:00
|
|
|
while True:
|
|
|
|
print "waiting..."
|
2016-03-10 20:25:13 +01:00
|
|
|
os.system('logger shutdownbutton waiting for press...')
|
2016-04-01 00:37:54 +02:00
|
|
|
try:
|
|
|
|
GPIO.wait_for_edge(buttonpin, GPIO.FALLING)
|
2015-05-08 21:27:28 +02:00
|
|
|
print('Button Pressed')
|
2016-03-10 20:25:13 +01:00
|
|
|
os.system('logger shutdownbutton pressen. bye bye')
|
2016-05-06 20:23:01 +02:00
|
|
|
# os.system("shutdown now -h")
|
2016-04-01 00:37:54 +02:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
GPIO.cleanup() # clean up GPIO on CTRL+C exit
|
2015-05-08 21:27:28 +02:00
|
|
|
GPIO.cleanup() #
|