diff --git a/docs/en/api.md b/docs/en/api.md index 506ce0d6..334b2684 100644 --- a/docs/en/api.md +++ b/docs/en/api.md @@ -6,10 +6,12 @@ |:---:|:---:| |**[System](en/api/system)** | **[Speaker](en/api/speaker)** | |**[LCD](en/api/lcd)** | **[Button](en/api/button)** | -|**[IMU sensor(MPU9250)](en/api/mpu9250)** | **[TF card](en/api/tf)** | +|**[IMU Sensor(MPU9250)](en/api/mpu9250)** | **[TF Card](en/api/tf)** | |**[Power](en/api/power)** | - - +## M5stickC + +||| +|:---:|:---:| +|**[System](en/api/system_m5stickc)** | **[Power Management(AXP192)](en/api/axp192_m5stickc)** | +|**[TFT Screen](en/api/lcd_m5stickc)** | **[IMU(SH200Q)](en/api/sh200q_m5stickc)** | diff --git a/docs/en/api/axp192_m5stickc.md b/docs/en/api/axp192_m5stickc.md new file mode 100644 index 00000000..b9a983d0 --- /dev/null +++ b/docs/en/api/axp192_m5stickc.md @@ -0,0 +1,108 @@ +# AXP192 (Power management) + +*The AXP192 is a highly integrated power system management chip.* + +## begin() + +**Syntax:** + +void begin(void); + +**Description: Initialize the AXP192.** + +**Example:** + +```arduino +#include + +void setup() { + M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip +} +void loop() {} +``` + +## ScreenBreath() + +**Syntax:** + +void ScreenBreath(uint8_t brightness); + +**Description: Change the LDO3 output voltage of the AXP192 chip.** + +| parameter | description | +| --- | --- | +| brightness | TFT backlight brightness (range: 7~15) | + +**Example:** + +```arduino +#include + +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() + +**Syntax:** + +uint16_t GetVbatData(void); + +**Description: Get the battery voltage value.** + +**Example:** + +```arduino +#include + +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() + +**Syntax:** + +uint16_t GetIchargeData(void); + +**Description: Get the battery charging current.** + +**Example:** + +```arduino +#include + +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); +} +``` \ No newline at end of file diff --git a/docs/en/api/lcd_m5stickc.md b/docs/en/api/lcd_m5stickc.md new file mode 100644 index 00000000..1c897f6f --- /dev/null +++ b/docs/en/api/lcd_m5stickc.md @@ -0,0 +1,362 @@ +# TFT Screen + +*The M5StickC screen resolution is **80x160**, the top left corner of the screen as the origin (0,0)* + +## ScreenBreath() + +**Syntax:** + +void ScreenBreath(uint8_t brightness); + +**Description: Adjust the brightness of the screen backlight.** + +| Parameter | Description | +| --- | --- | +| brightness | TFT backlight brightness ( 值: 7 - 15 ) | + +**Example:** + +```arduino +#include + +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() + +**Syntax:** + +fillScreen(uint16_t color); + +**Description: Fills the entire screen with the specified color.** + +| Parameter | Description | +| --- | --- | +| color | color value | + +**Example:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.fillScreen(BLUE); +} +void loop() {} +``` + +* * * + +## setTextColor() + +**Syntax:** + +setTextColor(uint16_t color, [uint16_t backgroundcolor]); + +**Description: Sets the foreground color and background color of the displayed text.** + +| Parameter | Description | +| --- | --- | +| color | foreground color | +| backgroundcolor| background color | + +*If the function's backgroundcolor value is not given, the current background color is used.* + +**Example:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.setTextColor(RED, WHITE); + M5.Lcd.println("Hello, M5Stack world!!"); +} +void loop() {} +``` + +* * * + +## setCursor() + +**Syntax:** + +setCursor(int16_t x0, int16_t y0, uint8_t font); + +**Description: Move the cursor position to (x0, y0).** + +**Example:** + +```arduino +#include + +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() + +**Syntax:** + +drawPixel(int16_t x, int16_t y, [uint16_t color]); + +**Description: Draw a pixel at the position (x, y).** + +| Parameter | Description | +| --- | --- | +| color | pixel color | + +*If the function's color value is not given, the current background color is used.* + +**Example:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.drawPixel(22, 22, RED); +} +void loop() {} +``` + +* * * + +## drawLine() + +**Syntax:** + +drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, [uint16_t color]); + +**Description: Draw a line from the point (x, y) to the point (x1, y1) in the specified color.** + +| Parameter | Description | +| --- | --- | +| color | line color | + +*If the function's color value is not given, the current background color is used.* + +**Example:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.drawLine(0, 0, 12, 12, BLUE); +} +void loop() {} +``` + +* * * + +## drawTriangle() + +**Syntax:** + +drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, [uint16_t color]); + +**Description: Draw a triangle with the specified color, with vertices of (x, y), (x1, y1), and (x2, y2).** + +| Parameter | Description | +| --- | --- | +| color | line color | + +*If the function's color value is not given, the current background color is used.* + +**Example:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.drawTriangle(22, 22, 69, 98, 51, 22, RED); +} +void loop() {} +``` + +* * * + +## fillTriangle() + +**Syntax:** + +fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, [uint16_t color]); + +**Description: Fill a triangle with the specified color, with vertices of (x, y), (x1, y1) and (x2, y2).** + +| Parameter | Description | +| --- | --- | +| color | fill color | + +*If the function's color value is not given, the current background color is used.* + +**Example:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.fillTriangle(22, 22, 69, 98, 51, 22, RED); +} +void loop() {} +``` + +* * * + +## drawRect() + +**Syntax:** + +drawRect(int16_t x, int16_t y, int16_t w, int16_t h, [uint16_t color]); + +**Description: Draws a rectangle with a specified color, where the coordinates of the upper left corner of the rectangle are (x, y), and the width and height.** + +| Parameter | Description | +| --- | --- | +| w | width (pixel) | +| h | height (pixel) | +| color | line color | + +*If the function's color value is not given, the current background color is used.* + +**Example:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.drawRect(50, 100, 30, 10, BLUE); +} +void loop() {} +``` + +* * * + +## fillRect() + +**Syntax:** + +fillRect(int16_t x, int16_t y, int16_t w, int16_t h, [uint16_t color]); + +**Description: Fill a rectangle with the specified color. The coordinates of the upper left corner are (x, y), and the width and height.** + +| Parameter | Description | +| --- | --- | +| w | width (pixel) | +| h | height (pixel) | +| color | fill color | + +*If the function's color value is not given, the current background color is used.* + +**Example:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.fillRect(50, 100, 20, 10, BLUE); +} +void loop() {} +``` + +* * * + +## drawRoundRect() + +**Syntax:** + +drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); + +**Description: Draw a rounded corner rectangle with the specified color, where the coordinates of the upper left corner of the rectangle are (x, y), the width, the height and the radius of the fillet.** + +| Parameter | Description | +| --- | --- | +| w | width (pixel) | +| h | height (pixel) | +| radius | radius of corner fillet | +| color | fill color | + +*If the function's color value is not given, the current background color is used.* + +**Example:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.fillRoundRect(40, 70, 20, 10, 4, BLUE); +} +void loop() {} +``` + +* * * + +## print() + +**Syntax:** + +print(); + +**Description: Printing text (string) at the current cursor position of the screen.** + +*The default printed content color style is white on black.* + +**Example:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.print("print text"); +} +void loop() {} +``` + +## Usage {docsify-ignore} + +```arduino +#include + +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() {} +``` diff --git a/docs/en/api/sh200q_m5stickc.md b/docs/en/api/sh200q_m5stickc.md new file mode 100644 index 00000000..b4b7a4d8 --- /dev/null +++ b/docs/en/api/sh200q_m5stickc.md @@ -0,0 +1,86 @@ +# IMU(SH200Q) + +*The SH200Q is a 6-axis IMU sensor. It can detect 3-axis gyro data and 3-axis acceleration data.* + +## Init() + +**Syntax:** + +void Init(); + +**Description: It initialize the SH200Q.** + +**Example:** + +```arduino +#include + +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() + +**Syntax:** + +void getGyroData(int16_t* gx, int16_t* gy, int16_t* gz); + +**Description: It get gyro data of SH200Q.** + +**Example:** + +```arduino +#include + +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() + +**Syntax:** + +void getAccelData(int16_t* ax, int16_t* ay, int16_t* az); + +**Description: It get SH200Q acceleration data.** + +**Example:** + +```arduino +#include + +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); +} +``` \ No newline at end of file diff --git a/docs/en/api/system_m5stickc.md b/docs/en/api/system_m5stickc.md new file mode 100644 index 00000000..f7d14839 --- /dev/null +++ b/docs/en/api/system_m5stickc.md @@ -0,0 +1,87 @@ +# System (M5StickC) + +## begin() + +**Syntax:** + +void begin(bool LCDEnable=true, bool PowerEnable=true, bool SerialEnable=true); + +**Description: Clear the serial port buffer, set the serial port baud rate to 115200; initialize the LCD; initialize the power management chip AXP192.** + +**Definition:** + +```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"); + } +} +``` + +**Example:** + +```arduino +#include + +void setup() { + M5.begin(); +} +void loop() {} +``` + +## GetBm8563Time() + +*This is the API function of the BM8563 chip. The chip communicates with the ESP32 via I2C, and the I2C address is 0x51.* + +**Syntax:** + +void GetBm8563Time(void); + +**Description: Get the current hour, minute, and second value and save it to M5.Rtc.Hour, M5.Rtc.Minute, M5.Rtc.Second, in ASCII format.** + +**Example::** + +```arduino +#include + +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); +} +``` \ No newline at end of file diff --git a/docs/ja/api.md b/docs/ja/api.md index a0e7ed33..2dd70256 100644 --- a/docs/ja/api.md +++ b/docs/ja/api.md @@ -7,4 +7,11 @@ |**[システム](ja/api/system)** | **[スピーカー](ja/api/speaker)** | |**[LCD 画面表示](ja/api/lcd)** | **[ボタン](ja/api/button)** | |**[IMUセンサー(MPU9250)](ja/api/mpu9250)** | **[TFカード(SDカード)](ja/api/tf)** | -|**[電源](ja/api/power)** | +|**[電源](ja/api/power)** | | + +## M5stickC + +||| +|:---:|:---:| +|**[システム](ja/api/system_m5stickc)** | **[電源IC(AXP192)](ja/api/axp192_m5stickc)** | +|**[TFT画面表示](ja/api/lcd_m5stickc)** | **[IMU(SH200Q)](ja/api/sh200q_m5stickc)** | diff --git a/docs/ja/api/axp192_m5stickc.md b/docs/ja/api/axp192_m5stickc.md new file mode 100644 index 00000000..262f7ff7 --- /dev/null +++ b/docs/ja/api/axp192_m5stickc.md @@ -0,0 +1,118 @@ +# AXP192 + +*AXP192は高度な電源管理ICです。* + +## begin() + +**説明** + +AXP192を初期化します。 + +**構文:** + +void begin(void); + +**使用例:** + +```arduino +#include + +void setup() { + M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip +} +void loop() {} +``` + +## ScreenBreath() + +**説明:** + +AXP192のLDO3出力電圧を制御します。 + +**構文:** + +void ScreenBreath(uint8_t brightness); + +**パラメータ:** + +| 引数 | 説明 | +| --- | --- | +| brightness | TFTバックライトの輝度 ( 範囲: 7 ~ 15 ) | + +**使用例:** + +```arduino +#include + +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() + +**説明:** + +電池電圧を取得します。 + +**構文:** + +uint16_t GetVbatData(void); + +**使用例:** + +```arduino +#include + +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() + +##説明:** + +電池の充電電流を取得します。 + +**構文:** + +uint16_t GetIchargeData(void); + +**使用例:** + +```arduino +#include + +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); +} +``` \ No newline at end of file diff --git a/docs/ja/api/lcd_m5stickc.md b/docs/ja/api/lcd_m5stickc.md new file mode 100644 index 00000000..c3f33923 --- /dev/null +++ b/docs/ja/api/lcd_m5stickc.md @@ -0,0 +1,412 @@ +# TFT スクリーン + +*M5StickC 解像度 **80x160**, 左上原点 (0,0)* + +## ScreenBreath() + +**説明:** + +スクリーンのバックライトの輝度を調整できます。 + +**構文:** + +void ScreenBreath(uint8_t brightness); + +**パラメータ:** + +| 引数 | 説明 | +| --- | --- | +| brightness | 輝度 ( 範囲: 7 ~ 15 ) | + +**使用例:** + +```arduino +#include + +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() + +**説明:** + +指定した色で画面を塗りつぶします。 + +**構文:** + +fillScreen(uint16_t color); + +**パラメータ:** + +| 引数 | 説明 | +| --- | --- | +| color | 色値 | + +**使用例:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.fillScreen(BLUE); +} +void loop() {} +``` + +* * * + +## setTextColor() + +**説明** + +テキストの色を変更できます。 + +**構文:** + +setTextColor(uint16_t color, [uint16_t backgroundcolor]); + +**パラメータ** + +| 引数 | 説明 | +| --- | --- | +| color | テキストの色 | +| backgroundcolor| テキストの背景色 option | + +*backgroundcolor を指定しない場合は、直前に使用されていた色が使用されます。* + +**使用例:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.setTextColor(RED, WHITE); + M5.Lcd.println("Hello, M5Stack world!!"); +} +void loop() {} +``` + +* * * + +## setCursor() + +**説明:** + +カーソルの位置を設定します。 + +**構文:** + +setCursor(int16_t x0, int16_t y0, [uint8_t fontSize]); + +**パラメータ:** + +| 引数 | 説明 | +| --- | --- | +| fontSize | テキストのサイズ option | + +**使用例:** + +```arduino +#include + +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() + +**説明:** + +指定の位置にピクセルを描画します。 + +**構文:** + +drawPixel(int16_t x, int16_t y, uint16_t color); + +**パラメータ:** + +| 引数 | 説明 | +| --- | --- | +| color | 色値 option | + +*color を指定しない場合は、直前に使用されていた色が使用されます。* + +**使用例:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.drawPixel(22, 22, RED); +} +void loop() {} +``` + +* * * + +## drawLine() + +**説明:** + +始点から終点に直線を描画します。 + +**構文:** + +drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, [uint16_t color]); + +**パラメータ:** + +| 引数 | 説明 | +| --- | --- | +| color | 色値 option | + +*color を指定しない場合は、直前に使用されていた色が使用されます。* + +**使用例:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.drawLine(0, 0, 12, 12, BLUE); +} +void loop() {} +``` + +* * * + +## drawTriangle() + +**説明:** + +3つの頂点からなる三角形を描画します。 + +**構文:** + +drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, [uint16_t color]); + +**パラメータ:** + +| 引数 | 説明 | +| --- | --- | +| color | 色値 option | + +*color を指定しない場合は、直前に使用されていた色が使用されます。* + +**使用例:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.drawTriangle(22, 22, 69, 98, 51, 22, RED); +} +void loop() {} +``` + +* * * + +## fillTriangle() + +**説明:** + +3つの頂点からなる三角形を塗りつぶします。 + +**構文:** + +fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, [uint16_t color]); + +**パラメータ:** + +| 引数 | 説明 | +| --- | --- | +| color | 色値 option | + +*color を指定しない場合は、直前に使用されていた色が使用されます。* + +**使用例:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.fillTriangle(22, 22, 69, 98, 51, 22, RED); +} +void loop() {} +``` + +* * * + +## drawRect() + +**説明:** + +四角形を描画します。 + +**構文:** + +drawRect(int16_t x, int16_t y, int16_t w, int16_t h, [uint16_t color]); + +**パラメータ:** + +| 引数 | 説明 | +| --- | --- | +| w | 四角形の幅(ピクセル) | +| h | 四角形の高さ(ピクセル) | +| color | 四角形の色 option | + +*color を指定しない場合は、直前に使用されていた色が使用されます。* + +**使用例:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.drawRect(50, 100, 30, 10, BLUE); +} +void loop() {} +``` + +* * * + +## fillRect() + +**説明:** + +四角形を塗りつぶします。 + +**構文:** + +fillRect(int16_t x, int16_t y, int16_t w, int16_t h, [uint16_t color]); + +**パラメータ:** + +| 引数 | 説明 | +| --- | --- | +| w | 四角形の幅(ピクセル) | +| h | 四角形の高さ(ピクセル) | +| color | 四角形の塗りつぶし色 option | + +*color を指定しない場合は、直前に使用されていた色が使用されます。* + +**使用例:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.fillRect(50, 100, 20, 10, BLUE); +} +void loop() {} +``` + +* * * + +## drawRoundRect() + +**説明:** + +角丸の四角形を描画します。 + +**構文:** + +drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, [uint16_t color]); + +**パラメータ:** + +| 引数 | 説明 | +| --- | --- | +| w | 四角形の幅(ピクセル) | +| h | 四角形の高さ(ピクセル) | +| radius | 角丸の半径 | +| color | 四角形の塗りつぶし色 option | + +*color を指定しない場合は、直前に使用されていた色が使用されます。* + +**使用例:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.fillRoundRect(40, 70, 20, 10, 4, BLUE); +} +void loop() {} +``` + +* * * + +## print() + +**説明:** + +指定した文字列を画面に表示します。 + +**構文:** + +print(); + +*デフォルトは白地に黒い文字* + +**使用例:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.print("print text"); +} +void loop() {} +``` + +## 使用例(一括) {docsify-ignore} + +```arduino +#include + +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() {} +``` diff --git a/docs/ja/api/sh200q_m5stickc.md b/docs/ja/api/sh200q_m5stickc.md new file mode 100644 index 00000000..404b5ecf --- /dev/null +++ b/docs/ja/api/sh200q_m5stickc.md @@ -0,0 +1,92 @@ +# IMU(SH200Q) + +*SH200Qは6自由度のIMUです。3軸(x, y, z)の角速度と加速度を取得することができます。* + +## Init() + +**説明** + +SH200Qを初期化します。 + +**構文:** + +void Init(); + +**使用例:** + +```arduino +#include + +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のジャイロデータを取得します。 + +**構文:** + +void getGyroData(int16_t* gx, int16_t* gy, int16_t* gz); + +**使用例:** + +```arduino +#include + +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の加速度データを取得します。 + +**構文:** + +void getAccelData(int16_t* ax, int16_t* ay, int16_t* az); + +**使用例:** + +```arduino +#include + +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); +} +``` \ No newline at end of file diff --git a/docs/ja/api/system_m5stickc.md b/docs/ja/api/system_m5stickc.md new file mode 100644 index 00000000..aa8fe692 --- /dev/null +++ b/docs/ja/api/system_m5stickc.md @@ -0,0 +1,91 @@ +# システム + +## begin() + +**説明:** + +シリアルポートバッファクリア、ボーレート設定:115200、LCD初期化、電源管理チップAXP192の初期化を行います。 + +**構文:** + +void begin(bool LCDEnable=true, bool PowerEnable=true, bool SerialEnable=true); + +**定義:** + +```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 + +void setup() { + M5.begin(); +} +void loop() {} +``` + +## GetBm8563Time() + +*BM8563はRTC機能を実現します。I2CでESP32と通信します。I2Cアドレスは 0x51 です。* + +**説明:** + +現在の時 / 分 / 秒の値を取得し、ASCII形式で Rtc.Hour / Rtc.Minute / Rtc.Second に保存します。 + +**構文:** + +void GetBm8563Time(void); + +**使用例:** + +```arduino +#include + +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); +} +``` \ No newline at end of file diff --git a/docs/ja/qs.md b/docs/ja/qs.md index 9e525fc4..c3ecffd5 100644 --- a/docs/ja/qs.md +++ b/docs/ja/qs.md @@ -35,7 +35,7 @@ M5Stackを使った開発に必要なもの: - +