Skip to content

Commit 7eb824c

Browse files
committed
Fix BGR/RGB bit settings
1 parent e1abf7d commit 7eb824c

File tree

3 files changed

+91
-1
lines changed

3 files changed

+91
-1
lines changed

adafruit_st7735r.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ def __init__(self, bus, *, bgr=False, invert=False, **kwargs):
7474
init_sequence = _INIT_SEQUENCE
7575
if bgr:
7676
init_sequence += (
77-
b"\x36\x01\xC8" # _MADCTL Default rotation plus BGR encoding
77+
b"\x36\x01\xC0" # _MADCTL Default rotation plus BGR encoding
78+
)
79+
else:
80+
init_sequence += (
81+
b"\x36\x01\xC8" # _MADCTL Default rotation plus RGB encoding
7882
)
7983
if invert:
8084
init_sequence += b"\x21\x00" # _INVON

docs/examples.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,27 @@ Ensure your device works with this simple test.
66
.. literalinclude:: ../examples/st7735r_simpletest.py
77
:caption: examples/st7735r_simpletest.py
88
:linenos:
9+
10+
.. literalinclude:: ../examples/st7735r_minitft_simpletest.py
11+
:caption: examples/st7735r_minitft_simpletest.py
12+
:linenos:
13+
14+
.. literalinclude:: ../examples/st7735r_minitft_featherwing_simpletest.py
15+
:caption: examples/st7735r_minitft_featherwing_simpletest.py
16+
:linenos:
17+
18+
.. literalinclude:: ../examples/st7735r_128x160_simpletest.py
19+
:caption: examples/st7735r_128x160_simpletest.py
20+
:linenos:
21+
22+
23+
Other Examples
24+
---------------
25+
26+
.. literalinclude:: ../examples/st7735r_18tftshield_buttons.py
27+
:caption: examples/st7735r_18tftshield_buttons.py
28+
:linenos:
29+
30+
.. literalinclude:: ../examples/st7735r_128x160_colored_labels.py
31+
:caption: examples/st7735r_128x160_colored_labels.py
32+
:linenos:
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
4+
"""
5+
This test will initialize the display using displayio and draw 8 colored
6+
labels. Useful for testing the color settings on an unknown display.
7+
"""
8+
9+
import board
10+
import terminalio
11+
import displayio
12+
from adafruit_display_text import label
13+
from adafruit_st7735r import ST7735R
14+
15+
# Release any resources currently in use for the displays
16+
displayio.release_displays()
17+
18+
spi = board.SPI()
19+
tft_cs = board.D5
20+
tft_dc = board.D6
21+
22+
display_bus = displayio.FourWire(
23+
spi, command=tft_dc, chip_select=tft_cs, reset=board.D9
24+
)
25+
26+
display = ST7735R(
27+
display_bus, width=160, height=80, colstart=24, rotation=270, bgr=False
28+
)
29+
30+
# Make the display context
31+
splash = displayio.Group(max_size=10)
32+
display.show(splash)
33+
34+
color_bitmap = displayio.Bitmap(160, 80, 1)
35+
color_palette = displayio.Palette(1)
36+
# write some text in each font color, rgb, cmyk
37+
color_palette[0] = 0x111111 # light grey
38+
39+
text_group_left = displayio.Group(max_size=10, scale=1, x=0, y=6)
40+
text_area_red = label.Label(terminalio.FONT, text="RED", color=0xFF0000)
41+
text_area_green = label.Label(terminalio.FONT, text="\nGREEN", color=0x00FF00)
42+
text_area_blue = label.Label(terminalio.FONT, text="\n\nBLUE", color=0x0000FF)
43+
text_area_white = label.Label(terminalio.FONT, text="\n\n\nWHITE", color=0xFFFFFF)
44+
text_group_left.append(text_area_red)
45+
text_group_left.append(text_area_green)
46+
text_group_left.append(text_area_blue)
47+
text_group_left.append(text_area_white)
48+
splash.append(text_group_left)
49+
50+
text_group_right = displayio.Group(max_size=10, scale=1, x=80, y=6)
51+
text_area_cyan = label.Label(terminalio.FONT, text="CYAN", color=0x00FFFF)
52+
text_group_right.append(text_area_cyan)
53+
text_area_magenta = label.Label(terminalio.FONT, text="\nMAGENTA", color=0xFF00FF)
54+
text_group_right.append(text_area_magenta)
55+
text_area_yellow = label.Label(terminalio.FONT, text="\n\nYELLOW", color=0xFFFF00)
56+
text_group_right.append(text_area_yellow)
57+
text_area_black = label.Label(terminalio.FONT, text="\n\n\nBLACK", color=0x000000)
58+
text_group_right.append(text_area_black)
59+
splash.append(text_group_right)
60+
61+
while True:
62+
pass

0 commit comments

Comments
 (0)