class ST7735 – Sitronix ST7735 abstract classes

The ST7735 class is the Sitronix ST7735 hardware abstraction class, which implements some common interfaces of the ST7735.

Constructors

class ST7735(bus: I8080, reset: Pin = None, backlight: Pin = None, reset_level: bool = false, color_space: int = RGB, bpp: int = 16)

Create an ST7735 hardware abstraction class.

These parameters are:

  • bus: I8080 obj

  • reset: Pin used to reset the LCD panel, set to None if it’s not used

  • backlight: Pin used for backlight signal

  • reset_level: Setting this if the panel reset is high level active

  • color_space: Set the color space used by the LCD panel

  • bpp: Color depth, in bpp

Methods

ST7735.reset()

Reset LCD panel.

ST7735.init()

Initialize LCD panel.

Note

Before calling this method, make sure the LCD panel has finished the reset stage by ST7735.reset().

ST7735.bitmap(x_start: int, y_start: int, x_end: int, y_end: int, color_data: bytes = None)

Draw bitmap on LCD panel.

The arguments are:

  • x_start - Start index on x-axis (x_start included)

  • y_start - Start index on y-axis (y_start included)

  • x_end - End index on x-axis (x_end not included)

  • y_end - End index on y-axis (y_end not included)

  • color_data - RGB color data that will be dumped to the specific window range

ST7735.mirror(mirror_x: bool, mirror_y: bool)

Mirror the LCD panel on specific axis.

The arguments are:

  • mirror_x - Whether the panel will be mirrored about the x axis

  • mirror_y - Whether the panel will be mirrored about the y axis

Note

Combined with ST7735.swap_xy(), one can realize screen rotation

ST7735.swap_xy(swap_axes: bool)

Swap/Exchange x and y axis.

  • swap_axes - Whether to swap the x and y axis

Note

Combined with ST7735.mirror(), one can realize screen rotation

ST7735.set_gap(x_gap: int, y_gap: int)

Set extra gap in x and y axis.

The gap is the space (in pixels) between the left/top sides of the LCD panel and the first row/column respectively of the actual contents displayed.

The arguments are:

  • x_gap - Extra gap on x axis, in pixels

  • y_gap - Extra gap on y axis, in pixels

Note

Setting a gap is useful when positioning or centering a frame that is smaller than the LCD.

ST7735.invert_color(invert_color_data: bool)

Invert the color (bit-wise invert the color data line)

  • invert_color_data - Whether to invert the color data

ST7735.disp_off(off: bool)

Turn off the display.

  • off - Whether to turn off the screen

ST7735.backlight_on()

Turn on the backlight

ST7735.backlight_off()

turn off the backlight.

ST7735.deint()

Deinitialize the LCD panel.

ST7735.rotation(r: int)

Set the rotates the logical display in a counter-clockwise direction.

The r parameter accepts only the following values:

  • 0: Portrait (0 degrees)

  • 1: Landscape (90 degrees)

  • 2: Inverse Portrait (180 degrees)

  • 3: Inverse Landscape (270 degrees)

rotations sets the orientation table. The orientation table is a list of tuples for each rotation used to set the MADCTL register, display width, display height, start_x, and start_y values.

Display

Default Orientation Tables

160x80

((0x00, 80, 160, 26, 1), (0x60, 160, 80, 1, 26), (0xC0, 80, 160, 26, 1), (0xA0, 160, 80, 1, 26))

160x80

((0x00, 80, 160, 24, 0), (0x60, 160, 80, 0, 24), (0xC0, 80, 160, 24, 0), (0xA0, 160, 80, 0, 24))

other

((0x00, 0, 0, 0, 0), (0x60, 0, 0, 0, 0), (0xC0, 0, 0, 0, 0), (0xA0, 0, 0, 0, 0))

ST7735.vscroll_area(tfa: int, height: int, bfa: int)

Set the vertical scrolling parameters.

  • tfa is the top fixed area in pixels. The top fixed area is the upper portion of the display frame buffer that will not be scrolled.

  • height is the total height in pixels of the area scrolled.

  • bfa is the bottom fixed area in pixels. The bottom fixed area is the lower portion of the display frame buffer that will not be scrolled.

ST7735.vscroll_start(address: int, order: bool = False)

Set the vertical scroll address.

  • address is the vertical scroll start address in pixels. The vertical scroll start address is the line in the frame buffer will be the first line shown after the TFA.

  • order is the Vertical Refresh Order. When order == False, LCD vertical refresh Top to Bottom; When order == False, LCD vertical refresh Bottom to Top.