初始化函数
语法:
void begin()
Initiate a panel transaction.
语法:
void beginTransaction()
校准触摸板. 传递一个指向uint16_t[8]的指针作为参数,以获得一个校准值,它可以在 setTouchCalibrate() 中使用. 你可以将这个值记录在flash中,等等,并在下次启动时使用 setTouchCalibrate() 来省略手工校准
语法:
void calibrateTouch<T>(uint16_t* parameters, const T &color_fg, const T &color_bg)
参数 | 类型 | 描述 |
---|---|---|
parameters | uint16_t* | uint16_t[8] 校准值 |
color_fg | const T(*1) | 前景色 |
color_bg | const T(*1) | 背景色 |
*1. About ColorCode
使用示例:
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
uint16_t touch_point[8];
void setup() {
display.begin();
display.calibrateTouch(touch_point, BLACK, YELLOW);
display.clear();
for (int i=0; i<8; i++) {
display.printf("%4x:", touch_point[i]);
}
}
void loop() {
}
清空屏幕,如果指定了一个参数,就用该颜色初始化屏幕
语法:
void clear(const T &color)
参数 | 类型 | 描述 |
---|---|---|
color | const T(*1) | 初始化后的颜色 |
*1. 关于颜色代码
使用示例:
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
void setup() {
display.begin();
display.clear(RED);
}
void loop() {
// put your main code here, to run repeatedly:
}
清除由 setClipRect() .
语法:
void clearClipRect()
清空屏幕,如果指定了一个参数,就用该颜色初始化屏幕
语法:
void clearDisplay(uint32_t color = 0)
参数 | 类型 | 描述 |
---|---|---|
color | uint32_t | 初始化后的颜色 |
清除由 setScrollRect() .
语法:
void clearScrollRect()
Convert color code from RGB332 to RGB565.
语法:
uint16_t color8to16(uint8_t rgb332)
参数 | 类型 | 描述 |
---|---|---|
rgb332 | uint8_t | ColorCode of RGB332 |
将 RGB565(16bit)颜色代码转换为 RGB888(24bit).
语法:
uint32_t color16to24(uint16_t rgb565)
参数 | 类型 | 描述 |
---|---|---|
rgb565 | uint16_t | ColorCode of RGB565 |
将 RGB565(16bit) 颜色代码转换为 RGB332(8bit).
语法:
uint8_t color16to8(uint16_t rgb565)
参数 | 类型 | 描述 |
---|---|---|
rgb565 | uint32_t | ColorCode of RGB565 |
将 RGB888(24bit) 颜色代码转换为 RGB565(16bit).
语法:
uint16_t color24to16(uint32_t rgb888)
参数 | 类型 | 描述 |
---|---|---|
rgb888 | uint32_t | ColorCode of RGB888 |
根据 R,G,B 生成颜色代码
语法:
uint8_t color332(uint8_t r, uint8_t g, uint8_t b)
参数 | 类型 | 描述 |
---|---|---|
r | uint8_t | 0 - 255 |
g | uint8_t | 0 - 255 |
b | uint8_t | 0 - 255 |
根据 R,G,B 生成颜色代码
语法:
uint16_t color332(uint8_t r, uint8_t g, uint8_t b)
参数 | 类型 | 描述 |
---|---|---|
r | uint8_t | 0 - 255 |
g | uint8_t | 0 - 255 |
b | uint8_t | 0 - 255 |
根据 R,G,B 生成颜色代码
语法:
uint32_t color332(uint8_t r, uint8_t g, uint8_t b)
参数 | 类型 | 描述 |
---|---|---|
r | uint8_t | 0 - 255 |
g | uint8_t | 0 - 255 |
b | uint8_t | 0 - 255 |
Convert coordinates obtained with getTouchRaw() .
语法:
void convertRawXY(touch_po2 *tp, uint_fast8_t count)
参数 | 类型 | 描述 |
---|---|---|
*tp | touch_point_t | touch point |
count | uint_fast8_t | count |
拷贝矩形范围
语法:
void copyRect(uint32_t dst_x, uint32_t dst_y, uint32_t w, uint32_t h, uint32_t src_x, uint32_t src_y)
参数 | 类型 | 描述 |
---|---|---|
dst_x | uint32_t | X 拷贝目的地的坐标 |
dst_y | uint32_t | Y coordinate of copy destination |
w | uint32_t | Rectangle width |
h | uint32_t | Rectangle height |
src_x | uint32_t | X coordinate of copy source |
src_y | uint32_t | Y coordinate of copy source |
Screenshot function. Executing this function saves the data displayed in the panel to memory in PNG format.
语法:
void* createPng(size_t* datalen, int32_t x, int32_t y, int32_t w, int32_t h)
参数 | 类型 | 描述 |
---|---|---|
datalen | size_t* | Data length |
x | int32_t | x coordinate |
y | int32_t | y coordinate |
w | int32_t | Rectangle width |
h | int32_t | Rectangle width |
Display to the panel.(for M5Paper, CoreInk, OLEDUnit)
语法:
void display()
Check if the panel is Busy.
语法:
bool displayBusy()
Check if the panel's DMA is busy.
语法:
bool dmaBusy()
Draws a circular arc. specifying r0 and r1 allows drawing a thick arc.
语法:
void drawArc(int32_t x, int32_t y, int32_t r0, int32_t r1, float angle0, float angle1, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | center x of arc |
y | int32_t | center y of arc |
r0 | int32_t | Inner circle radius |
r1 | int32_t | Outer circle radius |
angle0 | float | Angle at which the arc starts |
angle1 | float | Angle at which the arc ends |
color | const T(*1) | color of line |
*1. About ColorCode
使用示例:
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
void setup() {
display.begin();
uint16_t x = display.width() / 2;
uint16_t y = display.height() / 2;
display.drawArc(x, y, 10, 20, 20, 240, TFT_WHITE);
}
void loop() {
}
Draws a Bezier curve, available in two types: 3-point and 4-point.
语法:
void drawBezier(x0, y0, x1, y1, x2, y2, const int &color)
参数 | 类型 | 描述 |
---|---|---|
x0 | int32_t | point0 x |
y0 | int32_t | point0 y |
x1 | int32_t | point1 x |
y1 | int32_t | point1 y |
x2 | int32_t | point2 x |
y2 | int32_t | point2 y |
color | const T(*1) | color of line |
void drawBezier(x0, y0, x1, y1, x2, y2, x3, y3, const int &color)
参数 | 类型 | 描述 |
---|---|---|
x0 | int32_t | point0 x |
y0 | int32_t | point0 y |
x1 | int32_t | point1 x |
y1 | int32_t | point1 y |
x2 | int32_t | point2 x |
y2 | int32_t | point2 y |
x3 | int32_t | point3 x |
y3 | int32_t | point3 y |
color | const T(*1) | color of line |
*1. About ColorCode
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
void setup() {
display.begin();
uint16_t x = display.width() / 2;
uint16_t y = display.height() / 2;
display.drawBezier(0, 0, x, 0, x, y, TFT_WHITE);
display.drawBezier(0, 0, x, 0, x, y, 0, y, TFT_WHITE);
}
void loop() {
}
Draw bitmap data. File or HTTPStream can be specified for data.
语法:
void drawBmp(fs::FS &fs,const char *path, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
fs | fs::FS | SPIFFS or SD |
path | const char* | filepath |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
void drawBmp(Stream *dataSource, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
dataSource | Stream* | Stream object |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
void drawBmp(const uint8_t *data, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
dataSource | const uint8_t* | bmp data |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
Draw an image from a bmp file.
语法:
void drawBmpFile(fs::FS &fs,const char *path, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
fs | fs::FS | SPIFFS or SD |
pat | const char* | filepath |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
Displays a BMP image of the specified URL.
语法:
void drawBmpUrl(const String &url, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
url | const String | filepath |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
Draw the text centered.
语法:
void drawCenterString(const String &string, int32_t x, int32_t y, IFont* font)
参数 | 类型 | 描述 |
---|---|---|
string | const String | x |
x | int32_t | x |
y | int32_t | y |
font | IFont* (*1) | font |
*1. About Fonts
Draw an unicode character.
语法:
size_t drawChar(uint16_t uniCode, int32_t, x, int32_t y, uint8_t font)
Draw a circle.
语法:
void drawCircle(int32_t x, int32_t y, int32_t r, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | x |
y | int32_t | y |
r | int32_t | radius |
color | const T | color(*1) |
*1. About ColorCode |
Draw ellipse.
语法:
void drawEllipse(int32_t x, int32_t y, int32_t rx, int32_t ry, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | x |
y | int32_t | y |
rx | int32_t | radius X |
ry | int32_t | radius Y |
color | const T | color(*1) |
*1. About ColorCode |
Draw a thick elliptical arc.
语法:
void drawEllipseArc(int32_t x, int32_t y, int32_t r0x, int32_t r1x, int32_t r0y, int32_t r1y, float angle0, float angle1, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | center x of arc |
y | int32_t | center y of arc |
r0x | int32_t | Inner circle radius x |
r1x | int32_t | Inner circle radius y |
r0y | int32_t | Outer circle radius x |
r1y | int32_t | Outer circle radius y |
angle0 | float | Angle at which the arc starts |
angle1 | float | Angle at which the arc ends |
color | const T | color of line(*1) |
*1. About ColorCode
Draw horizontal line.
语法:
void drawFastHLine(int32_t x, int32_t y, int32_t w, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | x |
y | int32_t | y |
w | int32_t | width |
color | const T | color(*1) |
*1. About ColorCode
Draw vertical line.
语法:
void drawFastHLine(int32_t x, int32_t y, int32_t w, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | x |
y | int32_t | y |
h | int32_t | height |
color | const T | color(*1) |
*1. About ColorCode
Draws a float number.
语法:
size_t drawFloat(float floatNumber, uint8_ dp, int32_t poX, int32_t poY, const IFont* font)
参数 | 类型 | 描述 |
---|---|---|
floatNumber | float | Float number |
dp | uint8_t | Number of digits after the decimal point. |
poX | int32_t | x |
poY | int32_t | y |
font | IFont* (*1) | font |
*1. About Fonts
Draw a horizontal gradient line.
语法:
void drawGradientHLine(int32_t x, int32_t y, int32_t w, const T &colorstart, const T &colorend)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | x |
y | int32_t | y |
w | int32_t | width |
colorstart | const T | start color(*1) |
colorend | const T | end color(*1) |
*1. About ColorCode |
Draw a gradient line.
语法:
void drawGradientLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, const T &colorstart, const T &colorend)
参数 | 类型 | 描述 |
---|---|---|
x0 | int32_t | start x |
y0 | int32_t | start y |
x1 | int32_t | end x |
y1 | int32_t | end y |
colorstart | const T | start color(*1) |
colorend | const T | end color(*1) |
*1. About ColorCode |
Draw a vertical gradient line.
语法:
void drawGradientVLine(int32_t x, int32_t y, int32_t h, const T &colorstart, const T &colorend)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | x |
y | int32_t | y |
h | int32_t | height |
colorstart | const T | start color(*1) |
colorend | const T | end color(*1) |
*1. About ColorCode |
Draw JPG data. File or HTTPStream can be specified for data.
语法:
void drawJpg(fs::FS &fs,const char *path, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
fs | fs::FS | SPIFFS or SD |
path | const char* | filepath |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
void drawJpg(Stream *dataSource, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
dataSource | Stream* | Stream object |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
void drawJpg(const uint8_t *data, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
dataSource | const uint8_t* | bmp data |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
Draw a JPG image from file.
语法:
void drawJpgFile(fs::FS &fs,const char *path, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
fs | fs::FS | SPIFFS or SD |
pat | const char* | filepath |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
Draw an JPG image from URL.
语法:
void drawJpgUrl(const String &url, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
url | const String | filepath |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
Draw a line.
语法:
void drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x0 | int32_t | start x |
y0 | int32_t | start y |
x1 | int32_t | end x |
y1 | int32_t | end y |
color | const T | color(*1) |
*1. About ColorCode
Draws a long number.
语法:
size_t drawNumber(long long_num,int32_t poX, int32_t poY, const IFont* font)
参数 | 类型 | 描述 |
---|---|---|
long_num | long | long number |
poX | int32_t | x |
poY | int32_t | y |
font | IFont* (*1) | font |
*1. About Fonts
Draw a pixel.
语法:
void drawPixel(int32_t x, int32_t y, const int &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | x |
y | int32_t | y |
color | const int | color(*1) |
*1. About ColorCode
Draw PNG data. File or HTTPStream can be specified for data.
语法:
void drawPng(fs::FS &fs,const char *path, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
fs | fs::FS | SPIFFS or SD |
path | const char* | filepath |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
void drawPng(Stream *dataSource, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
dataSource | Stream* | Stream object |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
void drawPng(const uint8_t *data, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
dataSource | const uint8_t* | bmp data |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
Draw a PNG image from file.
语法:
void drawPngFile(fs::FS &fs,const char *path, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
fs | fs::FS | SPIFFS or SD |
pat | const char* | filepath |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
Draw a PNG image from URL.
语法:
void drawPngUrl(const String &url, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
url | const String | filepath |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
Draw Qoi data. File or HTTPStream can be specified for data.
语法:
void drawQoi(fs::FS &fs,const char *path, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
fs | fs::FS | SPIFFS or SD |
path | const char* | filepath |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
void drawQoi(Stream *dataSource, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
dataSource | Stream* | Stream object |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
void drawQoi(const uint8_t *data, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
dataSource | const uint8_t* | bmp data |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
Draw a Qoi image from file.
语法:
void drawQoiFile(fs::FS &fs,const char *path, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
fs | fs::FS | SPIFFS or SD |
pat | const char* | filepath |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
Draw a Qoi image from URL.
语法:
void drawPngQoi(const String &url, int32_t x = 0, y = 0, maxWidth = 0, maxHeight = 0, int32_t offX = 0, int32_t offY = 0, float scale_x = 1.0f, float scale_y = 1.0f, datum_t datum = datum_t::top_left )
参数 | 类型 | 描述 |
---|---|---|
url | const String | filepath |
x | int32_t | x |
y | int32_t | y |
maxWidth | int32_t | width |
maxHeight | int32_t | height |
offX | int32_t | offset X |
offY | int32_t | offset Y |
scaleX | float | scale X |
scaleY | float | scale Y |
datum | datum_t | image datum(*1) |
*1. About ImageDatum
Draw a rectangle.
语法:
void drawRect(int32_t x, int32_t y, int32_t w, int32_t h, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | start x |
y | int32_t | start y |
w | int32_t | Rect width |
h | int32_t | Rect height |
color | const T | color(*1) |
*1. About ColorCode |
Draw strings right-aligned.
语法:
void drawRightString(const String &string, int32_t x, int32_t y, IFont* font)
参数 | 类型 | 描述 |
---|---|---|
string | const String | String |
x | int32_t | x |
y | int32_t | y |
font | IFont* (*1) | font |
*1. About Fonts
Draw a rectangle with rounded corners.
语法:
void drawRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | start x |
y | int32_t | start y |
w | int32_t | Rect width |
h | int32_t | Rect height |
r | int32_t | radius |
color | const T | color(*1) |
*1. About ColorCode |
Draw strings.
语法:
void drawString(const char* string, int32_t x, int32_t y, const IFont* font)
参数 | 类型 | 描述 |
---|---|---|
string | const char* | String |
x | int32_t | x |
y | int32_t | y |
font | IFont* (*1) | font |
*1. About Fonts
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
void setup() {
display.begin();
display.setTextDatum(middle_center);
uint16_t x = display.width() / 2;
uint16_t y = display.height() / 2;
display.drawString("Text", x, y);
}
void loop() {
}
Draw a triangle by specifying three points.
语法:
void drawTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x0 | int32_t | point0 x |
y0 | int32_t | point0 y |
x1 | int32_t | point1 x |
y1 | int32_t | point1 y |
x2 | int32_t | point2 x |
y2 | int32_t | point2 y |
color | const T | color(*1) |
*1. About ColorCode
Effects the specified rectangle range using a user-defined transformation function.
语法:
void effect(int32_t x, int32_t y, int32_t w, int32_t h, TFunc&& effector)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | start point x |
y | int32_t | start point y |
w | int32_t | width |
h | int32_t | height |
effector | TFunc&& | transformation function |
It is pared with startTransaction()
语法:
void endTransaction()
It is paired with startWrite() .
语法:
void endWrite()
Fill affine transformed area.
void fillAffine(const float matrix[6], int32_t w, int32_t h, const T& color)
参数 | 类型 | 描述 |
---|---|---|
matrix | const float[6] | Matrix with 6 elements |
w | int32_t | Image width |
h | int32_t | Image height |
color | const T& (*1) | Color |
*1. About ColorCode
Draw a filled arc.
语法:
void fillArc(int32_t x, int32_t y, int32_t r0, int32_t r1, float angle0, float angle1, const int &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | center x of arc |
y | int32_t | center y of arc |
r0 | int32_t | Inner circle radius |
r1 | int32_t | Outer circle radius |
angle0 | float | Angle at which the arc starts |
angle1 | float | Angle at which the arc ends |
color | const T&(*1) | fill color |
*1. About ColorCode
使用示例:
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
void setup() {
display.begin();
uint16_t x = display.width() / 2;
uint16_t y = display.height() / 2;
display.fillArc(x, y, 10, 20, 20, 240, TFT_WHITE);
}
void loop() {
}
Draw a filled circle.
语法:
void fillCircle(int32_t x, int32_t y, int32_t r, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | x |
y | int32_t | y |
r | int32_t | radius |
color | const T& | color(*1) |
*1. About ColorCode
Draw a filled ellipse.
语法:
void fillEllipse(int32_t x, int32_t y, int32_t rx, int32_t ry, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | x |
y | int32_t | y |
rx | int32_t | radius X |
ry | int32_t | radius Y |
color | const T | color(*1) |
*1. About ColorCode
Fill a thick elliptical arc.
语法:
void fillEllipseArc(int32_t x, int32_t y, int32_t r0x, int32_t r1x, int32_t r0y, int32_t r1y, float angle0, float angle1, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | center x of arc |
y | int32_t | center y of arc |
r0x | int32_t | Inner circle radius x |
r1x | int32_t | Inner circle radius y |
r0y | int32_t | Outer circle radius x |
r1y | int32_t | Outer circle radius y |
angle0 | float | Angle at which the arc starts |
angle1 | float | Angle at which the arc ends |
color | const T | color of line(*1) |
*1. About ColorCode
Draw a filled rectangle.
语法:
void fillRect(int32_t x, int32_t y, int32_t w, int32_t h, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | start x |
y | int32_t | start y |
w | int32_t | Rect width |
h | int32_t | Rect height |
color | const T | color(*1) |
*1. About ColorCode |
Draw a filled rectangle that is transparent.
语法:
void fillRectAlpha(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t alpha, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | start x |
y | int32_t | start y |
w | int32_t | Rect width |
h | int32_t | Rect height |
alpha | uint8_t | 0 transparent - 255 opaque |
color | const T | color(*1) |
*1. About ColorCode
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
void setup()
{
display.begin();
display.fillScreen(TFT_BLACK);
uint16_t x = display.width() / 2;
uint16_t y = display.height() / 2;
display.fillRect(x - 10, y - 10, 50, 50, TFT_WHITE);
display.fillRectAlpha(x, y, 30, 30, 100, TFT_BLACK);
}
void loop()
{
}
Draw a filled rectangle with rounded corners.
语法:
void fillRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | start x |
y | int32_t | start y |
w | int32_t | Rect width |
h | int32_t | Rect height |
r | int32_t | corner radius |
color | const T& | color(*1) |
*1. About ColorCode
使用示例:
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
void setup()
{
display.begin();
display.fillScreen(TFT_BLACK);
uint16_t x = display.width() / 2;
uint16_t y = display.height() / 2;
display.fillRoundRect(x, y, 30, 30, 5, TFT_WHITE);
}
void loop()
{
}
Fill the screen.
语法:
参数 | 类型 | 描述 |
---|---|---|
color | const T | color(*1) |
*1. About ColorCode
Draw a filled triangle.
语法:
void fillTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x0 | int32_t | point0 x |
y0 | int32_t | point0 y |
x1 | int32_t | point1 x |
y1 | int32_t | point1 y |
x2 | int32_t | point2 x |
y2 | int32_t | point2 y |
color | const T& | color(*1) |
*1. About ColorCode
Fills the approximate gamut of the specified coordinates.
语法:
void floodFill(uint32_t x, uint32_t y, const T &color)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | point x |
y | int32_t | point y |
color | const T | fill color |
Returns the height of the specified font.
int32_t fontHeight(uint8_t font)
参数 | 类型 | 描述 |
---|---|---|
font | IFont* (*1) | font |
*1. About Fonts
Returns the width of the specified font.
int32_t fontHeight(uint8_t font)
参数 | 类型 | 描述 |
---|---|---|
font | IFont* (*1) | font |
*1. About Fonts
Get the attribute.
语法:
uint8_t getAttribute(attribute_t attr_id)
Get the color value set by setBaseColor() .
语法:
uint32_t getBaseColor()
Get Board.
语法:
uint8_t getBoard()
*1. enum board_t
Get the value set by setBrightness .
语法:
uint8_t getBrightness()
Get the coordinate parameters(x,y,w,h) set by setClipRect() .
语法:
void getClipRect(int32_t *x, int32_t *y, int32_t *w, int32_t *h)
Get the value set by setColorDepth() .
语法:
color_depth_t getColorDepth()
*1. About ColorDepth
Get current cursor X position.
语法:
int32_t getCursorX()
Get current cursor Y position.
语法:
int32_t getCursorY()
Get the value set by setEpdMode() .(M5Paper only)
语法:
epd_mode_t getEpdMode()
*1. epd_mode_t
Get the font set by setFont() .
const IFont* getFont()
*1. about font
Get an instance of M5GFX.
语法:
M5GFX* getInstance()
Get the value set by invertDisplay() Get Invert value of the panel.
语法:
bool getInvert()
Get palette information.
语法:
RGBColor* getPalette()
Get count of palette.
语法:
uint32_t getPaletteCount()
Get panel of device.
语法:
Panel_Device* getPanel()
Get X value set by setPivot
语法:
float getPivotX()
Get Y value set by setPivot
语法:
float getPivotY()
Get the value set by setRawColor() .
uint32_t getRawColor()
Get the value set by setRotation()
uint8_t getRotation()
Get information about the setScrollRect() .
void getScrollRect(int32_t *x, int32_t *y, int32_t *w, int32_t *h)
Get the count of the panel has startWrite() .
uint32_t getStartCount()
Get status of setSwapBytes() .
bool getSwapBytes()
Get TextDatum. setTextDatum()
语法:
textdatum_t getTextDatum()
*1. About TextDatum
Get TextPadding.
语法:
uint32_t getTextPadding()
Get the width set by setTextSize() .
语法:
float getTextSizeX()
Get the height set by setTextSize() .
语法:
float getTextSizeY()
Get the information set by setTextStyle() .
语法:
TextSytle& getTextStyle()
Get information when touching the touch panel.
语法:
uint_fast8_t getTouch(touch_point_t *tp, uint_fast8_t count = 1)
参数 | 类型 | 描述 |
---|---|---|
tp | touch_pont_t* | Return value of touch point |
count | uint_fast8_t | count |
Get raw information when touching the touch panel.
语法:
uint_fast8_t getTouchRaw(touch_point_t *tp, uint_fast8_t count = 1)
参数 | 类型 | 描述 |
---|---|---|
tp | touch_pont_t* | Return value of touch point |
count | uint_fast8_t | count |
Whether a color palette exists.
语法:
bool hasPalette()
Get height of panel.
语法:
int_fast16_t height()
Initialize panel.
语法:
void init()
Initialize DMA.
语法:
void initDMA
Set whether the brightness and color tones of the screen are inverted for output. (Negative-Positive Invert)
语法:
void invertDisplay(bool invert)
Whether Bus is shared.
语法:
bool isBusShared()
Whether Panel is an EPD.
语法:
bool isEPD()
Whether Panel is readable or not.
语法:
bool isReadable()
Whether SPI Bus is shared.
语法:
bool isSPIShared()
Load font data.
语法:
bool loadFont(const uint8_t *array)
| 参数 | 类型 | 描述 |
| ----- | -------------- | ------------- |
| array | const uint8_t* | VLW font data |
bool loadFont(fs::FS &fs, const char *path)
| 参数 | 类型 | 描述 |
| ---- | ----------- | ------------------------ |
| fs | fs::FS& | FileSystem(SD or SPIFFS) |
| path | const char* | file path |
Same function floodFill() .
语法:
void paint(int32_t x, int32_t y, const T& color)
Get panel of device.
语法:
Panel_Device* panel()
Temporarily saves text information. Restore is done by pushState() .
参数 | 类型 | 描述 |
---|---|---|
gfxFont | IFont * | |
style | TextStyle (*1) | |
metrics | FontMetrics (*2) | |
cursor_x | int32_t | |
cursor_y | int32_t |
*1. struct TextStyle *2. struct FontMetrics
语法:
void popState()
Set the status of powerSave.
语法:
void powerSave(bool flg)
参数 | 类型 | 描述 |
---|---|---|
flg | bool |
Set the status of powerSave to Off.
语法:
void powerSaveOff()
Set the status of powerSave to On.
语法:
void powerSaveOn()
Output text at the cursor position. Arduino Print.h compatible.
语法:
size_t print(...)
Output text at the cursor position. Arduino LibPrint.h compatible.
语法:
size_t printf(...)
Output text at the cursor position. Arduino Print.h compatible.
语法:
size_t print(...)
Displays a progress bar. Available in blue(0x09F1) only.
语法:
void progressBar(int x, int y, int w, int h, uint8_t val)
参数 | 类型 | 描述 |
---|---|---|
x | int | point x |
y | int | point y |
w | int | width |
h | int | height |
value | uint8_t | value( 0 - 100) |
Draw lines in the rectangular area allocated by setWindow() or setAddrWindow() , specifying the color and width of each line.
语法:
void pushBlock(const T& color, uint32_t length)
参数 | 类型 | 説明 |
---|---|---|
color | const T& | Color(*1) |
length | uint32_t | Length |
*1. About ColorCode
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
int32_t x;
int32_t y;
void setup()
{
display.begin();
display.fillScreen(TFT_BLACK);
x = display.width() / 2;
y = display.height() / 2;
display.startWrite();
display.setWindow(0, 0, x - 1 , y);
for (int i=0; i<y; i++) {
display.pushBlock(TFT_RED, x / 4);
display.pushBlock(TFT_BLUE, x / 4);
display.pushBlock(TFT_GREEN, x / 4);
display.pushBlock(TFT_YELLOW, x / 4);
}
display.endWrite();
}
void loop()
{
}
Push image data.
语法:
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const T* data)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | start point x |
y | int32_t | start point y |
w | int32_t | Image width |
h | int32_t | Image height |
data | const T* | Image data |
void pushImage(const float matrix[6], int32_t w, int32_t h, const T* data, const T2& transparent)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | start point x |
y | int32_t | start point y |
w | int32_t | Image width |
h | int32_t | Image height |
data | const T* | Image data |
transparent | const T2& | Color of transparent |
void pushImage(const float matrix[6], int32_t w, int32_t h, const T* data, color_depth_t depth, const T* palette)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | start point x |
y | int32_t | start point y |
w | int32_t | Image width |
h | int32_t | Image height |
data | const T* | Image data |
depth | color_depth_t (*1) | Color depth |
palette | const T | Color palette |
void pushImage(const float matrix[6], int32_t w, int32_t h, const T* data, uint32_t transparent, color_depth_t depth, const T* palette)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | start point x |
y | int32_t | start point y |
w | int32_t | Image width |
h | int32_t | Image height |
data | const T* | Image data |
transparent | uint32_t | Color of transparent |
depth | color_depth_t (*1) | Color depth |
palette | const T | Color palette |
Affine transformation are performed when drawing images.
语法:
void pushImageAffine(const float matrix[6], int32_t w, int32_t h, const T* data)
参数 | 类型 | 描述 |
---|---|---|
matrix | const float[6] | Matrix with 6 elements |
w | int32_t | Image width |
h | int32_t | Image height |
data | const T* | Image data |
void pushImageAffine(const float matrix[6], int32_t w, int32_t h, const T* data, const T2& transparent)
参数 | 类型 | 描述 |
---|---|---|
matrix | const float[6] | Matrix with 6 elements |
w | int32_t | Image width |
h | int32_t | Image height |
data | const T* | Image data |
transparent | const T2& | Color of transparent |
void pushImageAffine(const float matrix[6], int32_t w, int32_t h, const T* data, color_depth_t depth, const T* palette)
参数 | 类型 | 描述 |
---|---|---|
matrix | const float[6] | Matrix with 6 elements |
w | int32_t | Image width |
h | int32_t | Image height |
data | const T* | Image data |
depth | color_depth_t (*1) | Color depth |
palette | const T (*2) | Color palette |
void pushImageAffine(const float matrix[6], int32_t w, int32_t h, const T* data, uint32_t transparent, color_depth_t depth, const T* palette)
参数 | 类型 | 描述 |
---|---|---|
matrix | const float[6] | Matrix with 6 elements |
w | int32_t | Image width |
h | int32_t | Image height |
data | const T* | Image data |
transparent | uint32_t | Color of transparent |
depth | color_depth_t (*1) | Color depth |
palette | const T (*2) | Color palette |
Affine transformation and anti-aliasing are performed when drawing images.
语法:
void pushImageAffineWithAA(const float matrix[6], int32_t w, int32_t h, const T* data)
参数 | 类型 | 描述 |
---|---|---|
matrix | const float[6] | Matrix with 6 elements |
w | int32_t | Image width |
h | int32_t | Image height |
data | const T* | Image data |
void pushImageAffineWithAA(const float matrix[6], int32_t w, int32_t h, const T* data, const T2& transparent)
参数 | 类型 | 描述 |
---|---|---|
matrix | const float[6] | Matrix with 6 elements |
w | int32_t | Image width |
h | int32_t | Image height |
data | const T* | Image data |
transparent | const T2& | Color of transparent |
void pushImageAffineWithAA(const float matrix[6], int32_t w, int32_t h, const T* data, color_depth_t depth, const T* palette)
参数 | 类型 | 描述 |
---|---|---|
matrix | const float[6] | Matrix with 6 elements |
w | int32_t | Image width |
h | int32_t | Image height |
data | const T* | Image data |
depth | color_depth_t (*1) | Color depth |
palette | const T (*2) | Color palette |
void pushImageAffineWithAA(const float matrix[6], int32_t w, int32_t h, const T* data, uint32_t transparent, color_depth_t depth, const T* palette)
参数 | 类型 | 描述 |
---|---|---|
matrix | const float[6] | Matrix with 6 elements |
w | int32_t | Image width |
h | int32_t | Image height |
data | const T* | Image data |
transparent | uint32_t | Color of transparent |
depth | color_depth_t (*1) | Color depth |
palette | const T (*2) | Color palette |
Draw pixels within the clipped area set by setWindow() or setAddrWindow() .
语法:
void pushPixels(T* data, int32_t len)
参数 | 类型 | 描述 |
---|---|---|
data | T* | Image data |
len | int32_t | Data length |
void pushPixels(T* data, int32_t len, bool swap)
参数 | 类型 | 描述 |
---|---|---|
data | T* | Image data |
len | int32_t | Data length |
swap | bool | Swap bytes |
Draw pixels within the clipped area.
语法:
void pushPixelsDMA(T* data, int32_t len)
参数 | 类型 | 描述 |
---|---|---|
data | T* | Image data |
len | int32_t | Data length |
void pushPixelsDMA(T* data, int32_t len, bool swap)
参数 | 类型 | 描述 |
---|---|---|
data | T* | Image data |
len | int32_t | Data length |
swap | bool | Swap bytes |
Restore the text information that had been temporarily retired with popState() .
语法:
void pushState()
Generate qrcode from a string.
语法:
void qrcode(const char *string, int32_t x, int32_t y, int32_t w, uint8_t version)
参数 | 类型 | 描述 |
---|---|---|
string | const char* | String to convert |
x | int32_t | point x |
y | int32_t | point y |
w | int32_t | width |
version | uint8_t | version of qrcode(1 - 40) |
Reads 16 bits of data from the panel
语法:
uint16_t readData16(uint8_t index=0)
Reads 32 bits of data from the panel
语法:
uint32_t readData32(uint8_t index=0)
Reads 8 bits of data from the panel
语法:
uint8_t readData8(uint8_t index=0)
Reads the color code of the specified coordinates. Color code is RGB565.
语法:
uint16_t readPixel(int32_t x, int32_t y)
Reads the color code of the specified coordinates. Color code is RGB888.
语法:
RGBColor readPixelRGB(int32_t x, int32_t y)
Loads the color data for the specified rectangular area.
语法:
void readRect(int32_t x, int32_t y, int32_t w, int32_t h, T* data)
Loads the color data for the specified rectangular area.
语法:
void readRectRGB(int32_t x, int32_t y, int32_t w, int32_t h, RGBColor* data)
Scroll the displayed screen.
语法:
void scroll(int_fast16_t dx, int_fast16_t dy)
参数 | 类型 | 描述 |
---|---|---|
dx | int_fast16_t | Amount of X-axis movement |
dy | int_fast16_t | Amount of Y-axis movement |
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
uint16_t x;
uint16_t y;
void setup()
{
display.begin();
display.fillScreen(TFT_BLACK);
x = display.width() / 2;
y = display.height() / 2;
display.drawCenterString("scroll", x, y, &fonts::lgfxJapanGothic_24);
}
void loop()
{
for (int i=-10; i<=10; i+=1) {
display.scroll(0, i);
}
}
Specifies the rectangle range to which writePixels() , pushPixels() , etc. are to be drawn.
语法:
void setAddrWindow(int32_t x, int32_t y, int32_t w, int32_t h)
参数 | 类型 | 説明 |
---|---|---|
x | int32_t | x |
y | int32_t | y |
w | int32_t | width |
h | int32_t | height |
for M5Paper, CoreInk, UnitOLED only. Set a flag to automatically display on the panel at the time of drawing without executing display() .
语法:
void setAutoDisplay(bool auto_display)
Set the base color. The color outside the drawing area can be specified when using the scroll function.
语法:
void setBaseColor(T color)
参数 | 类型 | 描述 |
---|---|---|
color | T (*1) | Base color |
*1. About ColorCode
Specifies the brightness of the display panel.
语法:
void setBrightness(uint8_t brightness)
参数 | 类型 | 描述 |
---|---|---|
brightness | unit8_t | display brightness |
Specifying a drawing range with this function limits the drawing to within a rectangular area.
语法:
void setClipRect(int32_t x, int32_t y, int32_t w, int32_t h)
Specify the drawing color for draw-type functions.
语法:
void setColor(const T &color)
参数 | 类型 | 描述 |
---|---|---|
color | T (*1) | Base color |
*1. About ColorCode
Specify ColorDepth
void setColorDepth(int32_t bits)
参数 | 类型 | 描述 |
---|---|---|
bits | int | ColorDepth |
Specify the cursor position.
void setCursor(int32_t x, int32_t y)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | point x |
y | int32_t | point y |
Set EpdMode.
void setEpdMode(epd_mode_t epd_mode)
参数 | 类型 | 描述 |
---|---|---|
epd_mode | epd_mode_t(*1) | epd mode |
*1. About EpdMode
Specify the font for Text.
语法:
void setFont(const IFont *font)
参数 | 类型 | 描述 |
---|---|---|
font | IFont (*1) | font |
*1. About Font
Specifies the coordinates of Pivot.
notice:
The reason the argument is real (float) is that pivot is specified to indicate the center of the pixel. Rotation is offset by +0.5 pixels to the lower right. Therefore, an offset of -0.5 with setPivot will result in an offset.
语法:
void setPivot(float x, float y)
参数 | 类型 | 描述 |
---|---|---|
x | float | point x |
y | float | point y |
Set raw color.
语法:
void setRawColor(uint32_t color)
For only M5AtomDisplay. Set Resolution.
语法:
bool setResolution(uint16_t logical_width = 0, uint16_t logical_height = 0, float refresh_rate = 0.0f, uint16_t output_width = 0, uint16_t output_height = 0, uint_fast8_t scale_w = 0, uint_fast8_t scale_h = 0)
参数 | 类型 | 描述(*1) |
---|---|---|
logical_width | uint16_t | Logical screen widths handled by the program |
logical_height | uint16_t | Logical screen heights handled by the program |
refresh_rate | float | Screen Refresh Rate(*2) |
output_width | uint16_t | Actual output screen width |
output_height | uint16_t | Actual output screen height |
scale_w | uint_fast8_t | Magnification of logical_width |
scale_h | uint_fast8_t | Magnification of logical_height |
Rotate Screen
语法:
void setRotation(uint8_t m)
Function parameter:
参数 | 描述 | 类型 |
---|---|---|
m | uint8_t | Rotate angle ( * 90°) |
使用示例:
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
void setup() {
display.begin();
display.setRotation(2); //Rotate the screen 180 degrees clockwise (2*90)
display.fillEllipse(160, 100, 60, 100, YELLOW); //Create a yellow ellipse at (160, 100) with the long axis and the short axis to 60 and 100 respectively.
delay(1000);
display.setRotation(1); //Restore the screen to the default display state
display.fillEllipse(160, 100, 60, 100, GREEN);
}
void loop() {}
Specifies the range within which the text will scroll.
语法:
void setScrollRect(int32_t x, int32_t y, int32_t w, int32_t h)
参数 | 类型 | 描述 |
---|---|---|
x | int32_t | point x |
y | int32_t | point y |
w | int32_t | width |
h | int32_t | height |
使用示例:
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
uint16_t x;
uint16_t y;
void setup()
{
display.begin();
display.fillScreen(TFT_BLACK);
x = display.width() / 2;
y = display.height() / 2;
display.setTextScroll(true);
display.setScrollRect(x, y, x / 2, y / 2);
}
uint32_t count = 0;
void loop()
{
display.printf("ScrollTest:%d\n", count);
count++;
delay(100);
}
Set swap bytes.
语法:
void setSwapBytes(bool swap)
Set TextColor.
语法:
void setTextColor(const T &color)
参数 | 类型 | 描述 |
---|---|---|
color | T (*1) | Base color |
*1. About ColorCode
Set TextDatum.
语法:
void setTextDatum(textdatum_t datum)
参数 | 类型 | 描述 |
---|---|---|
datum | textdatum_t (*1) | Text Datum |
*1. About TextDatum
Enable/Disable text scrolling.
语法:
void setTextScroll(bool scroll)
参数 | 类型 | 描述 |
---|---|---|
scroll | bool | scroll mode |
Set text size.
语法:
void setTextSize(float size)
| 参数 | 类型 | 描述 |
| ---- | ----- | --------- |
| size | float | text size |
void setTextSize(float sx, float sy)
| 参数 | 类型 | 描述 |
| ---- | ----- | ----------- |
| sx | float | text size X |
| sy | float | text size Y |
Set text style.
语法:
void setTextStyle(TextStyle textstyle)
参数 | 类型 | 描述 |
---|---|---|
textstyle | TextStyle (*1) | Text Style |
*1. about TextStyle
X-axis is whether or not the turnaround is performed. Y-axis is whether to return to the top after reaching the bottom line.
语法:
void setTextWrap(bool wrapX, bool wrapY = false)
参数 | 类型 | 描述 |
---|---|---|
wrapX | bool | wrap X |
wrapY | bool | wrap Y |
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
void setup()
{
display.begin();
display.fillScreen(TFT_BLACK);
display.setTextWrap(true, true); // <- Change Value
}
uint32_t count = 0;
void loop()
{
display.printf("wrap--------------------------------------------:%d\n", count);
count++;
delay(100);
}
The Touch panel can be calibrated by setting the value obtained/saved by calibrateTouch() .
语法:
void setTouchCalibrate(uint16_t *parameters)
参数 | 类型 | 描述 |
---|---|---|
parameters | uint16_t* | uint16_t[8] |
Specifies the rectangle range to which writePixels() , pushPixels() , etc. are to be drawn.
语法:
void setWindow(uint_fast16_t xs, uint_fast16_t ys, uint_fast16_t xe, uint_fast16_t ye)
参数 | 类型 | 描述 |
---|---|---|
xs | uint_fast16_t | start point x |
ys | uint_fast16_t | start point y |
xe | uint_fast16_t | end point x |
ye | uint_fast16_t | end point y |
Display the specified time font.
语法:
void showFont(uint32_t msec)
参数 | 类型 | 描述 |
---|---|---|
msec | uint32_t | display time(msec) |
Sleeps the panel. Wakeup is wakeup()
语法:
void sleep()
Asserted CS on SPI bus.It is paired with endWrite() . Declaring startWrite() allows the M5GFX to use the DMA buffer efficiently.
语法:
void startWrite()
Function to get the swapped color code when changing it directly by getBuffer() since the sprite has swapped color data.
语法:
uint16_t swap565(uint8_t r, uint8_t g, uint8_t b)
Function to get the swapped color code when changing it directly by getBuffer() since the sprite has swapped color data.
语法:
uint32_t swap888(uint8_t r, uint8_t g, uint8_t b)
Obtains the number of characters that can be displayed in the specified width.
语法:
int32_t textLength(const char *string, int32_t width)
参数 | 类型 | 描述 |
---|---|---|
string | const char* | String |
width | int32_t | width |
Returns the width of the string displayed on the screen. If font is omitted, it is calculated using the default font or the font set with setFont().
语法:
uint32_t textWidth(const char *string)
参数 | 类型 | 描述 |
---|---|---|
string | const char* | String |
uint32_t textWidth(const char *string, IFont *font)
参数 | 类型 | 描述 |
---|---|---|
string | const char* | String |
font | IFont (*1) | font |
#1. About font
If a touch device is present, return the ITouch pointer.
语法:
ITouch* touch()
Restore font set by setFont() to the default font(&fonts::Font0).
语法:
void unloadFont()
Wait until display is released.
语法:
void waitDisplay()
Wait until DMA is released.
语法:
void waitDMA()
Wake up the slept panel device. sleep()
语法:
void wakeup()
Returns the width of the panel.
语法:
int32_t width()
Draw lines in the rectangular area allocated by setWindow() or setAddrWindow() , specifying the color and length of each line.
void writeColor(const T &color, uint32_t length)
参数 | 类型 | 描述 |
---|---|---|
color | const T& | Color |
length | uint32_t | line length |
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
int32_t x;
int32_t y;
void setup()
{
display.begin();
display.fillScreen(TFT_BLACK);
x = display.width() / 2;
y = display.height() / 2;
display.startWrite();
display.setWindow(0, 0, x - 1 , y);
for (int i=0; i<y; i++) {
display.writeColor(TFT_RED, x / 4);
display.writeColor(TFT_BLUE, x / 4);
display.writeColor(TFT_GREEN, x / 4);
display.writeColor(TFT_YELLOW, x / 4);
}
display.endWrite();
}
void loop()
{
}
Writes commands(16bit) to the panel.
语法:
void writeCommand(uint16_t cmd)
Writes data(16bit) to the panel.
语法:
void writeCommand(uint16_t data)
Writes data(32bit) to the panel.
语法:
void writeCommand(uint32_t data)
Writes data(8bit) to the panel.
语法:
void writeCommand(uint8_t data)
Draw a horizontal line within the clipped area.
语法:
void writeFastHLine(int32_t x, int32_t y, int32_t w)
Draw a vertical line within the clipped area.
语法:
void writeFastVLine(int32_t x, int32_t y, int32_t h)
Draw a rectangle within the clipped area.
语法:
void writefillRect(int32_t x, int32_t y, int32_t w, int32_t h)
Draw image data using a color palette.
语法:
void writeIndexedPixels(const uint8_t* data, T* palette, int32_t len, uint8_t depth = 8)
参数 | 类型 | 描述 |
---|---|---|
data | const uint8_t* | Image data |
palette | T* | palette data |
len | int32_t | data length |
depth | uint8_t | color depth |
Draw a pixel within the clipped area.
语法:
void writePixels(T* data, int32_t len)
参数 | 类型 | 描述 |
---|---|---|
data | T* | Image data |
len | int32_t | Data length |
void writePixels(T* data, int32_t len, bool swap)
参数 | 类型 | 描述 |
---|---|---|
data | T* | Image data |
len | int32_t | Data length |
swap | bool | Swap bytes |
Draw pixels within the clipped area. In the cropped rectangular area, data is drawn one line at a time, starting from the upper left corner.
语法:
void writePixels(T* data, int32_t len)
参数 | 类型 | 描述 |
---|---|---|
data | T* | Image data |
len | int32_t | Data length |
void writePixels(T* data, int32_t len, bool swap)
参数 | 类型 | 描述 |
---|---|---|
data | T* | Image data |
len | int32_t | Data length |
swap | bool | Swap bytes |
Draw pixels within the clipped area. In the cropped rectangular area, data is drawn one line at a time, starting from the upper left corner.
语法:
void writePixels(T* data, int32_t len)
参数 | 类型 | 描述 |
---|---|---|
data | T* | Image data |
len | int32_t | Data length |
void writePixels(T* data, int32_t len, bool swap)
参数 | 类型 | 描述 |
---|---|---|
data | T* | Image data |
len | int32_t | Data length |
swap | bool | Swap bytes |