mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
fix(drivers): do not accumulate invalid current
This commit is contained in:
parent
d91950ef10
commit
177017e034
@ -201,8 +201,9 @@ void Battery::updateDt(const hrt_abstime ×tamp)
|
||||
|
||||
float Battery::sumDischarged(float current_a)
|
||||
{
|
||||
if (_dt > FLT_EPSILON) {
|
||||
if (_dt > FLT_EPSILON && fabsf(current_a + 1.f) > FLT_EPSILON) {
|
||||
// mAh since last loop: (current[A] * 1000 = [mA]) * (dt[s] / 3600 = [h])
|
||||
// current = -1 means invalid current measurement
|
||||
_discharged_mah_loop = (current_a * 1e3f) * (_dt / 3600.f);
|
||||
_discharged_mah += _discharged_mah_loop;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user