Fix bug in gca9a01_8_bit.py.

pull/70/head
Peter Hinch 2024-05-26 17:16:56 +01:00
rodzic 108f3d9807
commit 6fc08b1a40
2 zmienionych plików z 27 dodań i 6 usunięć

Wyświetl plik

@ -823,6 +823,15 @@ Clock rates up to 100MHz are supported according to the chip datasheet section
7.3.4, but high speeds are sensitive to electrical issues such as lead lengths, 7.3.4, but high speeds are sensitive to electrical issues such as lead lengths,
PCB layout and grounding. I have run 33MHz without issue. PCB layout and grounding. I have run 33MHz without issue.
Two versions are provided:
* `gc9a01.py` 4-bit driver, frame buffer requires 28,800 bytes of RAM.
* `gc9a01_8_bit.py` 8-bit driver, requires 57,600 bytes.
For use with the three GUI options the 4-bit version is normally preferred. The
8-bit version allows more colors to be displayed on any given screen. It also
offers a mode in which 8-bit greyscale full-screen bitmap images can be
displayed. Both have identical constructor args.
#### GC9A01 Constructor args: #### GC9A01 Constructor args:
* `spi` An initialised SPI bus instance. * `spi` An initialised SPI bus instance.
@ -836,6 +845,19 @@ PCB layout and grounding. I have run 33MHz without issue.
* `mirror=False` If `True` a mirror-image is displayed * `mirror=False` If `True` a mirror-image is displayed
* `init_spi=False` For shared SPI bus applications. See note below. * `init_spi=False` For shared SPI bus applications. See note below.
#### Method (8-bit version only)
* `greyscale(gs=None)` By default the frame buffer contents are interpreted as
`rrrgggbb` color values. If `True` is passed, the contents will be treated as
8-bit greyscale values. This mode will persist until the method is called with
`False`. Returns the current greyscale state. It is possible to superimpose
widgets on an image, but the mapping of colors onto the greyscale may yield
unexpected grey values. `WHITE` and `BLACK` work well. In
[micro-gui](https://github.com/peterhinch/micropython-micro-gui) and
[micropython-touch](https://github.com/peterhinch/micropython-touch) the
`after_open` method should be used to render the image to the framebuf and to
overlay any widgets.
#### Shared SPI bus #### Shared SPI bus
This optional arg enables flexible options in configuring the SPI bus. The This optional arg enables flexible options in configuring the SPI bus. The

Wyświetl plik

@ -89,10 +89,9 @@ class GC9A01(framebuf.FrameBuffer):
# Default page address start == 0 end == 0xEF (239) # Default page address start == 0 end == 0xEF (239)
self._wcd(b"\x2b", int.to_bytes(height - 1, 4, "big")) # SET_PAGE ht self._wcd(b"\x2b", int.to_bytes(height - 1, 4, "big")) # SET_PAGE ht
# **** Start of opaque chip setup **** # **** Start of opaque chip setup ****
self._wcmd(b"\xEF") # Inter register enable 2
self._wcd(b"\xEB", b"\x14") # ?
self._wcmd(b"\xFE") # Inter register enable 1 self._wcmd(b"\xFE") # Inter register enable 1
self._wcmd(b"\xEF") # Inter register enable 2 self._wcmd(b"\xEF") # Inter register enable 2. Sequence is necessary
# to enable access to other registers.
self._wcd(b"\xEB", b"\x14") # ? self._wcd(b"\xEB", b"\x14") # ?
self._wcd(b"\x84", b"\x40") # ? self._wcd(b"\x84", b"\x40") # ?
self._wcd(b"\x85", b"\xFF") # ? self._wcd(b"\x85", b"\xFF") # ?
@ -134,9 +133,9 @@ class GC9A01(framebuf.FrameBuffer):
self._wcd(b"\x67", b"\x00\x3C\x00\x00\x00\x01\x54\x10\x32\x98") # Undoc but needed self._wcd(b"\x67", b"\x00\x3C\x00\x00\x00\x01\x54\x10\x32\x98") # Undoc but needed
self._wcd(b"\x74", b"\x10\x85\x80\x00\x00\x4E\x00") # ? self._wcd(b"\x74", b"\x10\x85\x80\x00\x00\x4E\x00") # ?
self._wcd(b"\x98", b"\x3e\x07") # ? self._wcd(b"\x98", b"\x3e\x07") # ?
self._wcmd(b"\x35") # Tearing effect line on # self._wcmd(b"\x35") # Tearing effect line on. This pin is unused.
self._wcmd(b"\x21") # Display inversion on ??? self._wcmd(b"\x21") # Display inversion on
self._wcmd(b"\x11") self._wcmd(b"\x11") # Sleep out
sleep_ms(120) sleep_ms(120)
# ************************* # *************************