Simple test
Ensure your device works with this simple test. This simple test is for the 2.9” Flexible Monochrome display.
examples/uc8151d_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 2.9" 296x128 monochrome display.
7
8Supported products:
9 * Adafruit Flexible 2.9" Monochrome
10 * https://www.adafruit.com/product/4262
11"""
12# pylint: disable=no-member
13
14import time
15
16import board
17import displayio
18from fourwire import FourWire
19
20import adafruit_uc8151d
21
22displayio.release_displays()
23
24# This pinout works on a Feather M4 and may need to be altered for other boards.
25spi = board.SPI() # Uses SCK and MOSI
26epd_cs = board.D9
27epd_dc = board.D10
28epd_reset = board.D5
29epd_busy = None
30
31display_bus = FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000)
32time.sleep(1)
33
34display = adafruit_uc8151d.UC8151D(
35 display_bus, width=296, height=128, rotation=90, busy_pin=epd_busy
36)
37
38g = displayio.Group()
39
40pic = displayio.OnDiskBitmap("/display-ruler.bmp")
41t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
42g.append(t)
43
44# Place the display group on the screen
45display.root_group = g
46
47# Refresh the display to have it actually show the image
48# NOTE: Do not refresh eInk displays sooner than 180 seconds
49display.refresh()
50print("refreshed")
51
52time.sleep(180)
Device Specific Examples
examples/uc8151d_1.54_grayscale.py
1# SPDX-FileCopyrightText: 2022 Martin Refseth, written for Adafruit Industries
2#
3# SPDX-License-Identifier: Unlicense
4
5"""Simple test script for 1.54" 152x152 grayscale display.
6
7Supported products:
8 * 1.54" Grayscale Display (GDEW0154T8D)
9"""
10# pylint: disable=no-member
11
12import time
13
14import board
15import busio
16import displayio
17from fourwire import FourWire
18
19import adafruit_uc8151d
20
21displayio.release_displays()
22
23# Pinout intended for use with a Raspberry Pi Pico
24clk = board.GP10
25si = board.GP11
26dc = board.GP8
27cs = board.GP9
28rst = board.GP12
29busy = board.GP13
30
31display_bus = FourWire(busio.SPI(clk, si), command=dc, chip_select=cs, reset=rst, baudrate=1000000)
32
33time.sleep(1)
34
35display = adafruit_uc8151d.UC8151D(
36 display_bus, width=152, height=152, busy_pin=busy, rotation=180, grayscale=True
37)
38
39
40bitmap = displayio.Bitmap(152, 152, 4)
41
42# Draw Black
43for x in range(0, 152):
44 for y in range(0, 38):
45 bitmap[x, y] = 0
46# Draw Dark Gray
47for x in range(0, 152):
48 for y in range(38, 76):
49 bitmap[x, y] = 1
50# Draw Light Gray
51for x in range(0, 152):
52 for y in range(76, 114):
53 bitmap[x, y] = 2
54# Draw White
55for x in range(0, 152):
56 for y in range(114, 152):
57 bitmap[x, y] = 3
58
59palette = displayio.Palette(4)
60palette[0] = 0x000000 # Black
61palette[1] = 0x404040 # Dark Gray
62palette[2] = 0x808080 # Light Gray
63palette[3] = 0xFFFFFF # White
64
65g = displayio.Group()
66t = displayio.TileGrid(bitmap, pixel_shader=palette)
67g.append(t)
68display.root_group = g
69display.refresh()
examples/uc8151d_2.9_color.py
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4"""Simple test script for Adafruit 2.9" 296x128 tri-color display
5Supported products:
6 * Adafruit 2.9" Tri-Color Display Breakout
7 * https://www.adafruit.com/product/1028
8"""
9
10import time
11
12import board
13import displayio
14from fourwire import FourWire
15
16import adafruit_uc8151d
17
18# Used to ensure the display is free in CircuitPython
19displayio.release_displays()
20
21# Define the pins needed for display use
22# This pinout is for a Feather M4 and may be different for other boards
23spi = board.SPI() # Uses SCK and MOSI
24epd_cs = board.D9
25epd_dc = board.D10
26epd_reset = board.D5
27epd_busy = board.D6
28
29# Create the displayio connection to the display pins
30display_bus = FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000)
31time.sleep(1) # Wait a bit
32
33# Create the display object - the third color is red (0xff0000)
34display = adafruit_uc8151d.UC8151D(
35 display_bus,
36 width=296,
37 height=128,
38 rotation=270,
39 busy_pin=epd_busy,
40 highlight_color=0xFF0000,
41)
42
43# Create a display group for our screen objects
44g = displayio.Group()
45
46# Display a ruler graphic from the root directory of the CIRCUITPY drive
47pic = displayio.OnDiskBitmap("/display-ruler.bmp")
48t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
49g.append(t)
50
51# Place the display group on the screen
52display.root_group = g
53
54# Refresh the display to have it actually show the image
55# NOTE: Do not refresh eInk displays sooner than 180 seconds
56display.refresh()
57print("refreshed")
58
59time.sleep(180)