pdf-icon

a - e

begin

初始化函数

语法:

void begin()

beginTransaction

Initiate a panel transaction.

语法:

void beginTransaction()

calibrateTouch

校准触摸板. 传递一个指向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() {
}

clear

清空屏幕,如果指定了一个参数,就用该颜色初始化屏幕

语法:

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:
}

clearClipRect

清除由 setClipRect() .

语法:

void clearClipRect()

clearDisplay

清空屏幕,如果指定了一个参数,就用该颜色初始化屏幕

语法:

void clearDisplay(uint32_t color = 0)

参数 类型 描述
color uint32_t 初始化后的颜色

clearScrollRect

清除由 setScrollRect() .

语法:

void clearScrollRect()

color8to16

Convert color code from RGB332 to RGB565.

语法:

uint16_t color8to16(uint8_t rgb332)

参数 类型 描述
rgb332 uint8_t ColorCode of RGB332

color16to24

将 RGB565(16bit)颜色代码转换为 RGB888(24bit).

语法:

uint32_t color16to24(uint16_t rgb565)

参数 类型 描述
rgb565 uint16_t ColorCode of RGB565

color16to8

将 RGB565(16bit) 颜色代码转换为 RGB332(8bit).

语法:

uint8_t color16to8(uint16_t rgb565)

参数 类型 描述
rgb565 uint32_t ColorCode of RGB565

color24to16

将 RGB888(24bit) 颜色代码转换为 RGB565(16bit).

语法:

uint16_t color24to16(uint32_t rgb888)

参数 类型 描述
rgb888 uint32_t ColorCode of RGB888

color332

根据 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

color565

根据 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

color888

根据 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

convertRawXY

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

copyRect

拷贝矩形范围

语法: 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

createPng

Screenshot function. Executing this function saves the data displayed in the panel to memory in PNG format.

Notice:
The size of image that can be stored depends on memory. For example, if PSRAM is disabled, a size of 320x240 cannot be saved.

语法:

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

Display to the panel.(for M5Paper, CoreInk, OLEDUnit)

  • CoreInk and OLEDUnit display the data drawn in memory on the panel.
  • M5Paper displays on the panel what is drawn in memory on the EPD side.

语法:

void display()

displayBusy

Check if the panel is Busy.

语法:

bool displayBusy()

dmaBusy

Check if the panel's DMA is busy.

语法:

bool dmaBusy()

drawArc

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() {
}

drawBezier

Draws a Bezier curve, available in two types: 3-point and 4-point.

语法:

  • 3-points

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
  • 4-points

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() {
}

drawBmp

Draw bitmap data. File or HTTPStream can be specified for data.

语法:

  • FileSystem

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

  • Stream

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

  • data

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

drawBmpFile

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

drawBmpUrl

Displays a BMP image of the specified URL.

Notice:
This function can be used by writing #include <HTTPClient.h> before #include <M5GFX.h>.

语法:

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

drawCenterString(drawCentreString)

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

drawChar

Draw an unicode character.

语法:

size_t drawChar(uint16_t uniCode, int32_t, x, int32_t y, uint8_t font)

drawCircle

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

drawEllipse

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

drawEllipseArc

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

drawFastHLine

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

drawFastVLine

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

drawFloat

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

drawGradientHLine

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

drawGradientLine

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

drawGradientVLine

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

drawJpg

Draw JPG data. File or HTTPStream can be specified for data.

语法:

  • FileSystem

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

  • Stream

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

  • data

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

drawJpgFile

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

drawJpgUrl

Draw an JPG image from URL.

Notice:
This function can be used by writing #include <HTTPClient.h> before #include <M5GFX.h>.

语法:

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

drawLine

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

drawNumber

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

drawPixel

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

drawPng

Draw PNG data. File or HTTPStream can be specified for data.

语法:

  • FileSystem

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

  • Stream

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

  • data

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

drawPngFile

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

drawPngUrl

Draw a PNG image from URL.

Notice:
This function can be used by writing #include <HTTPClient.h> before #include <M5GFX.h>.

语法:

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

drawQoi

Draw Qoi data. File or HTTPStream can be specified for data.

语法:

  • FileSystem

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

  • Stream

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

  • data

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

drawQoiFile

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

drawQoiUrl

Draw a Qoi image from URL.

Notice:
This function can be used by writing #include <HTTPClient.h> before #include <M5GFX.h>.

语法:

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

drawRect

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

drawRightString

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

drawRoundRect

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

drawString

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() {
}

drawTriangle

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

effect

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

endTransaction

It is pared with startTransaction()

语法:

void endTransaction()

endWrite

It is paired with startWrite() .

语法:

void endWrite()

f - h

fillAffine

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

fillArc

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() {
}

fillCircle

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

fillEllipse

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

fillEllipseArc

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

fillRect

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

fillRectAlpha

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()
{
}

fillRoundRect

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()
{
}

fillScreen

Fill the screen.

语法:

参数 类型 描述
color const T color(*1)

*1. About ColorCode

fillTriangle

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

floodFill

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

fontHeight

Returns the height of the specified font.

int32_t fontHeight(uint8_t font)

参数 类型 描述
font IFont* (*1) font

*1. About Fonts

fontWidth

Returns the width of the specified font.

int32_t fontHeight(uint8_t font)

参数 类型 描述
font IFont* (*1) font

*1. About Fonts

getAttribute

Get the attribute.

语法:

uint8_t getAttribute(attribute_t attr_id)

getBaseColor

Get the color value set by setBaseColor() .

语法:

uint32_t getBaseColor()

getBoard

Get Board.

语法:

uint8_t getBoard()

*1. enum board_t

getBrightness

Get the value set by setBrightness .

语法:

uint8_t getBrightness()

getClipRect

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)

getColorDepth

Get the value set by setColorDepth() .

语法:

color_depth_t getColorDepth()

*1. About ColorDepth

getCursorX

Get current cursor X position.

语法:

int32_t getCursorX()

getCursorY

Get current cursor Y position.

语法:

int32_t getCursorY()

getEpdMode

Get the value set by setEpdMode() .(M5Paper only)

语法:

epd_mode_t getEpdMode()

*1. epd_mode_t

getFont

Get the font set by setFont() .

const IFont* getFont()

*1. about font

getInstance

Get an instance of M5GFX.

语法:

M5GFX* getInstance()

getInvert

Get the value set by invertDisplay() Get Invert value of the panel.

语法:

bool getInvert()

getPalette

Get palette information.

语法:

RGBColor* getPalette()

getPaletteCount

Get count of palette.

语法:

uint32_t getPaletteCount()

getPanel

Get panel of device.

语法:

Panel_Device* getPanel()

getPivotX

Get X value set by setPivot

语法:

float getPivotX()

getPivotY

Get Y value set by setPivot

语法:

float getPivotY()

getRawColor

Get the value set by setRawColor() .

uint32_t getRawColor()

getRotation

Get the value set by setRotation()

uint8_t getRotation()

getScrollRect

Get information about the setScrollRect() .

void getScrollRect(int32_t *x, int32_t *y, int32_t *w, int32_t *h)

getStartCount

Get the count of the panel has startWrite() .

uint32_t getStartCount()

getSwapBytes

Get status of setSwapBytes() .

bool getSwapBytes()

getTextDatum

Get TextDatum. setTextDatum()

语法:

textdatum_t getTextDatum()

*1. About TextDatum

getTextPadding

Get TextPadding.

语法:

uint32_t getTextPadding()

getTextSizeX

Get the width set by setTextSize() .

语法:

float getTextSizeX()

getTextSizeY

Get the height set by setTextSize() .

语法:

float getTextSizeY()

getTextStyle

Get the information set by setTextStyle() .

语法:

TextSytle& getTextStyle()

getTouch

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

getTouchRaw

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

hasPalette

Whether a color palette exists.

语法:

bool hasPalette()

height

Get height of panel.

语法:

int_fast16_t height()

i - q

init

Initialize panel.

语法:

void init()

initDMA

Initialize DMA.

语法:

void initDMA

invertDisplay

Set whether the brightness and color tones of the screen are inverted for output. (Negative-Positive Invert)

语法:

void invertDisplay(bool invert)

isBusShared

Whether Bus is shared.

语法:

bool isBusShared()

isEPD

Whether Panel is an EPD.

语法:

bool isEPD()

isReadable

Whether Panel is readable or not.

语法:

bool isReadable()

isSPIShared

Whether SPI Bus is shared.

语法:

bool isSPIShared()

loadFont

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 |

paint

Same function floodFill() .

语法:

void paint(int32_t x, int32_t y, const T& color)

panel

Get panel of device.

语法:

Panel_Device* panel()

popState

Temporarily saves text information. Restore is done by pushState() .

  • Information to be temporarily evacuated
参数 类型 描述
gfxFont IFont *
style TextStyle (*1)
metrics FontMetrics (*2)
cursor_x int32_t
cursor_y int32_t

*1. struct TextStyle *2. struct FontMetrics

语法:

void popState()

powerSave

Set the status of powerSave.

语法:

void powerSave(bool flg)

参数 类型 描述
flg bool

powerSaveOff

Set the status of powerSave to Off.

语法:

void powerSaveOff()

powerSaveOn

Set the status of powerSave to On.

语法:

void powerSaveOn()

print

Output text at the cursor position. Arduino Print.h compatible.

语法:

size_t print(...)

printf

Output text at the cursor position. Arduino LibPrint.h compatible.

语法:

size_t printf(...)

println

Output text at the cursor position. Arduino Print.h compatible.

语法:

size_t print(...)

progressBar

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)

pushBlock

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()
{
}

pushImage

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

*1. About Color Depth

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

*1. About Color Depth

pushImageAffine

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

*1. About Color Depth

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

*1. About Color Depth

pushImageAffineWithAA

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

*1. About Color Depth

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

*1. About Color Depth

pushPixels

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

pushPixelsDMA

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

pushState

Restore the text information that had been temporarily retired with popState() .

语法:

void pushState()

qrcode

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)

r - s

readData16

Reads 16 bits of data from the panel

语法:

uint16_t readData16(uint8_t index=0)

readData32

Reads 32 bits of data from the panel

语法:

uint32_t readData32(uint8_t index=0)

readData8

Reads 8 bits of data from the panel

语法:

uint8_t readData8(uint8_t index=0)

readPixel

Reads the color code of the specified coordinates. Color code is RGB565.

语法:

uint16_t readPixel(int32_t x, int32_t y)

readPixelRGB

Reads the color code of the specified coordinates. Color code is RGB888.

语法:

RGBColor readPixelRGB(int32_t x, int32_t y)

readRect

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)

readRectRGB

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

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);
  }
}

setAddrWindow

Specifies the rectangle range to which writePixels() , pushPixels() , etc. are to be drawn.

notice:
Same as setWindow , but the arguments are different. setAddrWindows checks for off-screen overflow, while setWindow does not.

语法:

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

setAutoDisplay

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)

setBaseColor

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

setBrightness

Specifies the brightness of the display panel.

语法:

void setBrightness(uint8_t brightness)

参数 类型 描述
brightness unit8_t display brightness

setClipRect

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)

setColor

Specify the drawing color for draw-type functions.

语法:

void setColor(const T &color)

参数 类型 描述
color T (*1) Base color

*1. About ColorCode

setColorDepth

Specify ColorDepth

void setColorDepth(int32_t bits)

参数 类型 描述
bits int ColorDepth

setCursor

Specify the cursor position.

void setCursor(int32_t x, int32_t y)

参数 类型 描述
x int32_t point x
y int32_t point y

setEpdMode

Set EpdMode.

void setEpdMode(epd_mode_t epd_mode)

参数 类型 描述
epd_mode epd_mode_t(*1) epd mode

*1. About EpdMode

setFont

Specify the font for Text.

语法:

void setFont(const IFont *font)

参数 类型 描述
font IFont (*1) font

*1. About Font

setPivot

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

setRawColor

Set raw color.

语法:

void setRawColor(uint32_t color)

setResolution

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

setRotation

Rotate Screen

语法:

void setRotation(uint8_t m)

Function parameter:

参数 描述 类型
m uint8_t Rotate angle ( * 90°)
Pay Attention:
1.Rotate angle is a multiple of 90°
2.0-3 is clockwise rotation, 4-7 is counterclockwise rotation (default is 1)
3. Need to be set before display.

使用示例:

#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() {}

setScrollRect

Specifies the range within which the text will scroll.

**notice:**setTextScroll(true) must be executed beforehand.

语法:

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);
}

setSwapBytes

Set swap bytes.

语法:

void setSwapBytes(bool swap)

setTextColor

Set TextColor.

语法:

void setTextColor(const T &color)

参数 类型 描述
color T (*1) Base color

*1. About ColorCode

setTextDatum

Set TextDatum.

语法:

void setTextDatum(textdatum_t datum)

参数 类型 描述
datum textdatum_t (*1) Text Datum

*1. About TextDatum

setTextScroll

Enable/Disable text scrolling.

语法:

void setTextScroll(bool scroll)

参数 类型 描述
scroll bool scroll mode

setTextSize

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 |

setTextStyle

Set text style.

语法:

void setTextStyle(TextStyle textstyle)

参数 类型 描述
textstyle TextStyle (*1) Text Style

*1. about TextStyle

setTextWrap

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);
}

setTouchCalibrate

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]

setWindow

Specifies the rectangle range to which writePixels() , pushPixels() , etc. are to be drawn.

notice:
Same as setAddrWindow , but the arguments are different. setAddrWindows checks for off-screen overflow, while setWindow does not.

语法:

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

showFont

Display the specified time font.

语法:

void showFont(uint32_t msec)

参数 类型 描述
msec uint32_t display time(msec)

sleep

Sleeps the panel. Wakeup is wakeup()

语法:

void sleep()

startWrite

Asserted CS on SPI bus.It is paired with endWrite() . Declaring startWrite() allows the M5GFX to use the DMA buffer efficiently.

notice:
Cannot be used simultaneously with SD card access. Exclusive control is required when there are multiple drawing tasks.

语法:

void startWrite()

swap565

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)

swap888

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)

t - z

textLength

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

textWidth

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

touch

If a touch device is present, return the ITouch pointer.

语法:

ITouch* touch()

unloadFont

Restore font set by setFont() to the default font(&fonts::Font0).

语法:

void unloadFont()

waitDisplay

Wait until display is released.

语法:

void waitDisplay()

waitDMA

Wait until DMA is released.

语法:

void waitDMA()

wakeup

Wake up the slept panel device. sleep()

语法:

void wakeup()

width

Returns the width of the panel.

语法:

int32_t width()

writeColor

Draw lines in the rectangular area allocated by setWindow() or setAddrWindow() , specifying the color and length of each line.

**note:**This function is used in combination with startWrite() and endWrite() .
See the appendix difference between draw/push and write functions

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()
{
}

writeCommand16

Writes commands(16bit) to the panel.

**note:**This function is used in combination with startWrite() and endWrite() .
See the appendix difference between draw/push and write functions

语法:

void writeCommand(uint16_t cmd)

writeData16

Writes data(16bit) to the panel.

**note:**This function is used in combination with startWrite() and endWrite() .
See the appendix difference between draw/push and write functions

语法:

void writeCommand(uint16_t data)

writeData32

Writes data(32bit) to the panel.

**note:**This function is used in combination with startWrite() and endWrite() .
See the appendix difference between draw/push and write functions

语法:

void writeCommand(uint32_t data)

writeData

Writes data(8bit) to the panel.

**note:**This function is used in combination with startWrite() and endWrite() .
See the appendix difference between draw/push and write functions

语法:

void writeCommand(uint8_t data)

writeFastHLine

Draw a horizontal line within the clipped area.

**note:**This function is used in combination with startWrite() and endWrite() .
See the appendix difference between draw/push and write functions

语法:

void writeFastHLine(int32_t x, int32_t y, int32_t w)

writeFastVLine

Draw a vertical line within the clipped area.

**note:**This function is used in combination with startWrite() and endWrite() .
See the appendix difference between draw/push and write functions

语法:

void writeFastVLine(int32_t x, int32_t y, int32_t h)

writeFillRect

Draw a rectangle within the clipped area.

**note:**This function is used in combination with startWrite() and endWrite() .
See the appendix difference between draw/push and write functions

语法:

void writefillRect(int32_t x, int32_t y, int32_t w, int32_t h)

writeIndexedPixels

Draw image data using a color palette.

**note:**This function is used in combination with startWrite() and endWrite() .
See the appendix difference between draw/push and write functions

语法:

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

writePixel

Draw a pixel within the clipped area.

**note:**This function is used in combination with startWrite() and endWrite() .
See the appendix difference between draw/push and write functions

语法:

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

writePixels

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.

**note:**This function is used in combination with startWrite() and endWrite() .
See the appendix difference between draw/push and write functions

语法:

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

writePixelsDMA

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.

**note:**This function is used in combination with startWrite() and endWrite() .
See the appendix difference between draw/push and write functions

语法:

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
On This Page