Python Wiring and Usage

Wiring

It's easy to use display breakouts with Python and the Adafruit CircuitPython RA8875 module.  This module allows you to easily write Python code to control the display.

We'll cover how to wire the display to your Raspberry Pi. First assemble your display.

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

Connect the display as shown below to your Raspberry Pi.

Note this is not a kernel driver that will let you have the console appear on the TFT. However, this is handy when you can't install an fbtft driver, and want to use the TFT purely from 'user Python' code!
You can only use this technique with Linux/computer devices that have hardware SPI support, and not all single board computers have an SPI device so check before continuing
  • 3-5V Vin connects to the Raspberry Pi's 3V pin
  • GND connects to the Raspberry Pi's ground
  • SCK connects to SPI clock. On the Raspberry Pi, thats SLCK
  • MISO connects to SPI MISO. On the Raspberry Pi, thats also MISO
  • MOSI connects to SPI MOSI. On the Raspberry Pi, thats also MOSI
  • CS connects to our SPI Chip Select pin. We'll be using GPIO 13.
  • RST connects to our Reset pin. We'll be using GPIO 5 but you can later change this pin later.
  • INT connects to our Interrupt pin. This pin is actually optional, but improves the accuracy. We'll be using GPIO 6 but you can later change this pin too.

Setup

You'll need to install the Adafruit_Blinka library that provides the CircuitPython support in Python. This may also require enabling SPI 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!

Python Installation of RA8875 Library

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

  • sudo pip3 install adafruit-circuitpython-ra8875

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

If that complains about pip3 not being installed, then run this first to install it:

  • sudo apt-get install python3-pip

That's it. You should be ready to go.

Usage

To use the RA8875 with the Raspberry Pi, you only need to make one or two changes to the CircuitPython examples in order to use them on the Pi.

Pin Mapping

First we need to change the Pin mapping because some of the pins that are used on the Feather are not available on the Raspberry Pi. Find the section with the following code:

Download: file
cs_pin = digitalio.DigitalInOut(board.D9)
rst_pin = digitalio.DigitalInOut(board.D10)
int_pin = digitalio.DigitalInOut(board.D11)

and change it to the following:

Download: file
cs_pin = digitalio.DigitalInOut(board.D13)
rst_pin = digitalio.DigitalInOut(board.D5)
int_pin = digitalio.DigitalInOut(board.D6)

Display Size

Next, the driver defaults to the 480x800 sized display. If you have a different size, you will need to add a couple of parameters. Find the line that looks like this:

Download: file
display = ra8875.RA8875(spi, cs=cs_pin, rst=rst_pin, baudrate=BAUDRATE)

And go ahead and add a width and height parameter so if for instance, you had the 480x272 display, it would look like this:

Download: file
display = ra8875.RA8875(spi, cs=cs_pin, rst=rst_pin, baudrate=BAUDRATE, width=480, height=272)

That should be it. You should be able to run both examples as described on the CircuitPython page.

This guide was first published on Mar 19, 2019. It was last updated on Mar 19, 2019.
This page (Python Wiring and Usage) was last updated on Jul 16, 2020.