avoid NaN in case of zero battery voltage

This commit is contained in:
Matthew Kennedy 2023-11-17 18:19:55 -08:00
parent 99335f90c1
commit 52f306b6f5
1 changed files with 1 additions and 1 deletions

View File

@ -178,7 +178,7 @@ void HeaterControllerBase::Update(const ISampler& sampler, HeaterAllow heaterAll
}
// duty = (V_eff / V_batt) ^ 2
float voltageRatio = heaterVoltage / batteryVoltage;
float voltageRatio = (batteryVoltage < 1.0f) ? 0 : heaterVoltage / batteryVoltage;
float duty = voltageRatio * voltageRatio;
#ifdef HEATER_MAX_DUTY