@@ -60,6 +60,9 @@ To install in a virtual environment in your current project:
60
60
Usage Example
61
61
=============
62
62
63
+ 2.2", 2.4", 2.8", 3.2" TFT
64
+ ---------------------------
65
+
63
66
.. code-block :: python
64
67
65
68
import time
@@ -95,6 +98,59 @@ Usage Example
95
98
# Pause 2 seconds.
96
99
time.sleep(2 )
97
100
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
+
98
154
Contributing
99
155
============
100
156
0 commit comments