Initialize for use
Syntax:
void begin()
Initiate a panel transaction.
Syntax:
void beginTransaction()
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 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:
}
Clear the coordinates specified by setClipRect() .
Syntax:
void clearClipRect()
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 |
Clear the coordinates specified by setScrollRect() .
Syntax:
void clearScrollRect()
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 |
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 |
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 |
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 |
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 |
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 |
Convert color code from RGB332 to RGB565.
Syntax:
uint16_t color8to16(uint8_t rgb332)
Parameter | Type | Description |
---|---|---|
rgb332 | uint8_t | ColorCode of RGB332 |
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 |
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 |
Screenshot function. Executing this function saves the data displayed in the panel to memory in PNG format.
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 to the panel.(for M5Paper, CoreInk, OLEDUnit)
Syntax:
void display()
Check if the panel is Busy.
Syntax:
bool displayBusy()
Check if the panel's DMA is busy.
Syntax:
bool dmaBusy()
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() {
}
Draws a Bezier curve, available in two types: 3-point and 4-point.
Syntax:
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 |
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() {
}
Draw bitmap data. File or HTTPStream can be specified for data.
Syntax:
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
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
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
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
Displays a BMP image of the specified URL.
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
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
Draw an unicode character.
Syntax:
size_t drawChar(uint16_t uniCode, int32_t, x, int32_t y, uint8_t font)
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 |
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 |
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
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
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
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
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 |
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 |
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 |
Draw JPG data. File or HTTPStream can be specified for data.
Syntax:
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
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
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
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
Draw an JPG image from URL.
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
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
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
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
Draw PNG data. File or HTTPStream can be specified for data.
Syntax:
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
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
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
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
Draw a PNG image from URL.
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
Draw Qoi data. File or HTTPStream can be specified for data.
Syntax:
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
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
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
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
Draw a Qoi image from URL.
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
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 |
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
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 |
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() {
}
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
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 |
It is pared with startTransaction()
Syntax:
void endTransaction()
It is paired with startWrite() .
Syntax:
void endWrite()
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
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() {
}
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
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
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
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 |
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()
{
}
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()
{
}
Fill the screen.
Syntax:
Parameter | Type | Description |
---|---|---|
color | const T | color(*1) |
*1. About ColorCode
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
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 |
Returns the height of the specified font.
int32_t fontHeight(uint8_t font)
Parameter | Type | Description |
---|---|---|
font | IFont* (*1) | font |
*1. About Fonts
Returns the width of the specified font.
int32_t fontHeight(uint8_t font)
Parameter | Type | Description |
---|---|---|
font | IFont* (*1) | font |
*1. About Fonts
Get the attribute.
Syntax:
uint8_t getAttribute(attribute_t attr_id)
Get the color value set by setBaseColor() .
Syntax:
uint32_t getBaseColor()
Get Board.
Syntax:
uint8_t getBoard()
*1. enum board_t
Get the value set by setBrightness .
Syntax:
uint8_t getBrightness()
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)
Get the value set by setColorDepth() .
Syntax:
color_depth_t getColorDepth()
*1. About ColorDepth
Get current cursor X position.
Syntax:
int32_t getCursorX()
Get current cursor Y position.
Syntax:
int32_t getCursorY()
Get the value set by setEpdMode() .(M5Paper only)
Syntax:
epd_mode_t getEpdMode()
*1. epd_mode_t
Get the font set by setFont() .
const IFont* getFont()
*1. about font
Get an instance of M5GFX.
Syntax:
M5GFX* getInstance()
Get the value set by invertDisplay() Get Invert value of the panel.
Syntax:
bool getInvert()
Get palette information.
Syntax:
RGBColor* getPalette()
Get count of palette.
Syntax:
uint32_t getPaletteCount()
Get panel of device.
Syntax:
Panel_Device* getPanel()
Get X value set by setPivot
Syntax:
float getPivotX()
Get Y value set by setPivot
Syntax:
float getPivotY()
Get the value set by setRawColor() .
uint32_t getRawColor()
Get the value set by setRotation()
uint8_t getRotation()
Get information about the setScrollRect() .
void getScrollRect(int32_t *x, int32_t *y, int32_t *w, int32_t *h)
Get the count of the panel has startWrite() .
uint32_t getStartCount()
Get status of setSwapBytes() .
bool getSwapBytes()
Get TextDatum. setTextDatum()
Syntax:
textdatum_t getTextDatum()
*1. About TextDatum
Get TextPadding.
Syntax:
uint32_t getTextPadding()
Get the width set by setTextSize() .
Syntax:
float getTextSizeX()
Get the height set by setTextSize() .
Syntax:
float getTextSizeY()
Get the information set by setTextStyle() .
Syntax:
TextSytle& getTextStyle()
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 |
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 |
Whether a color palette exists.
Syntax:
bool hasPalette()
Get height of panel.
Syntax:
int_fast16_t height()
Initialize panel.
Syntax:
void init()
Initialize DMA.
Syntax:
void initDMA
Set whether the brightness and color tones of the screen are inverted for output. (Negative-Positive Invert)
Syntax:
void invertDisplay(bool invert)
Whether Bus is shared.
Syntax:
bool isBusShared()
Whether Panel is an EPD.
Syntax:
bool isEPD()
Whether Panel is readable or not.
Syntax:
bool isReadable()
Whether SPI Bus is shared.
Syntax:
bool isSPIShared()
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 |
Same function floodFill() .
Syntax:
void paint(int32_t x, int32_t y, const T& color)
Get panel of device.
Syntax:
Panel_Device* panel()
Temporarily saves text information. Restore is done by pushState() .
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()
Set the status of powerSave.
Syntax:
void powerSave(bool flg)
Parameter | Type | Description |
---|---|---|
flg | bool |
Set the status of powerSave to Off.
Syntax:
void powerSaveOff()
Set the status of powerSave to On.
Syntax:
void powerSaveOn()
Output text at the cursor position. Arduino Print.h compatible.
Syntax:
size_t print(...)
Output text at the cursor position. Arduino LibPrint.h compatible.
Syntax:
size_t printf(...)
Output text at the cursor position. Arduino Print.h compatible.
Syntax:
size_t print(...)
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) |
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()
{
}
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Restore the text information that had been temporarily retired with popState() .
Syntax:
void pushState()
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) |
Reads 16 bits of data from the panel
Syntax:
uint16_t readData16(uint8_t index=0)
Reads 32 bits of data from the panel
Syntax:
uint32_t readData32(uint8_t index=0)
Reads 8 bits of data from the panel
Syntax:
uint8_t readData8(uint8_t index=0)
Reads the color code of the specified coordinates. Color code is RGB565.
Syntax:
uint16_t readPixel(int32_t x, int32_t y)
Reads the color code of the specified coordinates. Color code is RGB888.
Syntax:
RGBColor readPixelRGB(int32_t x, int32_t y)
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)
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 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);
}
}
Specifies the rectangle range to which writePixels() , pushPixels() , etc. are to be drawn.
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 |
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)
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
Specifies the brightness of the display panel.
Syntax:
void setBrightness(uint8_t brightness)
Parameter | Type | Description |
---|---|---|
brightness | unit8_t | display brightness |
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)
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
Specify ColorDepth
void setColorDepth(int32_t bits)
Parameter | Type | Description |
---|---|---|
bits | int | ColorDepth |
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 |
Set EpdMode.
void setEpdMode(epd_mode_t epd_mode)
Parameter | Type | Description |
---|---|---|
epd_mode | epd_mode_t(*1) | epd mode |
*1. About EpdMode
Specify the font for Text.
Syntax:
void setFont(const IFont *font)
Parameter | Type | Description |
---|---|---|
font | IFont (*1) | font |
*1. About Font
Specifies the coordinates of Pivot.
notice:
The reason the argument is real (float) is that pivot is specified to indicate the center of the pixel. Rotation is offset by +0.5 pixels to the lower right. Therefore, an offset of -0.5 with setPivot will result in an offset.
Syntax:
void setPivot(float x, float y)
Parameter | Type | Description |
---|---|---|
x | float | point x |
y | float | point y |
Set raw color.
Syntax:
void setRawColor(uint32_t color)
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 |
Rotate Screen
Syntax:
void setRotation(uint8_t m)
Function parameter:
Parameter | Description | Type |
---|---|---|
m | uint8_t | Rotate angle ( * 90°) |
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() {}
Specifies the range within which the text will scroll.
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);
}
Set swap bytes.
Syntax:
void setSwapBytes(bool swap)
Set TextColor.
Syntax:
void setTextColor(const T &color)
Parameter | Type | Description |
---|---|---|
color | T (*1) | Base color |
*1. About ColorCode
Set TextDatum.
Syntax:
void setTextDatum(textdatum_t datum)
Parameter | Type | Description |
---|---|---|
datum | textdatum_t (*1) | Text Datum |
*1. About TextDatum
Enable/Disable text scrolling.
Syntax:
void setTextScroll(bool scroll)
Parameter | Type | Description |
---|---|---|
scroll | bool | scroll mode |
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 |
Set text style.
Syntax:
void setTextStyle(TextStyle textstyle)
Parameter | Type | Description |
---|---|---|
textstyle | TextStyle (*1) | Text Style |
*1. about TextStyle
X-axis is whether or not the turnaround is performed. Y-axis is whether to return to the top after reaching the bottom line.
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);
}
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] |
Specifies the rectangle range to which writePixels() , pushPixels() , etc. are to be drawn.
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 |
Display the specified time font.
Syntax:
void showFont(uint32_t msec)
Parameter | Type | Description |
---|---|---|
msec | uint32_t | display time(msec) |
Sleeps the panel. Wakeup is wakeup()
Syntax:
void sleep()
Asserted CS on SPI bus.It is paired with endWrite() . Declaring startWrite() allows the M5GFX to use the DMA buffer efficiently.
Syntax:
void startWrite()
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)
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)
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 |
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
If a touch device is present, return the ITouch pointer.
Syntax:
ITouch* touch()
Restore font set by setFont() to the default font(&fonts::Font0).
Syntax:
void unloadFont()
Wait until display is released.
Syntax:
void waitDisplay()
Wait until DMA is released.
Syntax:
void waitDMA()
Wake up the slept panel device. sleep()
Syntax:
void wakeup()
Returns the width of the panel.
Syntax:
int32_t width()
Draw lines in the rectangular area allocated by setWindow() or setAddrWindow() , specifying the color and length of each line.
void writeColor(const T &color, uint32_t length)
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()
{
}
Writes commands(16bit) to the panel.
Syntax:
void writeCommand(uint16_t cmd)
Writes data(16bit) to the panel.
Syntax:
void writeCommand(uint16_t data)
Writes data(32bit) to the panel.
Syntax:
void writeCommand(uint32_t data)
Writes data(8bit) to the panel.
Syntax:
void writeCommand(uint8_t data)
Draw a horizontal line within the clipped area.
Syntax:
void writeFastHLine(int32_t x, int32_t y, int32_t w)
Draw a vertical line within the clipped area.
Syntax:
void writeFastVLine(int32_t x, int32_t y, int32_t h)
Draw a rectangle within the clipped area.
Syntax:
void writefillRect(int32_t x, int32_t y, int32_t w, int32_t h)
Draw image data using a color palette.
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 |
Draw a pixel within the clipped area.
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 |
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.
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 |
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.
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 |