Skip to content

Commit 3761c4d

Browse files
committed
test switches
1 parent 7d08a07 commit 3761c4d

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

examples/epd_bonnet.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1+
import time
12
import digitalio
23
import busio
34
import board
5+
from digitalio import DigitalInOut, Direction, Pull
46

57
from PIL import Image
68
from PIL import ImageDraw
79
from PIL import ImageFont
810
from adafruit_epd.epd import Adafruit_EPD
911
from adafruit_epd.ssd1675b import Adafruit_SSD1675B # pylint: disable=unused-import
1012

13+
# create two buttons
14+
switch1 = DigitalInOut(board.D6)
15+
switch2 = DigitalInOut(board.D5)
16+
switch1.direction = Direction.INPUT
17+
switch2.direction = Direction.INPUT
18+
1119
# create the spi device and pins we will need
1220
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
1321
ecs = digitalio.DigitalInOut(board.D8)
@@ -32,6 +40,8 @@
3240

3341
# clear the buffer
3442
display.fill(Adafruit_EPD.WHITE)
43+
# clear it out
44+
display.display()
3545

3646
# Get drawing object to draw on image.
3747
draw = ImageDraw.Draw(image)
@@ -74,7 +84,18 @@
7484
# Write two lines of text.
7585
draw.text((x, top), 'Hello', font=font, fill=BLACK)
7686
draw.text((x, top+20), 'World!', font=font, fill=BLACK)
77-
# Display image.
78-
display.image(image)
7987

80-
display.display()
88+
while True:
89+
if not switch1.value:
90+
print("Switch 1")
91+
display.image(image)
92+
display.display()
93+
while not switch1.value:
94+
time.sleep(0.01)
95+
if not switch2.value:
96+
print("Switch 2")
97+
display.fill(Adafruit_EPD.WHITE)
98+
display.display()
99+
while not switch2.value:
100+
time.sleep(0.01)
101+
time.sleep(0.01)

0 commit comments

Comments
 (0)