LCD¶
The screen pixel is 320x240, with the top left corner of the screen as the origin (0,0)
fillScreen()¶
Syntax:
1 | fillScreen(uint16_t color); |
Function: Fill the entire screen with the specified color.
Param | Description |
---|---|
color | the color to be filled |
Example:
1 2 3 4 5 | #include <M5Stack.h> M5.begin(); M5.Lcd.fillScreen(RED); |
MicroPython¶
from m5stack import * from m5ui import *
lcd.fillScreen(lcd.RED) ``` →
setTextColor()¶
Syntax:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | setTextColor(uint16_t color, uint16_t ```backgroundcolor); **Function: Set the foreground color and background color of the displayed text.** | Param | Description | | --- | --- | | color | the color of text | | backgroundcolor| the background color of text | *If backgroundcolor is not given, current background color is used* **Example:** ```arduino #include <M5Stack.h> M5.begin(); M5.Lcd.setTextColor(RED); |
MicroPython¶
from m5stack import * from m5ui import *
lcd.setTextColor(lcd.RED) lcd.setTextColor(lcd.ORANGE, lcd.DARKCYAN) ``` →
setCursor()¶
Syntax:
1 | setCursor(uint16_t x0, uint16_t y0); |
Function: Move the cursor to (x0, y0).
Example:
1 2 3 4 5 6 | #include <M5Stack.h> M5.begin(); M5.Lcd.setCursor(100,100); M5.Lcd.print("Hello"); |
MicroPython¶
from m5stack import * from m5ui import *
lcd.drawPixel(22,22,lcd.RED) ``` →
drawPixel()¶
Syntax:
1 | drawPixel(int16_t x, int16_t y, uint16_t color); |
Function: Draw a point at position (x, y).
Param | Description |
---|---|
color | color value |
If color is not given, current background color is used
Example:
1 2 3 4 5 | #include <M5Stack.h> M5.begin(); M5.Lcd.drawPixel(22,22,RED); |
MicroPython¶
from m5stack import * from m5ui import *
lcd.drawPixel(22,22,lcd.RED) ``` →
drawLine()¶
Syntax:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t ```y1, uint16_t color); **Function: Draw the line from point (x,y) to point (x1,y1).** | Param | Description | | --- | --- | | color | color value | *If color is not given, current background color is used* **Example:** ```arduino #include <M5Stack.h> M5.begin(); M5.Lcd.drawLine(0,0,12,12,WHITE); |
MicroPython¶
from m5stack import * from m5ui import *
lcd.drawLine(0,0,12,12,lcd.WHITE) ``` →
drawTriangle()¶
Syntax:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | drawTriangle(int16_t x0, int16_t y0, int16_t x1, ```int16_t y1, int16_t x2, int16_t y2, uint16_t color); **Function: Draw the triangel between points (x,y), (x1,y1) and (x2,y2).** | Param | Description | | --- | --- | | color | color value | *If color is not given, current background color is used* **Example:** ```arduino #include <M5Stack.h> M5.begin(); M5.Lcd.drawTriangle(22,22,69,98,51,22,RED); |
MicroPython¶
from m5stack import * from m5ui import *
lcd.drawLine(0,0,12,12,lcd.WHITE) ``` →
fillTriangle()¶
Syntax:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | fillTriangle(int16_t x0, int16_t y0, int16_t x1, ```int16_t y1, int16_t x2, int16_t y2, uint16_t color); **Function: Fill the triangel between points (x,y), (x1,y1) and (x2,y2).** | Param | Description | | --- | --- | | color | color value | *If color is not given, current background color is used* **Example:** ```arduino #include <M5Stack.h> M5.begin(); M5.Lcd.fillTriangle(22,22,69,98,51,22,RED); |
MicroPython¶
from m5stack import * from m5ui import *
lcd.drawLine(0,0,12,12,lcd.WHITE) ``` →
drawRect()¶
Syntax:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | drawRect(int16_t x, int16_t y, int16_t w, int16_t h, ```uint16_t color); **Function: Draw the rectangle from the upper left point at (x,y) and width and height.** | Param | Description | | --- | --- | | w | display phisical width in pixels (display’s smaller dimension) | | h | display phisical height in pixels (display’s larger dimension) | | color | color value | *If color is not given, current background color is used* **Example:** ```arduino #include <M5Stack.h> M5.begin(); M5.Lcd.drawRect(180, 12, 122, 10, BLUE); |
MicroPython¶
from m5stack import * from m5ui import *
lcd.drawLine(0,0,12,12,lcd.WHITE) ``` →
fillRect()¶
Syntax:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | fillRect(int16_t x, int16_t y, int16_t w, int16_t h, ```uint16_t color); **Function: Fill the rectangle from the upper left point at (x,y) and width and height.** | Param | Description | | --- | --- | | w | display phisical width in pixels (display’s smaller dimension) | | h | display phisical height in pixels (display’s larger dimension) | | color | color value | *If color is not given, current background color is used* **Example:** ```arduino #include <M5Stack.h> M5.begin(); M5.Lcd.fillRect(180, 12, 122, 10, BLUE); |
MicroPython¶
from m5stack import * from m5ui import *
lcd.drawLine(0,0,12,12,lcd.WHITE) ``` →
drawRoundRect()¶
Syntax:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | drawRoundRect(int16_t x0, int16_t y0, int16_t w, ```int16_t h, int16_t radius, uint16_t color); **Function: Draw the rectangle with rounded corners from the upper left point at (x,y) and width and height. Corner radius is given by radius argument.** | Param | Description | | --- | --- | | w | display phisical width in pixels (display’s smaller dimension) | | h | display phisical height in pixels (display’s larger dimension) | | radius | the radius of circle | | color | color value | *If color is not given, current background color is used* **Example:** ```arduino #include <M5Stack.h> M5.begin(); M5.Lcd.fillRoundRect(180,70,122,10,4,BLUE); |
MicroPython¶
from m5stack import * from m5ui import *
lcd.drawLine(0,0,12,12,lcd.WHITE) ``` →
print()¶
Syntax:
1 | print(); |
Function: Start printing text at the current position of the screen.
The specified content is printed in the foreground color by default.
Example:
1 2 3 4 5 | #include <M5Stack.h> M5.begin(); M5.Lcd.print("this is a print text function"); |
MicroPython¶
from m5stack import * from m5ui import *
lcd.drawLine(0,0,12,12,lcd.WHITE) ``` →
Usage¶
1 2 3 4 5 6 7 8 9 10 11 12 13 | #include <M5Stack.h> M5.begin(); M5.Lcd.fillScreen(BLACK) #set the default background color M5.Lcd.drawLine(0, 0, WHITE); M5.Lcd.drawTriangle(22, 22, 69, 98, 51, 22, RED); M5.Lcd.fillTriangle(122, 122, 169, 198, 151, 182, RED); M5.Lcd.drawRect(180, 12, 122, 10, BLUE); M5.Lcd.fillRect(180, 30, 122, 10, BLUE); M5.Lcd.drawRoundRect(180, 50, 122, 10, 4, BLUE); M5.Lcd.fillRoundRect(180, 70, 122, 10, 4, BLUE); M5.Lcd.print("this is a print text function"); |