Skip to main content

gc9b72

Python driver for GC9B72 round SPI TFT panels on Raspberry Pi and other Linux single-board computers. Developed against a 2.1" 360x360 module.

If your GC9B72 panel stays black or white, you are probably sending a GC9A01 init sequence. The two controllers both drive round panels and are otherwise unrelated, and the GC9B72 is in none of the usual libraries — not TFT_eSPI, not Adafruit GFX. The sequence this driver sends is documented in INIT_SEQUENCE.md.

Installing

The C and imaging libraries come from apt rather than pip:

sudo apt install -y python3-lgpio python3-spidev python3-numpy python3-pil

Raspberry Pi OS will not let pip write to the system Python (PEP 668, the externally-managed-environment error). Install into a virtual environment that can still see those apt packages:

python3 -m venv --system-site-packages ~/.venvs/display
~/.venvs/display/bin/pip install gc9b72

Run your scripts with ~/.venvs/display/bin/python. If you would rather keep one system-wide Python, pip install --break-system-packages gc9b72 also works, at the usual risk of pip and apt disagreeing later.

SPI must be enabled (sudo raspi-config nonint do_spi 0, then reboot). A full frame is 253 KB and the default SPI buffer is 4 KB, so for a usable frame rate append spidev.bufsiz=65536 to the line in /boot/firmware/cmdline.txt.

If opening the device raises PermissionError, add yourself to the right groups with sudo usermod -aG spi,gpio $USER and log back in.

Wiring

4-wire SPI at 3.3V logic, so it connects straight to the header with no level shifter. GPIO numbers are BCM.

Panel BCM Header pin
VCC 3.3V power — 1
GND ground — 6
SCL SPI clock GPIO11 23
SDA SPI data in GPIO10 19
CS chip select GPIO8 24
DC data/command GPIO25 22
RST reset GPIO24 18
BL backlight GPIO18 12

BCM is the number you pass to the driver; the header pin is where the wire physically goes. They are not the same numbering and mixing them up is how VCC ends up on 5V.

SDO and TE are unused — leave them unconnected. SDA is MOSI and SCL is the clock: this is SPI, not I²C, despite the pin names, which is the usual way to lose an evening with these modules. VCC wants 3.3V, not 5V, unless the module carries its own regulator.

Using

from gc9b72 import GC9B72
from PIL import Image, ImageDraw

with GC9B72(dc=25, rst=24, bl=18, speed_hz=40_000_000) as d:
    img = Image.new("RGB", (d.width, d.height), (0, 0, 0))
    ImageDraw.Draw(img).ellipse([20, 20, 340, 340], fill=(255, 100, 0))
    d.show_image(img)

Pin numbers are BCM. dc, rst and bl are the only GPIOs the driver drives; everything else goes to the SPI bus (/dev/spidev0.0 by default).

Options

Argument Default
speed_hz 40_000_000 Drop to 20_000_000 or 10_000_000 if you see noise
rotation 0 0, 90, 180 or 270
bgr False Set if red and blue are swapped
invert False Set if the image is a negative
x_offset, y_offset 0 Shift the visible window
gpiochip auto Override if the header is not detected correctly
spi_bus, spi_device 0, 0 Which /dev/spidev* to open

Methods

show_image(image) draws a PIL image, blit(array) an (h, w, 3) uint8 numpy array, and fill(colour) a solid colour from rgb565(r, g, b). backlight(on) switches the backlight and backlight_pwm(percent) dims it.

Examples

The examples are not part of the installed package — clone the repository to get them:

git clone https://github.com/guillermozuur-design/gc9b72

examples/demo.py draws test patterns — solid colours, colour bars, alignment markers, a clock, and an fps benchmark:

python3 examples/demo.py           # all of them
python3 examples/demo.py bars      # left should be red, right blue
python3 examples/demo.py corners   # circle should meet the edge of the glass
python3 examples/demo.py bench

bars and corners are the quickest way to settle bgr, rotation and the offsets for your particular module.

Panels

Sold as 2.1" round TFT modules, silkscreened Driver IC: GC9B72. 480x480 variants exist — change WIDTH/HEIGHT at the top of gc9b72/__init__.py; the init sequence is the same.

Credits

The register init sequence is derived from fb-gc9b72.c in xboot. For the ESP32 there is Arduino_GC9B72, and for LVGL there is GC9B72-LVGL-Driver.

MIT licensed — see LICENSE.

Metadata

Release files for gc9b72 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gc9b72 0.1.0
File Size Uploaded
gc9b72-0.1.0.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gc9b72 0.1.0
File Interpreter ABI Platform
gc9b72-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.0 kB

Release files / gc9b72-0.1.0.tar.gz

Download URL gc9b72-0.1.0.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
830aa8c9eedc1fd89df8cd156e94e8ccdd583a1d6b4ee38b65e716ddc408263b
BLAKE2b-256 checksum
How to use checksums
d3e8f512326b599474958ccc933002002215442643a98ff4d1a746a95af6fc0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / gc9b72-0.1.0-py3-none-any.whl

Download URL gc9b72-0.1.0-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a01ca3ca9de985a3f70087e18d7c5f1553363a8cd27567da7ad130cf50da543
BLAKE2b-256 checksum
How to use checksums
60064c79ce0b56ff71caf95393ffb4adc116e672e5a87619692b5467428a2062
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page