From 423a535201be80049e4d316b66823840d358caaa Mon Sep 17 00:00:00 2001 From: Mori Naoyuki Date: Wed, 13 Mar 2019 23:42:54 +0900 Subject: [PATCH] Add: setAutoBootOnLoad() document (on M5Stack #127) Append to document : function return value / argument --- docs/en/api/power.md | 144 ++++++++++++++++++++++++++++++++++++-- docs/ja/api/power.md | 149 +++++++++++++++++++++++++++++++++++++--- docs/zh_CN/api/power.md | 144 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 418 insertions(+), 19 deletions(-) diff --git a/docs/en/api/power.md b/docs/en/api/power.md index a0801bf2..93578525 100644 --- a/docs/en/api/power.md +++ b/docs/en/api/power.md @@ -10,6 +10,17 @@ This function sets enable/disable power mode. +**Function argument** + +true: Output normally open. +false: Output normally close. + +**Function return value** + +true: controll success. +false: control failure. + + **Definition:** ```arduino @@ -32,9 +43,53 @@ bool setPowerBoostKeepOn(bool en){ } return false; } -#endif ``` +## setKeepLightLoad() + +**Syntax:** + +bool setKeepLightLoad(bool en); + +**Description:** + +Set mode of automatically shut down. + +**Function argument** + +true:when the current is too small, ip5306 will *not* automatically shut down. +false:when the current is too small, ip5306 will automatically shut down. + +**Function return value** +true: controll 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; +} +``` + + ## setCharge() **Syntax:** @@ -44,11 +99,22 @@ bool setPowerBoostKeepOn(bool en){ **Description:** This function sets enable/disable charge mode. +If charge full,try set charge enable->disable->enable,can be recharged + +**Function argument** + +true:set to charge. +false:set to not charging + +**Function return value** + +true: controll 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); @@ -73,12 +139,21 @@ bool POWER::setCharge(bool en){ **Syntax:** -bool isChargeFull(bool en); +bool isChargeFull(); **Description:** This function check battery level. +**Function argument** + +no argument. + +**Function return value** + +true:battery is full +false:battery is not full + **Definition:** ```arduino @@ -105,7 +180,16 @@ bool isChargeFull(){ **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 found. +false:battery controller not found. **Definition:** @@ -122,12 +206,24 @@ bool canControl(){ **Syntax:** -bool isCharging(){ +bool isCharging(); **Description:** This function checks the state of the charge +**Function argument** + +no argument. + +**Function return value** + +true: in charging +false: not in charging + + +true:charge, false:discharge + **Definition:** ```arduino @@ -145,6 +241,44 @@ bool isCharging(){ return false; } ``` +## getBatteryLevel() + +**Syntax:** + +bool getBatteryLevel(); + +**Description:** + +This function checks the battery charging level + +**Function argument** + +no argument. + +**Function return value** + +percent of battery level.(0-100) +if can't communicate to controller ,return -1. + + +**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() diff --git a/docs/ja/api/power.md b/docs/ja/api/power.md index 56334387..1b0c6541 100644 --- a/docs/ja/api/power.md +++ b/docs/ja/api/power.md @@ -10,7 +10,18 @@ 電源供給状態を設定します。 -**定義:** +**引数** + +true: 常時供給状態 +false: 常時切断状態 + +**戻り値** + +true: 制御成功 +false: 制御失敗 + + +**定義** ```arduino bool setPowerBoostKeepOn(bool en){ @@ -32,9 +43,53 @@ bool setPowerBoostKeepOn(bool en){ } return false; } -#endif ``` +## setKeepLightLoad() + +**構文:** + +bool setKeepLightLoad(bool en); + +**説明:** + +自動シャットダウン機能を設定します. + +**引数** + +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() **構文:** @@ -43,7 +98,19 @@ bool setPowerBoostKeepOn(bool en){ **説明:** -充電状態を設定します。 +充電制御状態を指示します。 +満充電時は、有効→無効→有効とセットすることで再充電ができます。 + +**引数** + +true:充電開始指示 +false:充電中止指示 + +**戻り値** + +true: 制御成功 +false: 制御失敗 + **定義:** @@ -70,14 +137,22 @@ bool POWER::setCharge(bool en){ ``` ## isChargeFull() - **構文:** -bool isChargeFull(bool en); +bool isChargeFull(); **説明:** -満充電かを判定します +満充電かを判断します. + +**引数** + +なし. + +**戻り値** + +true:満充電 +false:満充電ではない **定義:** @@ -107,6 +182,15 @@ bool isChargeFull(){ 電源コントローラが使用可能かを判断します +**引数** + +なし. + +**戻り値** + +true: 電源コントローラーが見つかった +false:電源コントローラーが見つからない + **定義:** ```arduino @@ -122,12 +206,21 @@ bool canControl(){ **構文:** -bool isCharging(){ +bool isCharging(); **説明:** 充電中かを返答します +**引数** + +なし. + +**戻り値** + +true: 充電中 +false: 充電中ではない + **定義:** ```arduino @@ -145,6 +238,44 @@ bool isCharging(){ return false; } ``` +## getBatteryLevel() + +**構文:** + +bool getBatteryLevel(); + +**説明:** + +バッテリー残量を返します + +**引数** + +なし + +**戻り値** + +バッテリーレベルを(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() @@ -201,7 +332,7 @@ bool boostMode(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 +340,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(); diff --git a/docs/zh_CN/api/power.md b/docs/zh_CN/api/power.md index df774a8c..0e7fddf7 100644 --- a/docs/zh_CN/api/power.md +++ b/docs/zh_CN/api/power.md @@ -8,7 +8,18 @@ **功能:BOOST输出常开功能** -**函数实现:** +**参数** + +true: 始终供应 +false: 通常關閉 + +**返回值** + +true: 控制成功 +false: 控制失败 + + +**函数实现** ```arduino bool setPowerBoostKeepOn(bool en){ @@ -33,6 +44,51 @@ bool setPowerBoostKeepOn(bool en){ #endif ``` +## setKeepLightLoad() + +**函数原型:** + +bool setKeepLightLoad(bool en); + +**功能:** + +设置自动关机功能。 + +**参数** + +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() **函数原型:** @@ -41,7 +97,16 @@ bool setPowerBoostKeepOn(bool en){ **功能:设置充电状态** -**函数实现:** +true:充电开始指令 +false:充电停止指令 + +**返回值** + +true: 控制成功 +false: 控制失败 + + +**定義:** ```arduino bool POWER::setCharge(bool en){ @@ -69,9 +134,20 @@ bool POWER::setCharge(bool en){ **函数原型:** -bool isChargeFull(bool en); +bool isChargeFull(); -**功能:确认完全充电** +**説明:** + +确认完全充电. + +**引数** + +なし. + +**戻り値** + +true:完全充电 +false:没有完全充电 **函数实现:** @@ -97,7 +173,18 @@ bool isChargeFull(){ bool canControl(); -**功能:确认可以使用电源控制器** +**功能:** + +确认完全充电 + +**参数** + +无. + +**返回值** + +true: 电源控制器发现 +false:找不到电源控制器 **函数实现:** @@ -118,6 +205,15 @@ bool canControl(){ **功能:确认是否正在充电** +**参数** + +无. + +**返回值** + +true: 在充电过程中 +false: 不收费 + **函数实现:** ```arduino @@ -135,6 +231,44 @@ bool isCharging(){ return false; } ``` +## getBatteryLevel() + +**函数原型:** + +bool getBatteryLevel(); + +**功能:** + +返回电池电量 + +**参数** + +无 + +**返回值** + +返回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()