Skip to content

Added all 3 ST7735R displays, added BGR param for miniTFT #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions adafruit_rgb_display/st7735.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,12 @@ class ST7735(DisplaySPI):
_ENCODE_POS = ">HH"

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


class ST7735R(ST7735):
Expand Down Expand Up @@ -167,17 +171,25 @@ class ST7735R(ST7735):
)

#pylint: disable-msg=useless-super-delegation, too-many-arguments
def __init__(self, spi, dc, cs, rst=None, width=128, height=160, rotation=0):
super().__init__(spi, dc, cs, rst, width, height, rotation)
def __init__(self, spi, dc, cs, rst=None, width=128, height=160,
baudrate=16000000, polarity=0, phase=0, *,
x_offset=0, y_offset=0, rotation=0, bgr=False):
self._bgr = bgr
super().__init__(spi, dc, cs, rst, width, height,
baudrate=baudrate, polarity=polarity, phase=phase,
x_offset=x_offset, y_offset=y_offset, rotation=rotation)

def init(self):
super().init()
cols = struct.pack('>HH', 0, self.width - 1)
rows = struct.pack('>HH', 0, self.height - 1)

for command, data in (
(_CASET, cols),
(_RASET, rows),
(_NORON, None),
(_DISPON, None),
):
self.write(command, data)
if self._bgr:
self.write(_MADCTL, b'\xc0')
4 changes: 4 additions & 0 deletions examples/rgb_display_pillow_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import adafruit_rgb_display.ili9341 as ili9341
import adafruit_rgb_display.st7789 as st7789 # pylint: disable=unused-import
import adafruit_rgb_display.hx8357 as hx8357 # pylint: disable=unused-import
import adafruit_rgb_display.st7735 as st7735 # pylint: disable=unused-import

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

Expand Down
4 changes: 4 additions & 0 deletions examples/rgb_display_pillow_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import adafruit_rgb_display.ili9341 as ili9341
import adafruit_rgb_display.st7789 as st7789 # pylint: disable=unused-import
import adafruit_rgb_display.hx8357 as hx8357 # pylint: disable=unused-import
import adafruit_rgb_display.st7735 as st7735 # pylint: disable=unused-import

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

Expand Down
4 changes: 4 additions & 0 deletions examples/rgb_display_pillow_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import adafruit_rgb_display.ili9341 as ili9341
import adafruit_rgb_display.st7789 as st7789 # pylint: disable=unused-import
import adafruit_rgb_display.hx8357 as hx8357 # pylint: disable=unused-import
import adafruit_rgb_display.st7735 as st7735 # pylint: disable=unused-import

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

Expand Down