Skip to content

Update example for 1.14" TFT users. #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ To install in a virtual environment in your current project:
Usage Example
=============

2.2", 2.4", 2.8", 3.2" TFT
---------------------------

.. code-block:: python

import time
Expand Down Expand Up @@ -95,6 +98,59 @@ Usage Example
# Pause 2 seconds.
time.sleep(2)


1.14" TFT with Raspbery Pi 4
-----------------------------

With 1.14" `wiring <https://learn.adafruit.com/adafruit-1-14-240x135-color-tft-breakout/python-wiring-and-setup>`_, here is the working code:

.. code-block:: python

import time
import busio
import digitalio
from board import SCK, MOSI, MISO, CE0, D24, D25

from adafruit_rgb_display import color565
from adafruit_rgb_display.st7789 import ST7789


# Configuration for CS and DC pins:
CS_PIN = CE0
DC_PIN = D25
RESET_PIN = D24
BAUDRATE = 24000000

# Setup SPI bus using hardware SPI:
spi = busio.SPI(clock=SCK, MOSI=MOSI, MISO=MISO)

# Create the ST7789 display:
display = ST7789(
spi,
rotation=90,
width=135,
height=240,
x_offset=53,
y_offset=40,
baudrate=BAUDRATE,
cs=digitalio.DigitalInOut(CS_PIN),
dc=digitalio.DigitalInOut(DC_PIN),
rst=digitalio.DigitalInOut(RESET_PIN))

# Main loop: same as above
while True:
# Clear the display
display.fill(0)
# Draw a red pixel in the center.
display.pixel(120, 160, color565(255, 0, 0))
# Pause 2 seconds.
time.sleep(2)
# Clear the screen blue.
display.fill(color565(0, 0, 255))
# Pause 2 seconds.
time.sleep(2)


Contributing
============

Expand Down