Simple test

Ensure your device works with this simple test.

examples/st7789_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5This test will initialize the display using displayio and draw a solid green
 6background, a smaller purple rectangle, and some yellow text.
 7"""
 8
 9import board
10import displayio
11import terminalio
12from adafruit_display_text import label
13from fourwire import FourWire
14
15from adafruit_st7789 import ST7789
16
17# Release any resources currently in use for the displays
18displayio.release_displays()
19
20spi = board.SPI()
21tft_cs = board.D5
22tft_dc = board.D6
23
24display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)
25
26display = ST7789(display_bus, width=240, height=240, rowstart=80, bgr=True, invert=True)
27
28# Make the display context
29splash = displayio.Group()
30display.root_group = splash
31
32color_bitmap = displayio.Bitmap(240, 240, 1)
33color_palette = displayio.Palette(1)
34color_palette[0] = 0x00FF00  # Bright Green
35
36bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
37splash.append(bg_sprite)
38
39# Draw a smaller inner rectangle
40inner_bitmap = displayio.Bitmap(200, 200, 1)
41inner_palette = displayio.Palette(1)
42inner_palette[0] = 0xAA0088  # Purple
43inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
44splash.append(inner_sprite)
45
46# Draw a label
47text_group = displayio.Group(scale=2, x=50, y=120)
48text = "Hello World!"
49text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
50text_group.append(text_area)  # Subgroup for text scaling
51splash.append(text_group)
52
53while True:
54    pass

240x135

examples/st7789_240x135_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5This test will initialize the display using displayio and draw a solid green
 6background, a smaller purple rectangle, and some yellow text.
 7"""
 8
 9import board
10import displayio
11import terminalio
12from adafruit_display_text import label
13from fourwire import FourWire
14
15from adafruit_st7789 import ST7789
16
17# First set some parameters used for shapes and text
18BORDER = 20
19FONTSCALE = 2
20BACKGROUND_COLOR = 0x00FF00  # Bright Green
21FOREGROUND_COLOR = 0xAA0088  # Purple
22TEXT_COLOR = 0xFFFF00
23
24# Release any resources currently in use for the displays
25displayio.release_displays()
26
27spi = board.SPI()
28tft_cs = board.D5
29tft_dc = board.D6
30
31display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs)
32display = ST7789(display_bus, rotation=270, width=240, height=135, rowstart=40, colstart=53)
33
34# Make the display context
35splash = displayio.Group()
36display.root_group = splash
37
38color_bitmap = displayio.Bitmap(display.width, display.height, 1)
39color_palette = displayio.Palette(1)
40color_palette[0] = BACKGROUND_COLOR
41
42bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
43splash.append(bg_sprite)
44
45# Draw a smaller inner rectangle
46inner_bitmap = displayio.Bitmap(display.width - BORDER * 2, display.height - BORDER * 2, 1)
47inner_palette = displayio.Palette(1)
48inner_palette[0] = FOREGROUND_COLOR
49inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=BORDER, y=BORDER)
50splash.append(inner_sprite)
51
52# Draw a label
53text = "Hello World!"
54text_area = label.Label(terminalio.FONT, text=text, color=TEXT_COLOR)
55text_width = text_area.bounding_box[2] * FONTSCALE
56text_group = displayio.Group(
57    scale=FONTSCALE,
58    x=display.width // 2 - text_width // 2,
59    y=display.height // 2,
60)
61text_group.append(text_area)  # Subgroup for text scaling
62splash.append(text_group)
63
64while True:
65    pass

280x240

examples/st7789_280x240_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5This test will initialize the display using displayio, set display brightness and draw a solid green
 6background, a smaller purple rectangle, and some yellow text. The test also has the option of
 7rotating the screen content.
 8"""
 9
10import board
11import displayio
12import terminalio
13from adafruit_display_text import label
14from fourwire import FourWire
15
16from adafruit_st7789 import ST7789
17
18# set the display rotation
19rotation = 90
20if rotation not in {0, 90, 180, 270}:
21    raise ValueError("The value of rotation must be one of: 0, 90, 180, 270")
22
23# Display settings depending on the selected rotation
24# first value default setting for 1.69" with 0° and 180° rotation
25# second value default setting for 1.69" with 90° and 270° rotation
26width = 240 if rotation in {0, 180} else 280
27height = 280 if rotation in {0, 180} else 240
28color_bitmap_x = 240 if rotation in {0, 180} else 280
29color_bitmap_y = 280 if rotation in {0, 180} else 240
30inner_bitmap_x = 200 if rotation in {0, 180} else 240
31inner_bitmap_y = 240 if rotation in {0, 180} else 200
32scale = 2 if rotation in {0, 180} else 3
33x = 50 if rotation in {0, 180} else 37
34y = 140 if rotation in {0, 180} else 120
35
36# Release any resources currently in use for the displays
37displayio.release_displays()
38spi = board.SPI()
39tft_cs = board.D20
40tft_dc = board.D21
41backlight = board.D6
42display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D5)
43display = ST7789(
44    display_bus,
45    width=width,
46    height=height,
47    colstart=0,
48    rowstart=20,
49    rotation=rotation,
50    backlight_pin=backlight,
51    bgr=True,
52    invert=True,
53)
54
55# set the backlight
56# minimum value 0.001 (0.000 would be off), maximum value 1.000
57display.brightness = 0.5
58
59# Make the display context
60splash = displayio.Group()
61display.root_group = splash
62
63# Draw background rectangle
64color_bitmap = displayio.Bitmap(color_bitmap_x, color_bitmap_y, 1)
65color_palette = displayio.Palette(1)
66color_palette[0] = 0x00FF00  # Bright Green
67bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
68splash.append(bg_sprite)
69
70# Draw a smaller inner rectangle
71inner_bitmap = displayio.Bitmap(inner_bitmap_x, inner_bitmap_y, 1)
72inner_palette = displayio.Palette(1)
73inner_palette[0] = 0xAA0088  # Purple
74inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
75splash.append(inner_sprite)
76
77# Draw a label
78text_group = displayio.Group(scale=scale, x=x, y=y)
79text = "Hello World!"
80text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
81text_group.append(text_area)  # Subgroup for text scaling
82splash.append(text_group)
83
84while True:
85    pass

320x240

examples/st7789_320x240_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5This test will initialize the display using displayio and draw a solid green
 6background, a smaller purple rectangle, and some yellow text.
 7"""
 8
 9import board
10import displayio
11import terminalio
12from adafruit_display_text import label
13from fourwire import FourWire
14
15from adafruit_st7789 import ST7789
16
17# Release any resources currently in use for the displays
18displayio.release_displays()
19
20spi = board.SPI()
21tft_cs = board.D5
22tft_dc = board.D6
23
24display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)
25
26display = ST7789(display_bus, width=320, height=240, rotation=90)
27
28# Make the display context
29splash = displayio.Group()
30display.root_group = splash
31
32color_bitmap = displayio.Bitmap(320, 240, 1)
33color_palette = displayio.Palette(1)
34color_palette[0] = 0x00FF00  # Bright Green
35
36bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
37splash.append(bg_sprite)
38
39# Draw a smaller inner rectangle
40inner_bitmap = displayio.Bitmap(280, 200, 1)
41inner_palette = displayio.Palette(1)
42inner_palette[0] = 0xAA0088  # Purple
43inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
44splash.append(inner_sprite)
45
46# Draw a label
47text_group = displayio.Group(scale=3, x=57, y=120)
48text = "Hello World!"
49text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
50text_group.append(text_area)  # Subgroup for text scaling
51splash.append(text_group)
52
53while True:
54    pass

Product specific examples

1.14” Mini PiTFT

examples/st7789_240x135_pitft_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5This test will initialize the display using displayio and draw a solid green
 6background, a smaller purple rectangle, and some yellow text.
 7
 8Pinouts are for the 1.14" Mini PiTFT and should be run in CPython.
 9"""
10
11import board
12import displayio
13import terminalio
14from adafruit_display_text import label
15from fourwire import FourWire
16
17from adafruit_st7789 import ST7789
18
19# First set some parameters used for shapes and text
20BORDER = 20
21FONTSCALE = 2
22BACKGROUND_COLOR = 0x00FF00  # Bright Green
23FOREGROUND_COLOR = 0xAA0088  # Purple
24TEXT_COLOR = 0xFFFF00
25
26# Release any resources currently in use for the displays
27displayio.release_displays()
28
29spi = board.SPI()
30tft_cs = board.CE0
31tft_dc = board.D25
32
33display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs)
34display = ST7789(display_bus, rotation=90, width=240, height=135, rowstart=40, colstart=53)
35
36# Make the display context
37splash = displayio.Group()
38display.root_group = splash
39
40color_bitmap = displayio.Bitmap(display.width, display.height, 1)
41color_palette = displayio.Palette(1)
42color_palette[0] = BACKGROUND_COLOR
43
44bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
45splash.append(bg_sprite)
46
47# Draw a smaller inner rectangle
48inner_bitmap = displayio.Bitmap(display.width - BORDER * 2, display.height - BORDER * 2, 1)
49inner_palette = displayio.Palette(1)
50inner_palette[0] = FOREGROUND_COLOR
51inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=BORDER, y=BORDER)
52splash.append(inner_sprite)
53
54# Draw a label
55text = "Hello World!"
56text_area = label.Label(terminalio.FONT, text=text, color=TEXT_COLOR)
57text_width = text_area.bounding_box[2] * FONTSCALE
58text_group = displayio.Group(
59    scale=FONTSCALE,
60    x=display.width // 2 - text_width // 2,
61    y=display.height // 2,
62)
63text_group.append(text_area)  # Subgroup for text scaling
64splash.append(text_group)
65
66while True:
67    pass

1.3” TFT Bonnet

examples/st7789_240x240_bonnet_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5This test will initialize the display using displayio and draw a solid green
 6background, a smaller purple rectangle, and some yellow text.
 7
 8Pinouts are for the 1.3" TFT Bonnet and should be run in CPython.
 9"""
10
11import board
12import displayio
13import terminalio
14from adafruit_display_text import label
15from fourwire import FourWire
16
17from adafruit_st7789 import ST7789
18
19# Release any resources currently in use for the displays
20displayio.release_displays()
21
22spi = board.SPI()
23tft_cs = board.CE0
24tft_dc = board.D25
25tft_lite = board.D26
26
27display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs)
28
29display = ST7789(
30    display_bus,
31    width=240,
32    height=240,
33    rowstart=80,
34    rotation=180,
35    backlight_pin=tft_lite,
36)
37
38# Make the display context
39splash = displayio.Group()
40display.root_group = splash
41
42color_bitmap = displayio.Bitmap(240, 240, 1)
43color_palette = displayio.Palette(1)
44color_palette[0] = 0x00FF00  # Bright Green
45
46bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
47splash.append(bg_sprite)
48
49# Draw a smaller inner rectangle
50inner_bitmap = displayio.Bitmap(200, 200, 1)
51inner_palette = displayio.Palette(1)
52inner_palette[0] = 0xAA0088  # Purple
53inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
54splash.append(inner_sprite)
55
56# Draw a label
57text_group = displayio.Group(scale=2, x=50, y=120)
58text = "Hello World!"
59text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
60text_group.append(text_area)  # Subgroup for text scaling
61splash.append(text_group)
62
63while True:
64    pass

1.3” PiTFT

examples/st7789_240x240_pitft_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5This test will initialize the display using displayio and draw a solid green
 6background, a smaller purple rectangle, and some yellow text.
 7
 8Pinouts are for the 1.3" PiTFT and should be run in CPython.
 9"""
10
11import board
12import displayio
13import terminalio
14from adafruit_display_text import label
15from fourwire import FourWire
16
17from adafruit_st7789 import ST7789
18
19# Release any resources currently in use for the displays
20displayio.release_displays()
21
22spi = board.SPI()
23tft_cs = board.CE0
24tft_dc = board.D25
25
26display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs)
27
28display = ST7789(display_bus, width=240, height=240, rowstart=80, rotation=180)
29
30# Make the display context
31splash = displayio.Group()
32display.root_group = splash
33
34color_bitmap = displayio.Bitmap(240, 240, 1)
35color_palette = displayio.Palette(1)
36color_palette[0] = 0x00FF00  # Bright Green
37
38bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
39splash.append(bg_sprite)
40
41# Draw a smaller inner rectangle
42inner_bitmap = displayio.Bitmap(200, 200, 1)
43inner_palette = displayio.Palette(1)
44inner_palette[0] = 0xAA0088  # Purple
45inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
46splash.append(inner_sprite)
47
48# Draw a label
49text_group = displayio.Group(scale=2, x=50, y=120)
50text = "Hello World!"
51text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
52text_group.append(text_area)  # Subgroup for text scaling
53splash.append(text_group)
54
55while True:
56    pass

Gizmo

examples/st7789_tft_gizmo_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5This test will initialize the display using displayio and draw a solid green
 6background, a smaller purple rectangle, and some yellow text.
 7"""
 8
 9import board
10import busio
11import displayio
12import terminalio
13from adafruit_display_text import label
14from fourwire import FourWire
15
16from adafruit_st7789 import ST7789
17
18# Release any resources currently in use for the displays
19displayio.release_displays()
20
21spi = busio.SPI(board.SCL, MOSI=board.SDA)
22tft_cs = board.RX
23tft_dc = board.TX
24tft_backlight = board.A3
25
26display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs)
27
28display = ST7789(
29    display_bus,
30    width=240,
31    height=240,
32    rowstart=80,
33    backlight_pin=tft_backlight,
34    rotation=180,
35)
36
37# Make the display context
38splash = displayio.Group()
39display.root_group = splash
40
41color_bitmap = displayio.Bitmap(240, 240, 1)
42color_palette = displayio.Palette(1)
43color_palette[0] = 0x00FF00  # Bright Green
44
45bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
46splash.append(bg_sprite)
47
48# Draw a smaller inner rectangle
49inner_bitmap = displayio.Bitmap(200, 200, 1)
50inner_palette = displayio.Palette(1)
51inner_palette[0] = 0xAA0088  # Purple
52inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
53splash.append(inner_sprite)
54
55# Draw a label
56text_group = displayio.Group(scale=2, x=50, y=120)
57text = "Hello World!"
58text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
59text_group.append(text_area)  # Subgroup for text scaling
60splash.append(text_group)
61
62while True:
63    pass

Pimoroni Pico Display Pack

examples/st7789_240x135_simpletest_Pimoroni_Pico_Display_Pack.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5This test will initialize the display using displayio and draw a solid green
 6background, a smaller purple rectangle, and some yellow text.
 7"""
 8
 9import board
10import busio
11import displayio
12import terminalio
13from adafruit_display_text import label
14from fourwire import FourWire
15
16from adafruit_st7789 import ST7789
17
18# First set some parameters used for shapes and text
19BORDER = 20
20FONTSCALE = 2
21BACKGROUND_COLOR = 0x00FF00  # Bright Green
22FOREGROUND_COLOR = 0xAA0088  # Purple
23TEXT_COLOR = 0xFFFF00
24
25# Release any resources currently in use for the displays
26displayio.release_displays()
27
28tft_cs = board.GP17
29tft_dc = board.GP16
30spi_mosi = board.GP19
31spi_clk = board.GP18
32spi = busio.SPI(spi_clk, spi_mosi)
33backlight = board.GP20
34
35display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs)
36
37display = ST7789(
38    display_bus,
39    rotation=270,
40    width=240,
41    height=135,
42    rowstart=40,
43    colstart=53,
44    backlight_pin=backlight,
45)
46
47# Set the backlight
48display.brightness = 0.8
49
50# Make the display context
51splash = displayio.Group()
52display.root_group = splash
53
54color_bitmap = displayio.Bitmap(display.width, display.height, 1)
55color_palette = displayio.Palette(1)
56color_palette[0] = BACKGROUND_COLOR
57
58bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
59splash.append(bg_sprite)
60
61# Draw a smaller inner rectangle
62inner_bitmap = displayio.Bitmap(display.width - BORDER * 2, display.height - BORDER * 2, 1)
63inner_palette = displayio.Palette(1)
64inner_palette[0] = FOREGROUND_COLOR
65inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=BORDER, y=BORDER)
66splash.append(inner_sprite)
67
68# Draw a label
69text = "Hello World!"
70text_area = label.Label(terminalio.FONT, text=text, color=TEXT_COLOR)
71text_width = text_area.bounding_box[2] * FONTSCALE
72text_group = displayio.Group(
73    scale=FONTSCALE,
74    x=display.width // 2 - text_width // 2,
75    y=display.height // 2,
76)
77text_group.append(text_area)  # Subgroup for text scaling
78splash.append(text_group)
79
80while True:
81    pass

Pimoroni Pico Explorer

examples/st7789_240x240_simpletest_Pimoroni_Pico_Explorer.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5This test will initialize the display using displayio and draw a solid green
 6background, a smaller purple rectangle, and some yellow text.
 7"""
 8
 9import board
10import busio
11import displayio
12import terminalio
13from adafruit_display_text import label
14from fourwire import FourWire
15
16from adafruit_st7789 import ST7789
17
18# Release any resources currently in use for the displays
19displayio.release_displays()
20
21tft_cs = board.GP17
22tft_dc = board.GP16
23spi_mosi = board.GP19
24spi_clk = board.GP18
25spi = busio.SPI(spi_clk, spi_mosi)
26
27display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs)
28
29display = ST7789(display_bus, width=240, height=240, rowstart=80, rotation=180)
30
31# Make the display context
32splash = displayio.Group()
33display.root_group = splash
34
35color_bitmap = displayio.Bitmap(240, 240, 1)
36color_palette = displayio.Palette(1)
37color_palette[0] = 0x00FF00  # Bright Green
38
39bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
40splash.append(bg_sprite)
41
42# Draw a smaller inner rectangle
43inner_bitmap = displayio.Bitmap(200, 200, 1)
44inner_palette = displayio.Palette(1)
45inner_palette[0] = 0xAA0088  # Purple
46inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
47splash.append(inner_sprite)
48
49# Draw a label
50text_group = displayio.Group(scale=2, x=50, y=120)
51text = "Hello World!"
52text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
53text_group.append(text_area)  # Subgroup for text scaling
54splash.append(text_group)
55
56while True:
57    pass

Pimoroni Pico Display Pack 2.0

examples/st7789_320x240_simpletest_Pimoroni_Pico_Display_2_0.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5This test will initialize the display using displayio and draw a solid green
 6background, a smaller purple rectangle, and some yellow text.
 7"""
 8
 9import board
10import busio
11import displayio
12import terminalio
13from adafruit_display_text import label
14from fourwire import FourWire
15
16from adafruit_st7789 import ST7789
17
18# Release any resources currently in use for the displays
19displayio.release_displays()
20
21tft_cs = board.GP17
22tft_dc = board.GP16
23spi_mosi = board.GP19
24spi_clk = board.GP18
25spi = busio.SPI(spi_clk, spi_mosi)
26backlight = board.GP20
27
28display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs)
29
30display = ST7789(
31    display_bus,
32    rotation=270,
33    width=320,
34    height=240,
35    backlight_pin=backlight,
36)
37
38# Set the backlight
39display.brightness = 0.8
40
41# Make the display context
42splash = displayio.Group()
43display.root_group = splash
44
45color_bitmap = displayio.Bitmap(320, 240, 1)
46color_palette = displayio.Palette(1)
47color_palette[0] = 0x00FF00  # Bright Green
48
49bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
50splash.append(bg_sprite)
51
52# Draw a smaller inner rectangle
53inner_bitmap = displayio.Bitmap(280, 200, 1)
54inner_palette = displayio.Palette(1)
55inner_palette[0] = 0xAA0088  # Purple
56inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
57splash.append(inner_sprite)
58
59# Draw a label
60text_group = displayio.Group(scale=3, x=57, y=120)
61text = "Hello World!"
62text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
63text_group.append(text_area)  # Subgroup for text scaling
64splash.append(text_group)
65
66while True:
67    pass

Waveshare Pico LCD 1.3

examples/st7789_240x240_simpletest_Waveshare_PicoLCD_1_3.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5This test will initialize the display using displayio and draw a solid green
 6background, a smaller purple rectangle, and some yellow text.
 7"""
 8
 9import board
10import busio
11import displayio
12import terminalio
13from adafruit_display_text import label
14from fourwire import FourWire
15
16from adafruit_st7789 import ST7789
17
18# Release any resources currently in use for the displays
19displayio.release_displays()
20
21tft_dc = board.GP8
22tft_cs = board.GP9
23spi_clk = board.GP10
24spi_mosi = board.GP11
25tft_rst = board.GP12
26backlight = board.GP13
27spi = busio.SPI(spi_clk, spi_mosi)
28
29display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_rst)
30
31display = ST7789(
32    display_bus,
33    rotation=270,
34    width=240,
35    height=240,
36    rowstart=80,
37    backlight_pin=backlight,
38)
39
40# Make the display context
41splash = displayio.Group()
42display.root_group = splash
43
44color_bitmap = displayio.Bitmap(240, 240, 1)
45color_palette = displayio.Palette(1)
46color_palette[0] = 0x00FF00  # Bright Green
47
48bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
49splash.append(bg_sprite)
50
51# Draw a smaller inner rectangle
52inner_bitmap = displayio.Bitmap(200, 200, 1)
53inner_palette = displayio.Palette(1)
54inner_palette[0] = 0xAA0088  # Purple
55inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
56splash.append(inner_sprite)
57
58# Draw a label
59text_group = displayio.Group(scale=2, x=50, y=120)
60text = "Hello World!"
61text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
62text_group.append(text_area)  # Subgroup for text scaling
63splash.append(text_group)
64
65while True:
66    pass