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