Ursprüngliche Datein von RaspberryPi hinzugefügt

This commit is contained in:
Philipp Clima 2019-08-20 14:21:53 +02:00
parent 74edf7b3c8
commit e47caa28d2
2 changed files with 60 additions and 0 deletions

38
onoff.py Normal file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
import RPi.GPIO as GPIO
import time, os, sys
GPIO.setmode(GPIO.BOARD)
input_pin = 36
GPIO.setup(input_pin, GPIO.IN)
a=0
# solange "wahr" gilt (immer!) wird folgende sequenz ausgeführt:
# wird der input pin als high (3V) erkannt, wird 60x alle 0.05 sekunden überprüft
# ob der pin wieder auf low (0V) zurückgesetzt wird. ist dies der fall, wird ein reboot ausgeführt.
# ist nach diesen 60x0.05 sekunden der pin immernoch high, wird ein poweroff ausgeführt.
# rein theorethisch wäre es möglich innerhalb der 0.05 sekunden wartezeit nach der überprüfung auf low
# den schalter loszulassen, und somit würde weder ein reboot noch ein shutdown ausgeführt werden.
# sollte das zu oft passieren bitte das time.sleep innerhalb der (while a) schleife auf 0.001 sekunden stellen,
# dafür aber a auf 3000.
while True:
print("State:", GPIO.input(input_pin))
if GPIO.input(input_pin) == GPIO.HIGH:
while a <= 60:
if GPIO.input(input_pin) == GPIO.LOW:
print("reboot")
time.sleep(2)
os.system("reboot")
a=a+1
time.sleep(0.05)
if GPIO.input(input_pin) == GPIO.HIGH:
print("poweroff")
time.sleep(2)
os.system("poweroff")
time.sleep(0.05)

22
start.py Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
input_pin = 3
GPIO.setup(input_pin, GPIO.IN)
while True:
if not(GPIO.input(input_pin)):
time.sleep(1)
#starte externen timer
#starte externen zähler
#Endpunkt: timer wird gespeichert und das externe programm beendet
#zähler wird gespeichert und zurückgesetzt
#Score wird gespeichert und geliestet \ Score tabbel wird ca. 8sek. lang angezeigt