Simple test

Ensure your device works with this simple test.

examples/uc8253_simpletest.py
 1# SPDX-FileCopyrightText: 2025 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 3.7" 240x416 monochrome display (ThinkInk_370_Mono_BAAMFGN)."""
 7
 8import time
 9
10import board
11import busio
12import displayio
13from fourwire import FourWire
14
15import adafruit_uc8253
16
17displayio.release_displays()
18
19# This pinout works on a MagTag with the newer screen and may need to be altered for other boards.
20spi = busio.SPI(board.EPD_SCK, board.EPD_MOSI)  # Uses SCK and MOSI
21epd_cs = board.EPD_CS
22epd_dc = board.EPD_DC
23epd_reset = board.EPD_RESET
24epd_busy = board.EPD_BUSY
25
26display_bus = FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000)
27time.sleep(1)
28
29display = adafruit_uc8253.UC8253(
30    display_bus, width=240, height=416, busy_pin=epd_busy, rotation=0, vcom_cdi=0x97
31)
32
33g = displayio.Group()
34
35pic = displayio.OnDiskBitmap("/display-ruler-1280x720.bmp")
36t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
37g.append(t)
38
39display.root_group = g
40
41display.refresh()
42
43print("refreshed")
44
45time.sleep(display.time_to_refresh + 5)
46# Always refresh a little longer. It's not a problem to refresh
47# a few seconds more, but it's terrible to refresh too early
48# (the display will throw an exception when if the refresh
49# is too soon)
50print("waited correct time")
51
52# Keep the display the same
53while True:
54    time.sleep(10)