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->isFuelPumpOn = enginePins.fuelPumpRelay.getLogicValue();
tsOutputChannels->isFanOn = enginePins.fanRelay.getLogicValue(); tsOutputChannels->isFanOn = enginePins.fanRelay.getLogicValue();
tsOutputChannels->isO2HeaterOn = enginePins.o2heater.getLogicValue(); tsOutputChannels->isO2HeaterOn = enginePins.o2heater.getLogicValue();
tsOutputChannels->isIgnitionEnabledIndicator = engineConfiguration->isIgnitionEnabled && ENGINE(limpManager).allowIgnition(); tsOutputChannels->isIgnitionEnabledIndicator = ENGINE(limpManager).allowIgnition();
tsOutputChannels->isInjectionEnabledIndicator = engineConfiguration->isInjectionEnabled && ENGINE(limpManager).allowInjection(); tsOutputChannels->isInjectionEnabledIndicator = ENGINE(limpManager).allowInjection();
tsOutputChannels->isCylinderCleanupEnabled = engineConfiguration->isCylinderCleanupEnabled; tsOutputChannels->isCylinderCleanupEnabled = engineConfiguration->isCylinderCleanupEnabled;
tsOutputChannels->isCylinderCleanupActivated = engine->isCylinderCleanupMode; 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_STACK_6627, getCurrentRemainingStack() > 128, "lowstck#3");
efiAssertVoid(CUSTOM_ERR_6628, trgEventIndex < engine->engineCycleEventCount, "handleFuel/event index"); efiAssertVoid(CUSTOM_ERR_6628, trgEventIndex < engine->engineCycleEventCount, "handleFuel/event index");
if (!isInjectionEnabled(PASS_ENGINE_PARAMETER_SIGNATURE) || limitedFuel) { if (limitedFuel) {
return; return;
} }
if (ENGINE(isCylinderCleanupMode)) { if (ENGINE(isCylinderCleanupMode)) {
@ -554,8 +554,6 @@ void initMainEventListener(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX
addConsoleActionP("maininfo", (VoidPtr) showMainInfo, engine); addConsoleActionP("maininfo", (VoidPtr) showMainInfo, engine);
printMsg(logger, "initMainLoop: %d", currentTimeMillis()); printMsg(logger, "initMainLoop: %d", currentTimeMillis());
if (!isInjectionEnabled(PASS_ENGINE_PARAMETER_SIGNATURE))
printMsg(logger, "!!!!!!!!!!!!!!!!!!! injection disabled");
#endif #endif

View File

@ -35,11 +35,6 @@ static Logging *logger;
static const char *prevSparkName = nullptr; 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) { int isIgnitionTimingError(void) {
return ignitionErrorDetection.sum(6) > 4; return ignitionErrorDetection.sum(6) > 4;
} }

View File

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

View File

@ -5,27 +5,34 @@
EXTERN_ENGINE; EXTERN_ENGINE;
void LimpManager::updateState(int rpm) { void LimpManager::updateState(int rpm) {
// User-configured hard RPM limit Clearable allowFuel = CONFIG(isInjectionEnabled);
bool isRevLimited = rpm > engine->getRpmHardLimit(PASS_ENGINE_PARAMETER_SIGNATURE); Clearable allowSpark = CONFIG(isIgnitionEnabled);
// TODO: user configurable what gets limited // User-configured hard RPM limit
bool limitFuel = isRevLimited; if (rpm > engine->getRpmHardLimit(PASS_ENGINE_PARAMETER_SIGNATURE)) {
bool limitSpark = isRevLimited; if (CONFIG(cutFuelOnHardLimit)) {
allowFuel.clear();
}
if (CONFIG(cutSparkOnHardLimit)) {
allowSpark.clear();
}
}
// Force fuel limiting on the fault rev limit // Force fuel limiting on the fault rev limit
if (rpm > m_faultRevLimit) { if (rpm > m_faultRevLimit) {
limitFuel = true; allowFuel.clear();
} }
// Limit fuel only on boost pressure (limiting spark bends valves) // Limit fuel only on boost pressure (limiting spark bends valves)
if (CONFIG(boostCutPressure) != 0) { if (CONFIG(boostCutPressure) != 0) {
if (Sensor::get(SensorType::Map).value_or(0) > CONFIG(boostCutPressure)) { if (Sensor::get(SensorType::Map).value_or(0) > CONFIG(boostCutPressure)) {
limitFuel = true; allowFuel.clear();
} }
} }
m_transientLimitInjection = limitFuel; m_transientAllowInjection = allowFuel;
m_transientLimitIgnition = limitSpark; m_transientAllowIgnition = allowSpark;
} }
void LimpManager::etbProblem() { void LimpManager::etbProblem() {
@ -57,9 +64,9 @@ bool LimpManager::allowTriggerInput() const {
} }
bool LimpManager::allowInjection() const { bool LimpManager::allowInjection() const {
return !m_transientLimitInjection && m_allowInjection; return m_transientAllowInjection && m_allowInjection;
} }
bool LimpManager::allowIgnition() const { 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. // Only allows clearing the value, but never resetting it.
class Clearable { class Clearable {
public: public:
Clearable() : m_value(true) {}
Clearable(bool value) : m_value(value) {}
void clear() { void clear() {
m_value = false; m_value = false;
} }
@ -49,6 +52,6 @@ private:
Clearable m_allowIgnition; Clearable m_allowIgnition;
Clearable m_allowTriggerInput; Clearable m_allowTriggerInput;
bool m_transientLimitInjection = false; bool m_transientAllowInjection = true;
bool m_transientLimitIgnition = false; bool m_transientAllowIgnition = true;
}; };