pdf-icon

AXP192

The AXP192 is a highly integrated power system management chip.

begin()

Function:

Initializes the AXP192 chip.

Function prototype:

void begin(void)

Usage example:

#include <M5StickC.h>

void setup() {
  M5.begin(); //By default, "M5.begin()" will initialize the AXP192 chip.
}
void loop() {}

GetWarningLeve()

Function:

Gets the current warning level.

Function prototype:

uint8_t GetWarningLeve(void)

Usage example:

#include <M5StickC.h>
int level;

void setup() { 
  M5.begin();
}
void loop() {
  level = M5.Axp.GetWarningLeve();
  M5.Lcd.setCursor(0, 0);
  M5.Lcd.print(level);
}

ScreenBreath()

Function:

Changes the LDO3 output voltage of the AXP192 chip.

Function prototype:

void ScreenBreath(uint8_t brightness)

Parameter Description
brightness TFT backlight (value range: 7-12)

Usage example:

#include <M5StickC.h>

uint8_t i = 7;

void setup() {
  M5.begin(); //By default, "M5.begin()" will initialize the AXP192 chip.
  M5.Lcd.printf("Hello, M5Stack!!");
}
void loop() {
  M5.Axp.ScreenBreath(i++);
  if (i > 15) i = 7;
  delay(1000);
}

GetVbatData()

Function:

Gets the battery voltage value.

Function prototype:

uint16_t GetVbatData(void)

Usage example:

#include <M5StickC.h>

double vbat = 0.0;

void setup() {
  M5.begin(); //By default, "M5.begin()" will initialize the AXP192 chip.
  M5.Lcd.fillScreen(BLACK);
}

void loop() {
  vbat = M5.Axp.GetVbatData() * 1.1 / 1000;
  M5.Lcd.setCursor(0, 0, 1);
  M5.Lcd.printf("vbat:%.3fV\r\n", vbat);
  delay(500);
}

LightSleep()

Function:

Controls the ESP32 to enter light sleep mode, waking up with the power button.

Function prototype:

void LightSleep(uint64_t time_in_us = 0)

Parameter Description
time_in_us Sleep duration

Usage example:

#include <M5StickC.h>

int count = 0;
void setup() { 
  M5.begin();
  M5.Lcd.fillScreen(WHITE);
  pinMode(M5_BUTTON_HOME, INPUT_PULLUP);
}
void loop() {
  if(digitalRead(M5_BUTTON_HOME) == LOW){
    while(digitalRead(M5_BUTTON_HOME) == LOW);
    M5.Axp.LightSleep(SLEEP_SEC(5));  //SLEEP_SEC(us)  (((uint64_t)us) * 1000000L)
  }
  count++;
  M5.Lcd.setCursor(60, 30);
  M5.Lcd.setTextColor(BLACK, WHITE);
  M5.Lcd.print(count);
}

DeepSleep()

Function:

Controls peripherals to enter sleep mode, automatically waking up after a set time.

Function prototype:

void DeepSleep(uint64_t time_in_us = 0)

Usage example:

#include <M5StickC.h>

void setup() {
  M5.begin();
  M5.Lcd.setRotation(3);
  M5.Lcd.fillScreen(WHITE);
  M5.Lcd.setTextColor(BLACK, WHITE);
  pinMode(M5_BUTTON_HOME,INPUT_PULLUP);
  M5.Lcd.setCursor(60, 30);
  M5.Lcd.print("SLEEP");
}

void loop() {
  if(digitalRead(M5_BUTTON_HOME) == LOW){
    while(digitalRead(M5_BUTTON_HOME) == LOW);
    M5.Axp.DeepSleep(SLEEP_SEC(5));
  }
}

SetSleep()

Function:

Controls the device to enter sleep mode, wake up by pressing the power button.

Function Prototype:

void SetSleep(void)

Usage Example:

#include <M5StickC.h>

void setup() { 
  M5.begin();
  M5.Lcd.fillScreen(WHITE);
  pinMode(M5_BUTTON_HOME,INPUT_PULLUP);
  M5.Lcd.setCursor(60, 30);
  M5.Lcd.print("SLEEP");
}
void loop() {
  if(digitalRead(M5_BUTTON_HOME) == LOW){
    while(digitalRead(M5_BUTTON_HOME) == LOW);
    M5.Axp.SetSleep(); 
  }
}

GetIchargeData()

Function:

Gets the battery charging current value.

Function Prototype:

uint16_t GetIchargeData(void)

Usage Example:

#include <M5StickC.h>
int charge;

void setup() {
  M5.begin(); //By default, "M5.begin()" will initialize the AXP192 chip.
  M5.Lcd.fillScreen(BLACK);
}

void loop() {
  charge = M5.Axp.GetIchargeData() / 2;
  M5.Lcd.setCursor(0, 0, 1);
  M5.Lcd.printf("icharge:%dmA\r\n", charge);
  delay(500);
}

GetPowerbatData()

Function:

Gets the current power supply power.

Function Prototype:

uint32_t GetPowerbatData(void)

Usage Example:

#include <M5StickC.h>

int bat;

void setup() {
  M5.begin(); //By default, "M5.begin()" will initialize the AXP192 chip.
  M5.Lcd.fillScreen(BLACK);
  M5.Axp.ScreenBreath(7);
}

void loop() {
  bat = M5.Axp.GetPowerbatData()*1.1*0.5/1000;
  M5.Lcd.setCursor(0, 0, 1);
  M5.Lcd.printf("battery power:%dmW\r\n", bat);
  delay(500);
}

GetVapsData()

Function:

Gets the APS voltage.

Function Prototype:

uint16_t GetVapsData(void)

Usage Example:

#include <M5StickC.h>

int Vaps;

void setup() {
  M5.begin(); //By default, "M5.begin()" will initialize the AXP192 chip.
  M5.Lcd.fillScreen(BLACK);
}

void loop() {
  Vaps = M5.Axp.GetVapsData();
  M5.Lcd.setCursor(0, 0, 1);
  M5.Lcd.printf("The APS Voltage is :%dmW\r\n", Vaps);
  delay(500);
}

GetTempData()

Function:

Gets the chip temperature.

Function Prototype:

uint16_t GetTempData(void)

Usage Example:

#include <M5StickC.h>

int temp;

void setup() {
  M5.begin(); //By default, "M5.begin()" will initialize the 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("temperature:%d\r\n", temp);
  delay(500);
}

GetIdischargeData()

Function:

Gets the discharge current.

Function Prototype:

uint16_t GetIdischargeData(void)

Usage Example:

#include <M5StickC.h>

int disCharge;

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

Function:

Gets the input current.

Function Prototype:

uint16_t GetIinData(void)

Usage Example:

#include <M5StickC.h>

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

Function:

Gets the current USB current.

Function Prototype:

uint16_t GetIusbinData(void)

Usage Example:

#include <M5StickC.h>

int Iusb;

void setup() {
  M5.begin(); //By default, "M5.begin()" will initialize the 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);
}
On This Page