diff --git a/firmware/controllers/algo/launch_control.cpp b/firmware/controllers/algo/launch_control.cpp index 1925777caf..cfa00b5c0b 100644 --- a/firmware/controllers/algo/launch_control.cpp +++ b/firmware/controllers/algo/launch_control.cpp @@ -106,7 +106,7 @@ void LaunchControlBase::update() { return; } - int rpm = GET_RPM(); + int rpm = Sensor::getOrZero(SensorType::Rpm); combinedConditions = isLaunchConditionMet(rpm); //and still recalculate in case user changed the values @@ -131,7 +131,7 @@ void LaunchControlBase::update() { } bool LaunchControlBase::isLaunchRpmRetardCondition() const { - return isLaunchCondition && (retardThresholdRpm < GET_RPM()); + return isLaunchCondition && (retardThresholdRpm < Sensor::getOrZero(SensorType::Rpm)); } bool LaunchControlBase::isLaunchSparkRpmRetardCondition() const { diff --git a/unit_tests/tests/test_launch.cpp b/unit_tests/tests/test_launch.cpp index 6bdc0e3466..5d9d01168a 100644 --- a/unit_tests/tests/test_launch.cpp +++ b/unit_tests/tests/test_launch.cpp @@ -108,11 +108,11 @@ TEST(LaunchControl, CombinedCondition) { Sensor::setMockValue(SensorType::DriverThrottleIntent, 20.0f); Sensor::setMockValue(SensorType::VehicleSpeed, 10.0); - engine->rpmCalculator.mockRpm = 1200; + Sensor::setMockValue(SensorType::Rpm, 1200); EXPECT_FALSE(dut.isLaunchConditionMet(1200)); - engine->rpmCalculator.mockRpm = 3200; + Sensor::setMockValue(SensorType::Rpm, 3200); EXPECT_TRUE(dut.isLaunchConditionMet(3200)); Sensor::setMockValue(SensorType::VehicleSpeed, 40.0); @@ -156,7 +156,7 @@ TEST(LaunchControl, CompleteRun) { Sensor::setMockValue(SensorType::DriverThrottleIntent, 20.0f); Sensor::setMockValue(SensorType::VehicleSpeed, 10.0); - engine->rpmCalculator.mockRpm = 1200; + Sensor::setMockValue(SensorType::Rpm, 1200); engine->launchController.update(); @@ -166,7 +166,7 @@ TEST(LaunchControl, CompleteRun) { EXPECT_FALSE(engine->launchController.isLaunchFuelRpmRetardCondition()); - engine->rpmCalculator.mockRpm = 3510; + Sensor::setMockValue(SensorType::Rpm, 3510); //update condition check engine->launchController.update();