Skip to content

Commit c524357

Browse files
authored
Merge pull request #4 from makermelissa/master
Added example for new 320x240 display
2 parents 7dd6f21 + 9db463b commit c524357

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
*.mpy
2+
.idea
13
__pycache__
24
_build
35
*.pyc
46
.env
57
build*
68
bundles
9+
*.DS_Store
10+
.eggs
11+
dist
12+
**/*.egg-info

examples/st7789_320x240_simpletest.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
This test will initialize the display using displayio
3+
and draw a solid red background
4+
"""
5+
6+
import board
7+
import displayio
8+
from adafruit_st7789 import ST7789
9+
10+
spi = board.SPI()
11+
while not spi.try_lock():
12+
pass
13+
spi.configure(baudrate=24000000) # Configure SPI for 24MHz
14+
spi.unlock()
15+
tft_cs = board.D5
16+
tft_dc = board.D6
17+
18+
displayio.release_displays()
19+
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)
20+
21+
display = ST7789(display_bus, width=320, height=240, rotation=90)
22+
23+
# Make the display context
24+
splash = displayio.Group(max_size=10)
25+
display.show(splash)
26+
27+
color_bitmap = displayio.Bitmap(320, 240, 1)
28+
color_palette = displayio.Palette(1)
29+
color_palette[0] = 0xFF0000
30+
31+
bg_sprite = displayio.TileGrid(color_bitmap,
32+
pixel_shader=color_palette,
33+
x=0, y=0)
34+
splash.append(bg_sprite)
35+
36+
while True:
37+
pass

0 commit comments

Comments
 (0)