GC9A01A Readme

May 11, 2026 ยท View on GitHub

Table of contents

Overview

  • Name: GC9A01A
  • Description:
  1. C++ Library for a TFT SPI LCD, GC9A01A Driver
  2. Dynamic install-able Linux C++ library.
  3. Power modes, Invert , Scroll, Rotate, Bitmaps supported.
  4. Graphics + print class included.
  5. 24 bit colour , 16 bit color, bi-color Bitmaps & sprites supported.
  6. Hardware and Software SPI
  7. Dependency: lgpio Library
  8. NB The Spidev buffer size setting must be larger than biggest buffer the code will attempt to write If not you will get 'Error 99'. See Notes section for more details.
  9. Make sure SPI is enabled in your computers configuration.
  10. Tested on 240x240 pixel round display.

Software

User options

In the example files. There are 3 sections in "Setup()" function where user can make adjustments to select for SPI type used, and screen size.

  1. USER OPTION 1 GPIO/SPI TYPE
  2. USER OPTION 2 SCREEN SECTION
  3. USER OPTION 3 SPI SETTINGS

USER OPTION 1 SPI TYPE / GPIO

This library supports both Hardware SPI and software SPI. The SetupGPIO function is overloaded(2 off one for HW SPI the other for SW SPI). The parameters set for SetupGPIO define which is used.

USER OPTION 2 Screen size

User can adjust screen pixel height, screen pixel width. The function InitScreenSize sets them.

USER OPTION 3 SPI Settings

InitSPI function is overloaded(2 off, one for HW SPI the other for SW SPI).

parameterdefault valuenoteSPi type
HWSPI_DEVICE0A SPI device, >= 0. which SPI interface to use , ls /dev/spi*Hardware
HWSPI_CHANNEL0A SPI channel, >= 0. Which Chip enable pin to use usually 0 or 1Hardware
HWSPI_SPEED1000000The speed of serial communication in bits per second.Hardware
HWSPI_FLAGS0mode 0 for this deviceHardware
GPIO_CHIP_DEVICE0gpio chip device >= 0, check ls/dev/gpiochip*both
SWSPI_CommDelay0uS delay for GPIOsoftware

The user can adjust if having reliability issues with SW SPI in some setups. This is a microsecond delay in SW SPI GPIO loop. It is set to 0 by default, Increasing it will slow down SW SPI further.

File system

In example sub folders: The main.cpp file contains tests showing library functions. A bitmap data file contains data for bi-color bitmaps and icons tests. The color bitmaps used in testing are in bitmap folder. Hello world can be setup for software or hardware SPI by changing "HardwareSPI" at top of file.

#example sub folder nameDescription
1hello_worldBasic use case
2testsTests bitmap, text,graphics & function testing
3demosVarious demos

Bitmap

Bitmap Documentation

Color codes

For functions that accept a 16 bit color value. There is list of pre-defined colors in the 'colors' folder in doc.

Advanced screen buffer mode

Advanced screen buffer mode. There is advanced buffer mode where the code writes to a global screen buffer instead of the VRAM of display. It is off by default more details at readme, which is in the 'doc' folder at link.

Hardware

pic

Connections as setup in main.cpp test file.

TFT PinNumPindescRPI HW SPIRPI SW SPI
1LEDVCCVCC
2CSSPI_CE0GPI21
3DCGPIO24GPIO24
4RESETGPI025GPIO25
5SDASPI_MOSIGPIO16
6SCLKSPI_CLKGPIO20
7VCCVCCVCC
8GNDGNDGND
  1. This is a 3.3V logic device do NOT connect the I/O logic lines to 5V logic device.
  2. SW SPI pick any GPIO you like , HW SPI CEX, SCLK and SDA will be tied to SPI interface.
  3. Backlight on/off control is left to user.

Output

 Demo pic

Notes

Error 99

Error 99 Documentation