.. module:: ST7735 ************** ST7735 Module ************** This module exposes all functionalities of Sitronix ST7735 Display driver (`datasheet `_). =============== ST7735 class =============== .. class:: ST7735(drv, cs, dc, bl=None, rst=None, clock=27000000) Creates an intance of a new ST7735. :param drv: SPI Bus used '( SPI0, ... )' :param cs: Chip Select :param dc: Data Control Pin :param bl: Backlight Pin :param rst: Reset Pin :param clock: Clock speed, default 100kHz Example: :: from sitronix.st7735 import st7735 ... display = st7735.ST7735(SPI0, D5, D23, bl=D27, rst=D26) display.clear() display.fill_screen([255,0,0]) display.fill_rect(10, 20, 20, 100, [255,255,0]) display.draw_pixel(50, 50, [255,255,255]) display.draw_line(30, 20, 100, [0,0,255]) display.draw_text("Hello Zerynth") .. method:: on() Turns on the display. .. method:: off() Turns off the display. .. method:: reset() Reset the display. .. method:: set_rotation(rotation = 1) :param rotation: is the rotation value to set (default = 1). Values accepted: 0, 1, 2 or 3. Set the direction of frame memory. .. method:: set_backlight(state) :param state: is the state of backlight. Values accepted: 0 or 1. Set the backlight. .. method:: invert(value) :param value: is the value of display inversion mode. Values accepted: 0 or 1. Set the display inversion mode. .. method:: clear() Clears the display. .. method:: fill_screen(color) :param color: is a list composed by RGB color. Fills the entire display with RGB color provided as argument. .. method:: fill_rect(x, y, w, h, color) :param x: x-coordinate for left high corner of the rectangular area. :param y: y-coordinate for left high corner of the rectangular area. :param w: width of the rectangular area. :param h: height of the rectangular area. :param color: is a list composed by RGB color for the rectangular area. Draws a rectangular area in the screen colored with the RGB color provided as argument. .. method:: draw_pixel(x, y, color) :param x: pixel x-coordinate. :param y: pixel y-coordinate. :param color: is a list composed by RGB color. Draws a single pixel in the screen colored with the RGB color provided as argument. .. method:: draw_line(x, y, lenght, color) :param x: pixel x-coordinate. :param y: pixel y-coordinate. :param lenght: is the lenght of line. :param color: is a list composed by RGB color. Draws a line in the screen colored with the RGB color provided as argument. .. method:: draw_img(image, x=0, y=0, w=80, h=80) :param image: image to draw in the display converted to hex array format and passed as bytearray. :param x: x-coordinate for left high corner of the image (default value is 0). :param y: y-coordinate for left high corner of the image (default value is 0). :param w: width of the image (default value is 80). :param h: height of the image (default value is 80). Draws the image passed in bytearray format as argument. .. note :: To obtain a converted image in hex array format, you can go and use this `online tool `_. After uploading your image, you can resize it setting the width and height fields; you can also choose the code format (HEX:0x recommended) and the color format (65K color recommended). Clicking on the "Get C string" button, the tool converts your image with your settings to a hex string that you can copy and paste inside a bytearray in your project and privide to this function. .. method:: draw_text(text, x=0, y=0, w=None, h=None, font_text=None, font_color=None, align=3, background=None) **Parameters:** **text:** string to be written in the display. **x:** x-coordinate for left high corner of the text box (default value is 0). **y:** y-coordinate for left high corner of the text box (default value is 0). **w:** width of the text box (default value is None). **h:** height of the text box (default value is None). **font_text:** is text font (default value is None). You can pass a font like showing in "write on display" example. **font_color:** is a list of RGB color for the font color (default value is None). **align:** alignment of the text inside the text box (default value is 3). ======== ===================== align Alignment ======== ===================== 0 None 1 Left 2 Right 3 Center ======== ===================== **background:** is a list composed by RGB color (default value is None). Prints a string inside a text box in the screen.