diff --git a/firmware/controllers/algo/engine_configuration_defaults.h b/firmware/controllers/algo/engine_configuration_defaults.h index b9a4c5c28e..e19c965f78 100644 --- a/firmware/controllers/algo/engine_configuration_defaults.h +++ b/firmware/controllers/algo/engine_configuration_defaults.h @@ -25,4 +25,6 @@ namespace engine_configuration_defaults { /* Launch Control: */ constexpr switch_input_pin_e LAUNCH_ACTIVATE_PIN = Gpio::Unassigned; constexpr bool LAUNCH_ACTIVATE_PIN_INVERTED = false; + constexpr launchActivationMode_e LAUNCH_ACTIVATION_MODE = SWITCH_INPUT_LAUNCH; + constexpr int LAUNCH_SPEED_THRESHOLD = 0; } diff --git a/unit_tests/tests/launch/launch_test_base.cpp b/unit_tests/tests/launch/launch_test_base.cpp index 7b13b11e05..3facb6c563 100644 --- a/unit_tests/tests/launch/launch_test_base.cpp +++ b/unit_tests/tests/launch/launch_test_base.cpp @@ -27,7 +27,8 @@ void LaunchTestBase::setUpTestConfig(const LaunchTestConfig& config) { } void LaunchTestBase::configureSatisfiedActivationSwithSpeedAndTpsConditions() { - engineConfiguration->launchActivationMode = ALWAYS_ACTIVE_LAUNCH; // to satisfy activateSwitchCondition - engineConfiguration->launchSpeedThreshold = 0; // to satisfy speedCondition + getTestEngineConfiguration() + .configureLaunchActivationMode(ALWAYS_ACTIVE_LAUNCH); // to satisfy activateSwitchCondition + getTestEngineConfiguration().configureLaunchSpeedThreshold(0); // to satisfy speedCondition Sensor::setMockValue(SensorType::DriverThrottleIntent, 1.7); // to satisfy tpsCondition } diff --git a/unit_tests/tests/util/test_engine_configuration.cpp b/unit_tests/tests/util/test_engine_configuration.cpp index 010ffcc35e..e40b96e073 100644 --- a/unit_tests/tests/util/test_engine_configuration.cpp +++ b/unit_tests/tests/util/test_engine_configuration.cpp @@ -20,6 +20,30 @@ void TestEngineConfiguration::configureLaunchControlEnabled(const std::optional< } } +void TestEngineConfiguration::configureLaunchActivationMode( + const std::optional launchActivationMode +) { + if (launchActivationMode.has_value()) { + engineConfiguration->launchActivationMode = launchActivationMode.value(); + } else { + ASSERT_EQ( + engineConfiguration->launchActivationMode, + engine_configuration_defaults::LAUNCH_ACTIVATION_MODE + ); // check default value + } +} + +void TestEngineConfiguration::configureLaunchSpeedThreshold(const std::optional launchSpeedThreshold) { + if (launchSpeedThreshold.has_value()) { + engineConfiguration->launchSpeedThreshold = launchSpeedThreshold.value(); + } else { + ASSERT_EQ( + engineConfiguration->launchSpeedThreshold, + engine_configuration_defaults::LAUNCH_SPEED_THRESHOLD + ); // check default value + } +} + void TestEngineConfiguration::configureLaunchRpm(const std::optional launchRpm) { if (launchRpm.has_value()) { engineConfiguration->launchRpm = launchRpm.value(); diff --git a/unit_tests/tests/util/test_engine_configuration.h b/unit_tests/tests/util/test_engine_configuration.h index 6638d24aab..93904a3390 100644 --- a/unit_tests/tests/util/test_engine_configuration.h +++ b/unit_tests/tests/util/test_engine_configuration.h @@ -13,6 +13,9 @@ public: // Launch Control Settings void configureLaunchControlEnabled(std::optional launchControlEnabled); + void configureLaunchActivationMode(std::optional launchActivationMode); + void configureLaunchSpeedThreshold(std::optional launchSpeedThreshold); + void configureLaunchRpm(std::optional launchRpm); void configureLaunchRpmWindow(std::optional launchRpmWindow); void configureLaunchCorrectionsEndRpm(std::optional launchCorrectionsEndRpm);