reducing code duplication

This commit is contained in:
rusefi 2017-06-11 15:27:23 -04:00
parent 571399b112
commit e7f59e218a
3 changed files with 8 additions and 9 deletions

View File

@ -404,8 +404,6 @@ static void setBosch02880155868(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engineConfiguration->injector.battLagCorr[7] = 0.726;
}
#define CLT_MANUAL_IDLE_CORRECTION config->cltIdleCorrBins, config->cltIdleCorr, CLT_CURVE_SIZE
static void setDefaultWarmupIdleCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
initTemperatureCurve(CLT_MANUAL_IDLE_CORRECTION, PERCENT_MULT);
@ -425,8 +423,6 @@ static void setDefaultWarmupIdleCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
setCurveValue(CLT_MANUAL_IDLE_CORRECTION, 70, 33.0 / baseIdle * 100);
}
#define WARMUP_CLT_EXTRA_FUEL_CURVE config->cltFuelCorrBins, config->cltFuelCorr, CLT_CURVE_SIZE
static void setDefaultWarmupFuelEnrichment(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
initTemperatureCurve(WARMUP_CLT_EXTRA_FUEL_CURVE, PERCENT_MULT);
@ -570,7 +566,6 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engineConfiguration->postCrankingTargetClt = 25;
engineConfiguration->postCrankingDurationSec = 2;
#define IAT_FUEL_CORRECTION_CURVE config->iatFuelCorrBins, config->iatFuelCorr, IAT_CURVE_SIZE
initTemperatureCurve(IAT_FUEL_CORRECTION_CURVE, 1);
engineConfiguration->tachPulseDuractionMs = 4;

View File

@ -16,6 +16,11 @@
#include "rusefi_types.h"
#include "engine_configuration_generated_structures.h"
#define CLT_MANUAL_IDLE_CORRECTION config->cltIdleCorrBins, config->cltIdleCorr, CLT_CURVE_SIZE
#define WARMUP_CLT_EXTRA_FUEL_CURVE config->cltFuelCorrBins, config->cltFuelCorr, CLT_CURVE_SIZE
#define IAT_FUEL_CORRECTION_CURVE config->iatFuelCorrBins, config->iatFuelCorr, IAT_CURVE_SIZE
#define INJECTOR_LAG_CURVE engineConfiguration->injector.battLagCorrBins, engineConfiguration->injector.battLagCorr, VBAT_INJECTOR_CURVE_SIZE
#define MOCK_UNDEFINED -1
// WARNING: by default, our small enums are ONE BYTE. this one is made 4-byte with the 'ENUM_32_BITS' hack

View File

@ -184,8 +184,7 @@ floatms_t getInjectorLag(float vBatt DECLARE_ENGINE_PARAMETER_SUFFIX) {
warning(OBD_System_Voltage_Malfunction, "vBatt=%f", vBatt);
return 0;
}
float vBattCorrection = interpolate2d("lag", vBatt, engineConfiguration->injector.battLagCorrBins,
engineConfiguration->injector.battLagCorr, VBAT_INJECTOR_CURVE_SIZE);
float vBattCorrection = interpolate2d("lag", vBatt, INJECTOR_LAG_CURVE);
return vBattCorrection;
}
@ -205,7 +204,7 @@ void prepareFuelMap(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, CLT_CURVE_SIZE) / PERCENT_MULT;
return interpolate2d("cltf", engine->sensors.clt, WARMUP_CLT_EXTRA_FUEL_CURVE) / PERCENT_MULT;
}
angle_t getCltTimingCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
@ -217,7 +216,7 @@ angle_t getCltTimingCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
float getIatFuelCorrection(float iat DECLARE_ENGINE_PARAMETER_SUFFIX) {
if (cisnan(iat))
return 1; // this error should be already reported somewhere else, let's just handle it
return interpolate2d("iatc", iat, config->iatFuelCorrBins, config->iatFuelCorr, IAT_CURVE_SIZE);
return interpolate2d("iatc", iat, IAT_FUEL_CORRECTION_CURVE);
}
/**