Skip to content

Commit dc42dff

Browse files
authored
Merge pull request #24 from makermelissa/master
Add 280x240 example for the 1.69" Display
2 parents 9020acb + 46ce7f1 commit dc42dff

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

docs/examples.rst

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ Ensure your device works with this simple test.
1414
:caption: examples/st7789_240x135_simpletest.py
1515
:linenos:
1616

17+
280x240
18+
=======
19+
20+
.. literalinclude:: ../examples/st7789_280x240_simpletest.py
21+
:caption: examples/st7789_280x240_simpletest.py
22+
:linenos:
23+
1724
320x240
1825
=======
1926

examples/st7789_280x240_simpletest.py

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 terminalio
10+
import displayio
11+
from adafruit_display_text import label
12+
from adafruit_st7789 import ST7789
13+
14+
# Release any resources currently in use for the displays
15+
displayio.release_displays()
16+
17+
spi = board.SPI()
18+
tft_cs = board.D5
19+
tft_dc = board.D6
20+
21+
display_bus = displayio.FourWire(
22+
spi, command=tft_dc, chip_select=tft_cs, reset=board.D9
23+
)
24+
25+
display = ST7789(display_bus, width=320, height=240, rotation=90)
26+
27+
# Make the display context
28+
splash = displayio.Group()
29+
display.show(splash)
30+
31+
color_bitmap = displayio.Bitmap(320, 240, 1)
32+
color_palette = displayio.Palette(1)
33+
color_palette[0] = 0x00FF00 # Bright Green
34+
35+
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
36+
splash.append(bg_sprite)
37+
38+
# Draw a smaller inner rectangle
39+
inner_bitmap = displayio.Bitmap(280, 200, 1)
40+
inner_palette = displayio.Palette(1)
41+
inner_palette[0] = 0xAA0088 # Purple
42+
inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
43+
splash.append(inner_sprite)
44+
45+
# Draw a label
46+
text_group = displayio.Group(scale=3, x=57, y=120)
47+
text = "Hello World!"
48+
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
49+
text_group.append(text_area) # Subgroup for text scaling
50+
splash.append(text_group)
51+
52+
while True:
53+
pass

0 commit comments

Comments
 (0)