Simple test

Ensure your device works with this simple test.

examples/ssd1681_simpletest.py
 1# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
 2# SPDX-FileCopyrightText: Copyright (c) 2021 Melissa LeBlanc-Williams for Adafruit Industries
 3#
 4# SPDX-License-Identifier: Unlicense
 5
 6"""Simple test script for 1.54" 200x200 tri-color display.
 7Supported products:
 8  * Adafruit 1.54" Tri-Color Display Breakout
 9    * https://www.adafruit.com/product/4868
10  """
11
12import time
13import board
14import displayio
15import adafruit_ssd1681
16
17# Compatibility with both CircuitPython 8.x.x and 9.x.x.
18# Remove after 8.x.x is no longer a supported release.
19try:
20    from fourwire import FourWire
21except ImportError:
22    from displayio import FourWire
23
24displayio.release_displays()
25
26# This pinout works on a Feather M4 and may need to be altered for other boards.
27spi = board.SPI()  # Uses SCK and MOSI
28epd_cs = board.D9
29epd_dc = board.D10
30epd_reset = board.D5
31epd_busy = board.D6
32
33display_bus = FourWire(
34    spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
35)
36time.sleep(1)
37
38display = adafruit_ssd1681.SSD1681(
39    display_bus,
40    width=200,
41    height=200,
42    busy_pin=epd_busy,
43    highlight_color=0xFF0000,
44    rotation=180,
45)
46
47g = displayio.Group()
48
49with open("/display-ruler.bmp", "rb") as f:
50    pic = displayio.OnDiskBitmap(f)
51    # CircuitPython 6 & 7 compatible
52    t = displayio.TileGrid(
53        pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
54    )
55    # CircuitPython 7 compatible only
56    # t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
57    g.append(t)
58
59    display.root_group = g
60
61    display.refresh()
62
63    print("refreshed")
64
65    time.sleep(120)