Better efi engine control guard (#5695)

* better EFI_ENGINE_CONTROL

* better EFI_ENGINE_CONTROL

* better EFI_ENGINE_CONTROL

* better EFI_ENGINE_CONTROL

* better EFI_ENGINE_CONTROL

* better EFI_ENGINE_CONTROL

* better EFI_ENGINE_CONTROL
This commit is contained in:
rusefillc 2023-11-05 13:54:06 -05:00 committed by GitHub
parent a4e0f5c345
commit 4cb45a354b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 33 additions and 17 deletions

View File

@ -12,7 +12,7 @@ DDEFS += -DLUA_USER_HEAP=50000
DDEFS += -DEFI_MC33816=FALSE
DDEFS += -DEFI_IDLE_CONTROL=FALSE
DDEFS += -DDL_OUTPUT_BUFFER=1000
DDEFS += -DEFI_ELECTRONIC_THROTTLE_BODY
DDEFS += -DEFI_ELECTRONIC_THROTTLE_BODY=FALSE
DDEFS += -DEFI_LOGIC_ANALYZER=FALSE
DDEFS += -DEFI_MALFUNCTION_INDICATOR=FALSE
DDEFS += -DEFI_ENGINE_SNIFFER=FALSE
@ -20,6 +20,7 @@ DDEFS += -DEFI_TCU=FALSE
DDEFS += -DEFI_ENGINE_EMULATOR=FALSE
DDEFS += -DEFI_SHAFT_POSITION_INPUT=FALSE
DDEFS += -DEFI_ALTERNATOR_CONTROL=FALSE
DDEFS += -DEFI_ENGINE_CONTROL=FALSE
DDEFS += -DEFI_VVT_PID=FALSE
DDEFS += -DEFI_EMULATE_POSITION_SENSORS=FALSE
DDEFS += -DEFI_MAP_AVERAGING=FALSE

View File

@ -176,8 +176,11 @@
/**
* Maybe we are just sniffing what's going on?
* EFI_ENGINE_CONTROL is covering injectors and spark control
*/
#ifndef EFI_ENGINE_CONTROL
#define EFI_ENGINE_CONTROL TRUE
#endif
/**
* MCP42010 digital potentiometer support. This could be useful if you are stimulating some

View File

@ -197,7 +197,11 @@ const throttle_model_s* getLiveData(size_t) {
template<>
const lambda_monitor_s* getLiveData(size_t) {
#if EFI_SHAFT_POSITION_INPUT
return &engine->lambdaMonitor;
#else
return nullptr;
#endif
}
static const FragmentEntry fragments[] = {

View File

@ -713,7 +713,7 @@ int TunerStudio::handleCrcCommand(TsChannelBase* tsChannel, char *data, int inco
uint16_t subsystem = SWAP_UINT16(data16[0]);
uint16_t index = SWAP_UINT16(data16[1]);
#if EFI_PROD_CODE && EFI_ENGINE_CONTROL
#if EFI_PROD_CODE
executeTSCommand(subsystem, index);
#endif /* EFI_PROD_CODE */
sendOkResponse(tsChannel, TS_CRC);

View File

@ -410,6 +410,7 @@ static void updateThrottles() {
static void updateLambda() {
float lambdaValue = Sensor::getOrZero(SensorType::Lambda1);
engine->outputChannels.lambdaValue = lambdaValue;
#if EFI_ENGINE_CONTROL
engine->outputChannels.AFRValue = lambdaValue * engine->fuelComputer.stoichiometricRatio;
engine->outputChannels.afrGasolineScale = lambdaValue * STOICH_RATIO;
@ -417,6 +418,7 @@ static void updateLambda() {
engine->outputChannels.lambdaValue2 = lambda2Value;
engine->outputChannels.AFRValue2 = lambda2Value * engine->fuelComputer.stoichiometricRatio;
engine->outputChannels.afr2GasolineScale = lambda2Value * STOICH_RATIO;
#endif // EFI_ENGINE_CONTROL
}
static void updateFuelSensors() {
@ -538,16 +540,19 @@ static void updateFuelResults() {
static void updateFuelInfo() {
updateFuelCorrections();
updateFuelResults();
#if EFI_ENGINE_CONTROL
const auto& wallFuel = engine->injectionEvents.elements[0].getWallFuel();
engine->outputChannels.wallFuelAmount = wallFuel.getWallFuel() * 1000; // Convert grams to mg
engine->outputChannels.wallFuelCorrectionValue = wallFuel.wallFuelCorrection * 1000; // Convert grams to mg
engine->outputChannels.veValue = engine->engineState.currentVe;
#endif // EFI_ENGINE_CONTROL
}
static void updateIgnition(int rpm) {
#if EFI_ENGINE_CONTROL
engine->outputChannels.coilDutyCycle = getCoilDutyCycle(rpm);
#endif // EFI_ENGINE_CONTROL
}
static void updateFlags() {

View File

@ -570,11 +570,11 @@ TriggerCentral * getTriggerCentral() {
}
#endif // EFI_SHAFT_POSITION_INPUT
#if EFI_ENGINE_CONTROL
LimpManager * getLimpManager() {
return &engine->module<LimpManager>().unmock();
}
#if EFI_ENGINE_CONTROL
FuelSchedule *getFuelSchedule() {
return &engine->injectionEvents;
}

View File

@ -163,7 +163,9 @@ public:
#endif // EFI_VEHICLE_SPEED
KnockController,
SensorChecker,
#if EFI_ENGINE_CONTROL
LimpManager,
#endif // EFI_ENGINE_CONTROL
#if EFI_VVT_PID
VvtController1,
VvtController2,
@ -207,7 +209,9 @@ public:
SoftSparkLimiter ALSsoftSparkLimiter;
#endif /* EFI_ANTILAG_SYSTEM */
#if EFI_ENGINE_CONTROL
LambdaMonitor lambdaMonitor;
#endif // EFI_ENGINE_CONTROL
IgnitionState ignitionState;
void resetLua();

View File

@ -195,8 +195,8 @@ void EngineState::periodicFastCallback() {
#endif // EFI_SHAFT_POSITION_INPUT
}
void EngineState::updateTChargeK(int rpm, float tps) {
#if EFI_ENGINE_CONTROL
void EngineState::updateTChargeK(int rpm, float tps) {
float newTCharge = engine->fuelComputer.getTCharge(rpm, tps);
// convert to microsecs and then to seconds
efitick_t curTime = getTimeNowNt();
@ -207,8 +207,8 @@ void EngineState::updateTChargeK(int rpm, float tps) {
sd.tChargeK = convertCelsiusToKelvin(sd.tCharge);
timeSinceLastTChargeK = curTime;
}
#endif
}
#endif
#if EFI_SIMULATOR
#define VCS_VERSION "123"

View File

@ -33,7 +33,6 @@ const OutputPin *getOutputOnTheBenchTest() {
return outputOnTheBenchTest;
}
#if EFI_ENGINE_CONTROL
#if !EFI_UNIT_TEST
#include "flash_main.h"
@ -666,4 +665,3 @@ void initBenchTest() {
}
#endif /* EFI_UNIT_TEST */
#endif

View File

@ -4,6 +4,8 @@
#include "fuel_math.h"
#include "main_trigger_callback.h"
#if EFI_ENGINE_CONTROL
#define CLEANUP_MODE_TPS 90
static bool noFiringUntilVvtSync(vvt_mode_e vvtMode) {
@ -101,7 +103,6 @@ void LimpManager::updateState(int rpm, efitick_t nowNt) {
allowFuel.clear(ClearReason::LambdaProtection);
}
#if EFI_SHAFT_POSITION_INPUT
if (noFiringUntilVvtSync(engineConfiguration->vvtMode[0])
&& !engine->triggerCentral.triggerState.hasSynchronizedPhase()) {
// Any engine that requires cam-assistance for a full crank sync (symmetrical crank) can't schedule until we have cam sync
@ -111,7 +112,6 @@ void LimpManager::updateState(int rpm, efitick_t nowNt) {
allowFuel.clear(ClearReason::EnginePhase);
allowSpark.clear(ClearReason::EnginePhase);
}
#endif // EFI_SHAFT_POSITION_INPUT
// Force fuel limiting on the fault rev limit
if (rpm > m_faultRevLimit) {
@ -126,7 +126,7 @@ void LimpManager::updateState(int rpm, efitick_t nowNt) {
allowFuel.clear(ClearReason::BoostCut);
}
}
#if EFI_SHAFT_POSITION_INPUT
if (engine->rpmCalculator.isRunning()) {
uint16_t minOilPressure = engineConfiguration->minOilPressureAfterStart;
@ -188,8 +188,6 @@ todo AndreiKA this change breaks 22 unit tests?
*/
}
#endif // EFI_SHAFT_POSITION_INPUT
#if EFI_LAUNCH_CONTROL
// Fuel cut if launch control engaged
if (engine->launchController.isLaunchFuelRpmRetardCondition()) {
@ -278,3 +276,4 @@ float LimpManager::getLimitingFuelCorrection() const {
float LimpManager::getTimeSinceAnyCut() const {
return m_lastCutTime.getElapsedSeconds();
}
#endif // EFI_ENGINE_CONTROL

View File

@ -161,6 +161,8 @@ private:
Timer m_lastCutTime;
};
#if EFI_ENGINE_CONTROL
LimpManager * getLimpManager();
#endif // EFI_ENGINE_CONTROL

View File

@ -48,7 +48,6 @@ size_t computeStftBin(int rpm, float load, stft_s& cfg) {
}
static bool shouldCorrect() {
#if EFI_SHAFT_POSITION_INPUT
const auto& cfg = engineConfiguration->stft;
// User disable bit
@ -74,9 +73,6 @@ static bool shouldCorrect() {
// If all was well, then we're enabled!
return true;
#else
return false;
#endif // EFI_SHAFT_POSITION_INPUT
}
bool shouldUpdateCorrection(SensorType sensor) {

View File

@ -2,6 +2,8 @@
#include "lambda_monitor.h"
#if EFI_SHAFT_POSITION_INPUT
float LambdaMonitor::getMaxAllowedLambda(float rpm, float load) const {
return
engine->fuelComputer.targetLambda
@ -109,3 +111,4 @@ bool LambdaMonitorBase::restoreConditionsMet(float rpm, float load) const {
return true;
}
#endif // EFI_SHAFT_POSITION_INPUT

View File

@ -191,3 +191,4 @@ Usages:
java: LambdaMonitor.java
folder: controllers/math
constexpr: "___engine.lambdaMonitor"
conditional_compilation: "EFI_ENGINE_CONTROL"