From 2a443b18a7220e09976da0d93d9e3ef0ed5f674f Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sat, 2 Jan 2016 16:01:27 -0500 Subject: [PATCH] auto-sync --- firmware/console/status_loop.cpp | 2 +- firmware/controllers/algo/accel_enrichment.cpp | 12 ++++++++---- firmware/controllers/algo/accel_enrichment.h | 4 ++-- firmware/controllers/algo/fuel_math.cpp | 2 +- firmware/controllers/math/speed_density.cpp | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 8da3c28f68..c342dae2d1 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -593,7 +593,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->manifold_air_pressure = getMap(); tsOutputChannels->engineLoad = engineLoad; tsOutputChannels->rpmAcceleration = engine->rpmCalculator.getRpmAcceleration(); - tsOutputChannels->currentEngineLoadAccelDelta = engine->engineLoadAccelEnrichment.getMapEnrichment(PASS_ENGINE_PARAMETER_F) * 100 / getMap(); + tsOutputChannels->currentEngineLoadAccelDelta = engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_ENGINE_PARAMETER_F) * 100 / getMap(); tsOutputChannels->tpsAccelFuel = engine->engineState.tpsAccelEnrich; tsOutputChannels->deltaTps = engine->tpsAccelEnrichment.getDelta(); tsOutputChannels->triggerErrorsCounter = engine->triggerCentral.triggerState.totalTriggerErrorCounter; diff --git a/firmware/controllers/algo/accel_enrichment.cpp b/firmware/controllers/algo/accel_enrichment.cpp index d2a7d8a6e4..caf8921ff2 100644 --- a/firmware/controllers/algo/accel_enrichment.cpp +++ b/firmware/controllers/algo/accel_enrichment.cpp @@ -66,22 +66,26 @@ float AccelEnrichmemnt::getDelta() { return cb.maxValue(cb.getSize()); } +// todo: eliminate code duplication between these two methods! Some pointer magic would help. floatms_t AccelEnrichmemnt::getTpsEnrichment(DECLARE_ENGINE_PARAMETER_F) { float d = getDelta(); if (d > engineConfiguration->tpsAccelEnrichmentThreshold) { return d * engineConfiguration->tpsAccelEnrichmentMultiplier; } + if (d < -engineConfiguration->tpsDecelEnleanmentThreshold) { + return d * engineConfiguration->tpsDecelEnleanmentMultiplier; + } return 0; } -float AccelEnrichmemnt::getMapEnrichment(DECLARE_ENGINE_PARAMETER_F) { +float AccelEnrichmemnt::getEngineLoadEnrichment(DECLARE_ENGINE_PARAMETER_F) { float d = getDelta(); if (d > engineConfiguration->engineLoadAccelEnrichmentThreshold) { return d * engineConfiguration->engineLoadAccelEnrichmentMultiplier; } -// if (d < engineConfiguration->deaccelEnrichmentThreshold) { -// return d * engineConfiguration->deaccelEnrichmentMultiplier; -// } + if (d < -engineConfiguration->engineLoadDecelEnleanmentThreshold) { + return d * engineConfiguration->engineLoadAccelEnrichmentMultiplier; + } return 0; } diff --git a/firmware/controllers/algo/accel_enrichment.h b/firmware/controllers/algo/accel_enrichment.h index 80c18a5759..66d7ef5fa4 100644 --- a/firmware/controllers/algo/accel_enrichment.h +++ b/firmware/controllers/algo/accel_enrichment.h @@ -20,9 +20,9 @@ class AccelEnrichmemnt { public: AccelEnrichmemnt(); /** - * @return Extra MAP value for Speed Density calculation + * @return Extra engine load value for fuel logic calculation */ - float getMapEnrichment(DECLARE_ENGINE_PARAMETER_F); + float getEngineLoadEnrichment(DECLARE_ENGINE_PARAMETER_F); /** * @return Extra fuel squirt duration for TPS acceleration */ diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 3b4978744c..dd28c2bd03 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -77,7 +77,7 @@ floatms_t getBaseFuel(int rpm DECLARE_ENGINE_PARAMETER_S) { if (CONFIG(algorithm) == LM_SPEED_DENSITY) { engine->engineState.baseFuel = getSpeedDensityFuel(rpm PASS_ENGINE_PARAMETER); } else if (engineConfiguration->algorithm == LM_REAL_MAF) { - float maf = getRealMaf(PASS_ENGINE_PARAMETER_F) + engine->engineLoadAccelEnrichment.getMapEnrichment(PASS_ENGINE_PARAMETER_F); + float maf = getRealMaf(PASS_ENGINE_PARAMETER_F) + engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_ENGINE_PARAMETER_F); engine->engineState.baseFuel = getRealMafFuel(maf, rpm PASS_ENGINE_PARAMETER); } else { engine->engineState.baseFuel = engine->engineState.baseTableFuel; diff --git a/firmware/controllers/math/speed_density.cpp b/firmware/controllers/math/speed_density.cpp index ad41ad8bc1..f8eb1f7878 100644 --- a/firmware/controllers/math/speed_density.cpp +++ b/firmware/controllers/math/speed_density.cpp @@ -87,7 +87,7 @@ float getSpeedDensityFuel(int rpm DECLARE_ENGINE_PARAMETER_S) { float tChargeK = ENGINE(engineState.tChargeK); float map = getMap(); - float adjustedMap = map + engine->engineLoadAccelEnrichment.getMapEnrichment(PASS_ENGINE_PARAMETER_F); + float adjustedMap = map + engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_ENGINE_PARAMETER_F); engine->engineState.airMass = getAirMass(engineConfiguration, ENGINE(engineState.currentVE), adjustedMap, tChargeK);