There's two ways you can use the EYESPI breakout board with a computer that has GPIO and Python thanks to Adafruit_Blinka, our CircuitPython-for-Python compatibility library. You can utilize CPython graphics libraries, such as PIL, when using the EYESPI breakout with Blinka.

Additionally, you can install a kernel module to add support for a supported TFT display that will make the console appear. This is cute because you can have any program print text or draw to the framebuffer (or, say, with pygame) and Linux will take care of displaying it for you. If you don't need the console or direct framebuffer access, please consider using the 'pure Python' technique instead as it is not as delicate.

Be aware that you can only choose to do one way at a time. If you choose the hard way, it will install the kernel driver, which will prevent you from doing it the easy way

Below is example wiring and code for an ST7789 TFT display using the Adafruit_CircuitPython_RGB_Display library.

Overhead video of OLED breakout wired up on breadboard to QT Py and BFF driver board. Video displays multi-colored shapes and animations.
We've been looking for a display like this for a long time - it's only 1.5" diagonal but has a high density 220 ppi, 240x240 pixel display with full-angle viewing. It...
$17.50
In Stock

Python Computer Wiring

Since there's dozens of Linux computers/boards you can use, below shows wiring for Raspberry Pi. For other platforms, please visit the guide for CircuitPython on Linux to see whether your platform is supported.

Here's the Raspberry Pi wired to the EYESPI breakout board connected to an ST7789 1.54" 240x240 TFT Display:

  • Pi 3V to breakout VIN (red wire)
  • Pi GND to breakout GND (black wire)
  • Pi SLCK (GPIO 11) to breakout SCK (blue wire)
  • Pi MISO (GPIO 9) to breakout MISO (green wire)
  • Pi MOSI (GPIO 10) to breakout MOSI (yellow wire)
  • Pi CE0 (GPIO 8) to breakout TCS (purple wire)
  • Pi GPIO 25 to breakout DC (white wire)
  • Pi GPIO 24 to breakout RST (pink wire)

Attach the TFT screen to the EYESPI breakout with an EYESPI cable as described on the Plugging in an EYESPI Cable page.

Python Installation of the RGB Display Library

You'll need to install the Adafruit_Blinka library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3. Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready!

Once that's done, from your command line run the following command:

  • sudo pip3 install adafruit-circuitpython-rgb-display

If your default Python is version 3, you may need to run pip instead. Make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

Python Usage

Once you have the library pip3 installed on your computer, copy or download the following example to your computer, and run the following, replacing code.py with whatever you named the file:

python3 code.py

Example Code

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

"""
This demo will draw a few rectangles onto the screen along with some text
on top of that.

This example is for use on (Linux) computers that are using CPython with
Adafruit Blinka to support CircuitPython libraries. CircuitPython does
not support PIL/pillow (python imaging library)!

Author(s): Melissa LeBlanc-Williams for Adafruit Industries
"""

import digitalio
import board
from PIL import Image, ImageDraw, ImageFont
from adafruit_rgb_display import ili9341
from adafruit_rgb_display import st7789  # pylint: disable=unused-import
from adafruit_rgb_display import hx8357  # pylint: disable=unused-import
from adafruit_rgb_display import st7735  # pylint: disable=unused-import
from adafruit_rgb_display import ssd1351  # pylint: disable=unused-import
from adafruit_rgb_display import ssd1331  # pylint: disable=unused-import

# First define some constants to allow easy resizing of shapes.
BORDER = 20
FONTSIZE = 24

# Configuration for CS and DC pins (these are PiTFT defaults):
cs_pin = digitalio.DigitalInOut(board.CE0)
dc_pin = digitalio.DigitalInOut(board.D25)
reset_pin = digitalio.DigitalInOut(board.D24)

# Config for display baudrate (default max is 24mhz):
BAUDRATE = 24000000

# Setup SPI bus using hardware SPI:
spi = board.SPI()

# pylint: disable=line-too-long
# Create the display:
# disp = st7789.ST7789(spi, rotation=90,                            # 2.0" ST7789
# disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=180,  # 1.3", 1.54" ST7789
# disp = st7789.ST7789(spi, rotation=90, width=135, height=240, x_offset=53, y_offset=40, # 1.14" ST7789
# disp = st7789.ST7789(spi, rotation=90, width=172, height=320, x_offset=34, # 1.47" ST7789
# disp = st7789.ST7789(spi, rotation=270, width=170, height=320, x_offset=35, # 1.9" ST7789
# disp = hx8357.HX8357(spi, rotation=180,                           # 3.5" HX8357
# disp = st7735.ST7735R(spi, rotation=90,                           # 1.8" ST7735R
# disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3,   # 1.44" ST7735R
# disp = st7735.ST7735R(spi, rotation=90, bgr=True, width=80,       # 0.96" MiniTFT Rev A ST7735R
# disp = st7735.ST7735R(spi, rotation=90, invert=True, width=80,    # 0.96" MiniTFT Rev B ST7735R
# x_offset=26, y_offset=1,
# disp = ssd1351.SSD1351(spi, rotation=180,                         # 1.5" SSD1351
# disp = ssd1351.SSD1351(spi, height=96, y_offset=32, rotation=180, # 1.27" SSD1351
# disp = ssd1331.SSD1331(spi, rotation=180,                         # 0.96" SSD1331
disp = ili9341.ILI9341(
    spi,
    rotation=90,  # 2.2", 2.4", 2.8", 3.2" ILI9341
    cs=cs_pin,
    dc=dc_pin,
    rst=reset_pin,
    baudrate=BAUDRATE,
)
# pylint: enable=line-too-long

# Create blank image for drawing.
# Make sure to create image with mode 'RGB' for full color.
if disp.rotation % 180 == 90:
    height = disp.width  # we swap height/width to rotate it to landscape!
    width = disp.height
else:
    width = disp.width  # we swap height/width to rotate it to landscape!
    height = disp.height

image = Image.new("RGB", (width, height))

# Get drawing object to draw on image.
draw = ImageDraw.Draw(image)

# Draw a green filled box as the background
draw.rectangle((0, 0, width, height), fill=(0, 255, 0))
disp.image(image)

# Draw a smaller inner purple rectangle
draw.rectangle(
    (BORDER, BORDER, width - BORDER - 1, height - BORDER - 1), fill=(170, 0, 136)
)

# Load a TTF Font
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", FONTSIZE)

# Draw Some Text
text = "Hello World!"
(font_width, font_height) = font.getsize(text)
draw.text(
    (width // 2 - font_width // 2, height // 2 - font_height // 2),
    text,
    font=font,
    fill=(255, 255, 0),
)

# Display image.
disp.image(image)

Edit the Code for the ST7789 Display

In the code, comment out the ILI9341 disp object and replace it with an ST7789 disp object:

'''disp = ili9341.ILI9341(
    spi,
    rotation=90,  # 2.2", 2.4", 2.8", 3.2" ILI9341
    cs=cs_pin,
    dc=dc_pin,
    rst=reset_pin,
    baudrate=BAUDRATE,
)'''
disp = st7789.ST7789(
  	spi, 
  	height=240, 
  	y_offset=80, 
  	rotation=180,
  	cs=cs_pin,
    dc=dc_pin,
    rst=reset_pin,
    baudrate=BAUDRATE,
)

The code begins by instantiating your display over SPI. Then, a green rectangle is drawn, followed by a smaller purple rectangle. The text "Hello World" is displayed over both of the rectangles.

Kernel Module Install

You can install a kernel module using one of Adafruit's Raspberry-Pi-Installer-Scripts to view your Raspberry Pi's terminal or desktop on a display connected to the EYESPI breakout board. This can be handy for projects such as cyberdecks or headless setups. Please proceed with caution though, as it can be tricky to setup and you may find that a 'pure Python' method with Blinka and Pillow (detailed above) can answer your Raspberry Pi display needs.

The following will detail an example of showing the terminal via an ST7789 display. If you want to run it on a different display, please reference this guide on PiTFT, which has terminal inputs for all of the supported displays.

Prepare the Pi

After wiring your ST7789 display to the Raspberry Pi with the EYESPI breakout as detailed above, its a good idea to get your Pi completely updated and upgraded. We assume you have burned an SD card and can log into the console to install stuff.

To update and upgrade, run:

sudo apt update -y
sudo apt-get update -y
sudo apt-get upgrade -y

Then, reboot the Pi with:

sudo reboot

Then, run the following at the terminal:

cd ~
sudo pip3 install --upgrade adafruit-python-shell click
sudo apt-get install -y git
git clone https://github.com/adafruit/Raspberry-Pi-Installer-Scripts.git
cd Raspberry-Pi-Installer-Scripts
sudo python3 adafruit-pitft.py --display=st7789_240x240 --rotation=0 --install-type=console

When you get asked to reboot, reboot!

After rebooting, you'll see the terminal on the ST7789 TFT display.

Uninstall the Kernel Module

If you decide that you no longer want to show the terminal on the ST7789 display, you can run the following at the terminal:

cd ~
cd Raspberry-Pi-Installer-Scripts
sudo python3 adafruit-pitft.py --install-type=uninstall

When you get asked to reboot, reboot!

After rebooting, you'll be brought to the terminal on your HDMI connected display. If you want to get back to the desktop, enter startx into the terminal.

startx

To permanently boot to the desktop going forward, enter the raspi-config tool via the terminal with:

sudo raspi-config

Select 1 System Options in the menu.

On the next screen, select S5 Boot / Auto Login.

Finally, select B4 Desktop Autologin to return to the default desktop login mode.

Exit the raspi-config by selecting Finish. When prompted to reboot, select Yes.

This guide was first published on Dec 14, 2022. It was last updated on Jun 18, 2024.

This page (Python) was last updated on Jun 18, 2024.

Text editor powered by tinymce.