-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGPIOClientSide.py
More file actions
56 lines (44 loc) · 1.42 KB
/
GPIOClientSide.py
File metadata and controls
56 lines (44 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import importlib.util
import _thread
try:
importlib.util.find_spec('RPi.GPIO')
import RPi.GPIO as GPIO
except ImportError:
import FakeRPi.GPIO as GPIO
import time
class GPIOClientSide:
#pin layout
ledGroen = 6
ledRood = 5
knopje = 4
knopje2 = 22
breached = False
armed = True
def __init__(self):
GPIO.setwarnings(False)
GPIO.cleanup()
GPIO.setmode(GPIO.BCM)
GPIO.setup(self.ledRood, GPIO.OUT)
GPIO.setup(self.ledGroen, GPIO.OUT)
GPIO.setup(self.knopje, GPIO.IN,pull_up_down=GPIO.PUD_UP)
GPIO.setup(self.knopje2, GPIO.IN,pull_up_down=GPIO.PUD_UP)
def disarm(self):
GPIO.output(self.ledRood,False)
GPIO.output(self.ledGroen,True)
def arm(self):
GPIO.output(self.ledRood,True)
GPIO.output(self.ledGroen,False)
def alarm(self):
GPIO.output(self.ledRood, True)
#print("Rood True") #DEBUG
time.sleep(1)
GPIO.output(self.ledRood, False)
#print("Rood False") #DEBUG
time.sleep(1)
#checks if one of the buttons is pressed, called from csn_cli_client in a separate thread.
def DoButtonCheck(self):
while True:
if GPIO.input(self.knopje) == True or GPIO.input(self.knopje2) == True:
print(GPIO.input(self.knopje))
print("KNOPJE INGEDRUKT -> breached: true")
self.breached = True