HeptaBattery library

Dependencies:   PowerControl

Dependents:   HEPTA_EPS

Revision:
9:7d0aaedfe1c0
Parent:
7:b701e9cd2108
Child:
10:00fc48db2361
--- a/HeptaBattery.cpp	Fri Nov 17 02:08:19 2017 +0000
+++ b/HeptaBattery.cpp	Wed Aug 08 10:50:17 2018 +0000
@@ -4,12 +4,12 @@
 HeptaBattery::HeptaBattery(PinName bat, PinName bat_ct) : _bat(bat),_bat_ct(bat_ct)
 {
     _bat_ct = 1;
-    PHY_PowerDown();//Ethernet PHYchip停止
+    PHY_PowerDown();//stop Ethernet PHYchip
 }
 
 void HeptaBattery::vol(float* bt)
 {
-    *bt = (_bat.read()*1.431*3.3);//バッテリー電圧読み出し
+    *bt = (_bat.read()*1.431*3.3);//read the battery voltage
 }
 
 void HeptaBattery::shut_down_regulator()
@@ -36,27 +36,29 @@
     //*dsize = 4;
 }
 
-void HeptaBattery::power_saving_mode()
+void HeptaBattery::power_saving_mode(int *flag,float* Bat)
 {
-    float Bat;
-    Bat = _bat.read()*1.431*3.3;
-    //4.2以上
-    if(Bat>=4.2) {
+    *Bat = _bat.read()*1.431*3.3;
+    //Above 4.2 or more
+    if(*Bat>=4.2) {
         _bat_ct = 1;
         LPC_SC->CCLKCFG = 2;
         SystemCoreClockUpdate();
+        *flag = 0;
     }
     //3.7 < Voltage < 4.1
-    else if(Bat<=4.1 && Bat>=3.7) {
+    else if(*Bat<=4.1 && *Bat>=3.7) {
         _bat_ct = 1;
         LPC_SC->CCLKCFG = 2;
         SystemCoreClockUpdate();
+        *flag = 0;
     }
-    //3.5V以下
-    else if(Bat<=3.5) {
+    //3.5V or less
+    else if(*Bat<=3.5) {
         _bat_ct = 0;
         LPC_SC->CCLKCFG = 5;
         SystemCoreClockUpdate();
+        *flag = 1;
     }
 
 }
\ No newline at end of file