preparation for #961

more unified access to pre-calculated value
This commit is contained in:
rusefi 2019-10-10 08:16:21 -04:00
parent 9a26b2eca2
commit 71e904e421
4 changed files with 10 additions and 6 deletions

View File

@ -294,7 +294,7 @@ static percent_t automaticIdleController(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (CONFIG(idlePidRpmUpperLimit) > 0) {
engine->engineState.idle.idleState = PID_UPPER;
if (CONFIGB(useIacTableForCoasting) && !cisnan(engine->sensors.clt)) {
percent_t iacPosForCoasting = interpolate2d("iacCoasting", engine->sensors.clt, CONFIG(iacCoastingBins), CONFIG(iacCoasting));
percent_t iacPosForCoasting = interpolate2d("iacCoasting", getCoolantTemperature(), CONFIG(iacCoastingBins), CONFIG(iacCoasting));
newValue = interpolateClamped(idlePidLowerRpm, newValue, idlePidLowerRpm + CONFIG(idlePidRpmUpperLimit), iacPosForCoasting, rpm);
} else {
// Well, just leave it as is, without PID regulation...

View File

@ -116,8 +116,8 @@ void EngineState::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engine->engineState.isCrankingState = ENGINE(rpmCalculator).isCranking(PASS_ENGINE_PARAMETER_SIGNATURE);
engine->sensors.iat = getIntakeAirTemperature();
engine->sensors.clt = getCoolantTemperature();
engine->sensors.iat = getIntakeAirTemperatureM(PASS_ENGINE_PARAMETER_SIGNATURE);
engine->sensors.clt = getCoolantTemperatureM(PASS_ENGINE_PARAMETER_SIGNATURE);
// todo: reduce code duplication with 'getCoolantTemperature'
if (engineConfiguration->auxTempSensor1.adcChannel != EFI_ADC_NONE) {

View File

@ -305,13 +305,13 @@ void initFuelMap(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
float getCltFuelCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (cisnan(engine->sensors.clt))
return 1; // this error should be already reported somewhere else, let's just handle it
return interpolate2d("cltf", engine->sensors.clt, config->cltFuelCorrBins, config->cltFuelCorr);
return interpolate2d("cltf", getCoolantTemperature(), config->cltFuelCorrBins, config->cltFuelCorr);
}
angle_t getCltTimingCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (cisnan(engine->sensors.clt))
return 0; // this error should be already reported somewhere else, let's just handle it
return interpolate2d("timc", engine->sensors.clt, engineConfiguration->cltTimingBins, engineConfiguration->cltTimingExtra);
return interpolate2d("timc", getCoolantTemperature(), engineConfiguration->cltTimingBins, engineConfiguration->cltTimingExtra);
}
float getIatFuelCorrection(float iat DECLARE_ENGINE_PARAMETER_SUFFIX) {

View File

@ -36,7 +36,11 @@ temperature_t getCoolantTemperatureM(DECLARE_ENGINE_PARAMETER_SIGNATURE);
bool isValidCoolantTemperature(temperature_t temperature);
temperature_t getIntakeAirTemperatureM(DECLARE_ENGINE_PARAMETER_SIGNATURE);
#define getCoolantTemperature() getCoolantTemperatureM(PASS_ENGINE_PARAMETER_SIGNATURE)
/**
* This macro points to readily-available pre-calculated value
* for actual slow calculation see 'getCoolantTemperatureM'
*/
#define getCoolantTemperature() engine->sensors.clt
#define getIntakeAirTemperature() getIntakeAirTemperatureM(PASS_ENGINE_PARAMETER_SIGNATURE)
bool isValidIntakeAirTemperature(temperature_t temperature);