pdf-icon

AXP192

The AXP192 is a highly integrated power system management chip, encapsulated in the M5Core2 library with a series of APIs for controlling the power supply of peripheral devices.

SetLcdVoltage()

Function:

Set the screen voltage to adjust brightness. Valid range for the parameter is 2500-3300.

Function Prototype:

void SetLcdVoltage(uint16_t voltage)

Usage Example:

#include <M5Core2.h>

void setup() {
  M5.begin(); //By default, "M5.begin()" will initialize the 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 supplies (except for RTC).

Function Prototype:

void PowerOff()

Usage 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 restart from the beginning after recovery).

Function Prototype:

void deepSleep(uint64_t time_in_us)

Parameter Type Description
time_in_us uint64_t Sleep time

Usage 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 execution from the next line after recovery).

Function Prototype:

void lightSleep(uint64_t time_in_us)

Parameter Type Description
time_in_us uint64_t Sleep time

Usage 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: state = 1 for on; state = 0 for off.

Function Prototype:

void SetLed(uint8_t state)

Usage 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, 0 for USB/BAT power supply, 1 for external input power supply.

Function Prototype:

void SetBusPowerMode( uint8_t state )

Usage Example:

#include <M5Core2.h>

void setup() {
  M5.begin();
  M5.Axp.SetBusPowerMode(0);  //Set the Bus power mode for USB/BAT power supply
}
void loop() {
}

SetSpkEnable()

Function:

Set speaker power enable.

Function Prototype:

void SetSpkEnable(uint8_t state)

Usage Example:

#include <M5Core2.h>

void setup() {
  M5.begin();
  M5.Axp.SetSpkEnable(1);  //Power on the speaker
}
void loop() {
}

SetCHGCurrent()

Function:

Set battery charging current.

Function Prototype:

void SetCHGCurrent(uint8_t state)

GetBatVoltage()

Function:

Read battery voltage.

Function Prototype:

float GetBatVoltage()

Usage Example:

#include <M5Core2.h>

void setup() {
  M5.begin();
}
void loop() {
  Serial.printf("Bat Voltage:%f\n", M5.Axp.GetBatVoltage());
  delay(500);
}

GetBatCurrent()

Function Prototype:

Function:

Read battery current.

float GetBatCurrent()

Usage Example:

#include <M5Core2.h>

void setup() {
  M5.begin();
}
void loop() {
  Serial.printf("Bat Current:%f\n", M5.Axp.GetBatCurrent());
  delay(500);
}

GetVBusVoltage()

Function:

Read VBUS voltage.

Function Prototype:

float GetVBusVoltage()

Usage Example:

#include <M5Core2.h>

void setup() {
  M5.begin();
}
void loop() {
  Serial.printf("VBus Voltage:%f\n", M5.Axp.GetVBusVoltage());
  delay(500);
}

GetVBusCurrent()

Function:

Read VBUS current.

Function Prototype:

float GetVBusCurrent()

Usage Example:

#include <M5Core2.h>

void setup() {
  M5.begin();
}
void loop() {
  Serial.printf("VBus Current:%f\n", M5.Axp.GetVBusCurrent());
  delay(500);
}

GetTempInAXP192()

Function:

Read the temperature of the AXP192 chip.

Function Prototype:

float GetTempInAXP192()

Usage Example:

#include <M5Core2.h>

void setup() {
  M5.begin();
}
void loop() {
  Serial.printf("AXP192 Temp:%f\n", M5.Axp.GetTempInAXP192());
  delay(500);
}

GetBatPower()

Function:

Read the current power consumption of the battery.

Function Prototype:

float GetBatPower()

Usage Example:

#include <M5Core2.h>

void setup() {
  M5.begin();
}
void loop() {
  Serial.printf("AXP192 Temp:%f\n", M5.Axp.GetTempInAXP192());
  delay(500);
}

GetBatChargeCurrent()

Function:

Read battery charging current.

Function Prototype:

float GetBatChargeCurrent()

Usage Example:

#include <M5Core2.h>

void setup() {
  M5.begin();
}
void loop() {
  Serial.printf("Bat Charge Current:%f\n", M5.Axp.GetBatChargeCurrent());
  delay(500);
}

isCharging()

Function:

Check if

it is in charging state.

Function Prototype:

bool isCharging()

Usage Example:

#include <M5Core2.h>

void setup() {
  M5.begin();
}
void loop() {
  Serial.printf("Charging state:%d\n", M5.Axp.isCharging());
  delay(500);
}
On This Page