Simple test

Ensure your device works with this simple test.

examples/epd_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4import digitalio
 5import busio
 6import board
 7from adafruit_epd.epd import Adafruit_EPD
 8from adafruit_epd.il0373 import Adafruit_IL0373
 9from adafruit_epd.il91874 import Adafruit_IL91874  # pylint: disable=unused-import
10from adafruit_epd.il0398 import Adafruit_IL0398  # pylint: disable=unused-import
11from adafruit_epd.ssd1608 import Adafruit_SSD1608  # pylint: disable=unused-import
12from adafruit_epd.ssd1675 import Adafruit_SSD1675  # pylint: disable=unused-import
13from adafruit_epd.ssd1680 import Adafruit_SSD1680  # pylint: disable=unused-import
14from adafruit_epd.ssd1681 import Adafruit_SSD1681  # pylint: disable=unused-import
15from adafruit_epd.uc8151d import Adafruit_UC8151D  # pylint: disable=unused-import
16
17# create the spi device and pins we will need
18spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
19ecs = digitalio.DigitalInOut(board.D12)
20dc = digitalio.DigitalInOut(board.D11)
21srcs = digitalio.DigitalInOut(board.D10)  # can be None to use internal memory
22rst = digitalio.DigitalInOut(board.D9)  # can be None to not use this pin
23busy = digitalio.DigitalInOut(board.D5)  # can be None to not use this pin
24
25# give them all to our drivers
26print("Creating display")
27# display = Adafruit_SSD1608(200, 200,        # 1.54" HD mono display
28# display = Adafruit_SSD1675(122, 250,        # 2.13" HD mono display
29# display = Adafruit_SSD1680(122, 250,        # 2.13" HD Tri-color display
30# display = Adafruit_SSD1681(200, 200,        # 1.54" HD Tri-color display
31# display = Adafruit_IL91874(176, 264,        # 2.7" Tri-color display
32# display = Adafruit_IL0373(152, 152,         # 1.54" Tri-color display
33# display = Adafruit_UC8151D(128, 296,        # 2.9" mono flexible display
34# display = Adafruit_IL0373(128, 296,         # 2.9" Tri-color display
35# display = Adafruit_IL0398(400, 300,         # 4.2" Tri-color display
36display = Adafruit_IL0373(
37    104,
38    212,  # 2.13" Tri-color display
39    spi,
40    cs_pin=ecs,
41    dc_pin=dc,
42    sramcs_pin=srcs,
43    rst_pin=rst,
44    busy_pin=busy,
45)
46
47# IF YOU HAVE A 2.13" FLEXIBLE DISPLAY uncomment these lines!
48# display.set_black_buffer(1, False)
49# display.set_color_buffer(1, False)
50
51# IF YOU HAVE A 2.9" FLEXIBLE DISPLAY uncomment these lines!
52# display.set_black_buffer(1, True)
53# display.set_color_buffer(1, True)
54
55display.rotation = 1
56
57# clear the buffer
58print("Clear buffer")
59display.fill(Adafruit_EPD.WHITE)
60display.pixel(10, 100, Adafruit_EPD.BLACK)
61
62print("Draw Rectangles")
63display.fill_rect(5, 5, 10, 10, Adafruit_EPD.RED)
64display.rect(0, 0, 20, 30, Adafruit_EPD.BLACK)
65
66print("Draw lines")
67display.line(0, 0, display.width - 1, display.height - 1, Adafruit_EPD.BLACK)
68display.line(0, display.height - 1, display.width - 1, 0, Adafruit_EPD.RED)
69
70print("Draw text")
71display.text("hello world", 25, 10, Adafruit_EPD.BLACK)
72display.display()