Skip to content

Commit 443d704

Browse files
committed
Added all 3 ST7735R displays, added BGR param for miniTFT
1 parent 221a935 commit 443d704

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

adafruit_rgb_display/st7735.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,12 @@ class ST7735(DisplaySPI):
133133
_ENCODE_POS = ">HH"
134134

135135
#pylint: disable-msg=useless-super-delegation, too-many-arguments
136-
def __init__(self, spi, dc, cs, rst=None, width=128, height=128, rotation=0):
137-
super().__init__(spi, dc, cs, rst, width, height, rotation)
136+
def __init__(self, spi, dc, cs, rst=None, width=128, height=128,
137+
baudrate=16000000, polarity=0, phase=0, *,
138+
x_offset=0, y_offset=0, rotation=0):
139+
super().__init__(spi, dc, cs, rst, width, height,
140+
baudrate=baudrate, polarity=polarity, phase=phase,
141+
x_offset=x_offset, y_offset=y_offset, rotation=rotation)
138142

139143

140144
class ST7735R(ST7735):
@@ -167,17 +171,25 @@ class ST7735R(ST7735):
167171
)
168172

169173
#pylint: disable-msg=useless-super-delegation, too-many-arguments
170-
def __init__(self, spi, dc, cs, rst=None, width=128, height=160, rotation=0):
171-
super().__init__(spi, dc, cs, rst, width, height, rotation)
174+
def __init__(self, spi, dc, cs, rst=None, width=128, height=160,
175+
baudrate=16000000, polarity=0, phase=0, *,
176+
x_offset=0, y_offset=0, rotation=0, bgr=False):
177+
self._bgr = bgr
178+
super().__init__(spi, dc, cs, rst, width, height,
179+
baudrate=baudrate, polarity=polarity, phase=phase,
180+
x_offset=x_offset, y_offset=y_offset, rotation=rotation)
172181

173182
def init(self):
174183
super().init()
175184
cols = struct.pack('>HH', 0, self.width - 1)
176185
rows = struct.pack('>HH', 0, self.height - 1)
186+
177187
for command, data in (
178188
(_CASET, cols),
179189
(_RASET, rows),
180190
(_NORON, None),
181191
(_DISPON, None),
182192
):
183193
self.write(command, data)
194+
if self._bgr:
195+
self.write(_MADCTL, b'\xc0')

examples/rgb_display_pillow_demo.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import adafruit_rgb_display.ili9341 as ili9341
55
import adafruit_rgb_display.st7789 as st7789 # pylint: disable=unused-import
66
import adafruit_rgb_display.hx8357 as hx8357 # pylint: disable=unused-import
7+
import adafruit_rgb_display.st7735 as st7735 # pylint: disable=unused-import
78

89
# First define some constants to allow easy resizing of shapes.
910
BORDER = 20
@@ -24,6 +25,9 @@
2425
#disp = st7789.ST7789(spi, rotation=90 # 2.0" ST7789
2526
#disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=90 # 1.3", 1.54" ST7789
2627
#disp = hx8357.HX8357(spi, rotation=180, # 3.5" HX8357
28+
#disp = st7735.ST7735R(spi, rotation=90, # 1.8" ST7735R
29+
#disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, # 1.44" ST7735R
30+
#disp = st7735.ST7735R(spi, rotation=90, bgr=True, # 0.96" MiniTFT ST7735R
2731
disp = ili9341.ILI9341(spi, rotation=90, # 2.2", 2.4", 2.8", 3.2" ILI9341
2832
cs=cs_pin, dc=dc_pin, rst=reset_pin, baudrate=BAUDRATE)
2933

examples/rgb_display_pillow_image.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import adafruit_rgb_display.ili9341 as ili9341
55
import adafruit_rgb_display.st7789 as st7789 # pylint: disable=unused-import
66
import adafruit_rgb_display.hx8357 as hx8357 # pylint: disable=unused-import
7+
import adafruit_rgb_display.st7735 as st7735 # pylint: disable=unused-import
78

89
# Configuration for CS and DC pins (these are PiTFT defaults):
910
cs_pin = digitalio.DigitalInOut(board.CE0)
@@ -20,6 +21,9 @@
2021
#disp = st7789.ST7789(spi, rotation=90 # 2.0" ST7789
2122
#disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=90 # 1.3", 1.54" ST7789
2223
#disp = hx8357.HX8357(spi, rotation=180, # 3.5" HX8357
24+
#disp = st7735.ST7735R(spi, rotation=90, # 1.8" ST7735R
25+
#disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, # 1.44" ST7735R
26+
#disp = st7735.ST7735R(spi, rotation=90, bgr=True, # 0.96" MiniTFT ST7735R
2327
disp = ili9341.ILI9341(spi, rotation=90, # 2.2", 2.4", 2.8", 3.2" ILI9341
2428
cs=cs_pin, dc=dc_pin, rst=reset_pin, baudrate=BAUDRATE)
2529

examples/rgb_display_pillow_stats.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import adafruit_rgb_display.ili9341 as ili9341
77
import adafruit_rgb_display.st7789 as st7789 # pylint: disable=unused-import
88
import adafruit_rgb_display.hx8357 as hx8357 # pylint: disable=unused-import
9+
import adafruit_rgb_display.st7735 as st7735 # pylint: disable=unused-import
910

1011
# Configuration for CS and DC pins (these are PiTFT defaults):
1112
cs_pin = digitalio.DigitalInOut(board.CE0)
@@ -22,6 +23,9 @@
2223
#disp = st7789.ST7789(spi, rotation=90 # 2.0" ST7789
2324
#disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=90 # 1.3", 1.54" ST7789
2425
#disp = hx8357.HX8357(spi, rotation=180, # 3.5" HX8357
26+
#disp = st7735.ST7735R(spi, rotation=90, # 1.8" ST7735R
27+
#disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, # 1.44" ST7735R
28+
#disp = st7735.ST7735R(spi, rotation=90, bgr=True, # 0.96" MiniTFT ST7735R
2529
disp = ili9341.ILI9341(spi, rotation=90, # 2.2", 2.4", 2.8", 3.2" ILI9341
2630
cs=cs_pin, dc=dc_pin, rst=reset_pin, baudrate=BAUDRATE)
2731

0 commit comments

Comments
 (0)