Skip to content

Commit 0e53954

Browse files
committed
upcoming shield
1 parent f10cbbd commit 0e53954

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

examples/epd_shieldtest.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# EInk Shield test
2+
import digitalio
3+
import busio
4+
import board
5+
import time
6+
from analogio import AnalogIn
7+
from adafruit_epd.epd import Adafruit_EPD
8+
from adafruit_epd.il91874 import Adafruit_IL91874
9+
10+
# create the spi device and pins we will need
11+
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
12+
ecs = digitalio.DigitalInOut(board.D10)
13+
dc = digitalio.DigitalInOut(board.D9)
14+
srcs = digitalio.DigitalInOut(board.D8) # can be None to use internal memory
15+
16+
# give them all to our driver
17+
print("Creating display")
18+
display = Adafruit_IL91874(176, 264, spi, # 2.7" Tri-color display
19+
cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs,
20+
rst_pin=None, busy_pin=None)
21+
22+
display.rotation = 1
23+
24+
def read_buttons():
25+
with AnalogIn(board.A3) as ain:
26+
reading = ain.value / 65535
27+
if reading > 0.75:
28+
return None
29+
if reading > 0.4:
30+
return 4
31+
if reading > 0.25:
32+
return 3
33+
if reading > 0.13:
34+
return 2
35+
return 1
36+
37+
while True:
38+
button = read_buttons()
39+
if not button:
40+
continue
41+
print("Button #%d pressed" % button)
42+
if button == 1:
43+
print("Clear buffer")
44+
display.fill(Adafruit_EPD.WHITE)
45+
display.display()
46+
if button == 2:
47+
print("Draw Rectangles")
48+
display.fill_rect(5, 5, 10, 10, Adafruit_EPD.RED)
49+
display.rect(0, 0, 20, 30, Adafruit_EPD.BLACK)
50+
display.display()
51+
if button == 3:
52+
print("Draw lines")
53+
display.line(0, 0, display.width-1, display.height-1, Adafruit_EPD.BLACK)
54+
display.line(0, display.height-1, display.width-1, 0, Adafruit_EPD.RED)
55+
display.display()
56+
if button == 4:
57+
print("Draw text")
58+
display.text('hello world', 25, 10, Adafruit_EPD.BLACK)
59+
display.display()
60+
time.sleep(0.01)

0 commit comments

Comments
 (0)