Simple test

Ensure your device works with this simple test.

examples/il91874_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5Simple test script for 2.7" 264x176 Tri-Color display shield
 6Supported products:
 7* Adafruit 2.7" Tri-Color ePaper Display Shield
 8  https://www.adafruit.com/product/4229
 9
10This program only requires the adafruit_il91874 library in /lib
11for CircuitPython 5.0 and above which has displayio support.
12"""
13
14import time
15
16import board
17import displayio
18from fourwire import FourWire
19
20import adafruit_il91874
21
22# Used to ensure the display is free in CircuitPython
23displayio.release_displays()
24
25# Define the pins needed for display use on the Metro
26spi = board.SPI()
27epd_cs = board.D10
28epd_dc = board.D9
29epd_reset = board.D5
30epd_busy = board.D6
31
32# Create the displayio connection to the display pins
33display_bus = FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000)
34time.sleep(1)  # Wait a bit
35
36# Create the display object - the third color is red (0xff0000)
37display = adafruit_il91874.IL91874(
38    display_bus,
39    width=264,
40    height=176,
41    busy_pin=epd_busy,
42    highlight_color=0xFF0000,
43    rotation=90,
44)
45
46# Create a display group for our screen objects
47g = displayio.Group()
48
49# Display a ruler graphic from the root directory of the CIRCUITPY drive
50
51pic = displayio.OnDiskBitmap("/display-ruler.bmp")
52# Create a Tilegrid with the bitmap and put in the displayio group
53t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
54g.append(t)
55
56# Place the display group on the screen (does not refresh)
57display.root_group = g
58
59# Show the image on the display
60display.refresh()
61
62print("refreshed")
63
64# Do Not refresh the screen more often than every 180 seconds
65#   for eInk displays! Rapid refreshes will damage the panel.
66time.sleep(180)