Simple test

Ensure your device works with this simple test.

examples/ssd1608_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""Simple test script for 1.54" 200x200 monochrome display.
 5
 6Supported products:
 7  * Adafruit 1.54" Monochrome ePaper Display Breakout
 8    * https://www.adafruit.com/product/4196
 9  """
10
11import time
12import board
13import displayio
14import fourwire
15import adafruit_ssd1608
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 = fourwire.FourWire(
27    spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
28)
29time.sleep(1)
30
31display = adafruit_ssd1608.SSD1608(
32    display_bus, width=200, height=200, busy_pin=epd_busy, rotation=180
33)
34
35g = displayio.Group()
36
37with open("/display-ruler.bmp", "rb") as f:
38    pic = displayio.OnDiskBitmap(f)
39    # CircuitPython 6 & 7 compatible
40    t = displayio.TileGrid(
41        pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
42    )
43    # CircuitPython 7 compatible only
44    # t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
45    g.append(t)
46
47    display.root_group = g
48
49    display.refresh()
50
51    print("refreshed")
52
53    time.sleep(120)