Skip to content

Commit 8410023

Browse files
committed
Add bgr and invert options
1 parent b1063ed commit 8410023

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

adafruit_ili9341.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
b"\xc1\x01\x10" # Power control SAP[2:0];BT[3:0]
7777
b"\xc5\x02\x3e\x28" # VCM control
7878
b"\xc7\x01\x86" # VCM control2
79-
b"\x36\x01\x38" # Memory Access Control
8079
b"\x37\x01\x00" # Vertical scroll zero
8180
b"\x3a\x01\x55" # COLMOD: Pixel Format Set
8281
b"\xb1\x02\x00\x18" # Frame Rate Control (In Normal Mode/Full Colors)
@@ -98,5 +97,19 @@ class ILI9341(BusDisplay):
9897
:param FourWire bus: bus that the display is connected to
9998
"""
10099

101-
def __init__(self, bus: FourWire, **kwargs: Any):
102-
super().__init__(bus, _INIT_SEQUENCE, **kwargs)
100+
def __init__(
101+
self, bus: FourWire, *, bgr: bool = False, invert: bool = False, **kwargs: Any
102+
):
103+
init_sequence = _INIT_SEQUENCE
104+
if bgr:
105+
init_sequence += (
106+
b"\x36\x01\x30" # _MADCTL Default rotation plus BGR encoding
107+
)
108+
else:
109+
init_sequence += (
110+
b"\x36\x01\x38" # _MADCTL Default rotation plus RGB encoding
111+
)
112+
if invert:
113+
init_sequence += b"\x21\x00" # _INVON
114+
115+
super().__init__(bus, init_sequence, **kwargs)

0 commit comments

Comments
 (0)