Simple test¶
Ensure your device works with this simple test. This simple test is for the 2.9” Flexible Monochrome display.
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
15import board
16import displayio
17import adafruit_uc8151d
18
19# For 8.x.x and 9.x.x. When 8.x.x is discontinued as a stable release, change this.
20try:
21 from fourwire import FourWire
22except ImportError:
23 from displayio import FourWire
24
25displayio.release_displays()
26
27# This pinout works on a Feather M4 and may need to be altered for other boards.
28spi = board.SPI() # Uses SCK and MOSI
29epd_cs = board.D9
30epd_dc = board.D10
31epd_reset = board.D5
32epd_busy = None
33
34display_bus = FourWire(
35 spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
36)
37time.sleep(1)
38
39display = adafruit_uc8151d.UC8151D(
40 display_bus, width=296, height=128, rotation=90, busy_pin=epd_busy
41)
42
43g = displayio.Group()
44
45with open("/display-ruler.bmp", "rb") as f:
46 pic = displayio.OnDiskBitmap(f)
47 t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
48 g.append(t)
49
50 display.root_group = g
51
52 display.refresh()
53
54 time.sleep(120)
Device Specific Examples¶
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
13import board
14import displayio
15import busio
16import adafruit_uc8151d
17
18# For 8.x.x and 9.x.x. When 8.x.x is discontinued as a stable release, change this.
19try:
20 from fourwire import FourWire
21except ImportError:
22 from displayio import FourWire
23
24displayio.release_displays()
25
26# Pinout intended for use with a Raspberry Pi Pico
27clk = board.GP10
28si = board.GP11
29dc = board.GP8
30cs = board.GP9
31rst = board.GP12
32busy = board.GP13
33
34display_bus = FourWire(
35 busio.SPI(clk, si), command=dc, chip_select=cs, reset=rst, baudrate=1000000
36)
37
38time.sleep(1)
39
40display = adafruit_uc8151d.UC8151D(
41 display_bus, width=152, height=152, busy_pin=busy, rotation=180, grayscale=True
42)
43
44
45bitmap = displayio.Bitmap(152, 152, 4)
46
47# Draw Black
48for x in range(0, 152):
49 for y in range(0, 38):
50 bitmap[x, y] = 0
51# Draw Dark Gray
52for x in range(0, 152):
53 for y in range(38, 76):
54 bitmap[x, y] = 1
55# Draw Light Gray
56for x in range(0, 152):
57 for y in range(76, 114):
58 bitmap[x, y] = 2
59# Draw White
60for x in range(0, 152):
61 for y in range(114, 152):
62 bitmap[x, y] = 3
63
64palette = displayio.Palette(4)
65palette[0] = 0x000000 # Black
66palette[1] = 0x404040 # Dark Gray
67palette[2] = 0x808080 # Light Gray
68palette[3] = 0xFFFFFF # White
69
70g = displayio.Group()
71t = displayio.TileGrid(bitmap, pixel_shader=palette)
72g.append(t)
73display.root_group = g
74display.refresh()
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
11import board
12import displayio
13import adafruit_uc8151d
14
15# For 8.x.x and 9.x.x. When 8.x.x is discontinued as a stable release, change this.
16try:
17 from fourwire import FourWire
18except ImportError:
19 from displayio import FourWire
20
21# Used to ensure the display is free in CircuitPython
22displayio.release_displays()
23
24# Define the pins needed for display use
25# This pinout is for a Feather M4 and may be different for other boards
26spi = board.SPI() # Uses SCK and MOSI
27epd_cs = board.D9
28epd_dc = board.D10
29epd_reset = board.D5
30epd_busy = board.D6
31
32# Create the displayio connection to the display pins
33display_bus = FourWire(
34 spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
35)
36time.sleep(1) # Wait a bit
37
38# Create the display object - the third color is red (0xff0000)
39display = adafruit_uc8151d.UC8151D(
40 display_bus,
41 width=296,
42 height=128,
43 rotation=270,
44 busy_pin=epd_busy,
45 highlight_color=0xFF0000,
46)
47
48# Create a display group for our screen objects
49g = displayio.Group()
50
51# Display a ruler graphic from the root directory of the CIRCUITPY drive
52with open("/display-ruler.bmp", "rb") as f:
53 pic = displayio.OnDiskBitmap(f)
54 # Create a Tilegrid with the bitmap and put in the displayio group
55 # CircuitPython 6 & 7 compatible
56 t = displayio.TileGrid(
57 pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
58 )
59 # CircuitPython 7 compatible only
60 # t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
61 g.append(t)
62
63 # Place the display group on the screen
64 display.root_group = g
65
66 # Refresh the display to have it actually show the image
67 # NOTE: Do not refresh eInk displays sooner than 180 seconds
68 display.refresh()
69 print("refreshed")
70
71 time.sleep(180)