Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# SPDX-FileCopyrightText: 2026 Brad Barnett
#
# SPDX-License-Identifier: MIT

"""Seeed Studio Round Display for XIAO on a XIAO ESP32C5.

For OmniPython's or stock MicroPython's ``SEEED_XIAO_ESP32C5`` build. The
GC9A01 240x240 panel is on the XIAO's SPI pins (D8 SCK, D10 MOSI, D9 MISO)
with chip select on D1, data/command on D3 and the backlight on D6. The
CHSC6X touch controller is on I2C (D4 SDA, D5 SCL) with its interrupt on D7,
sharing the bus with the display's PCF8563 clock.

The display's KE switch connects D6 to the backlight and A0 to the display's
battery divider. Leave it on, or the backlight stays dark.

Touch reaches x from about 30 to 225 only: the display's CHSC6X can't see
the outer 30 px or so at each side, and ``round_display_points`` corrects
its x scale.

``board_peripherals`` adds the microSD slot (``sdcard``), the clock (``rtc``),
the battery (``battery``), the XIAO's LED (``led``) and BOOT button
(``boot_button``), the I2C bus (``i2c``), Wi-Fi (``wlan``) and Bluetooth
(``ble``).

This config hasn't run on a board yet: the pins are Seeed's, from the XIAO
ESP32C5's and the Round Display's pin tables, and the panel settings are the
ones the same display uses on a XIAO nRF52840 and a QT Py ESP32-S3.
"""

from chsc6x import CHSC6X, round_display_points
from gc9a01 import GC9A01
from machine import I2C
from spibus import SPIBus

# XIAO header pin to ESP32-C5 GPIO.
_D1 = 0 # display chip select
_D3 = 7 # display data/command
_D4 = 23 # I2C SDA
_D5 = 24 # I2C SCL
_D6 = 11 # backlight
_D7 = 12 # touch interrupt
_SCK = 8 # D8
_MISO = 9 # D9
_MOSI = 10 # D10

# SPI(1) is the C5's one general-purpose SPI host. These pins reach it through
# the GPIO matrix, which carries a write-only clock of 40 MHz.
display_bus = SPIBus(
id=1,
baudrate=40_000_000,
sck=_SCK,
mosi=_MOSI,
miso=_MISO,
command=_D3,
chip_select=_D1,
swap_bytes=True, # the bus swaps each colour as it copies it
)

display_drv = GC9A01(
display_bus,
width=240,
height=240,
colstart=0,
rowstart=0,
rotation=0,
# The default table's rotation 0 sets MADCTL MX, which draws this panel
# mirrored left to right against its touch controller; mirrored=True
# clears it, so display and touch agree with no touch rotation.
mirrored=True,
color_depth=16,
bgr=True,
reverse_bytes_in_word=False,
invert=True,
brightness=1.0,
backlight_pin=_D6,
backlight_on_high=True,
)

i2c = I2C(0, scl=_D5, sda=_D4, freq=400_000)
touch = CHSC6X(i2c, irq_pin=_D7)
touch_rotation_table = (0, 5, 6, 3)


def touch_read():
return round_display_points(touch.read_points())


from board_peripherals import PERIPHERALS, load_peripherals

load_peripherals(globals())
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# SPDX-FileCopyrightText: 2026 Brad Barnett
#
# SPDX-License-Identifier: MIT

"""Lazy roles for the Seeed Round Display on a XIAO ESP32C5.

Nothing is constructed until it's asked for. None of these has run on a board
yet; the pins are from Seeed's pin tables:

microSD the display's slot, SPI on D8-D10, chip select D2 (GPIO25)
PCF8563 clock the board I2C, D4 SDA (GPIO23), D5 SCL (GPIO24)
battery the XIAO's own sense: GPIO6 through a 1:2 divider,
switched in by GPIO26
user LED GPIO27, yellow, low to light
BOOT button GPIO28, low when pressed
antenna Wi-Fi and Bluetooth through the XIAO's U.FL connector;
fit the antenna before using either

``sdcard`` is micropython-lib's ``sdcard.SDCard`` on the display's SPI bus. Mount
it yourself::

os.mount(board_config.sdcard, "/sd")

``rtc`` is the PCF8563; ``rtc.datetime()`` reads and sets it like
``machine.RTC``. ``rtc.lost_power`` turns True when its supply dropped since it
was last set.
"""

import sys

import boarddev

PERIPHERALS = frozenset(
{"sdcard", "rtc", "battery", "led", "boot_button", "i2c", "wlan", "ble"}
)

_D2 = 25 # microSD chip select
_BAT_ADC = 6 # battery divider tap
_BAT_EN = 26 # high connects the divider
_LED = 27
_BOOT = 28


def load_peripherals(ns):
boarddev.bind_lazy(ns, sys.modules[__name__])


def sdcard():
"""microSD on the display's SPI bus, chip select D2."""
import board_config as bc
from machine import Pin

from sdcard import SDCard

# SDCard drives the SPI peripheral itself; the display's SPIBus re-applies
# its own settings before every transfer, so the two take turns safely.
return SDCard(bc.display_bus._spi, Pin(_D2, Pin.OUT, value=1))


def rtc():
"""PCF8563 on the board I2C."""
import board_config as bc

from pcf8563 import PCF8563

return PCF8563(bc.i2c)


def battery():
"""LiPo voltage through the XIAO's 1:2 divider on GPIO6.

GPIO26 connects the divider; it stays connected once this role is opened,
which draws about 20 uA from the battery. Without a battery the reading is
the charger's output.
"""
from machine import Pin

from battery_adc import BatteryADC

Pin(_BAT_EN, Pin.OUT, value=1)
return BatteryADC(_BAT_ADC, scale=2.0)


def led():
"""The yellow user LED as a ``machine.Signal``: ``on()`` lights it."""
from machine import Pin, Signal

return Signal(Pin(_LED, Pin.OUT, value=1), invert=True)


def boot_button():
"""The BOOT button (GPIO28, ``value()`` 0 when pressed)."""
from machine import Pin

return Pin(_BOOT, Pin.IN, Pin.PULL_UP)


def i2c():
"""The board I2C bus: touch, clock and the XIAO's D4 and D5."""
import board_config as bc

return bc.i2c


def wlan():
import network

return network.WLAN(network.STA_IF)


def ble():
# A bledev adapter (docs/guides/bluetooth-le.md). It also answers every bluetooth.BLE
# method, so code written for the raw radio keeps working. Without bledev
# (or aioble) installed, the raw radio, as before.
try:
import bledev.mpble
except ImportError:
import bluetooth

return bluetooth.BLE()
return bledev.mpble.get()
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2026 Brad Barnett
#
# SPDX-License-Identifier: MIT

# The seeed_gc9a01_on_xiao_esp32c5 board package: what mip.install("seeed_gc9a01_on_xiao_esp32c5") brings.
metadata(
description="Seeed Studio Round Display for XIAO on a XIAO ESP32C5",
version="0.1",
)

require("omnipython")
require("gc9a01")
require("chsc6x")
require("pcf8563")
require("battery_adc")
require("sdcard") # micropython-lib's: frozen into OmniPython firmware, or mip.install("sdcard") first

module("board_config.py")
module("board_peripherals.py")
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"urls": [
[
"board_config.py",
"github:PyDevices/omnipython/board_configs/busdisplay/spi/seeed_gc9a01_on_xiao_esp32c5/board_config.py"
],
[
"board_peripherals.py",
"github:PyDevices/omnipython/board_configs/busdisplay/spi/seeed_gc9a01_on_xiao_esp32c5/board_peripherals.py"
],
[
"gc9a01.py",
"github:PyDevices/omnipython/drivers/display/gc9a01.py"
],
[
"chsc6x.py",
"github:PyDevices/omnipython/drivers/touch/chsc6x.py"
],
[
"pcf8563.py",
"github:PyDevices/omnipython/drivers/rtc/pcf8563.py"
],
[
"battery_adc.py",
"github:PyDevices/omnipython/drivers/power/battery_adc.py"
],
[
"sdcard.py",
"github:micropython/micropython-lib/micropython/drivers/storage/sdcard/sdcard.py"
]
],
"deps": [
[
"omnipython",
"latest"
]
],
"version": "0.1",
"description": "Seeed Studio Round Display for XIAO on a XIAO ESP32C5",
"generated": "from manifest.py by tools/libbuild.py installers; edit manifest.py, not this"
}
1 change: 1 addition & 0 deletions docs/boards/board-configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ and `omnipython`; its `manifest.py` lists them.
| Waveshare RP2040-Touch-LCD-1.28 | `busdisplay/spi/rp2040-touch-lcd-1.28` | | 240×240 round, GC9A01A SPI (`spibus` / FourWire); touch CST816 (`cst8xx` / `cst816`) | `touch` | `accelerometer`, `gyroscope`, `battery` |
| GC9A01 round display on QT Py ESP32-S3 | `busdisplay/spi/seeed_gc9a01_on_qtpy_esp32s3` | | | | |
| GC9A01 on QT Py RP2040 | `busdisplay/spi/seeed_gc9a01_on_qtpy_rp2040` | | | | |
| Seeed Round Display for XIAO on a XIAO ESP32C5 | `busdisplay/spi/seeed_gc9a01_on_xiao_esp32c5` | | 240×240 round, GC9A01 SPI (`spibus`); touch CHSC6X | `touch` | `sdcard`, `rtc`, `battery`, `led`, `boot_button`, `i2c`, `wlan`, `ble` |
| Seeed Round Display for XIAO (GC9A01, CHSC6X touch, microSD, PCF8563 clock) on a XIAO nRF52840, stock MicroPython | `busdisplay/spi/seeed_gc9a01_on_xiao_nrf52840` | yes | | | |
| SSD1331 color OLED (MP) | `busdisplay/spi/ssd1331_096_oled` | yes | | | |
| SSD1351 color OLED (MP) | `busdisplay/spi/ssd1351_128_oled` | yes | | | |
Expand Down
4 changes: 4 additions & 0 deletions tests/test_round_display_touch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"board_configs/busdisplay/spi/seeed_gc9a01_on_xiao_nrf52840/board_config.py",
_MP_DRIVER,
),
(
"board_configs/busdisplay/spi/seeed_gc9a01_on_xiao_esp32c5/board_config.py",
_MP_DRIVER,
),
(
"board_configs/cp/busdisplay/spi/seeed_gc9a01_on_xiao_nrf52840/board_config.py",
_CP_DRIVER,
Expand Down