mirror of
https://github.com/m5stack/m5-docs.git
synced 2026-05-20 10:23:01 -07:00
Merge branch 'master' of https://github.com/m5stack/m5-docs
This commit is contained in:
+154
-25
@@ -4,11 +4,21 @@
|
||||
|
||||
**Syntax:**
|
||||
|
||||
<mark>bool setPowerBoostKeepOn(bool en);</mark>
|
||||
<mark>bool setPowerBoostKeepOn(bool en)</mark>
|
||||
|
||||
**Description:**
|
||||
|
||||
This function sets enable/disable power mode.
|
||||
This function sets/unsets always boost output mode.
|
||||
|
||||
**Function argument**
|
||||
|
||||
true: Turn on always boost output mode,
|
||||
false: Turn off always boost output mode.
|
||||
|
||||
**Function return value**
|
||||
|
||||
true: Control success,
|
||||
false: Control failure.
|
||||
|
||||
**Definition:**
|
||||
|
||||
@@ -26,29 +36,83 @@ bool setPowerBoostKeepOn(bool en){
|
||||
Wire.beginTransmission(IP5306_ADDR);
|
||||
Wire.write(IP5306_REG_SYS_CTL0);
|
||||
if (en) Wire.write(data | BOOST_OUT_BIT);
|
||||
else Wire.write(data &(~BOOST_OUT_BIT));
|
||||
else Wire.write(data &(~BOOST_OUT_BIT));
|
||||
Wire.endTransmission();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
```
|
||||
|
||||
## setKeepLightLoad()
|
||||
|
||||
**Syntax:**
|
||||
|
||||
<mark>bool setKeepLightLoad(bool en)</mark>
|
||||
|
||||
**Description:**
|
||||
|
||||
This function sets/unsets to disable the automatic shutdown.
|
||||
|
||||
**Function argument**
|
||||
|
||||
true: When the current is too small, IP5306 will *not* automatically shutdown,
|
||||
false: When the current is too small, IP5306 will automatically shutdown.
|
||||
|
||||
**Function return value**
|
||||
|
||||
true: Control success,
|
||||
false: Control failure.
|
||||
|
||||
|
||||
**Definition:**
|
||||
|
||||
```arduino
|
||||
bool setKeepLightLoad(bool en) {
|
||||
uint8_t data;
|
||||
Wire.beginTransmission(IP5306_ADDR);
|
||||
Wire.write(IP5306_REG_SYS_CTL0);
|
||||
Wire.endTransmission();
|
||||
|
||||
if(Wire.requestFrom(IP5306_ADDR, 1))
|
||||
{
|
||||
data = Wire.read();
|
||||
|
||||
Wire.beginTransmission(IP5306_ADDR);
|
||||
Wire.write(IP5306_REG_SYS_CTL0);
|
||||
if (!en) Wire.write(data | LIGHT_LOAD_BIT);
|
||||
else Wire.write(data &(~LIGHT_LOAD_BIT));
|
||||
Wire.endTransmission();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
```
|
||||
|
||||
## setCharge()
|
||||
|
||||
**Syntax:**
|
||||
|
||||
<mark>bool setCharge(bool en);</mark>
|
||||
<mark>bool setCharge(bool en)</mark>
|
||||
|
||||
**Description:**
|
||||
|
||||
This function sets enable/disable charge mode.
|
||||
This function sets/unsets charge mode. When the battery is fully charged, try set charge enable->disable->enable, It can be recharged.
|
||||
|
||||
**Function argument**
|
||||
|
||||
true: Start charging,
|
||||
false: Stop charging.
|
||||
|
||||
**Function return value**
|
||||
|
||||
true: Control success,
|
||||
false: Control failure.
|
||||
|
||||
**Definition:**
|
||||
|
||||
```arduino
|
||||
bool POWER::setCharge(bool en){
|
||||
bool setCharge(bool en){
|
||||
uint8_t data;
|
||||
Wire.beginTransmission(IP5306_ADDR);
|
||||
Wire.write(IP5306_REG_SYS_CTL0);
|
||||
@@ -61,7 +125,7 @@ bool POWER::setCharge(bool en){
|
||||
Wire.beginTransmission(IP5306_ADDR);
|
||||
Wire.write(IP5306_REG_SYS_CTL0);
|
||||
if (en) Wire.write(data | CHARGE_OUT_BIT);
|
||||
else Wire.write(data &(~CHARGE_OUT_BIT));
|
||||
else Wire.write(data &(~CHARGE_OUT_BIT));
|
||||
Wire.endTransmission();
|
||||
return true;
|
||||
}
|
||||
@@ -73,11 +137,20 @@ bool POWER::setCharge(bool en){
|
||||
|
||||
**Syntax:**
|
||||
|
||||
<mark>bool isChargeFull(bool en);</mark>
|
||||
<mark>bool isChargeFull()</mark>
|
||||
|
||||
**Description:**
|
||||
|
||||
This function check battery level.
|
||||
This function checks if the battery is fully charged.
|
||||
|
||||
**Function argument**
|
||||
|
||||
No argument.
|
||||
|
||||
**Function return value**
|
||||
|
||||
true: Full charged,
|
||||
false: Not full charged.
|
||||
|
||||
**Definition:**
|
||||
|
||||
@@ -101,11 +174,20 @@ bool isChargeFull(){
|
||||
|
||||
**Syntax:**
|
||||
|
||||
<mark>bool canControl();</mark>
|
||||
<mark>bool canControl()</mark>
|
||||
|
||||
**Description:**
|
||||
|
||||
This function checks the existence of the battery controller
|
||||
This function checks the existence of the battery controller on I2C.
|
||||
|
||||
**Function argument**
|
||||
|
||||
No argument.
|
||||
|
||||
**Function return value**
|
||||
|
||||
true: Battery controller is found,
|
||||
false: Battery controller is not found.
|
||||
|
||||
**Definition:**
|
||||
|
||||
@@ -122,11 +204,20 @@ bool canControl(){
|
||||
|
||||
**Syntax:**
|
||||
|
||||
<mark>bool isCharging(){</mark>
|
||||
<mark>bool isCharging()</mark>
|
||||
|
||||
**Description:**
|
||||
|
||||
This function checks the state of the charge
|
||||
This function checks the state of the charging.
|
||||
|
||||
**Function argument**
|
||||
|
||||
No argument.
|
||||
|
||||
**Function return value**
|
||||
|
||||
true: In charging,
|
||||
false: Not in charging.
|
||||
|
||||
**Definition:**
|
||||
|
||||
@@ -145,17 +236,55 @@ bool isCharging(){
|
||||
return false;
|
||||
}
|
||||
```
|
||||
## getBatteryLevel()
|
||||
|
||||
**Syntax:**
|
||||
|
||||
<mark>bool getBatteryLevel()</mark>
|
||||
|
||||
**Description:**
|
||||
|
||||
This function gets the battery level.
|
||||
|
||||
**Function argument**
|
||||
|
||||
No argument.
|
||||
|
||||
**Function return value**
|
||||
|
||||
Battery remaining percentage. (0-100 %)
|
||||
Returns -1 if it can not communicate with the controller.
|
||||
|
||||
|
||||
**Definition:**
|
||||
|
||||
```arduino
|
||||
int8_t getBatteryLevel() {
|
||||
Wire.beginTransmission(0x75);
|
||||
Wire.write(0x78);
|
||||
if (Wire.endTransmission(false) == 0 && Wire.requestFrom(0x75, 1)) {
|
||||
switch (Wire.read() & 0xF0) {
|
||||
case 0xE0: return 25;
|
||||
case 0xC0: return 50;
|
||||
case 0x80: return 75;
|
||||
case 0x00: return 100;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## setWakeupButton()
|
||||
|
||||
**Syntax:**
|
||||
|
||||
<mark>void setWakeupButton(uint8_t button){</mark>
|
||||
<mark>void setWakeupButton(uint8_t button)</mark>
|
||||
|
||||
**Description:**
|
||||
|
||||
This function set the port to exit sleep
|
||||
This function sets the port to exit sleep mode.
|
||||
|
||||
**Definition:**
|
||||
|
||||
@@ -173,31 +302,31 @@ void setWakeupButton(uint8_t button) {
|
||||
|
||||
**Description:**
|
||||
|
||||
This function reset the CPU.
|
||||
This function resets the CPU.
|
||||
|
||||
**Definition:**
|
||||
|
||||
```arduino
|
||||
void POWER::reset() {
|
||||
void reset() {
|
||||
esp_restart();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
<!--
|
||||
## batteryMode()
|
||||
|
||||
**Syntax:**
|
||||
|
||||
<mark>bool boostMode(bool en)</mark>
|
||||
<mark>bool batteryMode(bool en)</mark>
|
||||
|
||||
**Description:**
|
||||
|
||||
This function controls power supply
|
||||
This function controls power supply.
|
||||
|
||||
**Definition:**
|
||||
|
||||
```arduino
|
||||
bool boostMode(bool en){
|
||||
bool batteryMode(bool en){
|
||||
|
||||
uint8_t data;
|
||||
Wire.beginTransmission(IP5306_ADDR);
|
||||
@@ -218,7 +347,7 @@ bool boostMode(bool en){
|
||||
return false;
|
||||
}
|
||||
```
|
||||
|
||||
-->
|
||||
|
||||
## deepSleep()
|
||||
|
||||
@@ -228,7 +357,7 @@ bool boostMode(bool en){
|
||||
|
||||
**Description:**
|
||||
|
||||
This function shifts to deep sleep mode
|
||||
This function shifts to deep sleep mode.
|
||||
|
||||
**Definition:**
|
||||
|
||||
@@ -252,4 +381,4 @@ void deepSleep(){
|
||||
}
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
+155
-28
@@ -4,13 +4,23 @@
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>bool setPowerBoostKeepOn(bool en);</mark>
|
||||
<mark>bool setPowerBoostKeepOn(bool en)</mark>
|
||||
|
||||
**説明:**
|
||||
|
||||
電源供給状態を設定します。
|
||||
|
||||
**定義:**
|
||||
**引数**
|
||||
|
||||
true: 常時供給モードon。
|
||||
false: 常時供給モードoff。
|
||||
|
||||
**戻り値**
|
||||
|
||||
true: 制御成功。
|
||||
false: 制御失敗。
|
||||
|
||||
**定義**
|
||||
|
||||
```arduino
|
||||
bool setPowerBoostKeepOn(bool en){
|
||||
@@ -26,24 +36,78 @@ bool setPowerBoostKeepOn(bool en){
|
||||
Wire.beginTransmission(IP5306_ADDR);
|
||||
Wire.write(IP5306_REG_SYS_CTL0);
|
||||
if (en) Wire.write(data | BOOST_OUT_BIT);
|
||||
else Wire.write(data &(~BOOST_OUT_BIT));
|
||||
else Wire.write(data &(~BOOST_OUT_BIT));
|
||||
Wire.endTransmission();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
```
|
||||
|
||||
## setKeepLightLoad()
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>bool setKeepLightLoad(bool en)</mark>
|
||||
|
||||
**説明:**
|
||||
|
||||
自動シャットダウン無効化機能を設定します。
|
||||
|
||||
**引数**
|
||||
|
||||
true: 軽負荷時に自動シャットダウンしません。
|
||||
false: 軽負荷時に自動シャットダウンします。
|
||||
|
||||
**戻り値**
|
||||
|
||||
true: 制御成功。
|
||||
false: 制御失敗。
|
||||
|
||||
**定義:**
|
||||
|
||||
```arduino
|
||||
bool setKeepLightLoad(bool en) {
|
||||
uint8_t data;
|
||||
Wire.beginTransmission(IP5306_ADDR);
|
||||
Wire.write(IP5306_REG_SYS_CTL0);
|
||||
Wire.endTransmission();
|
||||
|
||||
if(Wire.requestFrom(IP5306_ADDR, 1))
|
||||
{
|
||||
data = Wire.read();
|
||||
|
||||
Wire.beginTransmission(IP5306_ADDR);
|
||||
Wire.write(IP5306_REG_SYS_CTL0);
|
||||
if (!en) Wire.write(data | LIGHT_LOAD_BIT);
|
||||
else Wire.write(data &(~LIGHT_LOAD_BIT));
|
||||
Wire.endTransmission();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
```
|
||||
|
||||
## setCharge()
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>bool setCharge(bool en);</mark>
|
||||
<mark>bool setCharge(bool en)</mark>
|
||||
|
||||
**説明:**
|
||||
|
||||
充電状態を設定します。
|
||||
充電制御状態を指示します。
|
||||
満充電時は、有効→無効→有効とセットすることで再充電ができます。
|
||||
|
||||
**引数**
|
||||
|
||||
true: 充電開始指示。
|
||||
false: 充電中止指示。
|
||||
|
||||
**戻り値**
|
||||
|
||||
true: 制御成功。
|
||||
false: 制御失敗。
|
||||
|
||||
**定義:**
|
||||
|
||||
@@ -61,7 +125,7 @@ bool POWER::setCharge(bool en){
|
||||
Wire.beginTransmission(IP5306_ADDR);
|
||||
Wire.write(IP5306_REG_SYS_CTL0);
|
||||
if (en) Wire.write(data | CHARGE_OUT_BIT);
|
||||
else Wire.write(data &(~CHARGE_OUT_BIT));
|
||||
else Wire.write(data &(~CHARGE_OUT_BIT));
|
||||
Wire.endTransmission();
|
||||
return true;
|
||||
}
|
||||
@@ -70,14 +134,22 @@ bool POWER::setCharge(bool en){
|
||||
```
|
||||
|
||||
## isChargeFull()
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>bool isChargeFull(bool en);</mark>
|
||||
<mark>bool isChargeFull()</mark>
|
||||
|
||||
**説明:**
|
||||
|
||||
満充電かを判定します
|
||||
満充電かを判断します。
|
||||
|
||||
**引数**
|
||||
|
||||
なし。
|
||||
|
||||
**戻り値**
|
||||
|
||||
true: 満充電。
|
||||
false: 満充電ではない。
|
||||
|
||||
**定義:**
|
||||
|
||||
@@ -101,11 +173,20 @@ bool isChargeFull(){
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>bool canControl();</mark>
|
||||
<mark>bool canControl()</mark>
|
||||
|
||||
**説明:**
|
||||
|
||||
電源コントローラが使用可能かを判断します
|
||||
電源コントローラが制御可能かどうかを判断します。
|
||||
|
||||
**引数**
|
||||
|
||||
なし。
|
||||
|
||||
**戻り値**
|
||||
|
||||
true: 電源コントローラーを制御可能。
|
||||
false: 電源コントローラーを制御不可能。
|
||||
|
||||
**定義:**
|
||||
|
||||
@@ -122,11 +203,20 @@ bool canControl(){
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>bool isCharging(){</mark>
|
||||
<mark>bool isCharging()</mark>
|
||||
|
||||
**説明:**
|
||||
|
||||
充電中かを返答します
|
||||
充電状態かどうかを判断します。
|
||||
|
||||
**引数**
|
||||
|
||||
なし。
|
||||
|
||||
**戻り値**
|
||||
|
||||
true: 充電中。
|
||||
false: 充電中ではない。
|
||||
|
||||
**定義:**
|
||||
|
||||
@@ -146,16 +236,53 @@ bool isCharging(){
|
||||
}
|
||||
```
|
||||
|
||||
## getBatteryLevel()
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>bool getBatteryLevel()</mark>
|
||||
|
||||
**説明:**
|
||||
|
||||
バッテリー残量(%)を返します。
|
||||
|
||||
**引数**
|
||||
|
||||
なし
|
||||
|
||||
**戻り値**
|
||||
|
||||
バッテリーレベルを(0-100)の範囲で返します。(単位:%)
|
||||
もし残量が確認できる状態になければ-1を返します。
|
||||
|
||||
**定義:**
|
||||
|
||||
```arduino
|
||||
int8_t getBatteryLevel() {
|
||||
Wire.beginTransmission(0x75);
|
||||
Wire.write(0x78);
|
||||
if (Wire.endTransmission(false) == 0 && Wire.requestFrom(0x75, 1)) {
|
||||
switch (Wire.read() & 0xF0) {
|
||||
case 0xE0: return 25;
|
||||
case 0xC0: return 50;
|
||||
case 0x80: return 75;
|
||||
case 0x00: return 100;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
```
|
||||
|
||||
## setWakeupButton()
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>void setWakeupButton(uint8_t button){</mark>
|
||||
<mark>void setWakeupButton(uint8_t button)</mark>
|
||||
|
||||
**説明:**
|
||||
|
||||
スリープ復帰信号ポートを設定します
|
||||
スリープ復帰信号ポートを設定します。
|
||||
|
||||
**定義:**
|
||||
|
||||
@@ -169,39 +296,39 @@ void setWakeupButton(uint8_t button) {
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>void reset()</mark>
|
||||
<mark>void reset();</mark>
|
||||
|
||||
**説明:**
|
||||
|
||||
CPUをリセットします
|
||||
CPUをリセットします。
|
||||
|
||||
**定義:**
|
||||
|
||||
```arduino
|
||||
void POWER::reset() {
|
||||
void reset() {
|
||||
esp_restart();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
<!--
|
||||
## batteryMode()
|
||||
|
||||
**構文:**
|
||||
|
||||
<mark>bool boostMode(bool en)</mark>
|
||||
<mark>bool batteryMode(bool en)</mark>
|
||||
|
||||
**説明:**
|
||||
|
||||
電源の供給状態を設定します
|
||||
電源の供給状態を設定します。
|
||||
|
||||
**定義:**
|
||||
|
||||
```arduino
|
||||
bool boostMode(bool en){
|
||||
bool batteryMode(bool en){
|
||||
|
||||
uint8_t data;
|
||||
Wire.beginTransmission(IP5306_ADDR);
|
||||
Wire.write(IP5306_REG_READ1);
|
||||
Wire.write(IP5306_REG_SYS_CTL0);
|
||||
Wire.endTransmission();
|
||||
|
||||
if(Wire.requestFrom(IP5306_ADDR, 1))
|
||||
@@ -209,7 +336,7 @@ bool boostMode(bool en){
|
||||
data = Wire.read();
|
||||
|
||||
Wire.beginTransmission(IP5306_ADDR);
|
||||
Wire.write(IP5306_REG_READ1);
|
||||
Wire.write(IP5306_REG_SYS_CTL0);
|
||||
if (en) Wire.write(data | BOOST_ENABLE_BIT);
|
||||
else Wire.write(data &(~BOOST_ENABLE_BIT));
|
||||
Wire.endTransmission();
|
||||
@@ -218,7 +345,7 @@ bool boostMode(bool en){
|
||||
return false;
|
||||
}
|
||||
```
|
||||
|
||||
-->
|
||||
|
||||
## deepSleep()
|
||||
|
||||
@@ -228,7 +355,7 @@ bool boostMode(bool en){
|
||||
|
||||
**説明:**
|
||||
|
||||
省エネモードに移行します
|
||||
deep sleepモードに移行します。
|
||||
|
||||
**定義:**
|
||||
|
||||
@@ -252,4 +379,4 @@ void deepSleep(){
|
||||
}
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
+151
-17
@@ -4,11 +4,22 @@
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>bool setPowerBoostKeepOn(bool en);</mark>
|
||||
<mark>bool setPowerBoostKeepOn(bool en)</mark>
|
||||
|
||||
**功能:BOOST输出常开功能**
|
||||
|
||||
**函数实现:**
|
||||
**参数**
|
||||
|
||||
true: 始终供应
|
||||
false: 通常關閉
|
||||
|
||||
**返回值**
|
||||
|
||||
true: 控制成功
|
||||
false: 控制失败
|
||||
|
||||
|
||||
**函数实现**
|
||||
|
||||
```arduino
|
||||
bool setPowerBoostKeepOn(bool en){
|
||||
@@ -33,15 +44,69 @@ bool setPowerBoostKeepOn(bool en){
|
||||
#endif
|
||||
```
|
||||
|
||||
## setKeepLightLoad()
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>bool setKeepLightLoad(bool en)</mark>
|
||||
|
||||
**功能:**
|
||||
|
||||
设置自动关机功能。
|
||||
|
||||
**参数**
|
||||
|
||||
true:当电流消耗低时,不会发生自动关闭
|
||||
false:电流消耗低时自动关闭
|
||||
|
||||
**返回值**
|
||||
|
||||
true: 控制成功
|
||||
false: 控制失败
|
||||
|
||||
**函数实现**
|
||||
|
||||
```arduino
|
||||
bool setKeepLightLoad(bool en) {
|
||||
uint8_t data;
|
||||
Wire.beginTransmission(IP5306_ADDR);
|
||||
Wire.write(IP5306_REG_SYS_CTL0);
|
||||
Wire.endTransmission();
|
||||
|
||||
if(Wire.requestFrom(IP5306_ADDR, 1))
|
||||
{
|
||||
data = Wire.read();
|
||||
|
||||
Wire.beginTransmission(IP5306_ADDR);
|
||||
Wire.write(IP5306_REG_SYS_CTL0);
|
||||
if (!en) Wire.write(data | LIGHT_LOAD_BIT);
|
||||
else Wire.write(data &(~LIGHT_LOAD_BIT));
|
||||
Wire.endTransmission();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## setCharge()
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>bool setCharge(bool en);</mark>
|
||||
<mark>bool setCharge(bool en)</mark>
|
||||
|
||||
**功能:设置充电状态**
|
||||
|
||||
**函数实现:**
|
||||
true:充电开始指令
|
||||
false:充电停止指令
|
||||
|
||||
**返回值**
|
||||
|
||||
true: 控制成功
|
||||
false: 控制失败
|
||||
|
||||
|
||||
**定義:**
|
||||
|
||||
```arduino
|
||||
bool POWER::setCharge(bool en){
|
||||
@@ -69,9 +134,20 @@ bool POWER::setCharge(bool en){
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>bool isChargeFull(bool en);</mark>
|
||||
<mark>bool isChargeFull()</mark>
|
||||
|
||||
**功能:确认完全充电**
|
||||
**説明:**
|
||||
|
||||
确认完全充电.
|
||||
|
||||
**引数**
|
||||
|
||||
なし.
|
||||
|
||||
**戻り値**
|
||||
|
||||
true:完全充电
|
||||
false:没有完全充电
|
||||
|
||||
**函数实现:**
|
||||
|
||||
@@ -95,9 +171,20 @@ bool isChargeFull(){
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>bool canControl();</mark>
|
||||
<mark>bool canControl()</mark>
|
||||
|
||||
**功能:确认可以使用电源控制器**
|
||||
**功能:**
|
||||
|
||||
确认完全充电
|
||||
|
||||
**参数**
|
||||
|
||||
无.
|
||||
|
||||
**返回值**
|
||||
|
||||
true: 电源控制器发现
|
||||
false:找不到电源控制器
|
||||
|
||||
**函数实现:**
|
||||
|
||||
@@ -114,10 +201,19 @@ bool canControl(){
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>bool isCharging(){</mark>
|
||||
<mark>bool isCharging()</mark>
|
||||
|
||||
**功能:确认是否正在充电**
|
||||
|
||||
**参数**
|
||||
|
||||
无.
|
||||
|
||||
**返回值**
|
||||
|
||||
true: 在充电过程中
|
||||
false: 不收费
|
||||
|
||||
**函数实现:**
|
||||
|
||||
```arduino
|
||||
@@ -135,13 +231,51 @@ bool isCharging(){
|
||||
return false;
|
||||
}
|
||||
```
|
||||
## getBatteryLevel()
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>bool getBatteryLevel()</mark>
|
||||
|
||||
**功能:**
|
||||
|
||||
返回电池电量
|
||||
|
||||
**参数**
|
||||
|
||||
无
|
||||
|
||||
**返回值**
|
||||
|
||||
返回0到100范围内的电池电量.(单位:%)
|
||||
如果无法检查剩余金额,则返回-1
|
||||
|
||||
|
||||
**函数实现:**
|
||||
|
||||
```arduino
|
||||
int8_t getBatteryLevel() {
|
||||
Wire.beginTransmission(0x75);
|
||||
Wire.write(0x78);
|
||||
if (Wire.endTransmission(false) == 0 && Wire.requestFrom(0x75, 1)) {
|
||||
switch (Wire.read() & 0xF0) {
|
||||
case 0xE0: return 25;
|
||||
case 0xC0: return 50;
|
||||
case 0x80: return 75;
|
||||
case 0x00: return 100;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## setWakeupButton()
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>void setWakeupButton(uint8_t button){</mark>
|
||||
<mark>void setWakeupButton(uint8_t button)</mark>
|
||||
|
||||
**功能:设置睡眠返回端口**
|
||||
|
||||
@@ -164,24 +298,24 @@ void setWakeupButton(uint8_t button) {
|
||||
**函数实现:**
|
||||
|
||||
```arduino
|
||||
void POWER::reset() {
|
||||
void reset() {
|
||||
esp_restart();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## boostMode()
|
||||
<!--
|
||||
## batteryMode()
|
||||
|
||||
**函数原型:**
|
||||
|
||||
<mark>bool boostMode(bool en)</mark>
|
||||
<mark>bool batteryMode(bool en)</mark>
|
||||
|
||||
**功能:设置电池供电状态**
|
||||
|
||||
**函数实现:**
|
||||
|
||||
```arduino
|
||||
bool boostMode(bool en){
|
||||
bool batteryMode(bool en){
|
||||
|
||||
uint8_t data;
|
||||
Wire.beginTransmission(IP5306_ADDR);
|
||||
@@ -202,7 +336,7 @@ bool boostMode(bool en){
|
||||
return false;
|
||||
}
|
||||
```
|
||||
|
||||
-->
|
||||
|
||||
## deepSleep()
|
||||
|
||||
@@ -234,4 +368,4 @@ void deepSleep(){
|
||||
}
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user