Skip to content

Commit b6e7521

Browse files
authored
Merge pull request #24 from makermelissa/master
Fix BGR/RGB bit settings and add example
2 parents 72cbe2a + 64705ca commit b6e7521

File tree

3 files changed

+76
-6
lines changed

3 files changed

+76
-6
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: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Simple test
1+
Simple Test
22
------------
33

44
Ensure your device works with this simple test.
@@ -7,16 +7,20 @@ Ensure your device works with this simple test.
77
:caption: examples/st7735r_simpletest.py
88
:linenos:
99

10-
128x160 Simple test
10+
128x160 Tests
1111
--------------------
1212

13-
Example for the 128x160
13+
Examples for the 128x160
1414

1515
.. literalinclude:: ../examples/st7735r_128x160_simpletest.py
1616
:caption: examples/st7735r_128x160_simpletest.py
1717
:linenos:
1818

19-
Minitft featherwing test
19+
.. literalinclude:: ../examples/st7735r_128x160_colored_labels.py
20+
:caption: examples/st7735r_128x160_colored_labels.py
21+
:linenos:
22+
23+
Minitft FeatherWing Test
2024
-------------------------
2125

2226
Simple example for the minitft featherwing
@@ -25,7 +29,7 @@ Simple example for the minitft featherwing
2529
:caption: examples/st7735r_minitft_featherwing_simpletest.py
2630
:linenos:
2731

28-
Minitft test
32+
MiniTFT Test
2933
------------
3034

3135
Simple example for the minitft
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)