only:explicit and official radiatorFanStatus

This commit is contained in:
Andrey 2024-09-24 15:20:46 -04:00
parent f22116e791
commit 01c90830f2
3 changed files with 26 additions and 15 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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