class documentation

ST7789 driver class Args: spi (spi): spi object **Required** width (int): display width **Required** height (int): display height **Required** reset (pin): reset pin dc (pin): dc pin **Required** cs (pin): cs pin backlight(pin): backlight pin rotation (int): - 0-Portrait - 1-Landscape - 2-Inverted Portrait - 3-Inverted Landscape color_order (int): - RGB: Red, Green Blue, default - BGR: Blue, Green, Red custom_init (tuple): custom initialization commands - ((b'command', b'data', delay_ms), ...) custom_rotations (tuple): custom rotation definitions - ((width, height, xstart, ystart, madctl, needs_swap), ...)

Method __init__ Initialize display.
Method bitmap Draw a bitmap on display at the specified column and row
Method blit_buffer Copy buffer to display at the given location.
Method fill Fill the entire FrameBuffer with the specified color.
Method fill_rect Draw a rectangle at the given location, size and filled with color.
Method get_backlight Undocumented
Method hard_reset Hard reset display.
Method hline Draw horizontal line at the given location and color.
Method init Initialize display.
Method inversion_mode Enable or disable display inversion mode.
Method line Draw a single pixel wide line starting at x0, y0 and ending at x1, y1.
Method pbitmap Draw a bitmap on display at the specified column and row one row at a time
Method pixel Draw a pixel at the given location and color.
Method polygon Draw a polygon on the display.
Method rect Draw a rectangle at the given location, size and color.
Method rotation Set display rotation.
Method set_backlight Undocumented
Method sleep_mode Enable or disable display sleep mode.
Method soft_reset Soft reset display.
Method text Draw text on display in specified font and colors. 8 and 16 bit wide fonts are supported.
Method vline Draw vertical line at the given location and color.
Method vscrdef Set Vertical Scrolling Definition.
Method vscsad Set Vertical Scroll Start Address of RAM.
Method write Write a string using a converted true-type font on the display starting at the specified column and row
Method write_width Returns the width in pixels of the string if it was written with the specified font
Instance Variable backlight Undocumented
Instance Variable color_order Undocumented
Instance Variable cs Undocumented
Instance Variable dc Undocumented
Instance Variable height Undocumented
Instance Variable init_cmds Undocumented
Instance Variable needs_swap Undocumented
Instance Variable physical_height Undocumented
Instance Variable physical_width Undocumented
Instance Variable reset Undocumented
Instance Variable rotations Undocumented
Instance Variable spi Undocumented
Instance Variable width Undocumented
Instance Variable xstart Undocumented
Instance Variable ystart Undocumented
Static Method _find_rotations Undocumented
Static Method _pack16 Pack a character into a byte array.
Static Method _pack8 Undocumented
Method _set_window Set window to column and row address.
Method _text16 Internal method to draw characters with width of 16 and heights of 16 or 32.
Method _text8 Internal method to write characters with width of 8 and heights of 8 or 16.
Method _write SPI write to the device: commands and data.
Instance Variable _backlight_level Undocumented
Instance Variable _rotation Undocumented
def __init__(self, spi, width, height, reset=None, dc=None, cs=None, backlight=None, rotation=0, color_order=BGR, custom_init=None, custom_rotations=None):

Initialize display.

def bitmap(self, bitmap, x, y, index=0):

Draw a bitmap on display at the specified column and row Args: bitmap (bitmap_module): The module containing the bitmap to draw x (int): column to start drawing at y (int): row to start drawing at index (int): Optional index of bitmap to draw from multiple bitmap module

def blit_buffer(self, buffer, x, y, width, height):

Copy buffer to display at the given location. Args: buffer (bytes): Data to copy to display x (int): Top left corner x coordinate Y (int): Top left corner y coordinate width (int): Width height (int): Height

def fill(self, color):

Fill the entire FrameBuffer with the specified color. Args: color (int): 565 encoded color

def fill_rect(self, x, y, width, height, color):

Draw a rectangle at the given location, size and filled with color. Args: x (int): Top left corner x coordinate y (int): Top left corner y coordinate width (int): Width in pixels height (int): Height in pixels color (int): 565 encoded color

def get_backlight(self):

Undocumented

def hard_reset(self):

Hard reset display.

def hline(self, x, y, length, color):

Draw horizontal line at the given location and color. Args: x (int): x coordinate Y (int): y coordinate length (int): length of line color (int): 565 encoded color

def init(self, commands):

Initialize display.

def inversion_mode(self, value):

Enable or disable display inversion mode. Args: value (bool): if True enable inversion mode. if False disable inversion mode

def line(self, x0, y0, x1, y1, color):

Draw a single pixel wide line starting at x0, y0 and ending at x1, y1. Args: x0 (int): Start point x coordinate y0 (int): Start point y coordinate x1 (int): End point x coordinate y1 (int): End point y coordinate color (int): 565 encoded color

def pbitmap(self, bitmap, x, y, index=0):

Draw a bitmap on display at the specified column and row one row at a time Args: bitmap (bitmap_module): The module containing the bitmap to draw x (int): column to start drawing at y (int): row to start drawing at index (int): Optional index of bitmap to draw from multiple bitmap module

def pixel(self, x, y, color):

Draw a pixel at the given location and color. Args: x (int): x coordinate Y (int): y coordinate color (int): 565 encoded color

def polygon(self, points, x, y, color, angle=0, center_x=0, center_y=0):

Draw a polygon on the display. Args: points (list): List of points to draw. x (int): X-coordinate of the polygon's position. y (int): Y-coordinate of the polygon's position. color (int): 565 encoded color. angle (float): Rotation angle in radians (default: 0). center_x (int): X-coordinate of the rotation center (default: 0). center_y (int): Y-coordinate of the rotation center (default: 0). Raises: ValueError: If the polygon has less than 3 points.

def rect(self, x, y, w, h, color):

Draw a rectangle at the given location, size and color. Args: x (int): Top left corner x coordinate y (int): Top left corner y coordinate width (int): Width in pixels height (int): Height in pixels color (int): 565 encoded color

def rotation(self, rotation):

Set display rotation. Args: rotation (int): - 0-Portrait - 1-Landscape - 2-Inverted Portrait - 3-Inverted Landscape custom_rotations can have any number of rotations

def set_backlight(self, level):

Undocumented

def sleep_mode(self, value):

Enable or disable display sleep mode. Args: value (bool): if True enable sleep mode. if False disable sleep mode

def soft_reset(self):

Soft reset display.

def text(self, font, text, x0, y0, color=WHITE, background=BLACK):

Draw text on display in specified font and colors. 8 and 16 bit wide fonts are supported. Args: font (module): font module to use. text (str): text to write x0 (int): column to start drawing at y0 (int): row to start drawing at color (int): 565 encoded color to use for characters background (int): 565 encoded color to use for background

def vline(self, x, y, length, color):

Draw vertical line at the given location and color. Args: x (int): x coordinate Y (int): y coordinate length (int): length of line color (int): 565 encoded color

def vscrdef(self, tfa, vsa, bfa):

Set Vertical Scrolling Definition. To scroll a 135x240 display these values should be 40, 240, 40. There are 40 lines above the display that are not shown followed by 240 lines that are shown followed by 40 more lines that are not shown. You could write to these areas off display and scroll them into view by changing the TFA, VSA and BFA values. Args: tfa (int): Top Fixed Area vsa (int): Vertical Scrolling Area bfa (int): Bottom Fixed Area

def vscsad(self, vssa):

Set Vertical Scroll Start Address of RAM. Defines which line in the Frame Memory will be written as the first line after the last line of the Top Fixed Area on the display Example: for line in range(40, 280, 1): tft.vscsad(line) utime.sleep(0.01) Args: vssa (int): Vertical Scrolling Start Address

def write(self, font, string, x, y, fg=WHITE, bg=BLACK):

Write a string using a converted true-type font on the display starting at the specified column and row Args: font (font): The module containing the converted true-type font s (string): The string to write x (int): column to start writing y (int): row to start writing fg (int): foreground color, optional, defaults to WHITE bg (int): background color, optional, defaults to BLACK

def write_width(self, font, string):

Returns the width in pixels of the string if it was written with the specified font Args: font (font): The module containing the converted true-type font string (string): The string to measure Returns: int: The width of the string in pixels

backlight =

Undocumented

color_order =

Undocumented

cs =

Undocumented

dc =

Undocumented

height =

Undocumented

init_cmds =

Undocumented

needs_swap: bool =

Undocumented

physical_height =

Undocumented

physical_width =

Undocumented

reset =

Undocumented

rotations =

Undocumented

spi =

Undocumented

width =

Undocumented

xstart: int =

Undocumented

ystart: int =

Undocumented

@staticmethod
def _find_rotations(width, height):

Undocumented

@micropython.viper
@staticmethod
def _pack16(glyphs, idx: uint, fg_color: uint, bg_color: uint):

Pack a character into a byte array. Args: char (str): character to pack Returns: 128 bytes: character bitmap in color565 format

@micropython.viper
@staticmethod
def _pack8(glyphs, idx: uint, fg_color: uint, bg_color: uint):

Undocumented

def _set_window(self, x0, y0, x1, y1):

Set window to column and row address. Args: x0 (int): column start address y0 (int): row start address x1 (int): column end address y1 (int): row end address

def _text16(self, font, text, x0, y0, fg_color=WHITE, bg_color=BLACK):

Internal method to draw characters with width of 16 and heights of 16 or 32. Args: font (module): font module to use text (str): text to write x0 (int): column to start drawing at y0 (int): row to start drawing at color (int): 565 encoded color to use for characters background (int): 565 encoded color to use for background

def _text8(self, font, text, x0, y0, fg_color=WHITE, bg_color=BLACK):

Internal method to write characters with width of 8 and heights of 8 or 16. Args: font (module): font module to use text (str): text to write x0 (int): column to start drawing at y0 (int): row to start drawing at color (int): 565 encoded color to use for characters background (int): 565 encoded color to use for background

def _write(self, command=None, data=None):

SPI write to the device: commands and data.

_backlight_level =

Undocumented

_rotation =

Undocumented