From c52e5aa465f51357c9815010b64ab87867469eef Mon Sep 17 00:00:00 2001 From: rusefi Date: Mon, 27 May 2019 11:17:28 -0400 Subject: [PATCH] refactoring: better variable names --- firmware/console/status_loop.cpp | 4 ++-- firmware/controllers/algo/engine.h | 3 ++- firmware/controllers/algo/engine2.cpp | 6 +++--- firmware/controllers/algo/rusefi_enums.h | 5 +++++ firmware/controllers/math/speed_density.cpp | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 3510c6244d..6031bdfd62 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -273,7 +273,7 @@ static void printSensors(Logging *log, bool fileFormat) { reportSensorF(log, fileFormat, GAUGE_NAME_TCHARGE, "K", engine->engineState.tChargeK, 2); // log column #8 if (hasMapSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) { - reportSensorF(log, fileFormat, GAUGE_NAME_FUEL_VE, "%", engine->engineState.currentVE * PERCENT_MULT, 2); + reportSensorF(log, fileFormat, GAUGE_NAME_FUEL_VE, "%", engine->engineState.currentBaroCorrectedVE * PERCENT_MULT, 2); } reportSensorF(log, fileFormat, GAUGE_NAME_VVT, "deg", engine->triggerCentral.vvtPosition, 1); @@ -705,7 +705,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ if (hasMapSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) { float mapValue = getMap(); - tsOutputChannels->veValue = engine->engineState.currentVE * PERCENT_MULT; + tsOutputChannels->veValue = engine->engineState.currentBaroCorrectedVE * PERCENT_MULT; // todo: bug here? target afr could work based on real MAF? tsOutputChannels->currentTargetAfr = afrMap.getValue(rpm, mapValue); tsOutputChannels->manifoldAirPressure = mapValue; diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 5e10de2e32..15b8f0690b 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -233,7 +233,8 @@ public: float tChargeK = 0; efitick_t timeSinceLastTChargeK; - float currentVE = 0; + float currentRawVE = 0; + float currentBaroCorrectedVE = 0; float targetAFR = 0; int vssEventCounter = 0; diff --git a/firmware/controllers/algo/engine2.cpp b/firmware/controllers/algo/engine2.cpp index e8621707f4..1ff7bb8d58 100644 --- a/firmware/controllers/algo/engine2.cpp +++ b/firmware/controllers/algo/engine2.cpp @@ -215,14 +215,14 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { /** * *0.01 because of https://sourceforge.net/p/rusefi/tickets/153/ */ - float rawVe = veMap.getValue(rpm, CONFIGB(useTPSBasedVeTable) ? tps : map); + currentRawVE = veMap.getValue(rpm, CONFIGB(useTPSBasedVeTable) ? tps : map); // get VE from the separate table for Idle if (CONFIG(useSeparateVeForIdle)) { float idleVe = interpolate2d("idleVe", rpm, config->idleVeBins, config->idleVe, IDLE_VE_CURVE_SIZE); // interpolate between idle table and normal (running) table using TPS threshold - rawVe = interpolateClamped(0.0f, idleVe, CONFIGB(idlePidDeactivationTpsThreshold), rawVe, tps); + currentRawVE = interpolateClamped(0.0f, idleVe, CONFIGB(idlePidDeactivationTpsThreshold), currentRawVE, tps); } - currentVE = baroCorrection * rawVe * 0.01; + currentBaroCorrectedVE = baroCorrection * currentRawVE * PERCENT_DIV; targetAFR = afrMap.getValue(rpm, map); } else { baseTableFuel = getBaseTableFuel(rpm, engineLoad); diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 861e6d8c9a..b57a432e43 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -28,7 +28,12 @@ // I believe that TunerStudio curve editor has a bug with F32 support // because of that bug we cannot have '1.05' for 5% extra multiplier +/** + * *0.01 because of https://sourceforge.net/p/rusefi/tickets/153/ + */ + #define PERCENT_MULT 100.0f +#define PERCENT_DIV 0.01f /** * http://rusefi.com/wiki/index.php?title=Manual:Engine_Type diff --git a/firmware/controllers/math/speed_density.cpp b/firmware/controllers/math/speed_density.cpp index 8f76ca7046..c24d201f16 100644 --- a/firmware/controllers/math/speed_density.cpp +++ b/firmware/controllers/math/speed_density.cpp @@ -130,7 +130,7 @@ floatms_t getSpeedDensityFuel(float map DECLARE_GLOBAL_SUFFIX) { float adjustedMap = map + engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_GLOBAL_SIGNATURE); efiAssert(CUSTOM_ERR_ASSERT, !cisnan(adjustedMap), "NaN adjustedMap", 0); - float airMass = getCylinderAirMass(ENGINE(engineState.currentVE), adjustedMap, tChargeK PASS_GLOBAL_SUFFIX); + float airMass = getCylinderAirMass(ENGINE(engineState.currentBaroCorrectedVE), adjustedMap, tChargeK PASS_GLOBAL_SUFFIX); if (cisnan(airMass)) { warning(CUSTOM_ERR_6685, "NaN airMass"); return 0;