Programming with MicroPython: Screen and Display
Last updated
Last updated
Import the Library to make use of its functions.
color can be used in a few ways:
RGB, 0~255, for example (255,100,0).
Grey scale, 0~255, for example 100.
Built-in color, supported colors: RED, YELLOW, PINK, WHITE, GREEN, BLUE, PURPLE, CYAN, BLACK.
screen.fill((255,100,0))
(x,y) refer to the coordinates, ranges from 0~159 and 0~127 respectively.
color can be used in a few ways:
RGB, 0~255, for example (255,100,0).
Grey scale, 0~255, for example 100.
Built-in color, supported colors: RED, YELLOW, PINK, WHITE, GREEN, BLUE, PURPLE, CYAN, BLACK.
screen.pixel(50,50,(255,100,0))
(x1,y1) and (x2, y2) are the coordinates of the line, x and y range from 0~159 and 0~127 respectively.
color can be used in a few ways:
RGB, 0~255, for example (255,100,0).
Grey scale, 0~255, for example 100.
Built-in color, supported colors: RED, YELLOW, PINK, WHITE, GREEN, BLUE, PURPLE, CYAN, BLACK.
screen.line(50,50,100,100,(255,100,0))
(x,y) is the top left corner coordinates of the rectangle, x and y range from 0~159 and 0~127 respectively.
Parameters w and h are the width and height.
color can be used in a few ways:
RGB, 0~255, for example (255,100,0).
Grey scale, 0~255, for example 100.
Built-in color, supported colors: RED, YELLOW, PINK, WHITE, GREEN, BLUE, PURPLE, CYAN, BLACK.
Use fill to select whether to fill the shape with a color, 1 for true, 0 for false.
(x,y) is the center coordinates of the circle, x and y range from 0~159 and 0~127 respectively.
Parameter r is the radius.
color can be used in a few ways:
RGB, 0~255, for example (255,100,0).
Grey scale, 0~255, for example 100.
Built-in color, supported colors: RED, YELLOW, PINK, WHITE, GREEN, BLUE, PURPLE, CYAN, BLACK.
Use fill to select whether to fill the shape with a color, 1 for true, 0 for false.
(x1,y2), (x2,y2), (x3,y3) represent the coordinates of the three corners of a triangle, x and y range from 0~159 and 0~127 respectively.
color can be used in a few ways:
RGB, 0~255, for example (255,100,0).
Grey scale, 0~255, for example 100.
Built-in color, supported colors: RED, YELLOW, PINK, WHITE, GREEN, BLUE, PURPLE, CYAN, BLACK.
Use fill to select whether to fill the shape with a color, 1 for true, 0 for false.
screen.triangle(50,50,10,75,90,75,(255,100,0),1)
(x,y) is the center coordinates of the polygon, x and y range from 0~159 and 0~127 respectively.
Parameter side denotes the number of sides of the polygon, cannot be lower than 3.
Parameter is the radius of the polygon.
Parameter th is the thickness of the border.
Parameter rot is the rotation angle of the polygon.
color can be used in a few ways:
RGB, 0~255, for example (255,100,0).
Grey scale, 0~255, for example 100.
Built-in color, supported colors: RED, YELLOW, PINK, WHITE, GREEN, BLUE, PURPLE, CYAN, BLACK.
Use fill to select whether to fill the shape with a color, 1 for true, 0 for false.
(x,y) is the top left corner coordinates of the text, x and y range from 0~159 and 0~127 respectively.
Parameter ext represents the size of the text, 1 for 8x8, 2 for 16x16 and et-cetera.
color can be used in a few ways:
RGB, 0~255, for example (255,100,0).
Grey scale, 0~255, for example 100.
Built-in color, supported colors: RED, YELLOW, PINK, WHITE, GREEN, BLUE, PURPLE, CYAN, BLACK.
screen.text(”hello world”, 10, 10, 2, (255,100,0))
(x,y) is the top left corner coordinates of the text, x and y range from 0~159 and 0~127 respectively.
Parameter ext represents the size of the text, 1 for 8x8, 2 for 16x16 and et-cetera.
color can be used in a few ways:
RGB, 0~255, for example (255,100,0).
Grey scale, 0~255, for example 100.
Built-in color, supported colors: RED, YELLOW, PINK, WHITE, GREEN, BLUE, PURPLE, CYAN, BLACK.
screen.textCh(”你好”, 10, 10, 2, (255,100,0))
(x,y) is the top left corner coordinates of the image, x and y range from 0~159 and 0~127 respectively.
Download Testing Files(Right Click->Save As)
Enables or disables the screen sync, 1 for enabled and 0 for disabled.
Redraws the frame.