Skip to content
Merged
3 changes: 3 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# Required
version: 2

sphinx:
configuration: docs/conf.py

build:
os: ubuntu-20.04
tools:
Expand Down
126 changes: 126 additions & 0 deletions adafruit_rgb_display/gc9a01a.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# SPDX-FileCopyrightText: 2025 Liz Clark for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
`adafruit_rgb_display.gc9a01a`
====================================================
A simple driver for the GC9A01A-based displays.

* Author(s): Liz Clark

"""

import time
import busio
import digitalio
from micropython import const
from adafruit_rgb_display.rgb import DisplaySPI

try:
from typing import Optional
except ImportError:
pass

__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git"

# Command constants
_SWRESET = const(0xFE)
_SLPOUT = const(0x11)
_NORON = const(0x13)
_INVOFF = const(0x20)
_INVON = const(0x21)
_DISPOFF = const(0x28)
_DISPON = const(0x29)
_CASET = const(0x2A)
_RASET = const(0x2B)
_RAMWR = const(0x2C)
_RAMRD = const(0x2E)
_MADCTL = const(0x36)
_COLMOD = const(0x3A)


class GC9A01A(DisplaySPI):
"""
A simple driver for the GC9A01A-based displays.

>>> import busio
>>> import digitalio
>>> import board
>>> from adafruit_rgb_display import gc9a01a
>>> spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
>>> display = gc9a01a.GC9A01A(spi, cs=digitalio.DigitalInOut(board.CE0),
... dc=digitalio.DigitalInOut(board.D25), rst=digitalio.DigitalInOut(board.D27))
>>> display.fill(0x7521)
>>> display.pixel(64, 64, 0)
"""

_COLUMN_SET = _CASET
_PAGE_SET = _RASET
_RAM_WRITE = _RAMWR
_RAM_READ = _RAMRD
_INIT = (
(_SWRESET, None),
(0xEF, None), # Inter Register Enable2
(0xB6, b"\x00\x00"), # Display Function Control
(_MADCTL, b"\x48"), # Memory Access Control - Set to BGR color filter panel
(_COLMOD, b"\x05"), # Interface Pixel Format - 16 bits per pixel
(0xC3, b"\x13"), # Power Control 2
(0xC4, b"\x13"), # Power Control 3
(0xC9, b"\x22"), # Power Control 4
(0xF0, b"\x45\x09\x08\x08\x26\x2a"), # SET_GAMMA1
(0xF1, b"\x43\x70\x72\x36\x37\x6f"), # SET_GAMMA2
(0xF2, b"\x45\x09\x08\x08\x26\x2a"), # SET_GAMMA3
(0xF3, b"\x43\x70\x72\x36\x37\x6f"), # SET_GAMMA4
(0x66, b"\x3c\x00\xcd\x67\x45\x45\x10\x00\x00\x00"),
(0x67, b"\x00\x3c\x00\x00\x00\x01\x54\x10\x32\x98"),
(0x74, b"\x10\x85\x80\x00\x00\x4e\x00"),
(0x98, b"\x3e\x07"),
(0x35, None), # Tearing Effect Line ON
(_INVON, None), # Display Inversion ON
(_SLPOUT, None), # Sleep Out Mode
(_NORON, None), # Normal Display Mode ON
(_DISPON, None), # Display ON
)

# pylint: disable-msg=useless-super-delegation, too-many-arguments
def __init__(
self,
spi: busio.SPI,
dc: digitalio.DigitalInOut,
cs: digitalio.DigitalInOut,
rst: Optional[digitalio.DigitalInOut] = None,
width: int = 240,
height: int = 240,
baudrate: int = 24000000,
polarity: int = 0,
phase: int = 0,
*,
x_offset: int = 0,
y_offset: int = 0,
rotation: int = 0
) -> None:
super().__init__(
spi,
dc,
cs,
rst,
width,
height,
baudrate=baudrate,
polarity=polarity,
phase=phase,
x_offset=x_offset,
y_offset=y_offset,
rotation=rotation,
)

def init(self) -> None:
"""Initialize the display."""
if self.rst:
self.rst.value = 0
time.sleep(0.05)
self.rst.value = 1
time.sleep(0.05)

super().init()
2 changes: 1 addition & 1 deletion adafruit_rgb_display/rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def color565(
package namespace."""
if isinstance(r, (tuple, list)): # see if the first var is a tuple/list
if len(r) >= 3:
red, g, b = r
red, g, b = r[0:3]
else:
raise ValueError(
"Not enough values to unpack (expected 3, got %d)" % len(r)
Expand Down
2 changes: 0 additions & 2 deletions adafruit_rgb_display/ssd1331.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,5 @@ def write(
with self.spi_device as spi:
if command is not None:
spi.write(bytearray([command]))
print(bytearray([command]))
if data is not None:
spi.write(data)
print(data)
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
import sphinx_rtd_theme

html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand Down