-
Notifications
You must be signed in to change notification settings - Fork 11
/
demo.py
executable file
·151 lines (130 loc) · 3.53 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env python
from epd import *
from time import sleep
import sys
# draw lines
def lines():
for y in [y for y in range(0,601,100)]:
if y==0:
y = 1
epd_line(0,y-1,799,y-1)
for x in [x for x in range(0,801,100)]:
if x==0:
x = 1
epd_line(x-1,0,x-1,599)
epd_update()
# draw circles
def circles():
for x in [x for x in range(50,751,100)]:
epd_circle(x-1,49,40)
epd_update()
# draw filled circles
def filled_circles():
for x in [x for x in range(50,751,100)]:
epd_fill_circle(x-1,149,40)
epd_update()
# draw rectangles
def rectangles():
for x in [x for x in range(10,790,100)]:
epd_rect(x-1,210,x-1+80,290)
epd_update()
# draw filled rectangles
def filled_rectangles():
for x in [x for x in range(10,790,100)]:
epd_fill_rect(x-1,310,x-1+80,390)
epd_update()
# draw triangles
def triangles():
for x in [x for x in range(50,751,100)]:
epd_triangle(x-1,410,x-1-40,490,x-1+40,490)
epd_update()
# draw filled triangles
def filled_triangles():
for x in [x for x in range(50,751,100)]:
epd_fill_triangle(x-1,510,x-1-40,590,x-1+40,590)
epd_update()
# draw single pixels
def pixels():
for p in [(x,y) for x in range(50,751,100) for y in range(448,466,3)]:
epd_pixel(p[0]-1,p[1]-1)
epd_update()
# display ascii strings
def english():
for x in [x for x in range(25,790,100)]:
epd_ascii(x-1, 30, 'ABC')
epd_update()
# display Chinese in GB2312 encoding (2 bytes)
def chinese():
for x in [x for x in range(20,790,100)]:
epd_chinese(x-1, 215, "C4E3 BAC3")
epd_chinese(x-1, 250, "CAC0 BDE7")
epd_update()
# display blocks of long texts
def english_block():
txt = "The quick brown fox jumps over the lazy dog. "
wrap_ascii(0,0,txt*6)
epd_update()
sleep(5)
wrap_ascii(50,250,txt*6,limit=400)
epd_update()
sleep(5)
wrap_ascii(350,150,txt*6,limit=350)
epd_update()
# display LCD digits in 3 sizes
def lcd_digits():
epd_lcd_digits(0,0,'0:1234567',scale=LCD_SM)
sleep(3)
epd_lcd_digits(0,100,'0:1234567',scale=LCD_MD)
sleep(3)
epd_lcd_digits(0,300,'0:123',scale=LCD_LG)
# display block digits in 3 sizes
def block_digits():
epd_block_digits(0,0,':01234567891234',scale=BLOCK_SM)
sleep(3)
epd_block_digits(0,100,':012345',scale=BLOCK_MD)
sleep(3)
epd_block_digits(0,300,':0123',scale=BLOCK_LG)
if __name__=="__main__":
try:
epd_connect()
except:
sys.exit()
epd_clear()
# need some reaction time between each set of drawing commands
# this may be something to do with the instruction buffer of the epd
# another known issue is if hundreds of draw pixel commands are
# sent over before calling an update (e.g. in a 2-D loop), the module
# and in my case, all my USB ports IO are frozen. I lose USB mouse and
# keyboard. Have to restart the computer to get things working again.
lines()
sleep(5)
circles()
sleep(5)
filled_circles()
sleep(5)
rectangles()
sleep(5)
filled_rectangles()
sleep(5)
triangles()
sleep(5)
filled_triangles()
sleep(5)
pixels()
sleep(5)
epd_set_en_font(ASCII32)
english()
sleep(5)
chinese()
sleep(5)
english_block()
sleep(5)
lcd_digits()
sleep(5)
block_digits()
sleep(3)
epd_bitmap(100,0,"FACE.BMP")
epd_set_en_font(ASCII48)
epd_ascii(0,540,"http://github.com/yy502/ePaperDisplay")
epd_update()
epd_disconnect()