-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleds.py
More file actions
50 lines (43 loc) · 1.25 KB
/
Copy pathleds.py
File metadata and controls
50 lines (43 loc) · 1.25 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
import RPi.GPIO as GPIO
import time
import logging
class LEDs:
def __init__(self, logger=logging.getLogger(__name__)):
self.logger = logger
GPIO.setmode(GPIO.BOARD)
#GPIO.setwarnings(False)
#success LED
GPIO.setup(13,GPIO.OUT)
GPIO.output(13,0)
#Busy LED
GPIO.setup(7,GPIO.OUT)
GPIO.output(7,0)
#fail LED
GPIO.setup(12,GPIO.OUT)
GPIO.output(12,0)
logging.debug("LEDS initialised")
def __enter__(self):
return self
def busyOff(self):
GPIO.output(7,0)
def orange(self):
GPIO.output(7,1)
def green(self):
self.busyOff();
for _ in range(6):
GPIO.output(13,1)
time.sleep(0.3)
GPIO.output(13,0)
time.sleep(0.3)
self.logger.debug("Flashed success LED")
def red(self):
self.busyOff();
for _ in range(6):
GPIO.output(12,1)
time.sleep(0.3)
GPIO.output(12,0)
time.sleep(0.3)
logging.info("Flashed failed LED")
def __exit__(self, type, value, traceback):
self.logger.debug("lights exited")
GPIO.cleanup()