-
Notifications
You must be signed in to change notification settings - Fork 53
Adding GC9A01A #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Adding GC9A01A #129
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b55666b
Create gc9a01a.py
BlitzCityDIY 7d5528f
Update gc9a01a.py
BlitzCityDIY 67547fa
Update gc9a01a.py
BlitzCityDIY 9f02995
pre-commit, tested
BlitzCityDIY 8ce10d5
lint
BlitzCityDIY 664dcd2
oy vey, black
BlitzCityDIY f56a9ee
remove _block
BlitzCityDIY File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# 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() | ||
|
||
self._block(0, 0, self.width - 1, self.height - 1) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BlitzCityDIY What does this call to
self._block()
here do? If you're still set up to test on RPi can you check if everything still works if this is commented out or removed?I tested under CircuitPython with a QTPY esp32-S2 and found that this statement blocks execution during the display initializer, so the given example code never gets past the line
If I comment this call to
self._block()
out then the display initializes and drawing on it seems to work as expected from circuitpythonThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested and _block wasn't doing anything so just removed that