diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 9aab7ce735..81f19d74bf 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -199,14 +199,14 @@ static void printSensors(Logging *log) { // why do we still send data into console in text mode? if (hasCltSensor()) { - reportSensorF(log, "CLT", "C", getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE), 2); // log column #4 + reportSensorF(log, "CLT", "C", getCoolantTemperature(), 2); // log column #4 } if (hasTpsSensor()) { reportSensorF(log, "TPS", "%", getTPS(PASS_ENGINE_PARAMETER_SIGNATURE), 2); // log column #5 } if (hasIatSensor()) { - reportSensorF(log, "IAT", "C", getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE), 2); // log column #7 + reportSensorF(log, "IAT", "C", getIntakeAirTemperature(), 2); // log column #7 } if (hasVBatt(PASS_ENGINE_PARAMETER_SIGNATURE)) { @@ -694,8 +694,8 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ #endif /* EFI_PROD_CODE */ float tps = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE); - float coolant = getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE); - float intake = getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE); + float coolant = getCoolantTemperature(); + float intake = getIntakeAirTemperature(); float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE); @@ -855,8 +855,8 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->speedToRpmRatio = vehicleSpeed / rpm; #endif /* EFI_VEHICLE_SPEED */ - tsOutputChannels->isCltError = !isValidCoolantTemperature(getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE)); - tsOutputChannels->isIatError = !isValidIntakeAirTemperature(getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE)); + tsOutputChannels->isCltError = !isValidCoolantTemperature(getCoolantTemperature()); + tsOutputChannels->isIatError = !isValidIntakeAirTemperature(getIntakeAirTemperature()); #endif /* EFI_PROD_CODE */ tsOutputChannels->fuelConsumptionPerHour = engine->engineState.fuelConsumption.perSecondConsumption; diff --git a/firmware/controllers/actuators/lcd_controller.cpp b/firmware/controllers/actuators/lcd_controller.cpp index 30d4de6531..3ad4118f47 100644 --- a/firmware/controllers/actuators/lcd_controller.cpp +++ b/firmware/controllers/actuators/lcd_controller.cpp @@ -228,10 +228,10 @@ static void showLine(lcd_line_e line, int screenY) { #endif return; case LL_CLT_TEMPERATURE: - lcdPrintf("Coolant %.2f", getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE)); + lcdPrintf("Coolant %.2f", getCoolantTemperature()); return; case LL_IAT_TEMPERATURE: - lcdPrintf("Intake Air %.2f", getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE)); + lcdPrintf("Intake Air %.2f", getIntakeAirTemperature()); return; case LL_ALGORITHM: lcdPrintf(getEngine_load_mode_e(engineConfiguration->fuelAlgorithm)); diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/core/fsio_impl.cpp index a678afd5c7..03bcddf9ad 100644 --- a/firmware/controllers/core/fsio_impl.cpp +++ b/firmware/controllers/core/fsio_impl.cpp @@ -123,11 +123,11 @@ float getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) { case LE_METHOD_AC_TOGGLE: return getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE); case LE_METHOD_COOLANT: - return getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE); + return getCoolantTemperature(); case LE_METHOD_IS_COOLANT_BROKEN: return engine->isCltBroken; case LE_METHOD_INTAKE_AIR: - return getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE); + return getIntakeAirTemperature(); case LE_METHOD_RPM: return engine->rpmCalculator.getRpm(); case LE_METHOD_MAF: diff --git a/firmware/controllers/sensors/thermistors.cpp b/firmware/controllers/sensors/thermistors.cpp index 72b77fa509..23478f67c4 100644 --- a/firmware/controllers/sensors/thermistors.cpp +++ b/firmware/controllers/sensors/thermistors.cpp @@ -124,15 +124,15 @@ bool isValidIntakeAirTemperature(temperature_t temperature) { return !cisnan(temperature) && temperature > -50 && temperature < 100; } -bool hasCltSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) { +bool hasCltSensorM(DECLARE_ENGINE_PARAMETER_SIGNATURE) { return engineConfiguration->clt.adcChannel != EFI_ADC_NONE; } /** * @return coolant temperature, in Celsius */ -temperature_t getCoolantTemperature(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - if (!hasCltSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) { +temperature_t getCoolantTemperatureM(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + if (!hasCltSensor()) { engine->isCltBroken = false; return NO_CLT_SENSOR_TEMPERATURE; } @@ -206,15 +206,15 @@ void ThermistorMath::prepareThermistorCurve(thermistor_conf_s *tc) { #endif } -bool hasIatSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) { +bool hasIatSensorM(DECLARE_ENGINE_PARAMETER_SIGNATURE) { return engineConfiguration->iat.adcChannel != EFI_ADC_NONE; } /** * @return Celsius value */ -temperature_t getIntakeAirTemperature(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - if (!hasIatSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) { +temperature_t getIntakeAirTemperatureM(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + if (!hasIatSensor()) { return NO_IAT_SENSOR_TEMPERATURE; } float temperature = getTemperatureC(&engineConfiguration->iat, &engine->engineState.iatCurve, diff --git a/firmware/controllers/sensors/thermistors.h b/firmware/controllers/sensors/thermistors.h index 7ffe574a67..b72e168794 100644 --- a/firmware/controllers/sensors/thermistors.h +++ b/firmware/controllers/sensors/thermistors.h @@ -32,12 +32,19 @@ float convertFtoCelcius(float tempF); float getKelvinTemperature(float resistance, ThermistorMath *tm); float getResistance(ThermistorConf *cfg, float voltage); temperature_t getTemperatureC(ThermistorConf *cfg, ThermistorMath *tm, bool useLinear DECLARE_ENGINE_PARAMETER_SUFFIX); -temperature_t getCoolantTemperature(DECLARE_ENGINE_PARAMETER_SIGNATURE); +temperature_t getCoolantTemperatureM(DECLARE_ENGINE_PARAMETER_SIGNATURE); bool isValidCoolantTemperature(temperature_t temperature); -temperature_t getIntakeAirTemperature(DECLARE_ENGINE_PARAMETER_SIGNATURE); +temperature_t getIntakeAirTemperatureM(DECLARE_ENGINE_PARAMETER_SIGNATURE); + +#define getCoolantTemperature() getCoolantTemperatureM(PASS_ENGINE_PARAMETER_SIGNATURE) +#define getIntakeAirTemperature() getIntakeAirTemperatureM(PASS_ENGINE_PARAMETER_SIGNATURE) + bool isValidIntakeAirTemperature(temperature_t temperature); -bool hasIatSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE); -bool hasCltSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE); +bool hasIatSensorM(DECLARE_ENGINE_PARAMETER_SIGNATURE); +bool hasCltSensorM(DECLARE_ENGINE_PARAMETER_SIGNATURE); + +#define hasIatSensor() hasIatSensorM(PASS_ENGINE_PARAMETER_SIGNATURE) +#define hasCltSensor() hasCltSensorM(PASS_ENGINE_PARAMETER_SIGNATURE) void initThermistors(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX); diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 8dd70911f9..96e14acd65 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -432,12 +432,12 @@ static void printTemperatureInfo(void) { #if EFI_ANALOG_SENSORS printThermistor("CLT", &engineConfiguration->clt, &engine->engineState.cltCurve, engineConfiguration->useLinearCltSensor); - if (!isValidCoolantTemperature(getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE))) { + if (!isValidCoolantTemperature(getCoolantTemperature())) { scheduleMsg(&logger, "CLT sensing error"); } printThermistor("IAT", &engineConfiguration->iat, &engine->engineState.iatCurve, engineConfiguration->useLinearIatSensor); - if (!isValidIntakeAirTemperature(getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE))) { + if (!isValidIntakeAirTemperature(getIntakeAirTemperature())) { scheduleMsg(&logger, "IAT sensing error"); } diff --git a/unit_tests/tests/test_fuel_map.cpp b/unit_tests/tests/test_fuel_map.cpp index 71a7eb8a3a..0b2b7e021c 100644 --- a/unit_tests/tests/test_fuel_map.cpp +++ b/unit_tests/tests/test_fuel_map.cpp @@ -85,11 +85,11 @@ TEST(misc, testFuelMap) { setFlatInjectorLag(0 PASS_CONFIG_PARAMETER_SUFFIX); - float iat = getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE); + float iat = getIntakeAirTemperature(); ASSERT_FALSE(cisnan(iat)); float iatCorrection = getIatFuelCorrection(-KELV PASS_ENGINE_PARAMETER_SUFFIX); ASSERT_EQ( 2, iatCorrection) << "IAT"; - engine->sensors.clt = getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE); + engine->sensors.clt = getCoolantTemperature(); float cltCorrection = getCltFuelCorrection(PASS_ENGINE_PARAMETER_SIGNATURE); ASSERT_EQ( 1, cltCorrection) << "CLT"; float injectorLag = getInjectorLag(getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) PASS_ENGINE_PARAMETER_SUFFIX);