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.

Syntax:

void SetLcdVoltage(uint16_t voltage)

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

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

Syntax:

void deepSleep(uint64_t time_in_us)

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

Syntax:

void lightSleep(uint64_t time_in_us)

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: state = 1 for on; state = 0 for 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, 0 for USB/BAT power supply, 1 for external input power supply.

Syntax:

void SetBusPowerMode( uint8_t state )

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.

Syntax:

void SetSpkEnable(uint8_t state)

Example:

#include <M5Core2.h>

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

SetCHGCurrent()

Function:

Set battery charging current.

Syntax:

void SetCHGCurrent(uint8_t state)

GetBatVoltage()

Function:

Read battery voltage.

Syntax:

float GetBatVoltage()

Example:

#include <M5Core2.h>

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

GetBatCurrent()

Syntax:

Function:

Read battery current.

float GetBatCurrent()

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.

Syntax:

float GetVBusVoltage()

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.

Syntax:

float GetVBusCurrent()

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.

Syntax:

float GetTempInAXP192()

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.

Syntax:

float GetBatPower()

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.

Syntax:

float GetBatChargeCurrent()

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.

Syntax:

bool isCharging()

Example:

#include <M5Core2.h>

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