Skip to content

Commit 12a86de

Browse files
committed
Add PiTFT example and more hardware links
1 parent 6606bfb commit 12a86de

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

adafruit_ili9341.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@
3232
3333
**Hardware:**
3434
35+
* Adafruit PiTFT 2.2" HAT Mini Kit - 320x240 2.2" TFT - No Touch
36+
<https://www.adafruit.com/product/2315>
37+
* Adafruit PiTFT 2.4" HAT Mini Kit - 320x240 TFT Touchscreen
38+
<https://www.adafruit.com/product/2455>
39+
* Adafruit PiTFT - 320x240 2.8" TFT+Touchscreen for Raspberry Pi
40+
<https://www.adafruit.com/product/1601>
41+
* PiTFT 2.8" TFT 320x240 + Capacitive Touchscreen for Raspberry Pi
42+
<https://www.adafruit.com/product/1983>
43+
* Adafruit PiTFT Plus 320x240 2.8" TFT + Capacitive Touchscreen
44+
<https://www.adafruit.com/product/2423>
45+
* PiTFT Plus Assembled 320x240 2.8" TFT + Resistive Touchscreen
46+
<https://www.adafruit.com/product/2298>
47+
* PiTFT Plus 320x240 3.2" TFT + Resistive Touchscreen
48+
<https://www.adafruit.com/product/2616>
3549
* 2.2" 18-bit color TFT LCD display with microSD card breakout
3650
<https://www.adafruit.com/product/1480>
3751
* 2.4" TFT LCD with Touchscreen Breakout Board w/MicroSD Socket

examples/ili9341_pitft_simpletest.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"""
2+
This test will initialize the display using displayio and draw a solid green
3+
background, a smaller purple rectangle, and some yellow text. All drawing is done
4+
using the displayio module.
5+
6+
Pinouts are for the PiTFT and should be run in CPython.
7+
"""
8+
import board
9+
import terminalio
10+
import displayio
11+
from adafruit_display_text import label
12+
import adafruit_ili9341
13+
14+
# Release any resources currently in use for the displays
15+
displayio.release_displays()
16+
17+
spi = board.SPI()
18+
tft_cs = board.CE0
19+
tft_dc = board.D25
20+
21+
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
22+
display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240)
23+
24+
# Make the display context
25+
splash = displayio.Group(max_size=10)
26+
display.show(splash)
27+
28+
# Draw a green background
29+
color_bitmap = displayio.Bitmap(display.width, display.height, 1)
30+
color_palette = displayio.Palette(1)
31+
color_palette[0] = 0x00FF00 # Bright Green
32+
33+
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
34+
35+
splash.append(bg_sprite)
36+
37+
# Draw a smaller inner rectangle
38+
inner_bitmap = displayio.Bitmap(display.width - 40, display.height - 40, 1)
39+
inner_palette = displayio.Palette(1)
40+
inner_palette[0] = 0xAA0088 # Purple
41+
inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
42+
splash.append(inner_sprite)
43+
44+
# Draw a label
45+
text_group = displayio.Group(max_size=10, scale=3, x=57, y=120)
46+
text = "Hello World!"
47+
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
48+
text_group.append(text_area) # Subgroup for text scaling
49+
splash.append(text_group)
50+
51+
while True:
52+
pass

0 commit comments

Comments
 (0)