Skip to content

Commit 334be2d

Browse files
authored
Merge pull request #29 from mlashley/main
Add example for Waveshare Pico LCD 1.3
2 parents a3974d5 + ba2b01f commit 334be2d

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

docs/examples.rst

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

0 commit comments

Comments
 (0)