Merge branch 'master' of github.com:m5stack/m5-docs

This commit is contained in:
ali-admin
2021-01-13 18:38:36 +08:00
2 changed files with 193 additions and 585 deletions
+77 -260
View File
@@ -1,6 +1,35 @@
# AXP192
**AXP192 is a highly integrated power system management chip.**
**AXP192 is a highly integrated power system management chip. A series of power chips are packaged in the M5Core2 library to control the power of peripheral peripherals.**
## SetLcdVoltage()
**Syntax**
`void SetLcdVoltage(uint16_t voltage);`
**DescriptionSet screen voltage, adjust brightness, valid range of parameters is 2500-3300**
**Example**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
M5.Lcd.fillScreen(RED);
}
void loop() {
M5.update();
for(int i=2500; i<3300;i++){
M5.Axp.SetLcdVoltage(i);
delay(10);
}
for(int i=3300; i>2500;i--){
M5.Axp.SetLcdVoltage(i);
delay(10);
}
}
```
## SetLed()
@@ -8,60 +37,20 @@
`void SetLed(uint8_t state);`
**DescriptionSetting LED power indicator**
**DescriptionSet the built-in LED light, state: 1 is on, state: 0 is off**
**Example**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
M5.Axp.SetLed(1);
}
void loop() {}
```
## CHGCurrent()
**Syntax:**
`void SetCHGCurrent(uint8_t state);`
**Description: Set charging current.**
**Example:**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin();
M5.Axp.SetCHGCurrent(AXP192::kCHG_190mA);
}
void loop() {
}
```
## setSpkEnable()
**Syntax**
`void SetSpkEnable(uint8_t state);`
**DescriptionEnable speaker。**
**Example**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
M5.Axp.SetSpkEnable(1);
}
void loop() {
M5.Axp.SetLed(1);
delay(1000);
M5.Axp.SetLed(0);
delay(1000);
}
```
@@ -69,253 +58,81 @@ void loop() {
**Syntax**
`void SetBusPowerMode(uint8_t state);`
`void SetBusPowerMode( uint8_t state );`
**DescriptionEnable bus power output**
**Example**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
}
void loop() {
M5.Axp.SetBusPowerMode(1);
}
```
## SetLcdVoltage()
**Syntax:**
`void SetLcdVoltage(uint16_t voltage)`
**Description: Setting screen backlight voltage.**
**Example:**
```arduino
#include <M5Core2.h>
**DescriptionSet BUS power mode, set 0 for USB/BAT power supply, set 1 for external input power supply**
void setup() {
M5.begin();
M5.Axp.SetLcdVoltage(3300);
}
void loop() {
}
```
## SetLDOEnable()
**Syntax:**
`void SetLDOEnable(uint8_t number, bool state)`
**Description: Enable LDO Pin**
**Example:**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin();
}
void loop() {
M5.Axp.SetLDOEnable(3, 1);
delay(200);
M5.Axp.SetLDOEnable(3, 0);
delay(200);
}
```
## SetLDOVoltage()
**Syntax:**
`void SetLDOVoltage(uint8_t number, uint16_t voltage);`
**Description: Config LDO voltage**
**Example:**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin();
M5.Axp.SetLDOVoltage(3,3300);
}
void loop() {
}
```
## isACIN()
## SetSpkEnable()
**Syntax**
`bool isACIN()`
`void SetSpkEnable(uint8_t state);`
**DescriptionDetermine whether the external power supply is connected**
**Example**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
}
void loop() {
if(M5.Axp.isACIN){
Serial.print("AC IN");
}else{
Serial.print("Battery powered");
}
}
```
## GetVapsData()
**Syntax:**
`uint16_t GetVapsData(void);`
**Description: Get battery capacity.**
**Example:**
```arduino
#include <M5Core2.h>
int Vaps;
void setup() {
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
}
void loop() {
Vaps = M5.Axp.GetVapsData();
M5.Lcd.setCursor(0, 0, 1);
M5.Lcd.printf("battery capacity :%dmW\r\n", Vaps);
delay(500);
}
```
## GetTempData()
**Syntax:**
`uint16_t GetTempData(void);`
**Description: Get AXP192 chip temperature.**
**Example:**
```arduino
#include <M5Core2.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);
}
```
**DescriptionSet speaker power enable**
## GetIdischargeData()
## SetCHGCurrent()
**Syntax:**
**Syntax**
`uint16_t GetIdischargeData(void);`
`void SetCHGCurrent(uint8_t state);`
**Description: Obtain discharge current.**
**DescriptionSet battery charging current**
**Example:**
## GetBatVoltage()
```arduino
#include <M5Core2.h>
**Syntax**
int disCharge;
`float GetBatVoltage();`
void setup() {
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
M5.Lcd.fillScreen(BLACK);
}
**DescriptionRead battery voltage**
void loop() {
disCharge = M5.Axp.GetIdischargeData() / 2;
M5.Lcd.setCursor(0, 0, 1);
M5.Lcd.printf("disCharge:%dma\r\n", disCharge);
delay(500);
}
```
## GetBatCurrent()
**Syntax**
## GetIinData()
`float GetBatCurrent();`
**Syntax:**
**DescriptionRead battery current**
`uint16_t GetIinData(void);`
## GetVBusVoltage()
**Description: Get input current.**
**Syntax**
**Example:**
`float GetVBusVoltage();`
```arduino
#include <M5Core2.h>
**DescriptionRead VBUS voltage**
void setup() {
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
M5.Lcd.fillScreen(BLACK);
}
## GetVBusCurrent()
void loop() {
M5.Lcd.setCursor(0, 0, 1);
M5.Lcd.printf("Iin:%.3fmA\r\n",M5.Axp.GetIinData() * 0.625);
}
```
**Syntax**
`float GetVBusCurrent();`
## GetIusbinData()
**DescriptionRead VBUS current**
**Syntax:**
## GetTempInAXP192()
`uint16_t GetIusbinData(void);`
**Syntax**
**Description:Get USB current.**
`float GetTempInAXP192();`
**Example:**
**DescriptionRead AXP192 chip temperature**
```arduino
#include <M5Core2.h>
## GetBatPower()
int Iusb;
**Syntax**
void setup() {
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
M5.Lcd.fillScreen(BLACK);
}
`float GetBatPower();`
**DescriptionRead the current power consumption of the battery**
## GetBatChargeCurrent()
**Syntax**
`float GetBatChargeCurrent();`
**DescriptionRead battery charging current**
void loop() {
Iusb = M5.Axp.GetIdischargeData() * 0.375;
M5.Lcd.setCursor(0, 0, 1);
M5.Lcd.printf("Iusbin:%da\r\n", Iusb);
delay(500);
}
```
+116 -325
View File
@@ -1,327 +1,6 @@
<!-- # AXP192
**AXP192 是一款高度集成的电源系统管理芯片。**
## SetLed()
**函数原型:**
`void SetLed(uint8_t state);`
**功能:设置LED电源指示灯。**
**例程:**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
M5.Axp.SetLed(1);
}
void loop() {}
```
## CHGCurrent()
**函数原型:**
`void SetCHGCurrent(uint8_t state);`
**功能: 设置充电电流.**
**例程:**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin();
M5.Axp.SetCHGCurrent(AXP192::kCHG_190mA);
}
void loop() {
}
```
## setSpkEnable()
**函数原型:**
`void SetSpkEnable(uint8_t state);`
**功能:使能扬声器。**
**例程:**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
M5.Axp.SetSpkEnable(1);
}
void loop() {
}
```
## SetBusPowerMode()
**函数原型:**
`void SetBusPowerMode(uint8_t state);`
**功能:使能总线电源输出**
**例程:**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
}
void loop() {
M5.Axp.SetBusPowerMode(1);
}
```
## SetLcdVoltage()
**函数原型:**
`void SetLcdVoltage(uint16_t voltage)`
**功能: 设置屏幕背光电压.**
**例程:**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin();
M5.Axp.SetLcdVoltage(3300);
}
void loop() {
}
```
## SetLDOEnable()
**函数原型:**
`void SetLDOEnable(uint8_t number, bool state)`
**功能: 使能LDO引脚**
**例程:**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin();
}
void loop() {
M5.Axp.SetLDOEnable(3, 1);
delay(200);
M5.Axp.SetLDOEnable(3, 0);
delay(200);
}
```
## SetLDOVoltage()
**函数原型:**
`void SetLDOVoltage(uint8_t number, uint16_t voltage);`
**功能: 配置LDO引脚电压**
**例程:**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin();
M5.Axp.SetLDOVoltage(3,3300);
}
void loop() {
}
```
## isACIN()
**函数原型:**
`bool isACIN()`
**功能:判断是否外接供电**
**例程:**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
}
void loop() {
if(M5.Axp.isACIN){
Serial.print("AC IN");
}else{
Serial.print("Battery powered");
}
}
```
## GetVapsData()
**函数原型:**
`uint16_t GetVapsData(void);`
**功能: 获取电池容量.**
**例程:**
```arduino
#include <M5Core2.h>
int Vaps;
void setup() {
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
}
void loop() {
Vaps = M5.Axp.GetVapsData();
M5.Lcd.setCursor(0, 0, 1);
M5.Lcd.printf("battery capacity :%dmW\r\n", Vaps);
delay(500);
}
```
## GetTempData()
**函数原型:**
`uint16_t GetTempData(void);`
**功能: 获取芯片温度.**
**例程:**
```arduino
#include <M5Core2.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()
**函数原型:**
`uint16_t GetIdischargeData(void);`
**功能: 获取放电电流.**
**例程:**
```arduino
#include <M5Core2.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()
**函数原型:**
`uint16_t GetIinData(void);`
**功能: 获取输入电流.**
**例程:**
```arduino
#include <M5Core2.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()
**函数原型:**
`uint16_t GetIusbinData(void);`
**功能:获取USB电流.**
**例程:**
```arduino
#include <M5Core2.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);
}
``` -->
# AXP192
**AXP192 是一款高度集成的电源系统管理芯片, 在M5Core2库中封装了一系列电源芯片对周边外设电源控制的API**
## SetLcdVoltage()
@@ -337,11 +16,123 @@ void loop() {
void setup() {
M5.begin(); //By default, "M5.begin()" will initialize AXP192 chip
M5.Axp.ScreenBreath(12);
M5.Lcd.fillScreen(RED);
}
void loop() {
M5.update();
for(int i=2500; i<3300;i++){
M5.Axp.SetLcdVoltage(i);
delay(10);
}
for(int i=3300; i>2500;i--){
M5.Axp.SetLcdVoltage(i);
delay(10);
}
}
```
## SetLed()
**函数原型:**
`void SetLed(uint8_t state);`
**功能:设置内置LED灯, state:1为点亮,state0为熄灭**
**例程:**
```arduino
#include <M5Core2.h>
void setup() {
M5.begin();
}
void loop() {
M5.Axp.SetLed(1);
delay(1000);
M5.Axp.SetLed(0);
delay(1000);
}
```
## SetBusPowerMode()
**函数原型:**
`void SetBusPowerMode( uint8_t state );`
**功能:设置BUS电源模式,设置0为USB/BAT供电,设置1为外部输入供电**
## SetSpkEnable()
**函数原型:**
`void SetSpkEnable(uint8_t state);`
**功能:设置扬声器电源启用**
## SetCHGCurrent()
**函数原型:**
`void SetCHGCurrent(uint8_t state);`
**功能:设置电池充电电流**
## GetBatVoltage()
**函数原型:**
`float GetBatVoltage();`
**功能:读取电池电压**
## GetBatCurrent()
**函数原型:**
`float GetBatCurrent();`
**功能:读取电池电流**
## GetVBusVoltage()
**函数原型:**
`float GetVBusVoltage();`
**功能:读取VBUS电压**
## GetVBusCurrent()
**函数原型:**
`float GetVBusCurrent();`
**功能:读取VBUS电流**
## GetTempInAXP192()
**函数原型:**
`float GetTempInAXP192();`
**功能:读取AXP192芯片温度**
## GetBatPower()
**函数原型:**
`float GetBatPower();`
**功能:读取电池当前消耗功率**
## GetBatChargeCurrent()
**函数原型:**
`float GetBatChargeCurrent();`
**功能:读取电池充电电流**