Skip to content

Commit

Permalink
Merge pull request #28 from prjh/coulomb-fix
Browse files Browse the repository at this point in the history
Fix byte count for AXP192 coulomb counter readings
  • Loading branch information
Tinyu-Zhao authored Oct 24, 2021
2 parents 1c278ce + 57e51a7 commit edb3874
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 edb3874

Please sign in to comment.