/
Lights.py
41 lines (32 loc) · 825 Bytes
/
Lights.py
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
import time
import Platform
if Platform.is_raspberrypi():
import RPi.GPIO as GPIO
# we have to use BCM mode to stay compatible with the dot3k
GPIO.setmode(GPIO.BCM)
lamps = [6, 13, 19, 26]
if Platform.is_raspberrypi():
for lamp in lamps:
GPIO.setup(lamp, GPIO.OUT)
def set_lamp(lamp_id, state):
if Platform.is_raspberrypi() and lamp_id >= 0 and lamp_id < len(lamps):
GPIO.output(lamps[lamp_id], state)
def all_off():
for lamp in range(0, len(lamps)):
set_lamp(lamp, 0)
def build_good():
set_lamp(0, 1)
set_lamp(1, 1)
set_lamp(2, 0)
set_lamp(3, 0)
def broken_test():
set_lamp(0, 0)
set_lamp(1, 1)
set_lamp(2, 0)
set_lamp(3, 0)
def broken_build():
set_lamp(0, 0)
set_lamp(1, 0)
set_lamp(2, 1)
set_lamp(3, 0)
all_off()