-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.py
72 lines (63 loc) · 2.29 KB
/
demo.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
#!/usr/bin/env python3
import logging
import time
from PIL import Image, ImageOps
from lib import epd2in7b_u as epd2in7b
logging.basicConfig(level=logging.DEBUG)
try:
logging.info("epd2in7b-u Demo")
epd = epd2in7b.EPD()
logging.info("init and Clear")
epd.init()
epd.Clear()
time.sleep(1)
logging.info("Creating images...")
black_image = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame
red_image = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame
empty_image = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame
for x in range(epd.height):
for y in range(epd.width):
if (x + y) % 16 == 0:
red_image.putpixel((x, y), 0)
if (x + y + 8) % 16 == 0:
black_image.putpixel((x, y), 0)
mirrored_black_image = ImageOps.mirror(black_image)
black_image = black_image.rotate(90, expand=True)
red_image = red_image.rotate(90, expand=True)
empty_image = empty_image.rotate(90, expand=True)
mirrored_black_image = mirrored_black_image.rotate(90, expand=True)
logging.info("Differential refresh (fast partial update)...")
epd.set_lut(fast=True)
epd.display_partial_image(mirrored_black_image,
empty_image,
32,
epd.height - 64 - 32,
64,
64)
time.sleep(20)
epd.display_partial_image(black_image,
empty_image,
32,
epd.height - 64 - 32,
64,
64)
time.sleep(20)
logging.info("Windowed refresh using full flush cycle...")
epd.set_lut(fast=False)
epd.display_partial_image(black_image,
red_image,
32,
epd.height - 64*2 - 32*2,
64,
64)
time.sleep(20)
logging.info("Clear...")
epd.Clear()
logging.info("Goto Sleep...")
epd.sleep()
except IOError as e:
logging.info(e)
except KeyboardInterrupt:
logging.info("ctrl + c:")
epd2in7b.epdconfig.module_exit()
exit()