diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 43e431ba07..e0ace2b441 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -649,7 +649,7 @@ static void updateFlags() { tsOutputChannels.isCylinderCleanupActivated = engine->isCylinderCleanupMode; #if EFI_LAUNCH_CONTROL - tsOutputChannels.launchTriggered = engine->isLaunchCondition; + tsOutputChannels.launchTriggered = engine->launchController.isLaunchCondition; #endif tsOutputChannels.clutchUpState = engine->clutchUpState; diff --git a/firmware/controllers/algo/advance_map.cpp b/firmware/controllers/algo/advance_map.cpp index 1aef270599..6dad8551a3 100644 --- a/firmware/controllers/algo/advance_map.cpp +++ b/firmware/controllers/algo/advance_map.cpp @@ -61,7 +61,7 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME } #if EFI_LAUNCH_CONTROL - if (engine->isLaunchCondition && CONFIG(enableLaunchRetard)) { + if (engine->launchController.isLaunchCondition && CONFIG(enableLaunchRetard)) { if (CONFIG(launchSmoothRetard)) { float launchAngle = CONFIG(launchTimingRetard); int launchAdvanceRpmRange = CONFIG(launchTimingRpmRange); diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 4dc5286dfc..dde6c9f3e9 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -147,12 +147,6 @@ public: bool needTdcCallback = true; #endif /* EFI_UNIT_TEST */ - -#if EFI_LAUNCH_CONTROL - bool launchActivatePinState = false; - bool isLaunchCondition = false; -#endif /* EFI_LAUNCH_CONTROL */ - /** * By the way 32-bit value should hold at least 400 hours of events at 6K RPM x 12 events per revolution */ @@ -162,11 +156,6 @@ public: // GND input pins instead of leaving them floating bool hwTriggerInputEnabled = true; - -#if !EFI_PROD_CODE - float mockMapValue = 0; -#endif - int getGlobalConfigurationVersion(void) const; /** * true if a recent configuration change has changed any of the trigger settings which diff --git a/firmware/controllers/algo/launch_control.cpp b/firmware/controllers/algo/launch_control.cpp index 46ee48518f..0cc35f5ce9 100644 --- a/firmware/controllers/algo/launch_control.cpp +++ b/firmware/controllers/algo/launch_control.cpp @@ -19,14 +19,14 @@ * We can have active condition from switch or from clutch. * In case we are dependent on VSS we just return true. */ -bool LaunchControlBase::isInsideSwitchCondition() const { +bool LaunchControlBase::isInsideSwitchCondition() { switch (CONFIG(launchActivationMode)) { case SWITCH_INPUT_LAUNCH: if (isBrainPinValid(CONFIG(launchActivatePin))) { //todo: we should take into consideration if this sw is pulled high or low! - engine->launchActivatePinState = efiReadPin(CONFIG(launchActivatePin)); + launchActivatePinState = efiReadPin(CONFIG(launchActivatePin)); } - return engine->launchActivatePinState; + return launchActivatePinState; case CLUTCH_INPUT_LAUNCH: if (isBrainPinValid(CONFIG(clutchDownPin))) { @@ -75,7 +75,7 @@ bool LaunchControlBase::isInsideRPMCondition(int rpm) const { return (launchRpm < rpm); } -bool LaunchControlBase::isLaunchConditionMet(int rpm) const { +bool LaunchControlBase::isLaunchConditionMet(int rpm) { bool activateSwitchCondition = isInsideSwitchCondition(); bool rpmCondition = isInsideRPMCondition(rpm); @@ -109,17 +109,17 @@ void LaunchControlBase::update() { if (!combinedConditions) { // conditions not met, reset timer m_launchTimer.reset(); - engine->isLaunchCondition = false; + isLaunchCondition = false; } else { // If conditions are met... - engine->isLaunchCondition = m_launchTimer.hasElapsedSec(CONFIG(launchActivateDelay)); + isLaunchCondition = m_launchTimer.hasElapsedSec(CONFIG(launchActivateDelay)); } #if EFI_TUNER_STUDIO if (CONFIG(debugMode) == DBG_LAUNCH) { tsOutputChannels.debugIntField5 = engine->clutchDownState; - tsOutputChannels.debugFloatField1 = engine->launchActivatePinState; - tsOutputChannels.debugFloatField2 = engine->isLaunchCondition; + tsOutputChannels.debugFloatField1 = launchActivatePinState; + tsOutputChannels.debugFloatField2 = isLaunchCondition; tsOutputChannels.debugFloatField3 = combinedConditions; } #endif /* EFI_TUNER_STUDIO */ @@ -144,7 +144,7 @@ void setDefaultLaunchParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) { } bool LaunchControlBase::isLaunchRpmRetardCondition() const { - return engine->isLaunchCondition && (retardThresholdRpm < GET_RPM()); + return isLaunchCondition && (retardThresholdRpm < GET_RPM()); } bool LaunchControlBase::isLaunchSparkRpmRetardCondition() const { diff --git a/firmware/controllers/algo/launch_control.h b/firmware/controllers/algo/launch_control.h index 04c00a2f37..3b9f447727 100644 --- a/firmware/controllers/algo/launch_control.h +++ b/firmware/controllers/algo/launch_control.h @@ -20,14 +20,16 @@ public: bool isInsideSpeedCondition() const; bool isInsideTpsCondition() const; - bool isInsideSwitchCondition() const; + bool isInsideSwitchCondition(); bool isInsideRPMCondition(int rpm) const; - bool isLaunchConditionMet(int rpm) const; + bool isLaunchConditionMet(int rpm); bool isLaunchSparkRpmRetardCondition() const; bool isLaunchFuelRpmRetardCondition() const; int retardThresholdRpm; + bool launchActivatePinState = false; + bool isLaunchCondition = false; private: bool isLaunchRpmRetardCondition() const; diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.cpp b/firmware/controllers/engine_cycle/main_trigger_callback.cpp index efc7bedba2..815084c58d 100644 --- a/firmware/controllers/engine_cycle/main_trigger_callback.cpp +++ b/firmware/controllers/engine_cycle/main_trigger_callback.cpp @@ -414,7 +414,7 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp DECLARE bool limitedFuel = !ENGINE(limpManager).allowInjection(); #if EFI_LAUNCH_CONTROL - if (engine->isLaunchCondition && !limitedSpark && !limitedFuel) { + if (engine->launchController.isLaunchCondition && !limitedSpark && !limitedFuel) { /* in case we are not already on a limited conditions, check launch as well */ limitedSpark &= engine->launchController.isLaunchSparkRpmRetardCondition();