From 57e51a7e8ec1f5d26e703f909fa669ab78f46397 Mon Sep 17 00:00:00 2001 From: prjh Date: Tue, 5 Jan 2021 20:53:19 +0100 Subject: [PATCH] Fix byte count for AXP192 coulomb counter readings, fix GetCoulombData() for negative differences Signed-off-by: prjh --- src/AXP192.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AXP192.cpp b/src/AXP192.cpp index 7480a9e7..acc40e0a 100644 --- a/src/AXP192.cpp +++ b/src/AXP192.cpp @@ -136,7 +136,7 @@ uint32_t AXP192::Read32bit(uint8_t Addr) Wire1.beginTransmission(0x34); Wire1.write(Addr); Wire1.endTransmission(); - Wire1.requestFrom(0x34, 2); + Wire1.requestFrom(0x34, 4); for (int i = 0; i < 4; i++) { ReData <<= 8; @@ -224,7 +224,7 @@ float AXP192::GetCoulombData(void) //c = 65536 * current_LSB * (coin - coout) / 3600 / ADC rate //Adc rate can be read from 84H ,change this variable if you change the ADC reate - float ccc = 65536 * 0.5 * (coin - coout) / 3600.0 / 25.0; + float ccc = 65536 * 0.5 * (int32_t)(coin - coout) / 3600.0 / 25.0; return ccc; }