Skip to content

Commit 7061bb0

Browse files
deshiputannewt
authored andcommitted
Add support for the "red tab" ST7735 displays
1 parent a3747b7 commit 7061bb0

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

adafruit_rgb_display/st7735.py

+46
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from adafruit_rgb_display.rgb import DisplaySPI
2+
import ustruct
23

34

45
_NOP=const(0x00)
@@ -96,3 +97,48 @@ class ST7735(DisplaySPI):
9697

9798
def __init__(self, spi, dc, cs, rst=None, width=128, height=128):
9899
super().__init__(spi, dc, cs, rst, width, height)
100+
101+
102+
class ST7735R(ST7735):
103+
_INIT = (
104+
(_SWRESET, None),
105+
(_SLPOUT, None),
106+
107+
(_MADCTL, b'\xc8'),
108+
(_COLMOD, b'\x05'), # 16bit color
109+
(_INVCTR, b'\x07'),
110+
111+
(_FRMCTR1, b'\x01\x2c\x2d'),
112+
(_FRMCTR2, b'\x01\x2c\x2d'),
113+
(_FRMCTR3, b'\x01\x2c\x2d\x01\x2c\x2d'),
114+
115+
(_PWCTR1, b'\x02\x02\x84'),
116+
(_PWCTR2, b'\xc5'),
117+
(_PWCTR3, b'\x0a\x00'),
118+
(_PWCTR4, b'\x8a\x2a'),
119+
(_PWCTR5, b'\x8a\xee'),
120+
121+
(_VMCTR1, b'\x0e'),
122+
(_INVOFF, None),
123+
124+
(_GMCTRP1, b'\x02\x1c\x07\x12\x37\x32\x29\x2d'
125+
b'\x29\x25\x2B\x39\x00\x01\x03\x10'), # Gamma
126+
(_GMCTRN1, b'\x03\x1d\x07\x06\x2E\x2C\x29\x2D'
127+
b'\x2E\x2E\x37\x3F\x00\x00\x02\x10'),
128+
)
129+
130+
def __init__(self, spi, dc, cs, rst=None, width=128, height=160):
131+
super().__init__(spi, dc, cs, rst, width, height)
132+
133+
def init(self):
134+
super().init()
135+
cols = ustruct.pack('>HH', 0, self.width - 1)
136+
rows = ustruct.pack('>HH', 0, self.height - 1)
137+
for command, data in (
138+
(_CASET, cols),
139+
(_RASET, rows),
140+
141+
(_NORON, None),
142+
(_DISPON, None),
143+
):
144+
self._write(command, data)

0 commit comments

Comments
 (0)