Skip to content

Commit 3f6f08b

Browse files
authored
Merge pull request #38 from RetiredWizard/main
Add bgr and invert options
2 parents b1063ed + e0b03c9 commit 3f6f08b

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
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)

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# Uncomment the below if you use native CircuitPython modules such as
2828
# digitalio, micropython and busio. List the modules you use. Without it, the
2929
# autodoc module docs will fail to generate with a warning.
30-
# autodoc_mock_imports = ["digitalio", "busio"]
30+
autodoc_mock_imports = ["displayio"]
3131

3232
intersphinx_mapping = {
3333
"python": ("https://docs.python.org/3", None),

0 commit comments

Comments
 (0)