LCD スクリーン

Core2 屏幕像素为 320x240,以屏幕左上角为原点 (0,0)

カラーコードです:

定義します 16 進値です R G B
BLACK 0x0000 0 0 0
NAVY 0x000F 0 0 128
DARKGREEN 0x03E0 0 128 0
MAROON 0x7800 128 0 0
PURPLE 0x780F 128 0 128
OLIVE 0x7BE0 128 128 0
LIGHTGREY 0xC618 192 192 192
DARKGREY 0x7BEF 128 128 128
BLUE 0x001F 0 0 255
GREENYELLOW 0xB7E0 180 255 0
GREEN 0x07E0 0 255 0
YELLOW 0xFFE0 255 255 0
ORANGE 0xFDA0 255 180 0
PINK 0xFC9F 255 255 16
CYAN 0x07FF 0 255 255
DARKCYAN 0x03EF 0 128 128
RED 0xF800 255 0 0
MAGENTA 0xF81F 255 0 255
WHITE 0xFFFF 255 255 255

クラス名: Lcd

begin()

機能です:

初期化して使用

原型関数です:

void begin()

注意:
M5.begin()を使わないで LCD を初期化したい場合は、ディスプレイを使う前にこの関数を呼び出してください 使用例です:
#include <M5Core2.h>

void setup() {
  M5.Lcd.begin();  //初始化 M5Stack
}

void loop() {
}

sleep()

機能です:

ディスプレイを省エネモードに切り替え

原型関数です:

void sleep()

使用例です:

#include <M5Core2.h>

void setup() {
  M5.Lcd.begin();  //初始化 M5Core2
  M5.Lcd.sleep();    //切换至休眠模式
}

void loop() {
}

clear()

機能です:

ディスプレイ上の内容をクリア

原型関数です:

void clear()

使用例です:

#include <M5Core2.h>

void setup() {
  M5.Lcd.begin();  //初始化 M5Core2
  M5.Lcd.fillScreen(RED);
  delay(1000);
  M5.Lcd.clear();    //清空显示屏所显示的内容
}

void loop() {
}

wakeup()

機能です:

省エネモードからディスプレイを復元

原型関数です:

void wakeup()

使用例です:

#include <M5Core2.h>

void setup() {
  M5.Lcd.begin();  //初始化 M5Core2
  M5.Lcd.wakeup();    //从节能模式恢复显示
}

void loop() {
}

hight()

機能です:

画面の高さを返す

原型関数です:

void hight()

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();   //初始化 M5Core2
  M5.Lcd.print(M5.Lcd.height());    //在屏幕上显示屏幕的高度
}

void loop() {
}

width()

機能です:

画面の幅を返す

原型関数です:

void width()

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();   //初始化 M5Core2
  M5.Lcd.print(M5.Lcd.width());    //在屏幕上显示屏幕的宽度
}

void loop() {
}

getCursorX()

機能です:

文字列の末尾の x 座標を取得

原型関数です:

int16_t getCursorX()

注意:
drawNumber()は適用できません

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.print("Hello");
  int X = M5.Lcd.getCursorX();
  M5.Lcd.print(X);
}

void loop(){
}

getCursorY()

機能です:

文字列の末尾の y 座標を取得

原型関数です:

int16_t getCursorY()

注意:
drawNumber()は適用できません

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.print("Hello");
  int X = M5.Lcd.getCursorY();
  M5.Lcd.print(Y);
}

void loop(){
}

getRotation()

機能です:

画面の回転方向ですを返す

原型関数です:

uint8_t getRotation()

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.print(M5.Lcd.getRotation());    //在屏幕上输出屏幕的旋转方向です
}

void loop(){
}

getTextDatum()

機能です:

文字のアライメント方式を返す(上のリスト中のアライメント番号)

原型関数です:

textdatum_t getRotation()

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.setTextDatum(MC_DATUM);    //设置文字的对齐方式
  M5.Lcd.drawString("hello", 160, 120, 2);    //在(160,120)处以2号字体打印字符串hello
  M5.Lcd.print(M5.Lcd.getTextDatum());    //屏幕打印获取到的文字对齐方式
}

void loop(){
}

setCursor()

機能です:

文字のカーソルを(x,y)にセット

原型関数です:

void setCursor(int16_t x, int16_t y)

パラメータです タイプです タイプです
x int16_t x 座標(ピクセル)です
y int16_t y 座標(ピクセル)です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();             //初始化 M5Core2
  M5.Lcd.setCursor(0, 30);
  M5.Lcd.printf("Hello M5");
}

void loop() {}

setRotation()

機能です:

画面を回転

原型関数です:

void setRotation(uint8_t m)

パラメータです タイプです 記述します
m uint8_t 回転角度です ( * 90°)
注意:
1. 回転角度は 90° の倍数
0-3 は時計回り、4-7 は反時計回り(デフォルトは 1)
3. 表示前にセットする必要がある

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();             //初始化 M5Core2
  M5.Lcd.setRotation(2);  //将屏幕顺时针旋转180度(2*90)
  M5.Lcd.fillEllipse(160, 100, 60, 100, YELLOW);    //在(160,100)处创建一个长轴,短轴分别为60,100黄色椭圆
  delay(1000);
  M5.Lcd.setRotation(1);  //将屏幕恢复为默认显示状态
  M5.Lcd.fillEllipse(160, 100, 60, 100, GREEN);
}

void loop() {}

SetLcdVoltage()

機能です:

画面の明るさをセット

原型関数です:

void SetLcdVoltage(uint16_t voltage)

パラメータです タイプです 記述します
voltage uint16_t 電圧値です
注意:
電圧値の範囲は(2500~3300)

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();
  M5.Lcd.fillScreen(RED);
}
void loop() {
  M5.update();
  for(int i=2500; i<3300;i++){
    M5.Axp.SetLcdVoltage(i);  //每隔10ms设置一次電圧値です
    delay(10);
  }
  for(int i=3300; i>2500;i--){
    M5.Axp.SetLcdVoltage(i);
    delay(10);
  }
}

alphaBlend()

機能です:

透明度をセット、前景と背景色を混ぜ

原型関数です:

uint16_t alphaBlend(uint8_t alpha, uint16_t fgc, uint16_t bgc)

パラメータです 記述します タイプです
alpha uint8_t 透明性です
fgc uint16_t 前の景色です
bgc uint16_t 背景色です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.Lcd.begin();  //初始化 M5Core2
  M5.Lcd.fillScreen(M5.Lcd.alphaBlend(128, 0X00FF00, 0XFF0000));
  //设置前景、背景色分别为0X00FF00,0XFF0000 透明度为128,并填充至整个屏幕
}

void loop() {
}

setFreeFont()

機能です:

使用する GFX フォントをセット

原型関数です:

void setFreeFont(const GFXfont *f)

パラメータです タイプです 説明します
GFXfont *f const フォント名です

使用例です:

loadFont()

機能です:

VLW ファイルからフォントをロード

原型関数です:

void loadFont(String fontName, bool flash)

パラメータです タイプです 説明します
fontName String フォント名です
flash bool 文書の出所です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.loadFont("filename", SD);
}

void loop() {
}

unloadFont()

機能です:

フォントをアンロード

原型関数です:

void unloadFont()

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.unloadFont();
}

void loop() {
}

fontsLoaded()

機能です:

独自のフォントをロードしたかどうかを返す

原型関数です:

uint16_t fontsLoaded(void)

戻り値です:

表示フォントのエンコードの 16 進数値を返す

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.print(M5.Lcd.fontsLoaded());
}

void loop() {
}

fillScreen()

機能です:

指定の色で画面全体を塗りつくす

原型関数です:

void fillScreen(uint32_t color)

パラメータです タイプです 記述します
color uint32_t カラー値です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.fillScreen(RED);    //在屏幕上填充红色
}

void loop(){
}

invertDisplay()

機能です:

正/負方式で画面色を反転

原型関数です:

void invertDisplay(boolean i)

パラメータです タイプです 説明します
i boolean 反转时为 true

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.fillScreen(RED);    //在屏幕上填充红色
}

void loop() {
  M5.Lcd.invertDisplay(1);    //开启反转
  delay(1000);
  M5.Lcd.invertDisplay(0);    //关闭反转
}

color565()

機能です:

関数中で使用する色コード(rgb 565)を変更

原型関数です:

color565(uint8_t red, uint8_t green, uint8_t blue)

パラメータです タイプです 記述します
red uint8_t 赤です
green uint8_t 緑です
blue uint8_t ブルーです

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  uint16_t colorvalue = 0;
  colorvalue = color565(255, 255, 255);
  M5.Lcd.fillEllipse(160, 100, 60, 100, colorvalue);
}

void loop() {}

Text

print()

機能です:

画面の当前位置に文字列を印刷

原型関数です:

size_t print()

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.print("this is a print text function");
}

void loop() {
}

textWidth()

機能です:

文字が占めるピクセル幅を返す

原型関数です:

int16_t textWidth(const String& string)

パラメータです タイプです 記述します
string const String& 文字列です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();   //初始化 M5Core2
  String text = "hello  ";
  M5.Lcd.print(text);
  M5.Lcd.print(M5.Lcd.textWidth(text));    //在屏幕上打印字符串数组text所占像素宽度
}

void loop() {}

setTextSize()

機能です:

表示文字のサイズをセット

原型関数です:

void setTextSize(uint8_t s)

パラメータです タイプです 記述します
s uint8_t 文字の大きさです (1~7)

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.setTextSize(4);    //设置字体大小为4
  M5.Lcd.print("Hello M5Core2");
}

void loop() {
}

setTextColor()

機能です:

表示テキストの前の景色ですをセット / 表示テキストの前の景色ですと背景色をセット

原型関数です:

void setTextColor(uint16_t color)

void setTextColor(uint16_t color, uint16_t backgroundcolor)

パラメータです タイプです 記述します
color uint16_t テキストの前景の色です
backgroundcolor uint16_t テキストの背景色です
注意:
1.関数の backgroundcolor の値が指定されていない場合は、現在の背景色を使用
2.文字色をセットしなければ、デフォルトは白色

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin(); //初始化 M5Core2
  M5.Lcd.setTextColor(RED,BLACK);    //设置文本的前、背景色分别为红色和黑色
  //M5.Lcd.setTextColor(RED);
}

void loop(){
}

setTextWrap()

機能です:

自動改行機能をセット

原型関数です:

void setTextWrap(boolean wrapX, boolean wrapY)

パラメータです タイプです 記述します
wrapX boolean X 方向です(デフォルトで開いています)
wrapY boolean Y 方向です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();   //初始化 M5Core2
  M5.Lcd.setTextWrap(true, true);    //开启x、y轴自动换行
    M5.Lcd.print("hello M5Core2 hello M5Core2 hello M5Core2 hello M5Core2 hello M5Core2 hello M5Core2 hello M5Core2 hello M5Core2");
}

void loop() {}

setTextPadding()

機能です:

指定の空白幅を埋める(古いテキストと数字を消去に役立つ)

原型関数です:

void setTextPadding(uint16_t x_width)

パラメータです タイプです 記述します
x_width uint16_t 空白領域幅です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();
}

void loop() {
  M5.Lcd.drawString("Orbitron 32", 160, 60, 2);
  delay(2000);
  M5.Lcd.setTextPadding(M5.Lcd.width() - 20);
  M5.Lcd.drawString("Orbitron 32 with padding", 160, 60, 2);
  delay(2000);
}

setTextDatum()

機能です:

テキストのアライメント方式をセット

原型関数です:

void setTextDatum(uint8_t datum)

パラメータです タイプです 記述します
TL_DATUM (0) uint8_t 左上角のアライメント (既定)
TC_DATUM (1) uint8_t 中央上部のアライメント
TR_DATUM (2) uint8_t 右上角のアライメント
ML_DATUM (3) uint8_t 中央左のアライメント
MC_DATUM (4) uint8_t 中央のアライメント
MR_DATUM (5) uint8_t 中央右のアライメント
BL_DATUM (6) uint8_t 左下角のアライメント
BC_DATUM (7) uint8_t 中央下部のアライメント
BR_DATUM (8) uint8_t 右下角のアライメント
L_BASELINE (9) uint8_t 左文字のベースライン
C_BASELINE (10) uint8_t 中央文字のベースライン
R_BASELINE (11) uint8_t 右文字のベースライン
注意:
1.print()には適用されません

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.setTextDatum(MC_DATUM);    //设置文本对齐方式为中心对齐
  M5.Lcd.drawString("hello", 160, 120, 2);    //在(160,120)处以2号字体打印字符串hello
}

void loop(){
}

Draw

drawFastHLine()

機能です:

(X,Y)位置に長さ w の color 色の水平線を描く

原型関数です:

void drawFastHLine(int32_t x, int32_t y, int32_t w, uint32_t color)

パラメータです タイプです 機能です
x int32_t 座標 X です
y int32_t 座標 Y です
w int32_t 幅(ピクセル)です
color uint32_t ラインカラー(オプション)です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.drawFastHLine(3, 100, 255, GREEN);    //在(3,100)处划一条长度为255的绿色水平线条
}

void loop() {
}

drawFastVLine()

機能です:

(X,Y)位置に長さ w の color 色の垂直線を描く

原型関数です:

void drawFastVLine(int32_t x, int32_t y, int32_t w, uint32_t color)

パラメータです タイプです 機能です
x int32_t 座標 X です
y int32_t 座標 Y です
w int32_t 幅(ピクセル)です
color uint32_t ラインカラー(オプション)です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.drawFastVLine(100, 0, 255, TFT_GREEN);    //在(100,0)处划一条长度为255的绿色垂直线条
}

void loop(){
}

drawString()

機能です:

(x,y)位置に文字列を表示

原型関数です:

int16_t drawString(const char *string, int32_t poX, int32_t poY, uint8_t font)

パラメータです タイプです 記述します
string const char * 文字列です
poX int32_t X 座標です
poY int32_t Y 座標です
font uint8_t フォントです

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.drawString("Hello M5", 160, 100, 2);    //在(160,100)处以2号字体显示字符串Hello M5
}

void loop(){
}

drawNumber()

機能です:

(x,y)位置に整数を表示

原型関数です:

void drawNumber(long long_num, int32_t poX, int32_t poY)

パラメータです タイプです 記述します
long_num long 数字です
poX int32_t X 座標です
poY int32_t Y 座標です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.drawNumber(99, 55, 100);    //在(99,55)处显示整数100
}

void loop(){
}

drawChar()

機能です:

(X,Y)位置に font フォントで文字を表示

原型関数です:

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

パラメータです タイプです 記述します
uniCode int16_t 文字です
x int32_t X 座標です
y uint16_t Y 座標です
font uint8_t フォントです

使用例です:

#include <M5Core2.h>
void setup() {
  M5.begin(); //初始化 M5Core2
  M5.Lcd.drawChar('A', 160, 120, 2);    //在(160,120)处以字体2显示字符A
}
void loop(){
}

drawFloat()

機能です:

(X,Y)位置に小数点以下 dp 位の浮動小数点数 floatNumber を表示

原型関数です:

int16_t drawFloat(float floatNumber, uint8_t dp, int32_t poX, int32_t poY)

パラメータです タイプです 記述します
floatNumber float 表示する小数
dp uint8_t 小数点の桁数
poX int32_t x 位置で表示
poY int32_t Y 位置で表示

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();   //初始化 M5Core2
  M5.Lcd.drawFloat(3.1415928,7,100,100);    //在(100,100)处显示小数点后7位的浮点数3.1415928
}

void loop() {}

drawPixel()

機能です:

(X,Y)位置に点を描く

原型関数です:

void drawPixel(int32_t x, int32_t y, uint32_t color)

参数:

パラメータです タイプです 記述します
x int32_t X 座標です
y int32_t Y 座標です
color uint32_t 色です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.drawPixel(22,22,RED);    //在(22,22)处画一个红色的像素点
}

void loop() {}

drawLine()

機能です:

点(x0,y0)から点(x1,y1)まで指定色(color)で直線を描く

原型関数です:

void drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t color)

パラメータです タイプです 記述します
x int32_t X 座標です
y int32_t Y 座標です
color uint32_t 色です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.drawLine(200, 0, 200,2000,GREEN);    //从点(200,0)到点(200,200)以绿色绘制直线
}

void loop(){
}

drawRect()

機能です:

(x,y)位置に指定色で幅 width と高さ height の矩形の線枠を描く

原型関数です:

void drawRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)

パラメータです タイプです 記述します
x int32_t X 座標です
y int32_t Y 座標です
w int32_t 矩形枠の幅(単位:ピクセル)
h int32_t 矩形枠の高さ(単位:ピクセル)
color uint32_t カラー値です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.drawRect(180, 12, 122, 10, BLUE);    //在(180,12)处以蓝色绘制宽高分别为122和10的矩形线框
}

void loop(){
}

fillRect()

機能です:

(x,y)位置に指定色で幅 width と高さ height の矩形を塗りつくす

原型関数です:

void fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)

パラメータです タイプです 記述します
x int32_t X 座標です
y int32_t Y 座標です
w int32_t 矩形枠の幅(単位:ピクセル)
h int32_t 矩形枠の高さ(単位:ピクセル)
color uint32_t カラー値です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.fillRect(150, 120, 122, 10, BLUE);    //在(150,120)处绘制一个长122、宽为10的蓝色填充矩形
}

void loop(){
}

drawRoundRect()

機能です:

(x,y)位置に幅 width、高さ height の角丸矩形の線枠を描く、角丸の半径は radius、色は color

原型関数です:

void drawRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, uint32_t color)

パラメータです タイプです 記述します
x int32_t 左上の X 座標です
y int32_t 左上の Y 座標です
w int32_t 長方形(ピクセル)です
h int32_t 長方形の高さです
r int32_t 角半径 f です
color uint32_t 四角の色です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();   //初始化 M5Core2
  M5.Lcd.drawRoundRect(55,55,30,50,10,GREEN);    //在(55,55)处绘制宽高分别为3050的圆角半径为10,颜色为绿色的圆角矩形线框

void loop() {}

fillRoundRect()

機能です:

(x,y)位置に幅 width、高さ height の角丸矩形の線枠を描く、角丸の半径は radius、色は color

原型関数です:

void fillRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, uint32_t color)

パラメータです タイプです 記述します
x int32_t 左上の X 座標です
y int32_t 左上の Y 座標です
w int32_t 長方形(ピクセル)です
h int32_t 長方形の高さです
r int32_t 角半径 f です
color uint32_t 四角の色です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();   //初始化 M5Core2
  M5.Lcd.fillRoundRect(55, 55, 30, 50, 10, GREEN);//在(55,55)处绘制宽高分别为30、50的圆角半径为10,颜色为绿色的圆角矩形
}

void loop() {}

drawCircle()

機能です:

(x,y)位置に半径 r の color 色の円の線枠を描く

原型関数です:

void drawCircle(int32_t x0, int32_t y0, int32_t r, uint32_t color)

参数:

パラメータです タイプです 記述します
x0 int32_t 圆中心 X 座標です
y0 int32_t 円の中心の Y 座標です
r int32_t 円の半径です
color uint32_t 円の色です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();   //初始化 M5Core2
  M5.Lcd.drawCircle(100, 100, 50, RED);   //在(x,y)处绘制半径为50的红色圆线圈
}

void loop() {}

fillCircle()

機能です:

(x,y)位置に半径 r の color 色の円を塗りつくす

原型関数です:

void drawCircle(int32_t x0, int32_t y0, int32_t r, uint32_t color)

参数:

パラメータです タイプです 記述します
x0 int32_t 圆中心 X 座標です
y0 int32_t 円の中心の Y 座標です
r int32_t 円の半径です
color uint32_t 円の色です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();   //初始化 M5Core2
  M5.Lcd.fillCircle(100, 100, 50, RED); //在(x,y)处绘制半径为50的填充红色圆
}

void loop() {}

drawEllipse()

機能です:

(x,y)位置に幅、高さそれぞれ rx,ry の楕円の線枠を描く

原型関数です:

void fillEllipse(int16_t x0, int16_t y0, int32_t rx, int32_t ry, uint16_t color)

参数:

パラメータです タイプです 記述します
x0 int16_t 楕円の中心 X 座標です
y0 int16_t 楕円の中心の Y 座標です
rx int32_t 楕円の幅(画素)です
ry int32_t 楕円の高さ(画素)です
color uint16_t 楕円の色です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();   //初始化 M5Core2
  M5.Lcd.drawEllipse(160, 100, 60, 100, YELLOW);//在(160,100)处绘制颜色为黄色的宽度、高度分别为60,100的椭圆轮廓线
}

void loop() {}

fillEllipse()

機能です:

(x,y)位置に幅、高さそれぞれ rx,ry の楕円を塗りつくす

原型関数です:

void fillEllipse(int16_t x0, int16_t y0, int32_t rx, int32_t ry, uint16_t color)

参数:

パラメータです タイプです 記述します
x0 int16_t 楕円の中心 X 座標です
y0 int16_t 楕円の中心の Y 座標です
rx int32_t 楕円の幅(画素)です
ry int32_t 楕円の高さ(画素)です
color uint16_t 楕円の色です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.fillEllipse(160, 100, 60, 100, YELLOW);    //在(160,100)处绘制颜色为黄色的宽度、高度分别为60,100的填充黄色椭圆
}

void loop() {}

drawTriangle()

機能です:

(x1, y1) (x2, y2) (x3, y3)を頂点に三角形の線枠を描く

原型関数です:

void drawTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t color)

パラメータです タイプです 記述します
x* int32_t 頂点 X*の X 座標です
y* int32_t 頂点 Y*の X 座標です
color uint32_t 三角形の色です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();   //初始化 M5Core2
  M5.Lcd.drawTriangle(30, 30, 180, 100, 80, 150, YELLOW); //以 (30,30) (180,100) (80,150)为顶点绘制黄色三角形线框
}

void loop() {}

drawTriangle()

機能です:

(x1, y1) (x2, y2) (x3, y3)を頂点に三角形を塗りつくす

原型関数です:

void drawTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t color)

パラメータです タイプです 記述します
x* int32_t 頂点 X*の X 座標です
y* int32_t 頂点 Y*の X 座標です
color uint32_t 三角形の色です

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();   //初始化 M5Core2
  M5.Lcd.drawTriangle(30, 30, 180, 100, 80, 150, YELLOW); //以 (30,30) (180,100) (80,150)为顶点绘制填充黄色三角形
}

void loop() {}

drawXBitmap()

機能です:

ビットマップを描く

原型関数です:

void drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color)

パラメータです タイプです 記述します
x int16_t 座標 X です
y int16_t 座標 Y です
bitmap const uint8_t 画像を示します
w int16_t 幅(ピクセル)です
h int16_t 高さ(ピクセル)です
color uint16_t 色です

使用例です:

使用例 sketch:->->->を参照:M5Stack->Advanced->Display->drawXBitmap

drawBitmap()

機能です:

ビットマップを描く

原型関数です:

drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, const uint16_t *data)

drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, uint16_t *data)

drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, const uint16_t *data, uint16_t transparent)

drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, const uint8_t *data)

drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, uint8_t *data)

パラメータです タイプです 記述します
x0 uint16_t 座標 X です
y0 uint16_t 座標 Y です
w int16_t 幅(ピクセル)です
h int16_t 高さ(ピクセル)です
data uint16_t* / uint8_t* 画像のデータ
transparent uint16_t 透明色のコード
注意:
色コードは合計 16 ビットで表示:赤は 5 ビット、緑は 6 ビット、上の青は 5 ビット

使用例です:

使用例 sketch:->->を参照:M5Stack->games->Tetris

drawBmpFile()

機能です:

ファイルからビットマップを読み込み描画

原型関数です:

drawBmpFile(fs::FS &fs, const char *path, uint16_t x, uint16_t y)

パラメータです タイプです 記述します
fs fs::FS ファイルストリーム
path const char* ファイルのパス(SD、SPIFFS)
x int16_t 座標 X です
y int16_t 座標 Y です
注意:
1.サイズとビット数の問題で拡張できない可能性あり
2. Arduino ESP32 filesystem uploader を事前にインストールする必要がある

使用例です:

#include "FS.h"
//#include "SPIFFS.h"
#include <M5Core2.h>
void setup(){
    M5.begin(true, false, false, false);
  M5.Lcd.drawBmpFile(SD, "/p2.bmp",0,0);
  //M5.Lcd.drawBmpFile(SPIFFS, "/p2.bmp", 0, 0);
}

画像->ファイルの変換に使用できるスクリプトを提供、一部の画像を変換し、上記の API を使って画面に描画できる bin2code.py

drawJpg()

機能です:

メモリから JPEG 形式の画像データを読み込み描画

原型関数です:

void drawJpg(const uint8_t *jpg_data, size_t jpg_len, uint16_t x,uint16_t y, uint16_t maxWidth, uint16_t maxHeight,uint16_t offX, uint16_t offY, jpeg_div_t scale) {

パラメータです タイプです 記述します
jpg_data uint8_t* データの先頭
jpg_len size_t データの長さ
x uint16_t 座標 X です
y uint16_t 座標 Y です
maxWidth uint16_t 最大幅(ピクセル)です
maxHeight uint16_t 最大高さ(ピクセル)です
offX uint16_t オフセット X(ピクセル)
offY uint16_t オフセット Y(ピクセル)
scale jpeg_div_t 縮尺

仕様 (jpeg_div_t):

定義します 機能です
JPEG_DIV_NONE
JPEG_DIV_2 1/2
JPEG_DIV_4 1/4
JPEG_DIV_8 1/8
JPEG_DIV_MAX MAX
注意:
1.サイズ、ビット数、形式(漸進等)の問題で拡張できない可能性あり
2. tetris_img をダウンロード

使用例です:

#include <M5Core2.h>
extern uint8_t tetris_img[];    //引用存储图像的数组,需要提前和 xxx.ino放在同一文件夹中

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.drawJpg(tetris_img, 34215);    //从内存中读取名为tetris_img的jpeg文件
}
void loop(){
}

drawJpgFile()

機能です:

从ファイルストリームから JPEG データを読み込み描画

原型関数です:

void drawJpgFiledrawJpgFile(fs::FS &fs, const char *path, uint16_t x,uint16_t y,uint16_t maxWidth, uint16_t maxHeight, uint16_t offX,uint16_t offY, jpeg_div_t scale)

パラメータです タイプです 記述します
fs fs::FS ファイルストリーム
path const char * ファイルパス
x uint16_t 座標 X
y uint16_t 座標 Y
maxWidth uint16_t 最大幅(ピクセル)
maxHeight uint16_t 最大高さ(ピクセル)
offX uint16_t オフセット X(ピクセル)
offY uint16_t オフセット Y(ピクセル)
scale jpeg_div_t 規模

规模(jpeg_div_t):

定義します 機能です
JPEG_DIV_NONE no care.
JPEG_DIV_2 1/2
JPEG_DIV_4 1/4
JPEG_DIV_8 1/8
JPEG_DIV_MAX MAX
注意:
サイズと形式(漸進等)の問題で拡張できない可能性あり

progressBar()

機能です:

進捗を示す欄が表示されます

原型関数です:

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

パラメータです タイプです 記述します
x int 座標 X です
y int 座標 Y です
w int 幅(ピクセル)です
h int 高さ(ピクセル)です
val uint8_t 进度(0-100%)
注意:
プログレスバーが青で表示されます

使用例です:

#include <M5Core2.h>

void setup() {
  M5.begin();  //初始化 M5Core2
  M5.Lcd.progressBar(0, 0, 240, 20, 20);    //在(0,0)处显示宽高分别为240,20进度为20%的进度条
}

void loop() {
}

qrcode()

機能です:

qr コードを作ります

原型関数です:

void qrcode(const char *string, uint16_t x, uint16_t y, uint8_t width, uint8_t version)

void qrcode(const String &string, uint16_t x, uint16_t y, uint8_t width, uint8_t version)

パラメータです タイプです 記述します
val string / String& QR の文字列を埋め込みます
x uint16_t 座標 X です
y uint16_t 座標 Y です
width uint8_t 幅(ピクセル)です
version uint8_t qr コード版です
注意:
QR コードのバージョンを文字数に基づいて適切に選択してください

使用例です:

#include <M5Core2.h>

void setup() {
  M5.Lcd.begin();   //初始化 M5Core2
  M5.Lcd.qrcode("http://www.m5stack.com", 50, 10, 220, 6);
}

void loop() {
}

Sprite

setColorDepth()

機能です:

色深を設定

原型関数です:

void* TFT_eSprite::setColorDepth(int8_t b)

使用例です:

#include <M5Core2.h>
TFT_eSprite img = TFT_eSprite(&M5.Lcd);

void setup() {
    img.setColorDepth(8); // Set color depth.  设置色深
    img.setTextSize(2);
    img.createSprite(320, 240);  //Create a 320x240 canvas. 创建一块320x240的画布
}

void loop() {}

キャンバスを作成する前に適切な色深を設定してください

createSprite()

機能です:

指定の幅と高さを持つキャンバスを作成

原型関数です:

void createSprite(int16_t w, int16_t h, uint8_t frames)

パラメータです タイプです 記述します
x int16_t X 座標です
y int16_t Y 座標です
frames uint8_t 色深度[1~2,お選びいただけます]

使用例です:

#include <M5Core2.h>
TFT_eSprite img = TFT_eSprite(&M5.Lcd);

void setup() {
  M5.begin();  //初始化 M5Core2
  img.createSprite(320, 240);    //创建一块320x240的画布
  img.fillSprite(RED);    //在画布上全部填充红色
  img.pushSprite(0, 0, WHITE);    //把画布推送到屏幕(0,0)处并设置白色为穿透色
  M5.Lcd.print(img.height());    //屏幕打印画布的高度
}

void loop() {}

fillSprite()

機能です:

Sprite を指定色で塗りつくす

原型関数です:

void fillSprite(uint32_t color)

パラメータです タイプです 記述します
color int32_t filled color

使用例です:

#include <M5Core2.h>
TFT_eSprite img = TFT_eSprite(&M5.Lcd);

void setup() {
  M5.begin();  //初始化 M5Core2
  img.createSprite(320, 240);    //创建一块320x240的画布
  img.fillSprite(RED);    //在画布上全部填充红色
  img.pushSprite(0, 0);    //把画布推送到屏幕(0,0)处
}

void loop() {}

pushSprite()

機能です:

キャンバスを指定の座標にプッシュし、透過色を設定

原型関数です:

void pushSprite(int32_t x, int32_t y, uint16_t transparent)

パラメータです タイプです 記述します
x int32_t X 座標です
y int32_t Y 座標です
transparent int16_t 透過色(オプション)です

使用例です:

#include <M5Core2.h>
TFT_eSprite img = TFT_eSprite(&M5.Lcd);

void setup() {
  M5.begin();  //初始化 M5Core2
  img.createSprite(320, 240);    //创建一块320x240的画布
  img.fillSprite(RED);    //在画布上全部填充红色
  img.fillCircle(100,100,20,GREEN);
  img.pushSprite(0, 0, GREEN);    //把画布推送到屏幕(0,0)处并设置绿色为穿透色
}

void loop() {}

height()

機能です:

Sprite の高さを返す

原型関数です:

int16_t height()

使用例です:

#include <M5Core2.h>
TFT_eSprite img = TFT_eSprite(&M5.Lcd);

void setup() {
  M5.begin();  //初始化 M5Core2
  img.createSprite(320, 240);    //创建一块320x240的画布
  img.fillSprite(RED);    //在画布上全部填充红色
  img.pushSprite(0, 0, WHITE);    //把画布推送到屏幕(0,0)处并设置白色为穿透色
  M5.Lcd.print(img.height());    //屏幕打印画布的高度
}

void loop() {}

deleteSprite()

機能です:

キャンバスをメモリから削除

原型関数です:

void deleteSprite(void)

使用例です:

#include <M5Core2.h>
TFT_eSprite img = TFT_eSprite(&M5.Lcd);

void setup() {
  M5.begin();  //初始化 M5Core2
  img.deleteSprite();    //从内存中删除画布
}

void loop() {}
注意:
LCD.img は均一に此ファイルを継承し、使用法は類似 In_eSPI.h , 使い方も似ています
On This Page