LCD 屏幕

画面の解像度は 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()

注意:
1. M5.begin()を使わないで LCD を初期化したい場合は、ディスプレイを使用する前に此機能を呼び出してください

使用例です:

#include <M5Stack.h>

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

void loop() {
}

sleep()

機能です:

画面を省エネモードに切り替えます

原型関数です:

void sleep()

使用例です:

#include <M5Stack.h>

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

void loop() {
}

clear()

機能です:

画面上の表示内容をクリアします

原型関数です:

void clear()

使用例です:

#include <M5Stack.h>

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

void loop() {
}

wakeup()

機能です:

省エネモードから画面表示を復元します

原型関数です:

void wakeup()

使用例です:

#include <M5Stack.h>

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

void loop() {
}

hight()

機能です:

画面の高さを返します

原型関数です:

void hight()

使用例です:

#include <M5Stack.h>

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

void loop() {
}

width()

機能です:

画面の幅を返します

原型関数です:

void width()

使用例です:

#include <M5Stack.h>

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

void loop() {
}

getCursorX()

機能です:

文字末尾の x 座標を取得します

原型関数です:

int16_t getCursorX()

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

使用例です:

#include <M5Stack.h>

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

void loop(){
}

getCursorY()

機能です:

文字末尾の y 座標を取得します

原型関数です:

int16_t getCursorY()

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

使用例です:

#include <M5Stack.h>

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

void loop(){
}

getRotation()

機能です:

画面の回転方向を返します

原型関数です:

uint8_t getRotation()

使用例です:

#include <M5Stack.h>

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

void loop(){
}

getTextDatum()

機能です:

文字の配置位置(上記リスト中の配置位置の番号)を返します

原型関数です:

textdatum_t getRotation()

使用例です:

#include <M5Stack.h>

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

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

void loop() {}

setRotation()

機能です:

画面の回転方向を設定します

原型関数です:

void setRotation(uint8_t m)

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

使用例です:

#include <M5Stack.h>

void setup() {
  M5.begin();             //初始化 M5Stack
  M5.Power.begin();
  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() {}

setBrightness()

機能です:

画面の明度を設定します。

原型関数です:

void setBrightness(uint16_t voltage)

パラメータです タイプです 記述します
brightness uint16_t 亮度 (0: Off - 255:Full)

使用例です:

#include <M5Stack.h>

void setup() {
  M5.begin();
  M5.Power.begin();
  M5.Lcd.fillScreen(RED);
}
void loop() {
  M5.update();
  for(int i=0; i<255;i++){
    M5.Lcd.setBrightness(i);  //每隔10ms设置一次屏幕亮度
    delay(10);
  }
  for(int i=255; i>0;i--){
    M5.Lcd.setBrightness(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 <M5Stack.h>

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

void loop() {
}

loadFont()

機能です:

VLW ファイルからフォントを読み込みます。

原型関数です:

void loadFont(String fontName, bool flash)

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

使用例です:

#include <M5Stack.h>

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

void loop() {
}

unloadFont()

機能です:

フォントをアンロードします。

原型関数です:

void unloadFont()

使用例です:

#include <M5Stack.h>

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

void loop() {
}

fontsLoaded()

機能です:

独自のフォントが読み込まれているかどうかを返します。

原型関数です:

uint16_t fontsLoaded()

戻り値です:

表示中のフォントのコーディングの 16 進数値を返します。

使用例です:

#include <M5Stack.h>

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

void loop() {
}

fillScreen()

機能です:

指定の色で画面全体を塗りつぶします。

原型関数です:

void fillScreen(uint32_t color)

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

使用例です:

#include <M5Stack.h>

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

void loop(){
}

invertDisplay()

機能です:

画面の色を負の/正の方式で反転します。

原型関数です:

void invertDisplay(boolean i)

パラメータです タイプです 说明
i boolean 反転した場合は true です

使用例です:

#include <M5Stack.h>

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

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

void loop() {
}

textWidth()

機能です:

文字列が占有するピクセル幅を返します。

原型関数です:

int16_t textWidth(const String& string)

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

使用例です:

#include <M5Stack.h>

void setup() {
  M5.begin();   //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  M5.Lcd.setTextSize(4);    //设置文字列です大小为4
  M5.Lcd.print("Hello M5Stack");
}

void loop() {
}

setTextColor()

機能です:

表示テキストの前景色と背景色を設定します。

原型関数です:

void setTextColor(uint16_t color)

void setTextColor(uint16_t color, uint16_t backgroundcolor)

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

使用例です:

#include <M5Stack.h>

void setup() {
  M5.begin(); //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

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

void loop() {}

setTextPadding()

機能です:

指定の空白幅を埋め込みます(古いテキストや数字ですを消去するの手助けになります)。

原型関数です:

void setTextPadding(uint16_t x_width)

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

使用例です:

#include <M5Stack.h>

void setup() {
  M5.begin();
  M5.Power.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 右文字ベースライン
注意:
不适用于 print()

使用例です:

#include <M5Stack.h>

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>
void setup() {
  M5.begin(); //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();   //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();   //初始化 M5Stack
  M5.Power.begin();
  M5.Lcd.drawRoundRect(55,55,30,50,10,GREEN);    //在(55,55)处绘制宽高分别为30、50的圆角半径为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 <M5Stack.h>

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

void loop() {}

drawCircle()

機能です:

(x,y)に半径 r のカラー円枠を描きます

原型関数です:

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 <M5Stack.h>

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

void loop() {}

fillCircle()

機能です:

(x,y)に半径 r のカラーをプロットします

原型関数です:

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 <M5Stack.h>

void setup() {
  M5.begin();   //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();   //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();   //初始化 M5Stack
  M5.Power.begin();
  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 <M5Stack.h>

void setup() {
  M5.begin();   //初始化 M5Stack
  M5.Power.begin();
  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 透明カラーコードです
注意:
1.色のコードは合計 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 <M5Stack.h>
void setup(){
    M5.begin(true, false, false, false);
  M5.Power.begin();
  M5.Lcd.drawBmpFile(SD, "/p2.bmp",0,0);
  //M5.Lcd.drawBmpFile(SPIFFS, "/p2.bmp", 0, 0);
}

jpg 画像->.c ファイルを変換できるスクリプトを用意しています。一部の画像を変換し、上記 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 no care.
JPEG_DIV_2 1/2
JPEG_DIV_4 1/4
JPEG_DIV_8 1/8
JPEG_DIV_MAX MAX
注意:
1.サイズ、ビット数、形式(進行表示等)の問題で拡張できない可能性があります。
2. tetris_img のダウンロード

使用例です:

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

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 Max Width (像素)
maxHeight uint16_t Max Height (像素)
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
注意:
1.サイズや形式(進行表示等)の問題で拡張できない可能性があります。

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%)です
注意:
1.進行バーは青色で表示されます。

使用例です:

#include <M5Stack.h>

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 コード版です
注意:
1.QR コードのバージョンは文字数に基づいて適切に選択してください。

使用例です:

#include <M5Stack.h>

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

void loop() {
}

Sprite

setColorDepth()

機能です:

色深を設定します。

原型関数です:

void* TFT_eSprite::setColorDepth(int8_t b)

使用例です:

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

void setup() {
    M5.begin();        // Init M5Stack.  初始化M5Stack
    M5.Power.begin();  // Init power.  初始化电源模块
    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 <M5Stack.h>

TFT_eSprite img = TFT_eSprite(&M5.Lcd);

void setup() {
    M5.begin();  //初始化 M5Stack
    M5.Power.begin();
    img.setColorDepth(8);  // Set the color depth to 8 bits. 设置颜色深度为8位
    img.createSprite(320, 240);  //Create a 320x240 canvas. 创建一块320x240的画布
    img.fillSprite(RED);         //Fill the canvas with red. 在画布上全部填充红色
    img.pushSprite(0,0);  // Push the canvas to the screen at (0,0). 把画布推送到屏幕(0,0)处
}

void loop() {}

fillSprite()

機能です:

Sprite を指定の色で塗りつぶします。

原型関数です:

void fillSprite(uint32_t color)

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

使用例です:

#include <M5Stack.h>

TFT_eSprite img = TFT_eSprite(&M5.Lcd);

void setup() {
    M5.begin();  //初始化 M5Stack
    M5.Power.begin();
    img.setColorDepth(8);  // Set the color depth to 8 bits. 设置颜色深度为8位
    img.createSprite(320, 240);  //Create a 320x240 canvas. 创建一块320x240的画布
    img.fillSprite(RED);         //Fill the canvas with red. 在画布上全部填充红色
    img.pushSprite(0,0);  // Push the canvas to the screen at (0,0). 把画布推送到屏幕(0,0)处
}

void loop() {}
}

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 <M5Stack.h>
TFT_eSprite img = TFT_eSprite(&M5.Lcd);

void setup() {
  M5.begin();  //初始化 M5Stack
  M5.Power.begin();
  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 の高さを返します。

使用例です:

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

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

void loop() {}

deleteSprite()

機能です:

キャンバスをメモリから削除します。

使用例です:

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

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

void loop() {}
注意:
LCD. img.はすべて In_eSPI.h , を継承し、使い方も似通っています。
On This Page