M5Unified
m5::Power_Class Class Reference

#include <Power_Class.hpp>

Collaboration diagram for m5::Power_Class:

Public Types

enum  pmic_t {
  pmic_unknown , pmic_adc , pmic_axp192 , pmic_ip5306 ,
  pmic_axp2101
}
 
enum  is_charging_t { is_discharging = 0 , is_charging , charge_unknown }
 

Public Member Functions

bool begin (void)
 
void setExtOutput (bool enable, ext_port_mask_t port_mask=(ext_port_mask_t) 0xFF)
 
void setExtPower (bool enable, ext_port_mask_t port_mask=(ext_port_mask_t) 0xFF)
 deprecated : Change to "setExtOutput" More...
 
bool getExtOutput (void)
 
void setUsbOutput (bool enable)
 
bool getUsbOutput (void)
 
void setLed (uint8_t brightness=255)
 
void powerOff (void)
 all power off. More...
 
void timerSleep (int seconds)
 
void timerSleep (const rtc_time_t &time)
 
void timerSleep (const rtc_date_t &date, const rtc_time_t &time)
 
void deepSleep (std::uint64_t micro_seconds=0, bool touch_wakeup=true)
 
void lightSleep (std::uint64_t micro_seconds=0, bool touch_wakeup=true)
 
std::int32_t getBatteryLevel (void)
 
void setBatteryCharge (bool enable)
 
void setChargeCurrent (std::uint16_t max_mA)
 
void setChargeVoltage (std::uint16_t max_mV)
 
is_charging_t isCharging (void)
 
int16_t getBatteryVoltage (void)
 
int32_t getBatteryCurrent (void)
 
uint8_t getKeyState (void)
 
void setVibration (uint8_t level)
 
pmic_t getType (void) const
 

Public Attributes

AXP2101_Class Axp2101
 
AXP192_Class Axp192
 
IP5306_Class Ip5306
 
INA3221_Class Ina3221
 

Detailed Description

Definition at line 36 of file Power_Class.hpp.

Member Enumeration Documentation

◆ is_charging_t

Enumerator
is_discharging 
is_charging 
charge_unknown 

Definition at line 49 of file Power_Class.hpp.

◆ pmic_t

Enumerator
pmic_unknown 
pmic_adc 
pmic_axp192 
pmic_ip5306 
pmic_axp2101 

Definition at line 41 of file Power_Class.hpp.

Member Function Documentation

◆ begin()

bool m5::Power_Class::begin ( void  )

setup power management ic

++-----— reserved (00) ||+----— boost enable |||+---— charge enable ||||+--— reserved (0) |||||+-— Insert load auto power on function enable ||||||+— BOOST output normally open function (※ DeepSleepやRTC Timer使用時は1にすること (負荷が軽いと電力供給を停止されてしまうため)) |||||||+– Push button shutdown enable ||||||||

+------— Off boost control signal selection (1:Long press ; 0:Short press twice) |+-----— Switch WLED flashlight control signal selection (1:Short press twice ; 0:Long press) ||+----— Short press switch boost |||++--— reserved(11) |||||+-— Whether to turn on Boost after VIN is pulled out ||||||+— reserved(0) |||||||+– Batlow 3.0V Low Power Shutdown Enable ||||||||

+++----— reserved(011) |||+---— KEY Long press time setting (0:2s ; 1:3s) ||||++-— Light load shutdown time setting (00:8s ; 01:32s ; 10:16s ; 11:64s) ||||||++– reserved(00) ||||||||

++++++-— reserved(0) ||||||++– Charge full stop setting 4.14/4.26/4.305/4.35 ||||||||

++-----— Battery side stop charging current detection ||+----— reserved(0) |||+++-— Charging undervoltage loop setting (voltage at output VOUT during charging) ||||||++– reserved(01) ||||||||

++++---— reserved(0000) ||||++-— Battery voltage setting (00:4.2V ; 01:4.3V ; 10:4.35V ; 11:4.4V) ||||||++– Constant voltage charging voltage boost setting (00:nothing ; 01:14mV ; 10:28mV ; 11:42mV) ||||||||

++-----— reserved(10) ||+----— Charging constant current loop selection. (1:CC at VIN side ; 0:CC at BAT side) |||+++++– reserved(01110) ||||||||

+++----— reserved(110) |||+++++– Charger (VIN side) current setting. (I:0.05+b0*0.1+b1*0.2+b2*0.4+b3*0.8+b4*1.6A) ||||||||

+------— VBUS-IPSOUT channel selection control signal when VBUS is available (0:The N_VBUSEN pin determines whether to open this channel. / 1: The VBUS-IPSOUT path can be selected to be opened regardless of the status of N_VBUSEN) |+-----— VBUS VHOLD pressure limit control (0:disable ; 1:enable) ||+++--— VHOLD setting (x 100mV + 4.0V ; 000:4.0V ~ 111:4.7V) |||||+-— reserved(0) ||||||+— VBUS current limit control enable signal |||||||+– VBUS current limit control opens time limit flow selection (0:500mA ; 1:100mA) ||||||||

++++---— reserved ||||+--— PWRON short press wake-up function enable setting in Sleep mode. |||||+++– VOFF Settings (x 100mV + 2.6V 000:2.6V ~ 111:3.3V) ||||||||

+------— Shutdown control under mode A Writing 1 to this bit will turn off the output of the AXP192 |+-----— Battery monitoring function setting (0:off ; 1:on) ||++---— CHGLED pin function setting (00:High resistance ; 01:25% 1Hz blinking ; 10:25% 4Hz blinking ; 11:Output low level) ||||+--— CHGLED pin control settings (0: Controlled by charging function ; 1: Controlled by register REG 32HBit[5:4]) |||||+-— reserved(1) ||||||++– AXP192 Shutdown delay time after N_OE changes from low to high Delay time (00: 0.5S ; 01: 1S ; 10: 2S ; 11: 3S) ||||||||

+------— Charge function enable control bit, including internal and external channels |++----— Charging target voltage setting ( 00:4.1V ; 01:4.15V ; 10:4.2V ; 11:4.36V) |||+---— Charging end current setting (0:End charging when charging current is less than 10% setting ; 1: End charging when charging current is less than 15% setting) ||||++++– Internal path charging current setting ||||||||

Definition at line 46 of file Power_Class.cpp.

Here is the call graph for this function:

◆ deepSleep()

void m5::Power_Class::deepSleep ( std::uint64_t  micro_seconds = 0,
bool  touch_wakeup = true 
)

ESP32 deepsleep

Parameters
secondsNumber of micro seconds to wakeup.

Definition at line 695 of file Power_Class.cpp.

Here is the call graph for this function:

◆ getBatteryCurrent()

int32_t m5::Power_Class::getBatteryCurrent ( void  )

get battery current

Returns
battery current mA

Definition at line 953 of file Power_Class.cpp.

Here is the call graph for this function:

◆ getBatteryLevel()

std::int32_t m5::Power_Class::getBatteryLevel ( void  )

Get the remaining battery power.

Returns
0-100 level

Definition at line 854 of file Power_Class.cpp.

Here is the call graph for this function:

◆ getBatteryVoltage()

int16_t m5::Power_Class::getBatteryVoltage ( void  )

Get battery voltage

Returns
battery voltage [mV]

Definition at line 822 of file Power_Class.cpp.

Here is the call graph for this function:

◆ getExtOutput()

bool m5::Power_Class::getExtOutput ( void  )

Get power output of the external ports.

Returns
true=output enabled / false=output disabled

Definition at line 466 of file Power_Class.cpp.

Here is the call graph for this function:

◆ getKeyState()

uint8_t m5::Power_Class::getKeyState ( void  )

Get Power Key Press condition.

Returns
0=none / 1=long pressed / 2=short clicked / 3=both
Attention
Only for models with AXP192 or AXP2101
Once this function is called, the value is reset to 0, and the next time it is pressed on, the value changes.

Definition at line 1046 of file Power_Class.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getType()

pmic_t m5::Power_Class::getType ( void  ) const
inline

Definition at line 154 of file Power_Class.hpp.

◆ getUsbOutput()

bool m5::Power_Class::getUsbOutput ( void  )

Get power output of the main USB port.

Returns
true=output enabled / false=output disabled
Attention
for M5Stack CoreS3 main USB port.
※ Not for M5Station external USB.

Definition at line 520 of file Power_Class.cpp.

Here is the call graph for this function:

◆ isCharging()

Power_Class::is_charging_t m5::Power_Class::isCharging ( void  )

Get whether the battery is currently charging or not.

Attention
Non-functioning models : CoreInk , M5Paper , M5Stack(with non I2C IP5306)

Definition at line 1019 of file Power_Class.cpp.

Here is the call graph for this function:

◆ lightSleep()

void m5::Power_Class::lightSleep ( std::uint64_t  micro_seconds = 0,
bool  touch_wakeup = true 
)

ESP32 lightsleep

Parameters
secondsNumber of micro seconds to wakeup.

Definition at line 733 of file Power_Class.cpp.

Here is the call graph for this function:

◆ powerOff()

void m5::Power_Class::powerOff ( void  )

all power off.

Definition at line 768 of file Power_Class.cpp.

◆ setBatteryCharge()

void m5::Power_Class::setBatteryCharge ( bool  enable)

set battery charge enable.

Parameters
enabletrue=enable / false=disable

Definition at line 897 of file Power_Class.cpp.

Here is the call graph for this function:

◆ setChargeCurrent()

void m5::Power_Class::setChargeCurrent ( std::uint16_t  max_mA)

set battery charge current

Parameters
max_mAmilli ampere.
Attention
Non-functioning models : CoreInk , M5Paper , M5Stack(with non I2C IP5306)

Definition at line 925 of file Power_Class.cpp.

Here is the call graph for this function:

◆ setChargeVoltage()

void m5::Power_Class::setChargeVoltage ( std::uint16_t  max_mV)

set battery charge voltage

Parameters
max_mVmilli volt.
Attention
Non-functioning models : CoreInk , M5Paper , M5Stack(with non I2C IP5306)

Definition at line 990 of file Power_Class.cpp.

Here is the call graph for this function:

◆ setExtOutput()

void m5::Power_Class::setExtOutput ( bool  enable,
ext_port_mask_t  port_mask = (ext_port_mask_t)0xFF 
)

Set power output of the external ports.

Parameters
enabletrue=output / false=input
port_maskfor M5Station. ext_port (bitmask).

Definition at line 395 of file Power_Class.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setExtPower()

void m5::Power_Class::setExtPower ( bool  enable,
ext_port_mask_t  port_mask = (ext_port_mask_t)0xFF 
)
inline

deprecated : Change to "setExtOutput"

Definition at line 64 of file Power_Class.hpp.

Here is the call graph for this function:

◆ setLed()

void m5::Power_Class::setLed ( uint8_t  brightness = 255)

Turn on/off the power LED.

Parameters
brightness0=OFF: 1~255=ON (Set brightness if possible.)

M5StickC,CPlus /CoreInk : LED = GPIO10 / TimerCam:LED = GPIO2

Definition at line 539 of file Power_Class.cpp.

Here is the call graph for this function:

◆ setUsbOutput()

void m5::Power_Class::setUsbOutput ( bool  enable)

Set power output of the main USB port.

Parameters
enabletrue=output / false=input
Attention
for M5Stack CoreS3 main USB port.
※ Not for M5Station external USB.

Definition at line 505 of file Power_Class.cpp.

Here is the call graph for this function:

◆ setVibration()

void m5::Power_Class::setVibration ( uint8_t  level)

Operate the vibration motor

Parameters
levelVibration strength of the motor. (0=stop)

Definition at line 1070 of file Power_Class.cpp.

Here is the call graph for this function:

◆ timerSleep() [1/3]

void m5::Power_Class::timerSleep ( const rtc_date_t &  date,
const rtc_time_t &  time 
)

sleep and timer boot. The boot condition can be specified by the argument.

Parameters
dateDate to boot. (only date and weekDay can be specified. Ignore year and month)
timeTime to boot. (only minutes and hours can be specified. Ignore seconds)
Attention
CoreInk and M5Paper can't alarm boot because it can't be turned off while connected to USB.
CoreInk と M5Paper は USB接続中はRTCタイマー起動が出来ない。;

Definition at line 792 of file Power_Class.cpp.

Here is the call graph for this function:

◆ timerSleep() [2/3]

void m5::Power_Class::timerSleep ( const rtc_time_t &  time)

sleep and timer boot. The boot condition can be specified by the argument.

Parameters
timeTime to boot. (only minutes and hours can be specified. Ignore seconds)
Attention
CoreInk and M5Paper can't alarm boot because it can't be turned off while connected to USB.
CoreInk と M5Paper は USB接続中はRTCタイマー起動が出来ない。;

Definition at line 785 of file Power_Class.cpp.

Here is the call graph for this function:

◆ timerSleep() [3/3]

void m5::Power_Class::timerSleep ( int  seconds)

sleep and timer boot. The boot condition can be specified by the argument.

Parameters
secondsNumber of seconds to boot.

Definition at line 775 of file Power_Class.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ Axp192

AXP192_Class m5::Power_Class::Axp192

Definition at line 165 of file Power_Class.hpp.

◆ Axp2101

AXP2101_Class m5::Power_Class::Axp2101

Definition at line 164 of file Power_Class.hpp.

◆ Ina3221

INA3221_Class m5::Power_Class::Ina3221

Definition at line 167 of file Power_Class.hpp.

◆ Ip5306

IP5306_Class m5::Power_Class::Ip5306

Definition at line 166 of file Power_Class.hpp.


The documentation for this class was generated from the following files: