diff --git a/firmware/controllers/actuators/fuel_pump.cpp b/firmware/controllers/actuators/fuel_pump.cpp index 94c6af57ae..4c93f73ade 100644 --- a/firmware/controllers/actuators/fuel_pump.cpp +++ b/firmware/controllers/actuators/fuel_pump.cpp @@ -6,6 +6,7 @@ #include "pch.h" #include "fuel_pump.h" +#include "bench_test.h" void FuelPumpController::onSlowCallback() { auto timeSinceIgn = m_ignOnTimer.getElapsedSeconds(); diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 0d10cca6f8..c295eff103 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -482,10 +482,7 @@ todo: move to shutdown_controller.cpp } bool Engine::isInMainRelayBench() { - if (mainRelayBenchStartNt == 0) { - return false; - } - return (getTimeNowNt() - mainRelayBenchStartNt) < NT_PER_SECOND; + return !mainRelayBenchStart.hasElapsedSec(1); } bool Engine::isInShutdownMode() const { diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 74328fe945..95751c5dd3 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -299,7 +299,7 @@ public: SensorsState sensors; - efitick_t mainRelayBenchStartNt = 0; + Timer mainRelayBenchStart; void preCalculate(); diff --git a/firmware/controllers/bench_test.cpp b/firmware/controllers/bench_test.cpp index e21c57404e..5179786434 100644 --- a/firmware/controllers/bench_test.cpp +++ b/firmware/controllers/bench_test.cpp @@ -51,7 +51,7 @@ static bool isRunningBench = false; -bool isRunningBenchTest(void) { +bool isRunningBenchTest() { return isRunningBench; } @@ -263,7 +263,7 @@ void acRelayBench(void) { static void mainRelayBench(void) { // main relay is usually "ON" via FSIO thus bench testing that one is pretty unusual - engine->mainRelayBenchStartNt = getTimeNowNt(); + engine->mainRelayBenchStart.reset(); } static void hpfpValveBench(void) { diff --git a/firmware/controllers/bench_test.h b/firmware/controllers/bench_test.h index df817fb174..a081ebce1d 100644 --- a/firmware/controllers/bench_test.h +++ b/firmware/controllers/bench_test.h @@ -13,7 +13,7 @@ void initBenchTest(); void onConfigurationChangeBenchTest(); -bool isRunningBenchTest(void); +bool isRunningBenchTest(); void fanBench(void); void fan2Bench(void);