-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuva_lcd_display.py
121 lines (106 loc) · 2.82 KB
/
uva_lcd_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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# In Oboedencia Veritas
def print_row(screen, row, col, s):
# row, col = position of the row to print
col = col + 1
for i in range(s):
screen[row][col+i] = '-'
def print_col(screen, row, col, s):
# row, col = position of first char in the column to print
row = row + 1
for i in range(s):
screen[row+i][col] = '|'
def v0(screen, top_left, s):
print_col(screen, row=0, col=top_left, s=s)
def v1(screen, top_left, s):
print_col(screen, row=0, col=top_left+s+1, s=s)
def v2(screen, top_left, s):
print_col(screen, row=s+1, col=top_left, s=s)
def v3(screen, top_left, s):
print_col(screen, row=s+1, col=top_left+s+1, s=s)
def h0(screen, top_left, s):
print_row(screen, row=0, col=top_left, s=s)
def h1(screen, top_left, s):
print_row(screen, row=s+1, col=top_left, s=s)
def h2(screen,top_left, s):
print_row(screen, row=len(screen)-1, col=top_left, s=s)
def print_number(screen, s, n):
pos = 0
for i, d in enumerate(n):
pos = i * (s+3)
params = (screen, pos, s)
if d == '0':
h0(*params)
h2(*params)
v0(*params)
v1(*params)
v2(*params)
v3(*params)
elif d == '1':
v1(*params)
v3(*params)
elif d == '2':
h0(*params)
h1(*params)
h2(*params)
v1(*params)
v2(*params)
elif d == '3':
h0(*params)
h1(*params)
h2(*params)
v1(*params)
v3(*params)
elif d == '4':
v0(*params)
v1(*params)
v3(*params)
h1(*params)
elif d == '5':
h0(*params)
h1(*params)
h2(*params)
v0(*params)
v3(*params)
elif d == '6':
h0(*params)
h1(*params)
h2(*params)
v0(*params)
v2(*params)
v3(*params)
elif d == '7':
v1(*params)
v3(*params)
h0(*params)
elif d == '8':
h0(*params)
h1(*params)
h2(*params)
v0(*params)
v1(*params)
v2(*params)
v3(*params)
else: # d == '9'
h0(*params)
h1(*params)
h2(*params)
v0(*params)
v1(*params)
v3(*params)
def print_screen(screen):
for row in screen:
for c in row:
print(c, end='')
print()
while True:
s, n = input().split()
if (int(s), int(n)) == (0, 0):
break
ndigits = len(n)
s = int(s)
cols = (s+2) * ndigits + ndigits - 1
rows = 2 * s + 3
screen = [[' '] * cols for _ in range(rows)]
print_number(screen, s, n)
print_screen(screen)
print()