Programming with MicroPython: Screen and Display
Import FutureBoard Library
Import the Library to make use of its functions.
01: TFT
1. Screen fill
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))
2. Draw pixel
(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))
3. Draw lines
(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))
Sample Program for 1~3
4. Draw Rectangles
(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.
5. Draw Circles
(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.
6. Draw Triangles
(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)
7. Draw Polygons
(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.
Sample Program for 4~7
8. Show English Strings
(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))
9. Show Chinese Strings
(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))
Sample Program for 8~9
10. Showing Images
(x,y) is the top left corner coordinates of the image, x and y range from 0~159 and 0~127 respectively.
Sample Program for 10
Download Testing Files(Right Click->Save As)
11. Screen Sync
Enables or disables the screen sync, 1 for enabled and 0 for disabled.
12. Screen Refresh
Redraws the frame.
Sample Program for 11~12
Last updated