Library for I2C communication with LiPo battery fuel gauge to measure battery level.

Dependents:   MAX1704X_example_app

Files at this revision

API Documentation at this revision

Comitter:
maclobdell
Date:
Thu Nov 09 21:01:04 2017 +0000
Parent:
0:b3b7aff20a1d
Commit message:
update read_percent to just read out high byte for percentage of battery charge

Changed in this revision

MAX1704X.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r b3b7aff20a1d -r b2d54467330d MAX1704X.cpp
--- a/MAX1704X.cpp	Mon Oct 09 12:52:15 2017 +0000
+++ b/MAX1704X.cpp	Thu Nov 09 21:01:04 2017 +0000
@@ -80,13 +80,11 @@
   uint32_t xo;
   
   xm = read8(REG_SOC_H);  //high byte
-  xl = read8(REG_SOC_L);  //low byte
+  //xl = read8(REG_SOC_L);  //low byte
   
-  xo = (xl|(xm << 8));
-
-  //alternatively can read16
-//  xo = read16(REG_SOC_H);    //does this work?
-
+  //xo = (xl|(xm << 8));
+  xo = xm;  //just read out high byte which returns 0-100
+            // low byte provides unecessary extra resolution
   //percent_decimal = (0.003906)*xl + xm;
 
   //returns percent