Merge pull request #24 from lynniemagoo/master

Issue #22 - Cannot display proper color on Adafruit 358 160x128 ST7735R TFT display
This commit is contained in:
Philip Howard
2023-08-07 10:11:47 +01:00
committed by GitHub

View File

@@ -119,7 +119,7 @@ class ST7735(object):
"""Representation of an ST7735 TFT LCD."""
def __init__(self, port, cs, dc, backlight=None, rst=None, width=ST7735_TFTWIDTH,
height=ST7735_TFTHEIGHT, rotation=90, offset_left=None, offset_top=None, invert=True, spi_speed_hz=4000000):
height=ST7735_TFTHEIGHT, rotation=90, offset_left=None, offset_top=None, invert=True, bgr=True, spi_speed_hz=4000000):
"""Create an instance of the display using SPI communication.
Must provide the GPIO pin number for the D/C pin and the SPI driver.
@@ -154,6 +154,7 @@ class ST7735(object):
self._height = height
self._rotation = rotation
self._invert = invert
self._bgr = bgr
# Default left offset to center display
if offset_left is None:
@@ -297,7 +298,10 @@ class ST7735(object):
self.command(ST7735_INVOFF) # Don't invert display
self.command(ST7735_MADCTL) # Memory access control (directions)
self.data(0xC8) # row addr/col addr, bottom to top refresh
if self._bgr:
self.data(0xC8) # row addr/col addr, bottom to top refresh; Set D3 RGB Bit to 1 for format BGR
else:
self.data(0xC0) # row addr/col addr, bottom to top refresh; Set D3 RGB Bit to 0 for format RGB
self.command(ST7735_COLMOD) # set color mode
self.data(0x05) # 16-bit color