-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.py
37 lines (30 loc) · 1.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
from neodraw import NeoDraw
from logutil import get_logger
class Display:
def __init__(self, time, neodraw : NeoDraw) -> None:
yellow = (255, 100, 0)
orange = (255, 50, 0)
green = (0, 255, 0)
blue = (0, 0, 255)
red = (255, 0, 0)
self.color = orange
self.neodraw = neodraw
self.time = time
self.logger = get_logger(__name__)
def getTimeStrings(self):
currentTime = self.time.localtime()
hour = currentTime[3]
minute = currentTime[4]
hourString = '{:02d}'.format(hour)
minuteString = '{:02d}'.format(minute)
return (hourString, minuteString)
def showTime(self):
hours, minutes = self.getTimeStrings()
self.logger.info('{}:{}'.format(hours, minutes))
self.neodraw.clear()
self.neodraw.letter(0,0,hours[0], self.color)
self.neodraw.letter(6,0,hours[1], self.color)
self.neodraw.letter(12,0,'colon', self.color)
self.neodraw.letter(18,0,minutes[0], self.color)
self.neodraw.letter(24,0,minutes[1], self.color)
self.neodraw.show()