mirror of
https://github.com/m5stack/m5-docs.git
synced 2026-05-20 10:23:01 -07:00
fix axp192 mistaken add example
This commit is contained in:
@@ -314,32 +314,28 @@ void loop() {
|
||||
|
||||
**Syntax:**
|
||||
|
||||
<mark>uint16_t GetTempData(void);</mark>
|
||||
<mark>uint16_t GetIinData(void);</mark>
|
||||
|
||||
**Description: Get battery capacity.**
|
||||
**Description: ACIN current.**
|
||||
|
||||
**Example:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
int temp;
|
||||
|
||||
void setup() {
|
||||
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
|
||||
M5.Lcd.fillScreen(BLACK);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
temp = M5.Axp.GetTempData()*0.1-144.7;
|
||||
M5.Lcd.setCursor(0, 0, 1);
|
||||
M5.Lcd.printf("tempurature:%d\r\n", temp);
|
||||
delay(500);
|
||||
M5.Lcd.printf("Iin:%.3fmA\r\n",M5.Axp.GetIinData() * 0.625);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## GetIinData()
|
||||
## GetIdischargeData()
|
||||
|
||||
**Syntax:**
|
||||
|
||||
|
||||
@@ -476,4 +476,21 @@ Scanning I2C devices
|
||||
|
||||
>Read data from I2C
|
||||
|
||||
><img src="/image/Advanced module/I2C_user.gif" width="70%">
|
||||
><img src="/image/Advanced module/I2C_user.gif" width="70%">
|
||||
|
||||
|
||||
# Execute
|
||||
__________________________
|
||||
|
||||
#### Function Description
|
||||
|
||||
>Execution of external programs
|
||||
|
||||
><img src="/image/Advanced module/Execute.png" width="70%">
|
||||
|
||||
|
||||
#### Instructions
|
||||
|
||||
>import Library
|
||||
|
||||
><img src="/image/Advanced module/Execute_user.gif" width="70%">
|
||||
|
||||
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 208 KiB |
@@ -20,6 +20,31 @@ void setup() {
|
||||
void loop() {}
|
||||
```
|
||||
|
||||
## GetWarningLeve()
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>uint8_t GetWarningLeve(void);</mark>
|
||||
|
||||
**功能: 获取当前报警等级.**
|
||||
|
||||
**例程:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
int level;
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
}
|
||||
void loop() {
|
||||
level = M5.Axp.GetWarningLeve();
|
||||
M5.Lcd.setCursor(0, 0);
|
||||
M5.Lcd.print(level);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## ScreenBreath()
|
||||
|
||||
**函数原型:**
|
||||
@@ -30,7 +55,7 @@ void loop() {}
|
||||
|
||||
| 参数 | 描述 |
|
||||
| --- | --- |
|
||||
| brightness | TFT 的背光 ( 数值范围:7-15 ) |
|
||||
| brightness | TFT 的背光 ( 数值范围:7-12 ) |
|
||||
|
||||
**例程:**
|
||||
```arduino
|
||||
@@ -76,6 +101,101 @@ void loop() {
|
||||
}
|
||||
```
|
||||
|
||||
## LightSleep()
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>void LightSleep(uint64_t time_in_us = 0)</mark>
|
||||
|
||||
**功能: 控制ESP32进入轻度睡眠模式,开机键唤醒.**
|
||||
|
||||
| 参数 | 描述 |
|
||||
| --- | --- |
|
||||
| time_in_us| 休眠时间|
|
||||
|
||||
**例程:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
int count = 0;
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.Lcd.fillScreen(WHITE);
|
||||
pinMode(M5_BUTTON_HOME,INPUT_PULLUP);
|
||||
}
|
||||
void loop() {
|
||||
if(digitalRead(M5_BUTTON_HOME) == LOW){
|
||||
while(digitalRead(M5_BUTTON_HOME) == LOW);
|
||||
M5.Axp.LightSleep(SLEEP_SEC(5)); //SLEEP_SEC(us) (((uint64_t)us) * 1000000L)
|
||||
}
|
||||
count++;
|
||||
M5.Lcd.setCursor(60, 30);
|
||||
M5.Lcd.setTextColor(BLACK, WHITE);
|
||||
M5.Lcd.print(count);
|
||||
}
|
||||
```
|
||||
|
||||
## DeepSleep()
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>void DeepSleep(uint64_t time_in_us = 0)</mark>
|
||||
|
||||
**功能: 控制外设进入休眠模式,到达时间自动唤醒.**
|
||||
|
||||
**例程:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.Lcd.setRotation(3);
|
||||
M5.Lcd.fillScreen(WHITE);
|
||||
M5.Lcd.setTextColor(BLACK, WHITE);
|
||||
pinMode(M5_BUTTON_HOME,INPUT_PULLUP);
|
||||
M5.Lcd.setCursor(60, 30);
|
||||
M5.Lcd.print("SLEEP");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if(digitalRead(M5_BUTTON_HOME) == LOW){
|
||||
while(digitalRead(M5_BUTTON_HOME) == LOW);
|
||||
M5.Axp.DeepSleep(SLEEP_SEC(5));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## SetSleep()
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>void SetSleep(void);</mark>
|
||||
|
||||
**功能: 控制外设进入休眠模式,按下电源键唤醒.**
|
||||
|
||||
**例程:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
M5.Lcd.fillScreen(WHITE);
|
||||
pinMode(M5_BUTTON_HOME,INPUT_PULLUP);
|
||||
M5.Lcd.setCursor(60, 30);
|
||||
M5.Lcd.print("SLEEP");
|
||||
}
|
||||
void loop() {
|
||||
if(digitalRead(M5_BUTTON_HOME) == LOW){
|
||||
while(digitalRead(M5_BUTTON_HOME) == LOW);
|
||||
M5.Axp.SetSleep();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## GetIchargeData()
|
||||
|
||||
**函数原型:**
|
||||
@@ -101,4 +221,173 @@ void loop() {
|
||||
M5.Lcd.printf("icharge:%dmA\r\n", charge);
|
||||
delay(500);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## GetPowerbatData()
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>uint32_t GetPowerbatData(void);</mark>
|
||||
|
||||
**功能: 当前电源功率.**
|
||||
|
||||
**例程:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
int bat;
|
||||
|
||||
void setup() {
|
||||
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
|
||||
M5.Lcd.fillScreen(BLACK);
|
||||
M5.Axp.ScreenBreath(7);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
bat = M5.Axp.GetPowerbatData()*1.1*0.5/1000;
|
||||
M5.Lcd.setCursor(0, 0, 1);
|
||||
M5.Lcd.printf("battery power:%dmW\r\n", bat);
|
||||
delay(500);
|
||||
}
|
||||
```
|
||||
|
||||
## GetVapsData()
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>uint16_t GetVapsData(void);</mark>
|
||||
|
||||
**功能: 获取电池容量.**
|
||||
|
||||
**例程:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
int Vaps;
|
||||
|
||||
void setup() {
|
||||
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
|
||||
M5.Lcd.fillScreen(BLACK);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Vaps = M5.Axp.GetVapsData();
|
||||
M5.Lcd.setCursor(0, 0, 1);
|
||||
M5.Lcd.printf("battery capacity :%dmW\r\n", Vaps);
|
||||
delay(500);
|
||||
}
|
||||
```
|
||||
|
||||
## GetTempData()
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>uint16_t GetTempData(void);</mark>
|
||||
|
||||
**功能: 获取芯片温度.**
|
||||
|
||||
**例程:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
int temp;
|
||||
|
||||
void setup() {
|
||||
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
|
||||
M5.Lcd.fillScreen(BLACK);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
temp = M5.Axp.GetTempData()*0.1-144.7;
|
||||
M5.Lcd.setCursor(0, 0, 1);
|
||||
M5.Lcd.printf("tempurature:%d\r\n", temp);
|
||||
delay(500);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## GetIdischargeData()
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>uint16_t GetIdischargeData(void);</mark>
|
||||
|
||||
**功能: 获取放电电流.**
|
||||
|
||||
**例程:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
int disCharge;
|
||||
|
||||
void setup() {
|
||||
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
|
||||
M5.Lcd.fillScreen(BLACK);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
disCharge = M5.Axp.GetIdischargeData() / 2;
|
||||
M5.Lcd.setCursor(0, 0, 1);
|
||||
M5.Lcd.printf("disCharge:%dma\r\n", disCharge);
|
||||
delay(500);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## GetIinData()
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>uint16_t GetIinData(void);</mark>
|
||||
|
||||
**功能: 获取输入电流.**
|
||||
|
||||
**例程:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
|
||||
M5.Lcd.fillScreen(BLACK);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
M5.Lcd.setCursor(0, 0, 1);
|
||||
M5.Lcd.printf("Iin:%.3fmA\r\n",M5.Axp.GetIinData() * 0.625);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## GetIusbinData()
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>uint16_t GetIusbinData(void);</mark>
|
||||
|
||||
**功能:获取USB电流.**
|
||||
|
||||
**例程:**
|
||||
|
||||
```arduino
|
||||
#include <M5StickC.h>
|
||||
|
||||
int Iusb;
|
||||
|
||||
void setup() {
|
||||
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
|
||||
M5.Lcd.fillScreen(BLACK);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Iusb = M5.Axp.GetIdischargeData() * 0.375;
|
||||
M5.Lcd.setCursor(0, 0, 1);
|
||||
M5.Lcd.printf("Iusbin:%da\r\n", Iusb);
|
||||
delay(500);
|
||||
}
|
||||
```
|
||||
@@ -515,4 +515,21 @@ __________________________
|
||||
|
||||
>从I2C读取数据
|
||||
|
||||
><img src="/image/Advanced module/I2C_user.gif" width="70%">
|
||||
><img src="/image/Advanced module/I2C_user.gif" width="70%">
|
||||
|
||||
|
||||
# Execute
|
||||
__________________________
|
||||
|
||||
#### 功能说明
|
||||
|
||||
>执行外部程序
|
||||
|
||||
><img src="/image/Advanced module/Execute.png" width="70%">
|
||||
|
||||
|
||||
#### 使用方法
|
||||
|
||||
>导入库
|
||||
|
||||
><img src="/image/Advanced module/Execute_user.gif" width="70%">
|
||||
|
||||
Reference in New Issue
Block a user