From 4d435b073fa8ccba2b803c8749b8c9cf44a0e099 Mon Sep 17 00:00:00 2001 From: peterhinch Date: Mon, 20 Mar 2023 17:02:59 +0000 Subject: [PATCH] ILI9341: Provide fix for some Chinese display modules. --- README.md | 1 + drivers/ili94xx/ili9486.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f1aa36b..0b7eb2a 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,7 @@ development so check for updates. 7.4 [Class TSequence](./README.md#74-class-tsequence) Plotting realtime, time sequential data. 8. [ESP32 touch pads](./README.md#8-esp32-touch-pads) Replacing buttons with touch pads. 9. [Realtime applications](./README.md#9-realtime-applications) Accommodating tasks requiring fast RT performance. + [Appendix 1 Application design](./README.md#appendix-1-application-design) Tab order, button layout, encoder interface, use of graphics primitives [Appendix 2 Freezing bytecode](./README.md#appendix-2-freezing-bytecode) Optional way to save RAM. [Appendix 3 Cross compiling](./README.md#appendix-3-cross-compiling) Another way to save RAM. diff --git a/drivers/ili94xx/ili9486.py b/drivers/ili94xx/ili9486.py index c2833c6..ac52cf9 100644 --- a/drivers/ili94xx/ili9486.py +++ b/drivers/ili94xx/ili9486.py @@ -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