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
17displayio.release_displays()
18
19# This pinout works on a Feather M4 and may need to be altered for other boards.
20spi = board.SPI()  # Uses SCK and MOSI
21epd_cs = board.D9
22epd_dc = board.D10
23epd_reset = board.D5
24epd_busy = board.D6
25
26display_bus = displayio.FourWire(
27    spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
28)
29time.sleep(1)
30
31display = adafruit_ssd1681.SSD1681(
32    display_bus,
33    width=200,
34    height=200,
35    busy_pin=epd_busy,
36    highlight_color=0xFF0000,
37    rotation=180,
38)
39
40g = displayio.Group()
41
42with open("/display-ruler.bmp", "rb") as f:
43    pic = displayio.OnDiskBitmap(f)
44    # CircuitPython 6 & 7 compatible
45    t = displayio.TileGrid(
46        pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
47    )
48    # CircuitPython 7 compatible only
49    # t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
50    g.append(t)
51
52    display.show(g)
53
54    display.refresh()
55
56    print("refreshed")
57
58    time.sleep(120)