preparation for #961

macro as a syntax sugar for method invocation
This commit is contained in:
rusefi 2019-10-10 07:28:52 -04:00
parent 41192ba2f0
commit ca6e49dcbc
7 changed files with 31 additions and 24 deletions

View File

@ -199,14 +199,14 @@ static void printSensors(Logging *log) {
// why do we still send data into console in text mode? // why do we still send data into console in text mode?
if (hasCltSensor()) { 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()) { if (hasTpsSensor()) {
reportSensorF(log, "TPS", "%", getTPS(PASS_ENGINE_PARAMETER_SIGNATURE), 2); // log column #5 reportSensorF(log, "TPS", "%", getTPS(PASS_ENGINE_PARAMETER_SIGNATURE), 2); // log column #5
} }
if (hasIatSensor()) { 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)) { if (hasVBatt(PASS_ENGINE_PARAMETER_SIGNATURE)) {
@ -694,8 +694,8 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
#endif /* EFI_PROD_CODE */ #endif /* EFI_PROD_CODE */
float tps = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE); float tps = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE);
float coolant = getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE); float coolant = getCoolantTemperature();
float intake = getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE); float intake = getIntakeAirTemperature();
float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE); float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE);
@ -855,8 +855,8 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
tsOutputChannels->speedToRpmRatio = vehicleSpeed / rpm; tsOutputChannels->speedToRpmRatio = vehicleSpeed / rpm;
#endif /* EFI_VEHICLE_SPEED */ #endif /* EFI_VEHICLE_SPEED */
tsOutputChannels->isCltError = !isValidCoolantTemperature(getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE)); tsOutputChannels->isCltError = !isValidCoolantTemperature(getCoolantTemperature());
tsOutputChannels->isIatError = !isValidIntakeAirTemperature(getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE)); tsOutputChannels->isIatError = !isValidIntakeAirTemperature(getIntakeAirTemperature());
#endif /* EFI_PROD_CODE */ #endif /* EFI_PROD_CODE */
tsOutputChannels->fuelConsumptionPerHour = engine->engineState.fuelConsumption.perSecondConsumption; tsOutputChannels->fuelConsumptionPerHour = engine->engineState.fuelConsumption.perSecondConsumption;

View File

@ -228,10 +228,10 @@ static void showLine(lcd_line_e line, int screenY) {
#endif #endif
return; return;
case LL_CLT_TEMPERATURE: case LL_CLT_TEMPERATURE:
lcdPrintf("Coolant %.2f", getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE)); lcdPrintf("Coolant %.2f", getCoolantTemperature());
return; return;
case LL_IAT_TEMPERATURE: case LL_IAT_TEMPERATURE:
lcdPrintf("Intake Air %.2f", getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE)); lcdPrintf("Intake Air %.2f", getIntakeAirTemperature());
return; return;
case LL_ALGORITHM: case LL_ALGORITHM:
lcdPrintf(getEngine_load_mode_e(engineConfiguration->fuelAlgorithm)); lcdPrintf(getEngine_load_mode_e(engineConfiguration->fuelAlgorithm));

View File

@ -123,11 +123,11 @@ float getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) {
case LE_METHOD_AC_TOGGLE: case LE_METHOD_AC_TOGGLE:
return getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE); return getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE);
case LE_METHOD_COOLANT: case LE_METHOD_COOLANT:
return getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE); return getCoolantTemperature();
case LE_METHOD_IS_COOLANT_BROKEN: case LE_METHOD_IS_COOLANT_BROKEN:
return engine->isCltBroken; return engine->isCltBroken;
case LE_METHOD_INTAKE_AIR: case LE_METHOD_INTAKE_AIR:
return getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE); return getIntakeAirTemperature();
case LE_METHOD_RPM: case LE_METHOD_RPM:
return engine->rpmCalculator.getRpm(); return engine->rpmCalculator.getRpm();
case LE_METHOD_MAF: case LE_METHOD_MAF:

View File

@ -124,15 +124,15 @@ bool isValidIntakeAirTemperature(temperature_t temperature) {
return !cisnan(temperature) && temperature > -50 && temperature < 100; 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 engineConfiguration->clt.adcChannel != EFI_ADC_NONE;
} }
/** /**
* @return coolant temperature, in Celsius * @return coolant temperature, in Celsius
*/ */
temperature_t getCoolantTemperature(DECLARE_ENGINE_PARAMETER_SIGNATURE) { temperature_t getCoolantTemperatureM(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (!hasCltSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) { if (!hasCltSensor()) {
engine->isCltBroken = false; engine->isCltBroken = false;
return NO_CLT_SENSOR_TEMPERATURE; return NO_CLT_SENSOR_TEMPERATURE;
} }
@ -206,15 +206,15 @@ void ThermistorMath::prepareThermistorCurve(thermistor_conf_s *tc) {
#endif #endif
} }
bool hasIatSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) { bool hasIatSensorM(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
return engineConfiguration->iat.adcChannel != EFI_ADC_NONE; return engineConfiguration->iat.adcChannel != EFI_ADC_NONE;
} }
/** /**
* @return Celsius value * @return Celsius value
*/ */
temperature_t getIntakeAirTemperature(DECLARE_ENGINE_PARAMETER_SIGNATURE) { temperature_t getIntakeAirTemperatureM(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (!hasIatSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) { if (!hasIatSensor()) {
return NO_IAT_SENSOR_TEMPERATURE; return NO_IAT_SENSOR_TEMPERATURE;
} }
float temperature = getTemperatureC(&engineConfiguration->iat, &engine->engineState.iatCurve, float temperature = getTemperatureC(&engineConfiguration->iat, &engine->engineState.iatCurve,

View File

@ -32,12 +32,19 @@ float convertFtoCelcius(float tempF);
float getKelvinTemperature(float resistance, ThermistorMath *tm); float getKelvinTemperature(float resistance, ThermistorMath *tm);
float getResistance(ThermistorConf *cfg, float voltage); float getResistance(ThermistorConf *cfg, float voltage);
temperature_t getTemperatureC(ThermistorConf *cfg, ThermistorMath *tm, bool useLinear DECLARE_ENGINE_PARAMETER_SUFFIX); 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); 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 isValidIntakeAirTemperature(temperature_t temperature);
bool hasIatSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE); bool hasIatSensorM(DECLARE_ENGINE_PARAMETER_SIGNATURE);
bool hasCltSensor(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); void initThermistors(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);

View File

@ -432,12 +432,12 @@ static void printTemperatureInfo(void) {
#if EFI_ANALOG_SENSORS #if EFI_ANALOG_SENSORS
printThermistor("CLT", &engineConfiguration->clt, &engine->engineState.cltCurve, printThermistor("CLT", &engineConfiguration->clt, &engine->engineState.cltCurve,
engineConfiguration->useLinearCltSensor); engineConfiguration->useLinearCltSensor);
if (!isValidCoolantTemperature(getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE))) { if (!isValidCoolantTemperature(getCoolantTemperature())) {
scheduleMsg(&logger, "CLT sensing error"); scheduleMsg(&logger, "CLT sensing error");
} }
printThermistor("IAT", &engineConfiguration->iat, &engine->engineState.iatCurve, printThermistor("IAT", &engineConfiguration->iat, &engine->engineState.iatCurve,
engineConfiguration->useLinearIatSensor); engineConfiguration->useLinearIatSensor);
if (!isValidIntakeAirTemperature(getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE))) { if (!isValidIntakeAirTemperature(getIntakeAirTemperature())) {
scheduleMsg(&logger, "IAT sensing error"); scheduleMsg(&logger, "IAT sensing error");
} }

View File

@ -85,11 +85,11 @@ TEST(misc, testFuelMap) {
setFlatInjectorLag(0 PASS_CONFIG_PARAMETER_SUFFIX); setFlatInjectorLag(0 PASS_CONFIG_PARAMETER_SUFFIX);
float iat = getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE); float iat = getIntakeAirTemperature();
ASSERT_FALSE(cisnan(iat)); ASSERT_FALSE(cisnan(iat));
float iatCorrection = getIatFuelCorrection(-KELV PASS_ENGINE_PARAMETER_SUFFIX); float iatCorrection = getIatFuelCorrection(-KELV PASS_ENGINE_PARAMETER_SUFFIX);
ASSERT_EQ( 2, iatCorrection) << "IAT"; ASSERT_EQ( 2, iatCorrection) << "IAT";
engine->sensors.clt = getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE); engine->sensors.clt = getCoolantTemperature();
float cltCorrection = getCltFuelCorrection(PASS_ENGINE_PARAMETER_SIGNATURE); float cltCorrection = getCltFuelCorrection(PASS_ENGINE_PARAMETER_SIGNATURE);
ASSERT_EQ( 1, cltCorrection) << "CLT"; ASSERT_EQ( 1, cltCorrection) << "CLT";
float injectorLag = getInjectorLag(getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) PASS_ENGINE_PARAMETER_SUFFIX); float injectorLag = getInjectorLag(getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) PASS_ENGINE_PARAMETER_SUFFIX);