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 objreset: Pin used to reset the LCD panel, set to None if it’s not usedbacklight: Pin used for backlight signalreset_level: Setting this if the panel reset is high level activecolor_space: Set the color space used by the LCD panelbpp: 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 axismirror_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 pixelsy_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
rparameter accepts only the following values:0: Portrait (0 degrees)1: Landscape (90 degrees)2: Inverse Portrait (180 degrees)3: Inverse Landscape (270 degrees)
rotationssets the orientation table. The orientation table is a list of tuples for eachrotationused 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.
tfais the top fixed area in pixels. The top fixed area is the upper portion of the display frame buffer that will not be scrolled.heightis the total height in pixels of the area scrolled.bfais 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.
addressis 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.orderis the Vertical Refresh Order. Whenorder==False, LCD vertical refresh Top to Bottom; Whenorder==False, LCD vertical refresh Bottom to Top.