-
Notifications
You must be signed in to change notification settings - Fork 0
/
laneOutput.py
executable file
·101 lines (79 loc) · 2.05 KB
/
laneOutput.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/python3
import laneOutputDisplayReady
from gpiozero import PWMLED
##
# Class to display lane status
# We *JUST* display a status here - other classes check the status and request we display
#
class laneOutput:
redLED = None
greenLED = None
##
# Constructor
#
# We should change r/g LEDs to rgLED object
#
def __init__(self, rLED, gLED):
self.redLED = PWMLED(rLED)
self.greenLED = PWMLED(gLED)
##
# What to show prior to the race
#
def showClear(self):
# Red LED off
# Green LED on
pass
##
# What to show when we have finished the race
#
def showFinish(self):
# Red LED on
# Green LED off
pass
##
# What to show when the race is finished and we are displaying standings
#
def showPlace(self, place = None, lane = None):
# First = Green
# Second = Yellow (Green/Red)
# Third = Red
# Fourth = Off
if (place == None and lane == None):
# Throw an error or some shit
pass
# If we are passed a lane, get it's place
if (lane):
place = lane.getPlace()
# Display based off place
if(place == 1):
self.green()
elif(place == 2):
self.yellow()
elif(place == 3):
self.red()
else:
self.off()
##
# Displays whether the lane is ready to race or not.
#
def displayReady(self, lane):
if (lane.isReady()):
self.green()
return
self.red()
##
# Methods to set static colors
#
def off(self):
self.redLED.value = 0.0
self.greenLED.value = 0.0
def red(self):
self.redLED.value = 1.0
self.greenLED.value = 0.0
def yellow(self):
# Yellow = Red=100, Green=40
self.redLED.value = 1.0
self.greenLED.value = 0.4
def green(self):
self.redLED.value = 0.0
self.greenLED.value = 0.4