-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_epd.py
28 lines (25 loc) · 962 Bytes
/
my_epd.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
import sys
import os
picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic')
libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib')
if os.path.exists(libdir):
sys.path.append(libdir)
from waveshare_epd import epd1in54_V2
from PIL import Image,ImageDraw,ImageFont
import time
epd = epd1in54_V2.EPD()
epd.init()
epd.Clear(0xFF)
while True:
new_time = time.time()
new_time = time.ctime(new_time)
new_time = new_time.encode('GB2312')
image = Image.new('1', (epd.width, epd.height), 255)
draw = ImageDraw.Draw(image)
font = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24)
draw.text((8, 36), u'time', font = font, fill = 0)
draw.text((20,12), u'by_huangyifan', font = font, fill = 0)
draw.text((12,12), new_time, font = font, fill = 0)
epd.display(epd.getbuffer(image.rotate(90)))
time.sleep(0.1)
epd.sleep()