Skip to content

Commit

Permalink
Fix byte count for AXP192 coulomb counter readings, fix GetCoulombDat…
Browse files Browse the repository at this point in the history
…a() for negative differences

Signed-off-by: prjh <[email protected]>
  • Loading branch information
prjh committed Jan 5, 2021
1 parent c48b26a commit 57e51a7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/AXP192.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 57e51a7

Please sign in to comment.