improve tcharge error handling (#1328)
This commit is contained in:
parent
71e7fb7e50
commit
fefaa54c92
|
@ -37,14 +37,27 @@ baroCorr_Map3D_t baroCorrMap("baro");
|
||||||
// http://rusefi.com/math/t_charge.html
|
// http://rusefi.com/math/t_charge.html
|
||||||
/***panel:Charge Temperature*/
|
/***panel:Charge Temperature*/
|
||||||
temperature_t getTCharge(int rpm, float tps DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
temperature_t getTCharge(int rpm, float tps DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
const auto [cltValid, coolantTemp] = Sensor::get(SensorType::Clt);
|
const auto clt = Sensor::get(SensorType::Clt);
|
||||||
const auto [iatValid, airTemp] = Sensor::get(SensorType::Iat);
|
const auto iat = Sensor::get(SensorType::Iat);
|
||||||
|
|
||||||
if (!cltValid || !iatValid) {
|
float airTemp = 0;
|
||||||
warning(CUSTOM_ERR_NAN_TCHARGE, "getTCharge invalid iat/clt");
|
|
||||||
|
// Without either valid, return 0C. It's wrong, but it'll pretend to be nice and dense, so at least you won't go lean.
|
||||||
|
if (!iat && !clt) {
|
||||||
|
return 0;
|
||||||
|
} else if (!clt && iat) {
|
||||||
|
// Intake temperature will almost always be colder (richer) than CLT - use that
|
||||||
return airTemp;
|
return airTemp;
|
||||||
|
} else if (!iat && clt) {
|
||||||
|
// Without valid intake temperature, assume intake temp is 0C, and interpolate anyway
|
||||||
|
airTemp = 0;
|
||||||
|
} else {
|
||||||
|
// All is well - use real air temp
|
||||||
|
airTemp = iat.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float coolantTemp = clt.Value;
|
||||||
|
|
||||||
DISPLAY_STATE(Engine)
|
DISPLAY_STATE(Engine)
|
||||||
|
|
||||||
if ((engine->engineState.sd.DISPLAY_IF(isTChargeAirModel) = (CONFIG(tChargeMode) == TCHARGE_MODE_AIR_INTERP))) {
|
if ((engine->engineState.sd.DISPLAY_IF(isTChargeAirModel) = (CONFIG(tChargeMode) == TCHARGE_MODE_AIR_INTERP))) {
|
||||||
|
|
Loading…
Reference in New Issue