Skip to content

Commit db544c7

Browse files
authored
Merge pull request #30 from makermelissa/master
Added example for newer Revision B of the 0.96 MiniTFT
2 parents dfae353 + c9e7b0f commit db544c7

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

docs/examples.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ Simple example for the minitft featherwing
3232
MiniTFT Test
3333
------------
3434

35-
Simple example for the minitft
35+
Simple example for the minitft (newer Revision B)
36+
37+
.. literalinclude:: ../examples/st7735r_minitft_revb_simpletest.py
38+
:caption: examples/st7735r_minitft_revb_simpletest.py
39+
:linenos:
40+
41+
Simple example for the minitft (older Revision A)
3642

3743
.. literalinclude:: ../examples/st7735r_minitft_simpletest.py
3844
:caption: examples/st7735r_minitft_simpletest.py
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
9+
import board
10+
import terminalio
11+
import displayio
12+
from adafruit_display_text import label
13+
from adafruit_st7735r import ST7735R
14+
15+
# Release any resources currently in use for the displays
16+
displayio.release_displays()
17+
18+
spi = board.SPI()
19+
tft_cs = board.D5
20+
tft_dc = board.D6
21+
22+
display_bus = displayio.FourWire(
23+
spi, command=tft_dc, chip_select=tft_cs, reset=board.D9
24+
)
25+
26+
display = ST7735R(
27+
display_bus,
28+
width=160,
29+
height=80,
30+
rowstart=1,
31+
colstart=26,
32+
rotation=270,
33+
invert=True,
34+
)
35+
36+
# Make the display context
37+
splash = displayio.Group()
38+
display.show(splash)
39+
40+
color_bitmap = displayio.Bitmap(160, 80, 1)
41+
color_palette = displayio.Palette(1)
42+
color_palette[0] = 0x00FF00 # Bright Green
43+
44+
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
45+
splash.append(bg_sprite)
46+
47+
# Draw a smaller inner rectangle
48+
inner_bitmap = displayio.Bitmap(150, 70, 1)
49+
inner_palette = displayio.Palette(1)
50+
inner_palette[0] = 0xAA0088 # Purple
51+
inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=5, y=5)
52+
splash.append(inner_sprite)
53+
54+
# Draw a label
55+
text_group = displayio.Group(scale=2, x=11, y=40)
56+
text = "Hello World!"
57+
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
58+
text_group.append(text_area) # Subgroup for text scaling
59+
splash.append(text_group)
60+
61+
while True:
62+
pass

0 commit comments

Comments
 (0)