Limp handles inj/ign disable (#2245)

* status loop just asks limp mgr

* put logic in limp manager

* don't need that function any more

* bye

* TIL these bits already exist in the configuration
This commit is contained in:
Matthew Kennedy 2021-01-27 18:28:53 -08:00 committed by GitHub
parent 5ca29789ef
commit 93b034b8e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 24 deletions

View File

@ -681,8 +681,8 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
tsOutputChannels->isFuelPumpOn = enginePins.fuelPumpRelay.getLogicValue();
tsOutputChannels->isFanOn = enginePins.fanRelay.getLogicValue();
tsOutputChannels->isO2HeaterOn = enginePins.o2heater.getLogicValue();
tsOutputChannels->isIgnitionEnabledIndicator = engineConfiguration->isIgnitionEnabled && ENGINE(limpManager).allowIgnition();
tsOutputChannels->isInjectionEnabledIndicator = engineConfiguration->isInjectionEnabled && ENGINE(limpManager).allowInjection();
tsOutputChannels->isIgnitionEnabledIndicator = ENGINE(limpManager).allowIgnition();
tsOutputChannels->isInjectionEnabledIndicator = ENGINE(limpManager).allowInjection();
tsOutputChannels->isCylinderCleanupEnabled = engineConfiguration->isCylinderCleanupEnabled;
tsOutputChannels->isCylinderCleanupActivated = engine->isCylinderCleanupMode;

View File

@ -320,7 +320,7 @@ static void handleFuel(const bool limitedFuel, uint32_t trgEventIndex, int rpm,
efiAssertVoid(CUSTOM_STACK_6627, getCurrentRemainingStack() > 128, "lowstck#3");
efiAssertVoid(CUSTOM_ERR_6628, trgEventIndex < engine->engineCycleEventCount, "handleFuel/event index");
if (!isInjectionEnabled(PASS_ENGINE_PARAMETER_SIGNATURE) || limitedFuel) {
if (limitedFuel) {
return;
}
if (ENGINE(isCylinderCleanupMode)) {
@ -554,8 +554,6 @@ void initMainEventListener(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX
addConsoleActionP("maininfo", (VoidPtr) showMainInfo, engine);
printMsg(logger, "initMainLoop: %d", currentTimeMillis());
if (!isInjectionEnabled(PASS_ENGINE_PARAMETER_SIGNATURE))
printMsg(logger, "!!!!!!!!!!!!!!!!!!! injection disabled");
#endif

View File

@ -35,11 +35,6 @@ static Logging *logger;
static const char *prevSparkName = nullptr;
int isInjectionEnabled(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// todo: is this worth a method? should this be inlined?
return CONFIG(isInjectionEnabled);
}
int isIgnitionTimingError(void) {
return ignitionErrorDetection.sum(6) > 4;
}

View File

@ -9,7 +9,6 @@
#include "engine.h"
int isInjectionEnabled(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void onTriggerEventSparkLogic(bool limitedSpark, uint32_t trgEventIndex, int rpm, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX);
void initSparkLogic(Logging *sharedLogger);
void turnSparkPinHigh(IgnitionEvent *event);

View File

@ -5,27 +5,34 @@
EXTERN_ENGINE;
void LimpManager::updateState(int rpm) {
// User-configured hard RPM limit
bool isRevLimited = rpm > engine->getRpmHardLimit(PASS_ENGINE_PARAMETER_SIGNATURE);
Clearable allowFuel = CONFIG(isInjectionEnabled);
Clearable allowSpark = CONFIG(isIgnitionEnabled);
// TODO: user configurable what gets limited
bool limitFuel = isRevLimited;
bool limitSpark = isRevLimited;
// User-configured hard RPM limit
if (rpm > engine->getRpmHardLimit(PASS_ENGINE_PARAMETER_SIGNATURE)) {
if (CONFIG(cutFuelOnHardLimit)) {
allowFuel.clear();
}
if (CONFIG(cutSparkOnHardLimit)) {
allowSpark.clear();
}
}
// Force fuel limiting on the fault rev limit
if (rpm > m_faultRevLimit) {
limitFuel = true;
allowFuel.clear();
}
// Limit fuel only on boost pressure (limiting spark bends valves)
if (CONFIG(boostCutPressure) != 0) {
if (Sensor::get(SensorType::Map).value_or(0) > CONFIG(boostCutPressure)) {
limitFuel = true;
allowFuel.clear();
}
}
m_transientLimitInjection = limitFuel;
m_transientLimitIgnition = limitSpark;
m_transientAllowInjection = allowFuel;
m_transientAllowIgnition = allowSpark;
}
void LimpManager::etbProblem() {
@ -57,9 +64,9 @@ bool LimpManager::allowTriggerInput() const {
}
bool LimpManager::allowInjection() const {
return !m_transientLimitInjection && m_allowInjection;
return m_transientAllowInjection && m_allowInjection;
}
bool LimpManager::allowIgnition() const {
return !m_transientLimitIgnition && m_allowIgnition;
return m_transientAllowIgnition && m_allowIgnition;
}

View File

@ -7,6 +7,9 @@
// Only allows clearing the value, but never resetting it.
class Clearable {
public:
Clearable() : m_value(true) {}
Clearable(bool value) : m_value(value) {}
void clear() {
m_value = false;
}
@ -49,6 +52,6 @@ private:
Clearable m_allowIgnition;
Clearable m_allowTriggerInput;
bool m_transientLimitInjection = false;
bool m_transientLimitIgnition = false;
bool m_transientAllowInjection = true;
bool m_transientAllowIgnition = true;
};