mirror of
https://github.com/m5stack/m5-docs.git
synced 2026-05-20 10:23:01 -07:00
Add api of M5StickC docs en / ja
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
# AXP192
|
||||
|
||||
*AXP192は高度な電源管理ICです。*
|
||||
|
||||
## begin()
|
||||
|
||||
**説明**
|
||||
|
||||
AXP192を初期化します。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>void begin(void);</mark>
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
|
||||
}
|
||||
void loop() {}
|
||||
```
|
||||
|
||||
## ScreenBreath()
|
||||
|
||||
**説明:**
|
||||
|
||||
AXP192のLDO3出力電圧を制御します。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>void ScreenBreath(uint8_t brightness);</mark>
|
||||
|
||||
**パラメータ:**
|
||||
|
||||
| 引数 | 説明 |
|
||||
| --- | --- |
|
||||
| brightness | TFTバックライトの輝度 ( 範囲: 7 ~ 15 ) |
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
uint8_t i = 7;
|
||||
|
||||
void setup() {
|
||||
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
|
||||
M5.Lcd.printf("Hello, M5Stack!!");
|
||||
}
|
||||
void loop() {
|
||||
M5.Axp.ScreenBreath(i++);
|
||||
if (i > 15) i = 7;
|
||||
delay(1000);
|
||||
}
|
||||
```
|
||||
|
||||
## GetVbatData()
|
||||
|
||||
**説明:**
|
||||
|
||||
電池電圧を取得します。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>uint16_t GetVbatData(void);</mark>
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
double vbat = 0.0;
|
||||
|
||||
void setup() {
|
||||
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
|
||||
M5.Lcd.fillScreen(BLACK);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
vbat = M5.Axp.GetVbatData() * 1.1 / 1000;
|
||||
M5.Lcd.setCursor(0, 0, 1);
|
||||
M5.Lcd.printf("vbat:%.3fV\r\n", vbat);
|
||||
delay(500);
|
||||
}
|
||||
```
|
||||
|
||||
## GetIchargeData()
|
||||
|
||||
##説明:**
|
||||
|
||||
電池の充電電流を取得します。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>uint16_t GetIchargeData(void);</mark>
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
int charge;
|
||||
|
||||
void setup() {
|
||||
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
|
||||
M5.Lcd.fillScreen(BLACK);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
charge = M5.Axp.GetIchargeData() / 2;
|
||||
M5.Lcd.setCursor(0, 0, 1);
|
||||
M5.Lcd.printf("icharge:%dmA\r\n", charge);
|
||||
delay(500);
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,412 @@
|
||||
# TFT スクリーン
|
||||
|
||||
*M5StickC 解像度 **80x160**, 左上原点 (0,0)*
|
||||
|
||||
## ScreenBreath()
|
||||
|
||||
**説明:**
|
||||
|
||||
スクリーンのバックライトの輝度を調整できます。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>void ScreenBreath(uint8_t brightness);</mark>
|
||||
|
||||
**パラメータ:**
|
||||
|
||||
| 引数 | 説明 |
|
||||
| --- | --- |
|
||||
| brightness | 輝度 ( 範囲: 7 ~ 15 ) |
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
uint8_t i = 7;
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.Lcd.fillScreen(WHITE);
|
||||
}
|
||||
void loop() {
|
||||
M5.Axp.ScreenBreath(i++);
|
||||
if (i > 15) i = 7;
|
||||
delay(500);
|
||||
}
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
## fillScreen()
|
||||
|
||||
**説明:**
|
||||
|
||||
指定した色で画面を塗りつぶします。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>fillScreen(uint16_t color);</mark>
|
||||
|
||||
**パラメータ:**
|
||||
|
||||
| 引数 | 説明 |
|
||||
| --- | --- |
|
||||
| color | 色値 |
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.Lcd.fillScreen(BLUE);
|
||||
}
|
||||
void loop() {}
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
## setTextColor()
|
||||
|
||||
**説明**
|
||||
|
||||
テキストの色を変更できます。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>setTextColor(uint16_t color, [uint16_t backgroundcolor]);</mark>
|
||||
|
||||
**パラメータ**
|
||||
|
||||
| 引数 | 説明 |
|
||||
| --- | --- |
|
||||
| color | テキストの色 |
|
||||
| backgroundcolor| テキストの背景色 option |
|
||||
|
||||
*backgroundcolor を指定しない場合は、直前に使用されていた色が使用されます。*
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.Lcd.setTextColor(RED, WHITE);
|
||||
M5.Lcd.println("Hello, M5Stack world!!");
|
||||
}
|
||||
void loop() {}
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
## setCursor()
|
||||
|
||||
**説明:**
|
||||
|
||||
カーソルの位置を設定します。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>setCursor(int16_t x0, int16_t y0, [uint8_t fontSize]);</mark>
|
||||
|
||||
**パラメータ:**
|
||||
|
||||
| 引数 | 説明 |
|
||||
| --- | --- |
|
||||
| fontSize | テキストのサイズ option |
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.Lcd.setCursor(7, 20, 2);
|
||||
M5.Lcd.println("scan done");
|
||||
M5.Lcd.setCursor(5, 60, 4);
|
||||
M5.Lcd.printf("50 AP");
|
||||
}
|
||||
void loop(){}
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
## drawPixel()
|
||||
|
||||
**説明:**
|
||||
|
||||
指定の位置にピクセルを描画します。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>drawPixel(int16_t x, int16_t y, uint16_t color);</mark>
|
||||
|
||||
**パラメータ:**
|
||||
|
||||
| 引数 | 説明 |
|
||||
| --- | --- |
|
||||
| color | 色値 option |
|
||||
|
||||
*color を指定しない場合は、直前に使用されていた色が使用されます。*
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.Lcd.drawPixel(22, 22, RED);
|
||||
}
|
||||
void loop() {}
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
## drawLine()
|
||||
|
||||
**説明:**
|
||||
|
||||
始点から終点に直線を描画します。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, [uint16_t color]);</mark>
|
||||
|
||||
**パラメータ:**
|
||||
|
||||
| 引数 | 説明 |
|
||||
| --- | --- |
|
||||
| color | 色値 option |
|
||||
|
||||
*color を指定しない場合は、直前に使用されていた色が使用されます。*
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.Lcd.drawLine(0, 0, 12, 12, BLUE);
|
||||
}
|
||||
void loop() {}
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
## drawTriangle()
|
||||
|
||||
**説明:**
|
||||
|
||||
3つの頂点からなる三角形を描画します。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, [uint16_t color]);</mark>
|
||||
|
||||
**パラメータ:**
|
||||
|
||||
| 引数 | 説明 |
|
||||
| --- | --- |
|
||||
| color | 色値 option |
|
||||
|
||||
*color を指定しない場合は、直前に使用されていた色が使用されます。*
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.Lcd.drawTriangle(22, 22, 69, 98, 51, 22, RED);
|
||||
}
|
||||
void loop() {}
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
## fillTriangle()
|
||||
|
||||
**説明:**
|
||||
|
||||
3つの頂点からなる三角形を塗りつぶします。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, [uint16_t color]);</mark>
|
||||
|
||||
**パラメータ:**
|
||||
|
||||
| 引数 | 説明 |
|
||||
| --- | --- |
|
||||
| color | 色値 option |
|
||||
|
||||
*color を指定しない場合は、直前に使用されていた色が使用されます。*
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.Lcd.fillTriangle(22, 22, 69, 98, 51, 22, RED);
|
||||
}
|
||||
void loop() {}
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
## drawRect()
|
||||
|
||||
**説明:**
|
||||
|
||||
四角形を描画します。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>drawRect(int16_t x, int16_t y, int16_t w, int16_t h, [uint16_t color]);</mark>
|
||||
|
||||
**パラメータ:**
|
||||
|
||||
| 引数 | 説明 |
|
||||
| --- | --- |
|
||||
| w | 四角形の幅(ピクセル) |
|
||||
| h | 四角形の高さ(ピクセル) |
|
||||
| color | 四角形の色 option |
|
||||
|
||||
*color を指定しない場合は、直前に使用されていた色が使用されます。*
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.Lcd.drawRect(50, 100, 30, 10, BLUE);
|
||||
}
|
||||
void loop() {}
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
## fillRect()
|
||||
|
||||
**説明:**
|
||||
|
||||
四角形を塗りつぶします。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>fillRect(int16_t x, int16_t y, int16_t w, int16_t h, [uint16_t color]);</mark>
|
||||
|
||||
**パラメータ:**
|
||||
|
||||
| 引数 | 説明 |
|
||||
| --- | --- |
|
||||
| w | 四角形の幅(ピクセル) |
|
||||
| h | 四角形の高さ(ピクセル) |
|
||||
| color | 四角形の塗りつぶし色 option |
|
||||
|
||||
*color を指定しない場合は、直前に使用されていた色が使用されます。*
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.Lcd.fillRect(50, 100, 20, 10, BLUE);
|
||||
}
|
||||
void loop() {}
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
## drawRoundRect()
|
||||
|
||||
**説明:**
|
||||
|
||||
角丸の四角形を描画します。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, [uint16_t color]);</mark>
|
||||
|
||||
**パラメータ:**
|
||||
|
||||
| 引数 | 説明 |
|
||||
| --- | --- |
|
||||
| w | 四角形の幅(ピクセル) |
|
||||
| h | 四角形の高さ(ピクセル) |
|
||||
| radius | 角丸の半径 |
|
||||
| color | 四角形の塗りつぶし色 option |
|
||||
|
||||
*color を指定しない場合は、直前に使用されていた色が使用されます。*
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.Lcd.fillRoundRect(40, 70, 20, 10, 4, BLUE);
|
||||
}
|
||||
void loop() {}
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
## print()
|
||||
|
||||
**説明:**
|
||||
|
||||
指定した文字列を画面に表示します。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>print();</mark>
|
||||
|
||||
*デフォルトは白地に黒い文字*
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.Lcd.print("print text");
|
||||
}
|
||||
void loop() {}
|
||||
```
|
||||
|
||||
## 使用例(一括) {docsify-ignore}
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
|
||||
M5.Lcd.fillScreen(WHITE); // set the default background color
|
||||
M5.Lcd.drawLine(0, 0, 100, 100, WHITE);
|
||||
M5.Lcd.drawTriangle(22, 22, 69, 98, 51, 22, RED);
|
||||
M5.Lcd.fillTriangle(22, 22, 69, 98, 51, 22, RED);
|
||||
M5.Lcd.drawRect(50, 100, 30, 10, BLUE);
|
||||
M5.Lcd.fillRect(50, 100, 30, 10, BLUE);
|
||||
M5.Lcd.drawRoundRect(40, 70, 20, 10, 4, BLUE);
|
||||
M5.Lcd.fillRoundRect(40, 70, 20, 10, 4, BLUE);
|
||||
M5.Lcd.print("print text");
|
||||
}
|
||||
void loop() {}
|
||||
```
|
||||
@@ -0,0 +1,92 @@
|
||||
# IMU(SH200Q)
|
||||
|
||||
*SH200Qは6自由度のIMUです。3軸(x, y, z)の角速度と加速度を取得することができます。*
|
||||
|
||||
## Init()
|
||||
|
||||
**説明**
|
||||
|
||||
SH200Qを初期化します。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>void Init();</mark>
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
uint8_t c;
|
||||
M5.begin();
|
||||
M5.IMU.Init();
|
||||
M5.IMU.I2C_Read_NBytes(SH200I_ADDRESS, SH200I_WHOAMI, 1, &c);
|
||||
M5.Lcd.print("SH200Q I AM "); M5.Lcd.println(c, HEX);
|
||||
}
|
||||
void loop() {}
|
||||
```
|
||||
|
||||
## getGyroData()
|
||||
|
||||
**説明:**
|
||||
|
||||
SH200Qのジャイロデータを取得します。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>void getGyroData(int16_t* gx, int16_t* gy, int16_t* gz);</mark>
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
int16_t gyroX, gyroY, gyroZ;
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.IMU.Init();
|
||||
}
|
||||
void loop() {
|
||||
M5.IMU.getGyroData(&gyroX, &gyroY, &gyroZ);
|
||||
M5.Lcd.setCursor(0, 30);
|
||||
M5.Lcd.printf("X:%7.2f\nY:%7.2f\nZ:%7.2f mg",
|
||||
((float)gyroX) * M5.IMU.gRes,
|
||||
((float)gyroY) * M5.IMU.gRes,
|
||||
((float)gyroZ) * M5.IMU.gRes);
|
||||
delay(500);
|
||||
}
|
||||
```
|
||||
|
||||
## getAccelData()
|
||||
|
||||
**説明:**
|
||||
|
||||
SH200Qの加速度データを取得します。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>void getAccelData(int16_t* ax, int16_t* ay, int16_t* az);</mark>
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
int16_t accX, accY, accZ;
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.IMU.Init();
|
||||
}
|
||||
void loop() {
|
||||
M5.IMU.getAccelData(&accX, &accY, &accZ);
|
||||
M5.Lcd.setCursor(0, 45);
|
||||
M5.Lcd.printf("X:%5.2f\nY:%5.2f\nZ:%5.2f o/s",
|
||||
((float)accX) * M5.IMU.aRes,
|
||||
((float)accY) * M5.IMU.aRes,
|
||||
((float)accZ) * M5.IMU.aRes);
|
||||
delay(500);
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,91 @@
|
||||
# システム
|
||||
|
||||
## begin()
|
||||
|
||||
**説明:**
|
||||
|
||||
シリアルポートバッファクリア、ボーレート設定:115200、LCD初期化、電源管理チップAXP192の初期化を行います。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>void begin(bool LCDEnable=true, bool PowerEnable=true, bool SerialEnable=true);</mark>
|
||||
|
||||
**定義:**
|
||||
|
||||
```arduino
|
||||
void M5StickC::begin(bool LCDEnable, bool PowerEnable, bool SerialEnable) {
|
||||
|
||||
//! Correct init once
|
||||
if (isInited) return;
|
||||
else isInited = true;
|
||||
|
||||
//! UART
|
||||
if (SerialEnable) {
|
||||
Serial.begin(115200);
|
||||
Serial.flush();
|
||||
delay(50);
|
||||
Serial.print("M5StickC initializing...");
|
||||
}
|
||||
|
||||
// Power
|
||||
if (PowerEnable) {
|
||||
Axp.begin();
|
||||
}
|
||||
|
||||
// LCD INIT
|
||||
if (LCDEnable) {
|
||||
Lcd.begin();
|
||||
}
|
||||
|
||||
if (SerialEnable) {
|
||||
Serial.println("OK");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
}
|
||||
void loop() {}
|
||||
```
|
||||
|
||||
## GetBm8563Time()
|
||||
|
||||
*BM8563はRTC機能を実現します。I2CでESP32と通信します。I2Cアドレスは 0x51 です。*
|
||||
|
||||
**説明:**
|
||||
|
||||
現在の時 / 分 / 秒の値を取得し、ASCII形式で Rtc.Hour / Rtc.Minute / Rtc.Second に保存します。
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>void GetBm8563Time(void);</mark>
|
||||
|
||||
**使用例:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
M5.begin();
|
||||
M5.Lcd.setRotation(3);
|
||||
M5.Lcd.fillScreen(BLACK);
|
||||
|
||||
M5.Lcd.setTextSize(2);
|
||||
M5.Lcd.println("rtc test");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
M5.Rtc.GetBm8563Time();
|
||||
M5.Lcd.setCursor(0, 30, 2);
|
||||
M5.Lcd.printf("%02d : %02d : %02d\n", M5.Rtc.Hour, M5.Rtc.Minute, M5.Rtc.Second);
|
||||
delay(1000);
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user