pdf-icon

a - e

begin

Initialize for use

Syntax:

void begin()

beginTransaction

Initiate a panel transaction.

Syntax:

void beginTransaction()

calibrateTouch

Calibrate the touch panel. Pass a pointer to uint16_t[8] as the first argument to obtain a calibration value that can be used in setTouchCalibrate. You can record this value in flash, etc., and use setTouchCalibrate() at the next startup to omit manual calibration.

Syntax:

void calibrateTouch<T>(uint16_t* parameters, const T &color_fg, const T &color_bg)

Parameter Type Description
parameters uint16_t* uint16_t[8] Calibration Value
color_fg const T(*1) Color of foreground
color_bg const T(*1) Color of background

*1. About ColorCode

Example:

#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() {
  // put your main code here, to run repeatedly:
}

clear

Clear the display. If an argument is specified, the display is initialized with that color.

Syntax:

void clear(const T &color)

Parameter Type Description
color const T(*1) Color after initialization

*1. About ColorCode

Example:

#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

Clear the coordinates specified by setClipRect() .

Syntax:

void clearClipRect()

clearDisplay

Clear the display. If an argument is specified, the display is initialized with that color.

Syntax:

void clearDisplay(uint32_t color = 0)

Parameter Type Description
color uint32_t Color after initialization

clearScrollRect

Clear the coordinates specified by setScrollRect() .

Syntax:

void clearScrollRect()

color16to24

Convert color code from RGB565(16bit) to RGB888(24bit).

Syntax:

uint32_t color16to24(uint16_t rgb565)

Parameter Type Description
rgb565 uint16_t ColorCode of RGB565

color16to8

Convert color code from RGB565(16bit) to RGB332(8bit).

Syntax:

uint8_t color16to8(uint16_t rgb565)

Parameter Type Description
rgb565 uint32_t ColorCode of RGB565

color24to16

Convert color code from RGB888(24bit) to RGB565(16bit).

Syntax:

uint16_t color24to16(uint32_t rgb888)

Parameter Type Description
rgb888 uint32_t ColorCode of RGB888

color332

Generate color codes from the values of r, g, and b.

Syntax:

uint8_t color332(uint8_t r, uint8_t g, uint8_t b)

Parameter Type Description
r uint8_t 0 - 255
g uint8_t 0 - 255
b uint8_t 0 - 255

color565

Generate color codes from the values of r, g, and b.

Syntax:

uint16_t color332(uint8_t r, uint8_t g, uint8_t b)

Parameter Type Description
r uint8_t 0 - 255
g uint8_t 0 - 255
b uint8_t 0 - 255

color888

Generate color codes from the values of r, g, and b.

Syntax:

uint32_t color332(uint8_t r, uint8_t g, uint8_t b)

Parameter Type Description
r uint8_t 0 - 255
g uint8_t 0 - 255
b uint8_t 0 - 255

color8to16

Convert color code from RGB332 to RGB565.

Syntax:

uint16_t color8to16(uint8_t rgb332)

Parameter Type Description
rgb332 uint8_t ColorCode of RGB332

convertRawXY

Convert coordinates obtained with getTouchRaw() .

Syntax: void convertRawXY(touch_po2 *tp, uint_fast8_t count)

Parameter Type Description
*tp touch_point_t touch point
count uint_fast8_t count

copyRect

Copy rectangle range.

Syntax: void copyRect(uint32_t dst_x, uint32_t dst_y, uint32_t w, uint32_t h, uint32_t src_x, uint32_t src_y)

Parameter Type Description
dst_x uint32_t X coordinate of copy destination
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.

Syntax:

void* createPng(size_t* datalen, int32_t x, int32_t y, int32_t w, int32_t h)

Parameter Type Description
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.

Syntax:

void display()

displayBusy

Check if the panel is Busy.

Syntax:

bool displayBusy()

dmaBusy

Check if the panel's DMA is busy.

Syntax:

bool dmaBusy()

drawArc

Draws a circular arc. specifying r0 and r1 allows drawing a thick arc.

Syntax:

void drawArc(int32_t x, int32_t y, int32_t r0, int32_t r1, float angle0, float angle1, const T &color)

Parameter Type Description
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

Example:

#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.

Syntax:

  • 3-points

void drawBezier(x0, y0, x1, y1, x2, y2, const int &color)

Parameter Type Description
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)

Parameter Type Description
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.

Syntax:

  • 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 )

Parameter Type Description
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 )

Parameter Type Description
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 )

Parameter Type Description
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.

Syntax:

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 )

Parameter Type Description
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>.

Syntax:

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 )

Parameter Type Description
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.

Syntax:

void drawCenterString(const String &string, int32_t x, int32_t y, IFont* font)

Parameter Type Description
string const String x
x int32_t x
y int32_t y
font IFont* (*1) font

*1. About Fonts

drawChar

Draw an unicode character.

Syntax:

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

drawCircle

Draw a circle.

Syntax:

void drawCircle(int32_t x, int32_t y, int32_t r, const T &color)

Parameter Type Description
x int32_t x
y int32_t y
r int32_t radius
color const T color(*1)
*1. About ColorCode

drawEllipse

Draw ellipse.

Syntax:

void drawEllipse(int32_t x, int32_t y, int32_t rx, int32_t ry, const T &color)

Parameter Type Description
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.

Syntax:

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)

Parameter Type Description
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.

Syntax:

void drawFastHLine(int32_t x, int32_t y, int32_t w, const T &color)

Parameter Type Description
x int32_t x
y int32_t y
w int32_t width
color const T color(*1)

*1. About ColorCode

drawFastVLine

Draw vertical line.

Syntax:

void drawFastHLine(int32_t x, int32_t y, int32_t w, const T &color)

Parameter Type Description
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.

Syntax:

size_t drawFloat(float floatNumber, uint8_ dp, int32_t poX, int32_t poY, const IFont* font)

Parameter Type Description
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.

Syntax:

void drawGradientHLine(int32_t x, int32_t y, int32_t w, const T &colorstart, const T &colorend)

Parameter Type Description
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.

Syntax:

void drawGradientLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, const T &colorstart, const T &colorend)

Parameter Type Description
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.

Syntax:

void drawGradientVLine(int32_t x, int32_t y, int32_t h, const T &colorstart, const T &colorend)

Parameter Type Description
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.

Syntax:

  • 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 )

Parameter Type Description
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 )

Parameter Type Description
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 )

Parameter Type Description
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.

Syntax:

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 )

Parameter Type Description
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>.

Syntax:

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 )

Parameter Type Description
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.

Syntax:

void drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, const T &color)

Parameter Type Description
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.

Syntax:

size_t drawNumber(long long_num,int32_t poX, int32_t poY, const IFont* font)

Parameter Type Description
long_num long long number
poX int32_t x
poY int32_t y
font IFont* (*1) font

*1. About Fonts

drawPixel

Draw a pixel.

Syntax:

void drawPixel(int32_t x, int32_t y, const int &color)

Parameter Type Description
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.

Syntax:

  • 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 )

Parameter Type Description
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 )

Parameter Type Description
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 )

Parameter Type Description
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.

Syntax:

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 )

Parameter Type Description
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>.

Syntax:

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 )

Parameter Type Description
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.

Syntax:

  • 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 )

Parameter Type Description
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 )

Parameter Type Description
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 )

Parameter Type Description
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.

Syntax:

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 )

Parameter Type Description
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>.

Syntax:

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 )

Parameter Type Description
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.

Syntax:

void drawRect(int32_t x, int32_t y, int32_t w, int32_t h, const T &color)

Parameter Type Description
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.

Syntax:

void drawRightString(const String &string, int32_t x, int32_t y, IFont* font)

Parameter Type Description
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.

Syntax:

void drawRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, const T &color)

Parameter Type Description
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.

Syntax:

void drawString(const char* string, int32_t x, int32_t y, const IFont* font)

Parameter Type Description
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.

Syntax:

void drawTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, const T &color)

Parameter Type Description
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.

Syntax:

void effect(int32_t x, int32_t y, int32_t w, int32_t h, TFunc&& effector)

Parameter Type Description
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()

Syntax:

void endTransaction()

endWrite

It is paired with startWrite() .

Syntax:

void endWrite()

f - h

fillAffine

Fill affine transformed area.

void fillAffine(const float matrix[6], int32_t w, int32_t h, const T& color)

Parameter Type Description
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.

Syntax:

void fillArc(int32_t x, int32_t y, int32_t r0, int32_t r1, float angle0, float angle1, const int &color)

Parameter Type Description
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

Example:

#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.

Syntax:

void fillCircle(int32_t x, int32_t y, int32_t r, const T &color)

Parameter Type Description
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.

Syntax:

void fillEllipse(int32_t x, int32_t y, int32_t rx, int32_t ry, const T &color)

Parameter Type Description
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.

Syntax:

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)

Parameter Type Description
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.

Syntax:

void fillRect(int32_t x, int32_t y, int32_t w, int32_t h, const T &color)

Parameter Type Description
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.

Syntax:

void fillRectAlpha(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t alpha, const T &color)

Parameter Type Description
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.

Syntax:

void fillRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, const T &color)

Parameter Type Description
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

Example:

#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.

Syntax:

Parameter Type Description
color const T color(*1)

*1. About ColorCode

fillTriangle

Draw a filled triangle.

Syntax:

void fillTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, const T &color)

Parameter Type Description
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.

Syntax:

void floodFill(uint32_t x, uint32_t y, const T &color)

Parameter Type Description
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)

Parameter Type Description
font IFont* (*1) font

*1. About Fonts

fontWidth

Returns the width of the specified font.

int32_t fontHeight(uint8_t font)

Parameter Type Description
font IFont* (*1) font

*1. About Fonts

getAttribute

Get the attribute.

Syntax:

uint8_t getAttribute(attribute_t attr_id)

getBaseColor

Get the color value set by setBaseColor() .

Syntax:

uint32_t getBaseColor()

getBoard

Get Board.

Syntax:

uint8_t getBoard()

*1. enum board_t

getBrightness

Get the value set by setBrightness .

Syntax:

uint8_t getBrightness()

getClipRect

Get the coordinate parameters(x,y,w,h) set by setClipRect() .

Syntax:

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

getColorDepth

Get the value set by setColorDepth() .

Syntax:

color_depth_t getColorDepth()

*1. About ColorDepth

getCursorX

Get current cursor X position.

Syntax:

int32_t getCursorX()

getCursorY

Get current cursor Y position.

Syntax:

int32_t getCursorY()

getEpdMode

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

Syntax:

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.

Syntax:

M5GFX* getInstance()

getInvert

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

Syntax:

bool getInvert()

getPalette

Get palette information.

Syntax:

RGBColor* getPalette()

getPaletteCount

Get count of palette.

Syntax:

uint32_t getPaletteCount()

getPanel

Get panel of device.

Syntax:

Panel_Device* getPanel()

getPivotX

Get X value set by setPivot

Syntax:

float getPivotX()

getPivotY

Get Y value set by setPivot

Syntax:

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

Syntax:

textdatum_t getTextDatum()

*1. About TextDatum

getTextPadding

Get TextPadding.

Syntax:

uint32_t getTextPadding()

getTextSizeX

Get the width set by setTextSize() .

Syntax:

float getTextSizeX()

getTextSizeY

Get the height set by setTextSize() .

Syntax:

float getTextSizeY()

getTextStyle

Get the information set by setTextStyle() .

Syntax:

TextSytle& getTextStyle()

getTouch

Get information when touching the touch panel.

Syntax:

uint_fast8_t getTouch(touch_point_t *tp, uint_fast8_t count = 1)

Parameter Type Description
tp touch_pont_t* Return value of touch point
count uint_fast8_t count

getTouchRaw

Get raw information when touching the touch panel.

Syntax:

uint_fast8_t getTouchRaw(touch_point_t *tp, uint_fast8_t count = 1)

Parameter Type Description
tp touch_pont_t* Return value of touch point
count uint_fast8_t count

hasPalette

Whether a color palette exists.

Syntax:

bool hasPalette()

height

Get height of panel.

Syntax:

int_fast16_t height()

i - q

init

Initialize panel.

Syntax:

void init()

initDMA

Initialize DMA.

Syntax:

void initDMA

invertDisplay

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

Syntax:

void invertDisplay(bool invert)

isBusShared

Whether Bus is shared.

Syntax:

bool isBusShared()

isEPD

Whether Panel is an EPD.

Syntax:

bool isEPD()

isReadable

Whether Panel is readable or not.

Syntax:

bool isReadable()

isSPIShared

Whether SPI Bus is shared.

Syntax:

bool isSPIShared()

loadFont

Load font data.

Syntax:

bool loadFont(const uint8_t *array) | Parameter | Type | Description | | ---------- | -------------- | -------------------------------- | | array | const uint8_t* | VLW font data |

bool loadFont(fs::FS &fs, const char *path) | Parameter | Type | Description | | ---------- | ----------- | -------------------------------- | | fs | fs::FS& | FileSystem(SD or SPIFFS) | | path | const char* | file path |

paint

Same function floodFill() .

Syntax:

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

panel

Get panel of device.

Syntax:

Panel_Device* panel()

popState

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

  • Information to be temporarily evacuated
Parameter Type Description
gfxFont IFont *
style TextStyle (*1)
metrics FontMetrics (*2)
cursor_x int32_t
cursor_y int32_t

*1. struct TextStyle *2. struct FontMetrics

Syntax:

void popState()

powerSave

Set the status of powerSave.

Syntax:

void powerSave(bool flg)

Parameter Type Description
flg bool

powerSaveOff

Set the status of powerSave to Off.

Syntax:

void powerSaveOff()

powerSaveOn

Set the status of powerSave to On.

Syntax:

void powerSaveOn()

print

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

Syntax:

size_t print(...)

printf

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

Syntax:

size_t printf(...)

println

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

Syntax:

size_t print(...)

progressBar

Displays a progress bar. Available in blue(0x09F1) only.

Syntax:

void progressBar(int x, int y, int w, int h, uint8_t val)

Parameter Type Description
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.

Syntax:

void pushBlock(const T& color, uint32_t length)

Parameter Type 説明
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.

Syntax:

void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const T* data)

Parameter Type Description
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)

Parameter Type Description
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)

Parameter Type Description
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)

Parameter Type Description
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.

Syntax:

void pushImageAffine(const float matrix[6], int32_t w, int32_t h, const T* data)

Parameter Type Description
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)

Parameter Type Description
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)

Parameter Type Description
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)

Parameter Type Description
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.

Syntax:

void pushImageAffineWithAA(const float matrix[6], int32_t w, int32_t h, const T* data)

Parameter Type Description
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)

Parameter Type Description
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)

Parameter Type Description
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)

Parameter Type Description
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() .

Syntax:

void pushPixels(T* data, int32_t len)

Parameter Type Description
data T* Image data
len int32_t Data length

void pushPixels(T* data, int32_t len, bool swap)

Parameter Type Description
data T* Image data
len int32_t Data length
swap bool Swap bytes

pushPixelsDMA

Draw pixels within the clipped area.

Syntax:

void pushPixelsDMA(T* data, int32_t len)

Parameter Type Description
data T* Image data
len int32_t Data length

void pushPixelsDMA(T* data, int32_t len, bool swap)

Parameter Type Description
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() .

Syntax:

void pushState()

qrcode

Generate qrcode from a string.

Syntax:

void qrcode(const char *string, int32_t x, int32_t y, int32_t w, uint8_t version)

Parameter Type Description
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

Syntax:

uint16_t readData16(uint8_t index=0)

readData32

Reads 32 bits of data from the panel

Syntax:

uint32_t readData32(uint8_t index=0)

readData8

Reads 8 bits of data from the panel

Syntax:

uint8_t readData8(uint8_t index=0)

readPixel

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

Syntax:

uint16_t readPixel(int32_t x, int32_t y)

readPixelRGB

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

Syntax:

RGBColor readPixelRGB(int32_t x, int32_t y)

readRect

Loads the color data for the specified rectangular area.

Syntax:

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.

Syntax:

void readRectRGB(int32_t x, int32_t y, int32_t w, int32_t h, RGBColor* data)

scroll

Scroll the displayed screen.

Syntax:

void scroll(int_fast16_t dx, int_fast16_t dy)

Parameter Type Description
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.

Syntax:

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

Parameter Type 説明
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() .

Syntax:

void setAutoDisplay(bool auto_display)

setBaseColor

Set the base color. The color outside the drawing area can be specified when using the scroll function.

Syntax:

void setBaseColor(T color)

Parameter Type Description
color T (*1) Base color

*1. About ColorCode

setBrightness

Specifies the brightness of the display panel.

Syntax:

void setBrightness(uint8_t brightness)

Parameter Type Description
brightness unit8_t display brightness

setClipRect

Specifying a drawing range with this function limits the drawing to within a rectangular area.

Syntax:

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

setColor

Specify the drawing color for draw-type functions.

Syntax:

void setColor(const T &color)

Parameter Type Description
color T (*1) Base color

*1. About ColorCode

setColorDepth

Specify ColorDepth

void setColorDepth(int32_t bits)

Parameter Type Description
bits int ColorDepth

setCursor

Specify the cursor position.

void setCursor(int32_t x, int32_t y)

Parameter Type Description
x int32_t point x
y int32_t point y

setEpdMode

Set EpdMode.

void setEpdMode(epd_mode_t epd_mode)

Parameter Type Description
epd_mode epd_mode_t(*1) epd mode

*1. About EpdMode

setFont

Specify the font for Text.

Syntax:

void setFont(const IFont *font)

Parameter Type Description
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.

Syntax:

void setPivot(float x, float y)

Parameter Type Description
x float point x
y float point y

setRawColor

Set raw color.

Syntax:

void setRawColor(uint32_t color)

setResolution

For only M5AtomDisplay. Set Resolution.

Syntax:

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)

Parameter Type Description(*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

Syntax:

void setRotation(uint8_t m)

Function parameter:

Parameter Description Type
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.

Example:

#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.

Syntax:

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

Parameter Type Description
x int32_t point x
y int32_t point y
w int32_t width
h int32_t height

Example:

#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.

Syntax:

void setSwapBytes(bool swap)

setTextColor

Set TextColor.

Syntax:

void setTextColor(const T &color)

Parameter Type Description
color T (*1) Base color

*1. About ColorCode

setTextDatum

Set TextDatum.

Syntax:

void setTextDatum(textdatum_t datum)

Parameter Type Description
datum textdatum_t (*1) Text Datum

*1. About TextDatum

setTextScroll

Enable/Disable text scrolling.

Syntax:

void setTextScroll(bool scroll)

Parameter Type Description
scroll bool scroll mode

setTextSize

Set text size.

Syntax:

void setTextSize(float size) | Parameter | Type | Description | | ---------- | -------------- | -------------------------------- | | size | float | text size |

void setTextSize(float sx, float sy) | Parameter | Type | Description | | ---------- | -------------- | -------------------------------- | | sx | float | text size X | | sy | float | text size Y |

setTextStyle

Set text style.

Syntax:

void setTextStyle(TextStyle textstyle)

Parameter Type Description
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.

Syntax:

void setTextWrap(bool wrapX, bool wrapY = false)

Parameter Type Description
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() .

Syntax:

void setTouchCalibrate(uint16_t *parameters)

Parameter Type Description
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.

Syntax:

void setWindow(uint_fast16_t xs, uint_fast16_t ys, uint_fast16_t xe, uint_fast16_t ye)

Parameter Type Description
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.

Syntax:

void showFont(uint32_t msec)

Parameter Type Description
msec uint32_t display time(msec)

sleep

Sleeps the panel. Wakeup is wakeup()

Syntax:

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.

Syntax:

void startWrite()

swap565

Function to get the swapped color code when changing it directly by getBuffer() since the sprite has swapped color data.

Syntax:

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.

Syntax:

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.

Syntax:

int32_t textLength(const char *string, int32_t width)

Parameter Type Description
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().

Syntax:

uint32_t textWidth(const char *string)

Parameter Type Description
string const char* String

uint32_t textWidth(const char *string, IFont *font)

Parameter Type Description
string const char* String
font IFont (*1) font

#1. About font

touch

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

Syntax:

ITouch* touch()

unloadFont

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

Syntax:

void unloadFont()

waitDisplay

Wait until display is released.

Syntax:

void waitDisplay()

waitDMA

Wait until DMA is released.

Syntax:

void waitDMA()

wakeup

Wake up the slept panel device. sleep()

Syntax:

void wakeup()

width

Returns the width of the panel.

Syntax:

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)

Parameter Type Description
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

Syntax:

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

Syntax:

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

Syntax:

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

Syntax:

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

Syntax:

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

Syntax:

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

Syntax:

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

Syntax:

void writeIndexedPixels(const uint8_t* data, T* palette, int32_t len, uint8_t depth = 8)

Parameter Type Description
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

Syntax:

void writePixels(T* data, int32_t len)

Parameter Type Description
data T* Image data
len int32_t Data length

void writePixels(T* data, int32_t len, bool swap)

Parameter Type Description
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

Syntax:

void writePixels(T* data, int32_t len)

Parameter Type Description
data T* Image data
len int32_t Data length

void writePixels(T* data, int32_t len, bool swap)

Parameter Type Description
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

Syntax:

void writePixels(T* data, int32_t len)

Parameter Type Description
data T* Image data
len int32_t Data length

void writePixels(T* data, int32_t len, bool swap)

Parameter Type Description
data T* Image data
len int32_t Data length
swap bool Swap bytes
On This Page