AXP192

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()

Function:

Set screen voltage, adjust brightness, valid range of parameters is 2500-3300

Syntax:

void SetLcdVoltage(uint16_t voltage)

Example:

#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);
  }
}

PowerOff()

Function:

Cut off all power supply (except RTC)

Syntax:

void PowerOff()

Example:

#include <M5Core2.h>

void setup() {
  M5.begin();
  M5.Lcd.fillScreen(RED);
  delay(1000);
}
void loop() {
  M5.Axp.PowerOff();
}

deepSleep()

Function:

Deep sleep (the program will be executed from scratch after recovery).

Syntax:

void deepSleep(uint64_t time_in_us)

Function prototype:

Parameter Type Description
time_in_us uint64_t Sleep time

Example:

#include <M5Core2.h>

void setup() {
  M5.begin();
  M5.Lcd.println("Going to deep sleep for 5 seconds.");
  delay(2000);
  M5.Axp.DeepSleep(SLEEP_SEC(5));
}
void loop() {
}

lightSleep()

Function:

Light sleep (the program will continue from the next line after recovery)

Syntax:

void lightSleep(uint64_t time_in_us){

Function prototype:

Parameter Type Description
time_in_us uint64_t Sleep time

Example:

#include <M5Core2.h>

void setup() {
  M5.begin();
  M5.Lcd.println("Going to light sleep for 5 seconds.");
  delay(2000);
  M5.Axp.lightSleep(SLEEP_SEC(5));
}
void loop() {
}

SetLed()

Function:

Set the built-in LED light, state: 1 is on, state: 0 is off

Syntax:

void SetLed(uint8_t state)

Example:

#include <M5Core2.h>

void setup() {
  M5.begin();
}
void loop() {
  M5.Axp.SetLed(1);
  delay(1000);
  M5.Axp.SetLed(0);
  delay(1000);
}

SetBusPowerMode()

Function:

Set BUS power mode, set 0 for USB/BAT power supply, set 1 for external input power supply

Syntax:

void SetBusPowerMode( uint8_t state )

SetSpkEnable()

Function:Set speaker power enable

Syntax:

void SetSpkEnable(uint8_t state)

SetCHGCurrent()

Function:

Set battery charging current

Syntax:

void SetCHGCurrent(uint8_t state)

GetBatVoltage()

Function:

Read battery voltage

Syntax:

float GetBatVoltage()

GetBatCurrent()

Function:

Read battery current

Syntax:

float GetBatCurrent()

GetVBusVoltage()

Function:

Read VBUS voltage

Syntax:

float GetVBusVoltage()

GetVBusCurrent()

Function:Read VBUS current

Syntax:

float GetVBusCurrent()

GetTempInAXP192()

Function:

Read AXP192 chip temperature

Syntax:

float GetTempInAXP192()

GetBatPower()

Function:

Read the current power consumption of the battery

Syntax:

float GetBatPower()

GetBatChargeCurrent()

Function:

Read battery charging current

Syntax:

float GetBatChargeCurrent()

isCharging()

Function:

Check if it is charging

Syntax:

bool isCharging()

On This Page