-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisplay.py
64 lines (57 loc) · 2.13 KB
/
Display.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
from NumberLCD import NumberLCD
class Display():
def __init__(self, numbers, width, height):
self.numbersOnDisplay = numbers
self.width = int(width)
self.height = int(height)
self.horizontalSpace = self.getHorizontalSpaces()
self.lineOne = []
self.lineTwo = []
self.lineTree = []
self.lineFour = []
self.lineFive = []
self.fillLines()
def getHorizontalSpaces(self):
returnData = ""
for i in range(self.width):
returnData += "_"
return returnData
def fillLines(self):
for i in range(len(self.numbersOnDisplay)):
numberLcd = NumberLCD(self.numbersOnDisplay[i])
line1, line2, line3, line4, line5 = numberLcd.returnLines()
self.lineOne.append(line1)
self.lineTwo.append(line2)
self.lineTree.append(line3)
self.lineFour.append(line4)
self.lineFive.append(line5)
def getHorizontalLine(self, line):
stringOut = ""
for i in range(len(line)):
for j in range(len(line[i])):
if not j == 1:
stringOut += " "
elif j == 1:
if line[i][j] == True:
stringOut += "_" * self.width
else:
stringOut += " " * self.width
print(stringOut)
def getVerticalLine(self, line):
for k in range(self.height):
stringOut = ""
for i in range(len(line)):
for j in range(len(line[i])):
if (j == 0 or j == 2) and line[i][j] == True:
stringOut += "|"
elif j == 1:
stringOut += " " * self.width
else:
stringOut += " "
print (stringOut)
def printDisplay(self):
self.getHorizontalLine(self.lineOne)
self.getVerticalLine(self.lineTwo)
self.getHorizontalLine(self.lineTree)
self.getVerticalLine(self.lineFour)
self.getHorizontalLine(self.lineFive)