diff --git a/firmware/controllers/actuators/idle_thread.cpp b/firmware/controllers/actuators/idle_thread.cpp index baa89dda88..7f0fc4cdb6 100644 --- a/firmware/controllers/actuators/idle_thread.cpp +++ b/firmware/controllers/actuators/idle_thread.cpp @@ -565,6 +565,10 @@ float getIdleTimingAdjustment(int rpm) { return idleControllerInstance.getIdleTimingAdjustment(rpm); } +bool isIdling() { + return idleControllerInstance.isIdling(); +} + static void applyPidSettings(DECLARE_ENGINE_PARAMETER_SIGNATURE) { getIdlePid(PASS_ENGINE_PARAMETER_SIGNATURE)->updateFactors(engineConfiguration->idleRpmPid.pFactor, engineConfiguration->idleRpmPid.iFactor, engineConfiguration->idleRpmPid.dFactor); iacPidMultMap.init(CONFIG(iacPidMultTable), CONFIG(iacPidMultLoadBins), CONFIG(iacPidMultRpmBins)); diff --git a/firmware/controllers/actuators/idle_thread.h b/firmware/controllers/actuators/idle_thread.h index c3a0ec5f9c..a2f797cd9b 100644 --- a/firmware/controllers/actuators/idle_thread.h +++ b/firmware/controllers/actuators/idle_thread.h @@ -53,6 +53,11 @@ public: float getIdleTimingAdjustment(int rpm); float getIdleTimingAdjustment(int rpm, int targetRpm, Phase phase); + // Allow querying state from outside + bool isIdling() { + return m_lastPhase == Phase::Idling; + } + private: // These are stored by getIdlePosition() and used by getIdleTimingAdjustment() Phase m_lastPhase = Phase::Cranking; @@ -66,6 +71,8 @@ percent_t getIdlePosition(); float getIdleTimingAdjustment(int rpm); +bool isIdling(); + void applyIACposition(percent_t position DECLARE_ENGINE_PARAMETER_SUFFIX); void setManualIdleValvePosition(int positionPercent); diff --git a/firmware/controllers/algo/advance_map.cpp b/firmware/controllers/algo/advance_map.cpp index 9d3c474e3d..5233094003 100644 --- a/firmware/controllers/algo/advance_map.cpp +++ b/firmware/controllers/algo/advance_map.cpp @@ -82,7 +82,7 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME float advanceAngle = advanceMap.getValue((float) rpm, engineLoad); // get advance from the separate table for Idle - if (CONFIG(useSeparateAdvanceForIdle)) { + if (CONFIG(useSeparateAdvanceForIdle) && isIdling()) { float idleAdvance = interpolate2d("idleAdvance", rpm, config->idleAdvanceBins, config->idleAdvance); auto [valid, tps] = Sensor::get(SensorType::DriverThrottleIntent); @@ -92,7 +92,6 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME } } - #if EFI_LAUNCH_CONTROL if (engine->isLaunchCondition && CONFIG(enableLaunchRetard)) { if (CONFIG(launchSmoothRetard)) { diff --git a/firmware/controllers/algo/airmass/airmass.cpp b/firmware/controllers/algo/airmass/airmass.cpp index a7116ee2db..f4d6940699 100644 --- a/firmware/controllers/algo/airmass/airmass.cpp +++ b/firmware/controllers/algo/airmass/airmass.cpp @@ -1,5 +1,6 @@ #include "airmass.h" #include "sensor.h" +#include "idle_thread.h" EXTERN_ENGINE; @@ -23,8 +24,8 @@ float AirmassModelBase::getVe(int rpm, float load) const { float ve = m_veTable->getValue(rpm, load); auto tps = Sensor::get(SensorType::Tps1); - // get VE from the separate table for Idle - if (tps.Valid && CONFIG(useSeparateVeForIdle)) { + // get VE from the separate table for Idle if idling + if (isIdling() && tps && CONFIG(useSeparateVeForIdle)) { float idleVe = interpolate2d("idleVe", rpm, config->idleVeBins, config->idleVe); // interpolate between idle table and normal (running) table using TPS threshold ve = interpolateClamped(0.0f, idleVe, CONFIG(idlePidDeactivationTpsThreshold), ve, tps.Value);