2020-08-30 13:06:46 +08:00
# AXP192
2021-01-13 18:38:14 +08:00
**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);`
**Description: Set screen voltage, adjust brightness, valid range of parameters is 2500-3300**
**Example: **
2021-02-26 17:27:20 +08:00
```clike
2021-01-13 18:38:14 +08:00
#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);
}
}
```
2020-08-30 13:06:46 +08:00
## SetLed()
**Syntax: **
2020-11-05 11:39:06 +08:00
`void SetLed(uint8_t state);`
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Description: Set the built-in LED light, state: 1 is on, state: 0 is off**
2020-08-30 13:06:46 +08:00
**Example: **
2021-02-26 17:27:20 +08:00
```clike
2020-08-30 13:06:46 +08:00
#include <M5Core2.h>
void setup() {
M5.begin();
}
void loop() {
2021-01-13 18:38:14 +08:00
M5.Axp.SetLed(1);
delay(1000);
M5.Axp.SetLed(0);
delay(1000);
2020-08-30 13:06:46 +08:00
}
```
## SetBusPowerMode()
**Syntax: **
2021-01-13 18:38:14 +08:00
`void SetBusPowerMode( uint8_t state );`
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Description: Set BUS power mode, set 0 for USB/BAT power supply, set 1 for external input power supply**
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
## SetSpkEnable()
2020-08-30 13:06:46 +08:00
**Syntax: **
2021-01-13 18:38:14 +08:00
`void SetSpkEnable(uint8_t state);`
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Description: Set speaker power enable**
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
## SetCHGCurrent()
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Syntax: **
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
`void SetCHGCurrent(uint8_t state);`
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Description: Set battery charging current**
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
## GetBatVoltage()
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Syntax: **
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
`float GetBatVoltage();`
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Description: Read battery voltage**
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
## GetBatCurrent()
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Syntax: **
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
`float GetBatCurrent();`
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Description: Read battery current**
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
## GetVBusVoltage()
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Syntax: **
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
`float GetVBusVoltage();`
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Description: Read VBUS voltage**
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
## GetVBusCurrent()
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Syntax: **
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
`float GetVBusCurrent();`
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Description: Read VBUS current**
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
## GetTempInAXP192()
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Syntax: **
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
`float GetTempInAXP192();`
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Description: Read AXP192 chip temperature**
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
## GetBatPower()
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
**Syntax: **
2020-08-30 13:06:46 +08:00
2021-01-13 18:38:14 +08:00
`float GetBatPower();`
**Description: Read the current power consumption of the battery**
## GetBatChargeCurrent()
**Syntax: **
`float GetBatChargeCurrent();`
**Description: Read battery charging current**
2020-08-30 13:06:46 +08:00
2021-01-15 15:21:40 +08:00
## isCharging()
**Syntax: **
`bool isCharging();`
**Description: Check if it is charging**