From 01c90830f26a86d5214f2768997df76f5d0d5254 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 24 Sep 2024 15:20:46 -0400 Subject: [PATCH] only:explicit and official radiatorFanStatus --- .../controllers/actuators/fan_control.cpp | 24 +++++++++---------- firmware/controllers/actuators/fan_control.h | 14 +++++++++++ .../controllers/actuators/fan_control.txt | 3 +-- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/firmware/controllers/actuators/fan_control.cpp b/firmware/controllers/actuators/fan_control.cpp index 1c62d3cf9c..4ac397eba4 100644 --- a/firmware/controllers/actuators/fan_control.cpp +++ b/firmware/controllers/actuators/fan_control.cpp @@ -29,36 +29,34 @@ bool FanController::getState(bool acActive, bool lastState) { if (cranking) { // Inhibit while cranking - tempCode = 31; + radiatorFanStatus = (int)RadiatorFanState::Cranking; return false; } else if (disabledWhileEngineStopped) { // Inhibit while not running (if so configured) - tempCode = 32; + radiatorFanStatus = (int)RadiatorFanState::EngineStopped; return false; } else if (disabledBySpeed) { // Inhibit while driving fast - tempCode = 33; + radiatorFanStatus = (int)RadiatorFanState::VehicleIsTooFast; return false; } else if (fansDisabledByBoardStatus()) { - tempCode = 34; + radiatorFanStatus = (int)RadiatorFanState::BoardStatus; return false; } else if (brokenClt) { // If CLT is broken, turn the fan on - tempCode = 35; + radiatorFanStatus = (int)RadiatorFanState::CltBroken; return true; } else if (enabledForAc) { - tempCode = 36; + radiatorFanStatus = (int)RadiatorFanState::AC; return true; } else if (hot) { - // If hot, turn the fan on - tempCode = 37; + radiatorFanStatus = (int)RadiatorFanState::Hot; return true; } else if (cold) { - // If cold, turn the fan off - tempCode = 38; + radiatorFanStatus = (int)RadiatorFanState::Cold; return false; } else { - tempCode = 40; + radiatorFanStatus = (int)RadiatorFanState::Previous; // no condition met, maintain previous state return lastState; } @@ -67,7 +65,7 @@ bool FanController::getState(bool acActive, bool lastState) { void FanController::onSlowCallback() { #if EFI_PROD_CODE if (isRunningBenchTest()) { - tempCode = 30; + radiatorFanStatus = (int)RadiatorFanState::Bench; return; // let's not mess with bench testing } #endif @@ -77,7 +75,7 @@ void FanController::onSlowCallback() { auto& pin = getPin(); bool result = getState(acActive, pin.getLogicValue()); - tempAlive = tempAlive + 1; + pin.setValue(result); } diff --git a/firmware/controllers/actuators/fan_control.h b/firmware/controllers/actuators/fan_control.h index c15e6d959b..46a0f7279d 100644 --- a/firmware/controllers/actuators/fan_control.h +++ b/firmware/controllers/actuators/fan_control.h @@ -2,6 +2,20 @@ #include "fan_control_generated.h" +enum class RadiatorFanState : uint8_t { + None, // 0 + Cranking, // 1 + EngineStopped, // 2 + VehicleIsTooFast, // 3 + BoardStatus, // 4 + CltBroken, // 5 + AC, // 6 + Hot, // 7 + Cold, // 8 + Previous, // 9 + Bench +}; + struct FanController : public EngineModule, public fan_control_s { void onSlowCallback() override; diff --git a/firmware/controllers/actuators/fan_control.txt b/firmware/controllers/actuators/fan_control.txt index 5006b9730c..e3073a292c 100644 --- a/firmware/controllers/actuators/fan_control.txt +++ b/firmware/controllers/actuators/fan_control.txt @@ -7,6 +7,5 @@ struct_no_prefix fan_control_s bit hot bit cold bit disabledBySpeed - uint8_t tempAlive - uint8_t tempCode + uint8_t radiatorFanStatus end_struct