-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_clock.py
More file actions
27 lines (23 loc) · 867 Bytes
/
Copy pathexample_clock.py
File metadata and controls
27 lines (23 loc) · 867 Bytes
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
import ILI9341 as TFT
from pyA20.gpio import connector
import time
from PIL import ImageFont
DC = connector.gpio1p26
disp = TFT.ILI9341(DC) # Do not configure RST
disp.begin()
disp.clear((0, 0, 0))
draw = disp.draw()
# Load default font.
timeFont = ImageFont.truetype("times.ttf", size=64)
dayFont = ImageFont.truetype("times.ttf", size=22)
while 1:
disp.clear((0, 0, 0))
# Draw time
timeText = time.strftime("%H:%M:%S", time.localtime())
timeWidth, timeHeight = draw.textsize(timeText, font=timeFont)
dayText = time.strftime("%Y-%m-%d %A, %b", time.localtime())
dayWidth, dayHeight = draw.textsize(dayText, font=dayFont)
draw.text(((disp.width-timeWidth)/2,50), timeText, font=timeFont, fill=(255,255,255))
draw.text(((disp.width-dayWidth)/2,110), dayText, font=dayFont, fill=(150,150,150))
disp.display()
time.sleep(0.2)