ILI9341: Provide fix for some Chinese display modules.

pull/9/merge
peterhinch 2023-03-20 17:04:10 +00:00
rodzic 032a9ba4be
commit 597ab5ef3f
2 zmienionych plików z 15 dodań i 2 usunięć

Wyświetl plik

@ -416,6 +416,13 @@ training makes me baulk at exceeding datasheet limits but the choice is yours.
I raised [this isse](https://github.com/adafruit/Adafruit_CircuitPython_ILI9341/issues/24).
The response may be of interest.
#### Troubleshooting
Some Chinese modules produce garbled displays. Please try the
[ILI9486 driver](./DRIVERS.md#34-driver-for-ili94xx) with the `mirror`
constructor arg set `True`. Patch and testing provided by
[Abel Deuring](https://github.com/peterhinch/micropython-micro-gui/issues/25#issuecomment-1475329104).
###### [Contents](./DRIVERS.md#contents)
## 3.3 Drivers for ST7789
@ -709,6 +716,8 @@ powered from 5V or 3.3V: there is a regulator on board.
`height` and `width` values.
* `width=480`
* `usd=False` Upside down: set `True` to invert display.
* `mirror=False` If `True` reflects display. Has been found necessary for some
Chinese ILI9341 modules.
* `init_spi=False` This optional arg enables flexible options in configuring
the SPI bus. The default assumes exclusive access to the bus. In this normal
case, `color_setup.py` initialises it and the settings will be left in place.

Wyświetl plik

@ -66,7 +66,7 @@ class ILI9486(framebuf.FrameBuffer):
return cls.COLOR_INVERT ^ ((r & 0xF8) | (g & 0xE0) >> 5 | (g & 0x1C) << 11 | (b & 0xF8) << 5)
# Transpose width & height for landscape mode
def __init__(self, spi, cs, dc, rst, height=320, width=480, usd=False, init_spi=False):
def __init__(self, spi, cs, dc, rst, height=320, width=480, usd=False, mirror=False, init_spi=False):
self._spi = spi
self._cs = cs
self._dc = dc
@ -107,7 +107,11 @@ class ILI9486(framebuf.FrameBuffer):
# Default page address start == 0 end == 0x1DF (479)
if self._long != 480:
self._wcd(b"\x2b", int.to_bytes(self._long - 1, 4, "big")) # SET_PAGE ht
self._wcd(b"\x36", b"\x48" if usd else b"\x88") # MADCTL: RGB portrait mode
# self._wcd(b"\x36", b"\x48" if usd else b"\x88") # MADCTL: RGB portrait mode
madctl = 0x48 if usd else 0x88
if mirror:
madctl ^= 0x80
self._wcd(b"\x36", madctl.to_bytes(1, 'big')) # MADCTL: RGB portrait mode
self._wcmd(b"\x11") # sleep out
self._wcmd(b"\x29") # display on