mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Fix div by 0 risk in mixer vbat sag compensation
Fix division by zero if `batteryConfig()->vbatwarningcellvoltage` was set to 420 (4.2v).
This commit is contained in:
parent
5b374c6fe0
commit
ae76defa56
1 changed files with 1 additions and 1 deletions
|
@ -366,7 +366,7 @@ void mixerInitProfile(void)
|
||||||
//TODO: Make this voltage user configurable
|
//TODO: Make this voltage user configurable
|
||||||
vbatFull = CELL_VOLTAGE_FULL_CV;
|
vbatFull = CELL_VOLTAGE_FULL_CV;
|
||||||
vbatRangeToCompensate = vbatFull - batteryConfig()->vbatwarningcellvoltage;
|
vbatRangeToCompensate = vbatFull - batteryConfig()->vbatwarningcellvoltage;
|
||||||
if (vbatRangeToCompensate >= 0) {
|
if (vbatRangeToCompensate > 0) {
|
||||||
vbatSagCompensationFactor = ((float)currentPidProfile->vbat_sag_compensation) / 100.0f;
|
vbatSagCompensationFactor = ((float)currentPidProfile->vbat_sag_compensation) / 100.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue