1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 04:45:24 +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:
Bruce Luckcuck 2020-03-26 17:30:55 -04:00
parent 5b374c6fe0
commit ae76defa56

View file

@ -366,7 +366,7 @@ void mixerInitProfile(void)
//TODO: Make this voltage user configurable
vbatFull = CELL_VOLTAGE_FULL_CV;
vbatRangeToCompensate = vbatFull - batteryConfig()->vbatwarningcellvoltage;
if (vbatRangeToCompensate >= 0) {
if (vbatRangeToCompensate > 0) {
vbatSagCompensationFactor = ((float)currentPidProfile->vbat_sag_compensation) / 100.0f;
}
}