diff --git a/firmware/controllers/algo/launch_control.h b/firmware/controllers/algo/launch_control.h index e245ce07b0..04c00a2f37 100644 --- a/firmware/controllers/algo/launch_control.h +++ b/firmware/controllers/algo/launch_control.h @@ -23,9 +23,14 @@ public: bool isInsideSwitchCondition() const; bool isInsideRPMCondition(int rpm) const; bool isLaunchConditionMet(int rpm) const; + + bool isLaunchSparkRpmRetardCondition() const; + bool isLaunchFuelRpmRetardCondition() const; + int retardThresholdRpm; - void applyLaunchControlLimiting(bool *limitedSpark, bool *limitedFuel DECLARE_ENGINE_PARAMETER_SUFFIX); private: + bool isLaunchRpmRetardCondition() const; + Timer m_launchTimer; }; diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.cpp b/firmware/controllers/engine_cycle/main_trigger_callback.cpp index 07d290a74c..efc7bedba2 100644 --- a/firmware/controllers/engine_cycle/main_trigger_callback.cpp +++ b/firmware/controllers/engine_cycle/main_trigger_callback.cpp @@ -416,7 +416,9 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp DECLARE #if EFI_LAUNCH_CONTROL if (engine->isLaunchCondition && !limitedSpark && !limitedFuel) { /* in case we are not already on a limited conditions, check launch as well */ - engine->launchController.applyLaunchControlLimiting(&limitedSpark, &limitedFuel PASS_ENGINE_PARAMETER_SUFFIX); + + limitedSpark &= engine->launchController.isLaunchSparkRpmRetardCondition(); + limitedFuel &= engine->launchController.isLaunchFuelRpmRetardCondition(); } #endif if (trgEventIndex == 0) { diff --git a/unit_tests/tests/test_engine_math.cpp b/unit_tests/tests/test_engine_math.cpp index 899f3f3caf..70be2ac862 100644 --- a/unit_tests/tests/test_engine_math.cpp +++ b/unit_tests/tests/test_engine_math.cpp @@ -93,7 +93,3 @@ TEST(misc, testIgnitionMapGenerator) { assertEqualsM2("4400", 41.9, getInitialAdvance(4400, 40, 36), 0.1); assertEqualsM2("20@800", 14.2, getInitialAdvance(800, 20, 36), 0.2); } - -float getMap(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - return engine->mockMapValue; -} diff --git a/unit_tests/tests/test_launch.cpp b/unit_tests/tests/test_launch.cpp index fc3d68b522..c09d24f9d3 100644 --- a/unit_tests/tests/test_launch.cpp +++ b/unit_tests/tests/test_launch.cpp @@ -127,7 +127,6 @@ TEST(LaunchControl, CombinedCondition) { } TEST(LaunchControl, CompleteRun) { - bool spark, fuel; WITH_ENGINE_TEST_HELPER(TEST_ENGINE); initLaunchControl(PASS_ENGINE_PARAMETER_SIGNATURE); @@ -152,11 +151,8 @@ TEST(LaunchControl, CompleteRun) { //check if we have some sort of cut? we should not have at this point - spark = false; - fuel = false; - engine->launchController.applyLaunchControlLimiting(&spark, &fuel PASS_ENGINE_PARAMETER_SUFFIX); - EXPECT_FALSE(spark); - EXPECT_FALSE(fuel); + EXPECT_FALSE(engine->launchController.isLaunchSparkRpmRetardCondition()); + EXPECT_FALSE(engine->launchController.isLaunchFuelRpmRetardCondition()); engine->rpmCalculator.mockRpm = 3510; @@ -167,29 +163,22 @@ TEST(LaunchControl, CompleteRun) { //we have a 3 seconds delay to actually enable it! eth.moveTimeForwardAndInvokeEventsSec(1); engine->launchController.update(); - - spark = false; - fuel = false; - engine->launchController.applyLaunchControlLimiting(&spark, &fuel PASS_ENGINE_PARAMETER_SUFFIX); - EXPECT_FALSE(spark); - EXPECT_FALSE(fuel); + EXPECT_FALSE(engine->launchController.isLaunchSparkRpmRetardCondition()); + EXPECT_FALSE(engine->launchController.isLaunchFuelRpmRetardCondition()); eth.moveTimeForwardAndInvokeEventsSec(3); engine->launchController.update(); - spark = false; - fuel = false; - engine->launchController.applyLaunchControlLimiting(&spark, &fuel PASS_ENGINE_PARAMETER_SUFFIX); - EXPECT_TRUE(spark); - EXPECT_FALSE(fuel); + + EXPECT_TRUE(engine->launchController.isLaunchSparkRpmRetardCondition()); + EXPECT_FALSE(engine->launchController.isLaunchFuelRpmRetardCondition()); Sensor::setMockValue(SensorType::VehicleSpeed, 40.0); engine->launchController.update(); - spark = false; - fuel = false; - engine->launchController.applyLaunchControlLimiting(&spark, &fuel PASS_ENGINE_PARAMETER_SUFFIX); - EXPECT_FALSE(spark); - EXPECT_FALSE(fuel); + + + EXPECT_FALSE(engine->launchController.isLaunchSparkRpmRetardCondition()); + EXPECT_FALSE(engine->launchController.isLaunchFuelRpmRetardCondition()); }