Skip to content

Commit be66e26

Browse files
authored
Merge pull request #75 from chfw/master
Update example for 1.14" TFT users.
2 parents d8daca4 + ebb6488 commit be66e26

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

README.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ To install in a virtual environment in your current project:
6060
Usage Example
6161
=============
6262

63+
2.2", 2.4", 2.8", 3.2" TFT
64+
---------------------------
65+
6366
.. code-block:: python
6467
6568
import time
@@ -95,6 +98,59 @@ Usage Example
9598
# Pause 2 seconds.
9699
time.sleep(2)
97100
101+
102+
1.14" TFT with Raspbery Pi 4
103+
-----------------------------
104+
105+
With 1.14" `wiring <https://learn.adafruit.com/adafruit-1-14-240x135-color-tft-breakout/python-wiring-and-setup>`_, here is the working code:
106+
107+
.. code-block:: python
108+
109+
import time
110+
import busio
111+
import digitalio
112+
from board import SCK, MOSI, MISO, CE0, D24, D25
113+
114+
from adafruit_rgb_display import color565
115+
from adafruit_rgb_display.st7789 import ST7789
116+
117+
118+
# Configuration for CS and DC pins:
119+
CS_PIN = CE0
120+
DC_PIN = D25
121+
RESET_PIN = D24
122+
BAUDRATE = 24000000
123+
124+
# Setup SPI bus using hardware SPI:
125+
spi = busio.SPI(clock=SCK, MOSI=MOSI, MISO=MISO)
126+
127+
# Create the ST7789 display:
128+
display = ST7789(
129+
spi,
130+
rotation=90,
131+
width=135,
132+
height=240,
133+
x_offset=53,
134+
y_offset=40,
135+
baudrate=BAUDRATE,
136+
cs=digitalio.DigitalInOut(CS_PIN),
137+
dc=digitalio.DigitalInOut(DC_PIN),
138+
rst=digitalio.DigitalInOut(RESET_PIN))
139+
140+
# Main loop: same as above
141+
while True:
142+
# Clear the display
143+
display.fill(0)
144+
# Draw a red pixel in the center.
145+
display.pixel(120, 160, color565(255, 0, 0))
146+
# Pause 2 seconds.
147+
time.sleep(2)
148+
# Clear the screen blue.
149+
display.fill(color565(0, 0, 255))
150+
# Pause 2 seconds.
151+
time.sleep(2)
152+
153+
98154
Contributing
99155
============
100156

0 commit comments

Comments
 (0)