-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrgb7seg_countupdown
executable file
·46 lines (35 loc) · 1.17 KB
/
rgb7seg_countupdown
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
#!/usr/bin/env python3
import random
from time import sleep
from rgb7seg import NumberDisplay
sleeptime = .25
COLORS = {
# name hue sat val
'white': (0, 0, 0.01),
'red': (0, 1, 0.01),
'yellow': (0.16666666, 1, 0.01),
'lime': (0.33333333, 1, 0.01),
'aqua': (0.5, 1, 0.01),
'blue': (0.66666666, 1, 0.01),
'purple': (0.83333333, 1, 0.01)
}
colors = [
COLORS['red'], COLORS['lime'], COLORS['blue'], COLORS['yellow'], COLORS['red'], COLORS['aqua'], COLORS['lime'], COLORS['white'], COLORS['purple'], COLORS['lime'], COLORS['red'], COLORS['aqua'], COLORS['white'], COLORS['blue'], COLORS['lime'], COLORS['red'], COLORS['purple'], COLORS['yellow'], COLORS['aqua']
]
colors.reverse()
numeral = NumberDisplay()
def rand_color():
while True:
color = random.choice(list(COLORS.keys()))
if color != 'black':
break
return color
for i in range(1, 10):
numeral.display(i, colors.pop())
sleep(sleeptime)
numeral.display(0, colors.pop())
sleep(sleeptime)
for i in range(9, 0, -1):
numeral.display(i, colors.pop())
sleep(sleeptime)
numeral.display()