From 1edc2d2c17a458a490b63cbb5622d172d2b670ef Mon Sep 17 00:00:00 2001
From: LiHuashen <854410664@qq.com>
Date: Tue, 9 Apr 2019 14:55:01 +0800
Subject: [PATCH] ..
---
...5stick_quick_start_with_arduino_Windows.md | 2 +-
docs/zh_CN/api.md | 43 ++-
docs/zh_CN/api/lcd_m5stickc.md | 322 ++++++++++++++++++
docs/zh_CN/api/system_m5stickc.md | 153 +++------
...5stick_quick_start_with_arduino_Windows.md | 2 +-
5 files changed, 394 insertions(+), 128 deletions(-)
create mode 100644 docs/zh_CN/api/lcd_m5stickc.md
diff --git a/docs/en/quick_start/m5stick/m5stick_quick_start_with_arduino_Windows.md b/docs/en/quick_start/m5stick/m5stick_quick_start_with_arduino_Windows.md
index 2fe7cd82..75ada4b0 100644
--- a/docs/en/quick_start/m5stick/m5stick_quick_start_with_arduino_Windows.md
+++ b/docs/en/quick_start/m5stick/m5stick_quick_start_with_arduino_Windows.md
@@ -74,7 +74,7 @@ Select your board name, baudrate, the specified serial port: M5Stack-Core-ESP32,
-Then select an example likes `Stick` -> `FactoryTest.ino`
+Then select an example likes `M5Stack` -> `Stick` -> `FactoryTest.ino`
diff --git a/docs/zh_CN/api.md b/docs/zh_CN/api.md
index 8739bf68..cf4fec45 100644
--- a/docs/zh_CN/api.md
+++ b/docs/zh_CN/api.md
@@ -5,24 +5,35 @@
|||
|:---:|:---:|
|**[System](zh_CN/api/system)** | **[喇叭](zh_CN/api/speaker)** |
-|**[LCD 屏幕](zh_CN/api/lcd)** | **[按键](zh_CN/api/button)** |
-|**[姿态传感器 (MPU9250)](zh_CN/api/mpu9250)** | **[TF 卡](zh_CN/api/tf)** |
+|**[LCD 屏](zh_CN/api/lcd)** | **[按键](zh_CN/api/button)** |
+|**[MPU9250](zh_CN/api/mpu9250)** | **[TF 卡](zh_CN/api/tf)** |
|**[Power](zh_CN/api/power)** |
-
+
+## M5stickC
+
+
|||
|:---:|:---:|
-|**[system](zh_CN/api/system)** | **[Speaker](zh_CN/api/speaker)** |
-|**[OLED](zh_CN/api/oled)** | **[button](zh_CN/api/button)** |
-|**[MPU9250](zh_CN/api/mpu9250)** | **[Microphone](zh_CN/api/mic)** | -->
-
-
-
-
-
-
-
+|**[System](zh_CN/api/system_m5stickc)** | **[AXP192](zh_CN/api/axp192_m5stickc)** |
+|**[TFT 屏](zh_CN/api/lcd_m5stickc)** | **[SH200Q](zh_CN/api/sh200q_m5stickc)** |
diff --git a/docs/zh_CN/api/lcd_m5stickc.md b/docs/zh_CN/api/lcd_m5stickc.md
new file mode 100644
index 00000000..9d27cdcb
--- /dev/null
+++ b/docs/zh_CN/api/lcd_m5stickc.md
@@ -0,0 +1,322 @@
+# TFT 屏幕
+
+*M5StickC 屏幕像素为 **80x160**,以屏幕左上角为原点 (0,0)*
+
+## ScreenBreath()
+
+**函数原型:**
+
+void ScreenBreath(uint8_t brightness);
+
+**功能:调节屏幕背光亮度。**
+
+| 参数 | 描述 |
+| --- | --- |
+| brightness | 背光值 ( 值: 7 - 16 ) |
+
+**例程:**
+```arduino
+#include
+
+M5.begin();
+M5.Lcd.fillScreen(WHITE);
+
+M5.Axp.ScreenBreath(7);
+delay(2000);
+M5.Axp.ScreenBreath(16);
+```
+
+* * *
+
+## fillScreen()
+
+**函数原型:**
+
+fillScreen(uint16_t color);
+
+**功能:以指定的颜色填充整个屏幕。**
+
+| 参数 | 描述 |
+| --- | --- |
+| color | 颜色值 |
+
+**例程:**
+```arduino
+#include
+
+M5.begin();
+
+M5.Lcd.fillScreen(WHITE);
+```
+
+* * *
+
+## setTextColor()
+
+**函数原型:**
+
+setTextColor(uint16_t color, uint16_t backgroundcolor);
+
+**功能:设置显示文本的前景颜色和背景颜色。**
+
+| 参数 | 描述 |
+| --- | --- |
+| color | 文本的前景颜色 |
+| backgroundcolor| 文本的背景颜色 |
+
+*如果函数的 backgroundcolor 值没给出,则使用当前的背景颜色。*
+
+**例程:**
+```arduino
+#include
+
+M5.begin();
+
+M5.Lcd.setTextColor(RED, WHITE);
+```
+
+* * *
+
+## setCursor()
+
+**函数原型:**
+
+setCursor(int16_t x0, int16_t y0, uint8_t font);
+
+
+
+**功能:移动光标位置到 (x0, y0) 处。**
+
+**例程:**
+```arduino
+#include
+
+M5.begin();
+
+M5.Lcd.setCursor(7, 20, 2);
+M5.Lcd.println("scan done");
+
+M5.Lcd.setCursor(5, 60, 4);
+M5.Lcd.printf("50 AP");
+```
+
+* * *
+
+## drawPixel()
+
+**函数原型:**
+
+drawPixel(int16_t x, int16_t y, uint16_t color);
+
+**功能:在位置(x,y)处画点。**
+
+| 参数 | 描述 |
+| --- | --- |
+| color | 颜色值 |
+
+*如果函数的 color 值没给出,则使用当前的背景颜色。*
+
+**例程:**
+```arduino
+#include
+
+M5.begin();
+
+M5.Lcd.drawPixel(22,22,RED);
+```
+
+* * *
+
+## drawLine()
+
+**函数原型:**
+
+drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
+
+**功能:以指定的颜色从点(x,y)到点(x1,y1)画直线。**
+
+| 参数 | 描述 |
+| --- | --- |
+| color | 颜色值 |
+
+*如果函数的 color 值没给出,则使用当前的背景颜色。*
+
+**例程:**
+```arduino
+#include
+
+M5.begin();
+
+M5.Lcd.drawLine(0,0,12,12,BLUE);
+```
+
+* * *
+
+## drawTriangle()
+
+**函数原型:**
+
+drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
+
+**功能:以指定颜色画三角形,顶点分别为(x,y),(x1,y1)和(x2,y2)。**
+
+| 参数 | 描述 |
+| --- | --- |
+| color | 颜色值 |
+
+*如果函数的 color 值没给出,则使用当前的背景颜色。*
+
+**例程:**
+```arduino
+#include
+
+M5.begin();
+
+M5.Lcd.drawTriangle(22,22,69,98,51,22,RED);
+```
+
+* * *
+
+## fillTriangle()
+
+**函数原型:**
+
+fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
+
+**功能:以指定颜色画填充形式的三角形,顶点分别为(x,y),(x1,y1)和(x2,y2)。**
+
+| 参数 | 描述 |
+| --- | --- |
+| color | 颜色值 |
+
+*如果函数的 color 值没给出,则使用当前的背景颜色。*
+
+**例程:**
+```arduino
+#include
+
+M5.begin();
+
+M5.Lcd.fillTriangle(22,22,69,98,51,22,RED);
+```
+
+* * *
+
+## drawRect()
+
+**函数原型:**
+
+drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
+
+**功能:以指定颜色画矩形,其中矩形左上角坐标为(x,y),宽高分别为width和height。**
+
+| 参数 | 描述 |
+| --- | --- |
+| w | 图形宽(单位: 像素) |
+| h | 图形高(单位: 像素) |
+| color | 颜色值 |
+
+*如果函数的 color 值没给出,则使用当前的背景颜色。*
+
+**例程:**
+```arduino
+#include
+
+M5.begin();
+
+M5.Lcd.drawRect(50, 100, 30, 10, BLUE);
+```
+
+* * *
+
+## fillRect()
+
+**函数原型:**
+
+fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
+
+**功能:以指定颜色画填充形式的矩形,其左上角坐标为(x,y),宽高分别为width和height。**
+
+| 参数 | 描述 |
+| --- | --- |
+| w | 图形宽(单位: 像素) |
+| h | 图形高(单位: 像素) |
+| color | 颜色值 |
+
+*如果函数的 color 值没给出,则使用当前的背景颜色。*
+
+**例程:**
+```arduino
+#include
+
+M5.begin();
+
+M5.Lcd.fillRect(50, 100, 20, 10, BLUE);
+```
+
+* * *
+
+## drawRoundRect()
+
+**函数原型:**
+
+drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
+
+**功能:以指定颜色画圆角矩形,其中矩形左上角坐标为(x,y),宽高分别为width和height,圆角半径为radius。**
+
+| 参数 | 描述 |
+| --- | --- |
+| w | 图形宽(单位: 像素) |
+| h | 图形高(单位: 像素) |
+| radius | 圆角半径 |
+| color | 颜色值 |
+
+*如果函数的 color 值没给出,则使用当前的背景颜色。*
+
+**例程:**
+```arduino
+#include
+
+M5.begin();
+
+M5.Lcd.fillRoundRect(40,70,20,10,4,BLUE);
+```
+
+* * *
+
+## print()
+
+**函数原型:**
+
+print();
+
+**功能:在屏幕的当前位置开始打印文本(字符串) text。**
+
+*默认打印的内容颜色样式是黑底白字。*
+
+**例程:**
+```arduino
+#include
+
+M5.begin();
+
+M5.Lcd.print("print text");
+```
+
+## Usage {docsify-ignore}
+
+```arduino
+#include
+
+M5.begin();
+
+M5.Lcd.fillScreen(WHITE) #set the default background color
+M5.Lcd.drawLine(0, 0, 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");
+```
diff --git a/docs/zh_CN/api/system_m5stickc.md b/docs/zh_CN/api/system_m5stickc.md
index 1a10b10a..23c6cfac 100644
--- a/docs/zh_CN/api/system_m5stickc.md
+++ b/docs/zh_CN/api/system_m5stickc.md
@@ -4,154 +4,87 @@
**函数原型:**
-void begin(bool LCDEnable=true, bool SDEnable=true, bool SerialEnable=true,bool I2CEnable=false);
+void begin(bool LCDEnable=true, bool PowerEnable=true, bool SerialEnable=true);
-**功能:清串口缓冲区,设置串口波特率为 115200;初始化 LCD;初始化 SD 卡;初始化 I2C;设置按键 A 是睡眠唤醒按键。**
+**功能:清串口缓冲区,设置串口波特率为 115200;初始化 LCD;初始化电源管理芯片 AXP192。**
**函数实现**
```arduino
-void M5Stack::begin(bool LCDEnable, bool SDEnable, bool SerialEnable,bool I2CEnable) {
+void M5StickC::begin(bool LCDEnable, bool PowerEnable, bool SerialEnable){
- // Correct init once
- if (isInited) return;
- else isInited = true;
+ //! Correct init once
+ if (isInited) return;
+ else isInited = true;
- // UART
- if (SerialEnable) {
- Serial.begin(115200);
- Serial.flush();
- delay(50);
- Serial.print("M5Stack initializing...");
- }
+ //! UART
+ if (SerialEnable) {
+ Serial.begin(115200);
+ Serial.flush();
+ delay(50);
+ Serial.print("M5StickC initializing...");
+ }
- // LCD INIT
- if (LCDEnable) {
- Lcd.begin();
- }
+ // Power
+ if (PowerEnable) {
+ Axp.begin();
+ }
- // TF Card
- if (SDEnable) {
- SD.begin(TFCARD_CS_PIN, SPI, 40000000);
- }
+ // LCD INIT
+ if (LCDEnable) {
+ Lcd.begin();
+ }
- // TONE
- // Speaker.begin();
- // Set wakeup button
- Power.setWakeupButton(BUTTON_A_PIN);
- // I2C init
- if(I2CEnable)
- {
- Wire.begin(21, 22);
- }
- if (SerialEnable) {
- Serial.println("OK");
- }
+ if (SerialEnable) {
+ Serial.println("OK");
+ }
}
-
-void M5Stack::update() {
-
- //Button update
- BtnA.read();
- BtnB.read();
- BtnC.read();
-
- //Speaker update
- Speaker.update();
-}
-
```
**例程**
```arduino
-#include
+#include
void setup() {
M5.begin();
}
```
-## update()
+## GetBm8563Time()
+
+*这是 BM8563 芯片的 API 函数。该芯片与 ESP32 之间通过 IIC 通信,IIC 地址为 0x51*
**函数原型:**
-void update();
+void GetBm8563Time(void);
-
-
-**功能:读取按键 A, B, C 的状态。**
-
-**函数实现**
+**功能:获取当前时分秒的值,并保存到 M5.Rtc.Hour,M5.Rtc.Minute,M5.Rtc.Second 中,ASCII 格式。**
+**例程:**
```arduino
-void M5Stack::update() {
-
- //Button update
- BtnA.read();
- BtnB.read();
- BtnC.read();
-
- //Speaker update
- Speaker.update();
-}
-```
-
-**例程**
-
-```arduino
-#include
+#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() {
- M5.update();
-}
-```
-
-## powerOFF()
-
-!> 不推荐使用:请使用Power::deepSleep()
-
-**函数原型:**
-
-void powerOFF();
-
-
-
-**功能:系统进入深度睡眠状态。**
-
-**函数实现**
-
-```arduino
-void M5Stack::powerOFF() {
- M5.Power.deepSleep();
-}
-```
-
-**例程**
-
-```arduino
-#include
-
-void setup() {
- M5.begin();
- M5.Lcd.println("This is software power off demo");
- M5.Lcd.println("Press the button A to power off.");
- M5.setWakeupButton(BUTTON_A_PIN);
-}
-
-void loop() {
- M5.update();
- if (M5.BtnA.wasPressed()) {
- M5.powerOFF();
- }
+ // 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/zh_CN/quick_start/m5stick/m5stick_quick_start_with_arduino_Windows.md b/docs/zh_CN/quick_start/m5stick/m5stick_quick_start_with_arduino_Windows.md
index e2928e7c..1821f072 100644
--- a/docs/zh_CN/quick_start/m5stick/m5stick_quick_start_with_arduino_Windows.md
+++ b/docs/zh_CN/quick_start/m5stick/m5stick_quick_start_with_arduino_Windows.md
@@ -74,7 +74,7 @@
-选择示例程序 `Stick` -> `FactoryTest.ino`
+选择示例程序 `M5Stack` -> `Stick` -> `FactoryTest.ino`