mirror of https://github.com/rusefi/rusefi-1.git
Whatever we call it, how ever we implement it - we need live data / remote view into rusEFI actual state #3353
This commit is contained in:
parent
6f3a453dc9
commit
ff864ec0bf
|
@ -8,52 +8,49 @@ static Deadband<200> maxRpmDeadband;
|
|||
static Deadband<5> maxCltDeadband;
|
||||
static Deadband<5> maxTpsDeadband;
|
||||
|
||||
static bool getAcState(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
bool AcState::getAcState(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
auto rpm = Sensor::getOrZero(SensorType::Rpm);
|
||||
|
||||
// Engine too slow, disable
|
||||
if (rpm < 500) {
|
||||
engineTooSlow = rpm < 500;
|
||||
|
||||
if (engineTooSlow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Engine too fast, disable
|
||||
auto maxRpm = CONFIG(maxAcRpm);
|
||||
if (maxRpm != 0) {
|
||||
if (maxRpmDeadband.gt(rpm, maxRpm)) {
|
||||
engineTooFast = maxRpm != 0 && maxRpmDeadband.gt(rpm, maxRpm);
|
||||
if (engineTooFast) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
auto clt = Sensor::get(SensorType::Clt);
|
||||
|
||||
noClt = !clt;
|
||||
// No AC with failed CLT
|
||||
if (!clt) {
|
||||
if (noClt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Engine too hot, disable
|
||||
auto maxClt = CONFIG(maxAcClt);
|
||||
if (maxClt != 0) {
|
||||
if (maxCltDeadband.gt(maxClt, clt.Value)) {
|
||||
engineTooHot = (maxClt != 0) && maxCltDeadband.gt(maxClt, clt.Value);
|
||||
if (engineTooHot) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// TPS too high, disable
|
||||
auto maxTps = CONFIG(maxAcTps);
|
||||
if (maxTps != 0) {
|
||||
auto tps = Sensor::getOrZero(SensorType::Tps1);
|
||||
|
||||
if (maxTpsDeadband.gt(maxTps, tps)) {
|
||||
tpsTooHigh = maxTps != 0 && maxTpsDeadband.gt(maxTps, Sensor::getOrZero(SensorType::Tps1));
|
||||
if (tpsTooHigh) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
acButtonState = ENGINE(acSwitchState);
|
||||
// All conditions allow AC, simply pass thru switch
|
||||
return ENGINE(acSwitchState);
|
||||
return acButtonState;
|
||||
}
|
||||
|
||||
bool updateAc(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
bool AcState::updateAc(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
bool isEnabled = getAcState(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
enginePins.acRelay.setValue(isEnabled);
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "engine_ptr.h"
|
||||
#include "ac_control_generated.h"
|
||||
|
||||
// Returns true if AC is currently active
|
||||
bool updateAc(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
class AcState final : public ac_control_s {
|
||||
public:
|
||||
// Returns true if AC is currently active
|
||||
bool updateAc(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
private:
|
||||
bool getAcState(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
};
|
||||
|
|
|
@ -225,7 +225,7 @@ void Engine::periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
runHardcodedFsio(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
#endif /* EFI_FSIO */
|
||||
|
||||
bool acActive = updateAc(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
bool acActive = acState.updateAc(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
updateFans(acActive PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
updateGppwm();
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "gear_controller.h"
|
||||
#include "limp_manager.h"
|
||||
#include "pin_repository.h"
|
||||
#include "ac_control.h"
|
||||
|
||||
#if EFI_SIGNAL_EXECUTOR_ONE_TIMER
|
||||
// PROD real firmware uses this implementation
|
||||
|
@ -88,6 +89,7 @@ public:
|
|||
DECLARE_ENGINE_PTR;
|
||||
|
||||
Engine();
|
||||
AcState acState;
|
||||
bool enableOverdwellProtection = true;
|
||||
bool isPwmEnabled = true;
|
||||
int triggerActivitySecond = 0;
|
||||
|
|
|
@ -1762,6 +1762,7 @@ end_struct
|
|||
#define LDS_ALTERNATOR_PID_STATE_INDEX 9
|
||||
#define LDS_CJ125_PID_STATE_INDEX 10
|
||||
#define LDS_TRIGGER_STATE_STATE_INDEX 11
|
||||
#define LDS_AC_STATE 12
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue