Skip to content

Commit 20e8302

Browse files
authored
📚 update usage example for 1.14" TFT users
The usage example may only work for 2.2", 2.4", 2.8", 3.2" TFT ( which I could not verify ). With 1.14" TFT and raspberry pi 4, the wiring are different, chipset is different. At the first try-out, as a novice user, I was doubting my soldering skills. Why does not it work? Blank screen! It turns out that wrong chipset driver was used. After updating its chipset driver, it is still blank! I was doubting my connections and my soldering skills again! It turns out that the CS_PIN, DC_PIN are not the same as bigger TFTs. After all those adjustments, it worked.
1 parent d8daca4 commit 20e8302

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

README.rst

Lines changed: 54 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,57 @@ 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-44-color-tft-with-micro-sd-socket/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 ILI9341 display:
128+
display = ST7789(
129+
spi,
130+
rotation=90,
131+
width=135,
132+
height=240,
133+
baudrate=BAUDRATE,
134+
cs=digitalio.DigitalInOut(CS_PIN),
135+
dc=digitalio.DigitalInOut(DC_PIN),
136+
rst=digitalio.DigitalInOut(RESET_PIN))
137+
138+
# Main loop: same as above
139+
while True:
140+
# Clear the display
141+
display.fill(0)
142+
# Draw a red pixel in the center.
143+
display.pixel(120, 160, color565(255, 0, 0))
144+
# Pause 2 seconds.
145+
time.sleep(2)
146+
# Clear the screen blue.
147+
display.fill(color565(0, 0, 255))
148+
# Pause 2 seconds.
149+
time.sleep(2)
150+
151+
98152
Contributing
99153
============
100154

0 commit comments

Comments
 (0)