antilag and anti-lag #2403

TurboMarian is the ALS boss
This commit is contained in:
rusefillc 2022-12-21 20:12:00 -05:00
parent 318aa6d8c9
commit 6146b01a36
7 changed files with 22 additions and 17 deletions

View File

@ -19,7 +19,9 @@ bool AntilagSystemBase::isInsideALSSwitchCondition() {
if (isALSSwitchActivated) {
if (isBrainPinValid(engineConfiguration->ALSActivatePin)) {
#if EFI_PROD_CODE
ALSActivatePinState = engineConfiguration->ALSActivateInverted ^ efiReadPin(engineConfiguration->ALSActivatePin);
#endif
}
return ALSActivatePinState;
} else {

View File

@ -24,19 +24,3 @@ public:
bool isAntilagConditionMet();
bool isInsideALSSwitchCondition();
};
/**
* See also SoftLimiterSandbox.java
*/
class ALSSoftSparkLimiter {
public:
/**
* targetSkipRatio of '0' means 'do not skip', would always return false
*/
void setTargetSkipRatio(float ALSSkipRatio);
bool shouldSkip();
private:
bool wasJustSkipped = false;
float ALSSkipRatio = 0;
};

View File

@ -166,9 +166,12 @@ public:
#if EFI_ANTILAG_SYSTEM
AntilagSystemBase antilagController;
SoftSparkLimiter ALSsoftSparkLimiter;
#endif // EFI_ANTILAG_SYSTEM
#if EFI_ANTILAG_SYSTEM
SoftSparkLimiter ALSsoftSparkLimiter;
#endif /* EFI_ANTILAG_SYSTEM */
#if EFI_BOOST_CONTROL
BoostController boostController;
#endif // EFI_BOOST_CONTROL

View File

@ -192,6 +192,10 @@ void EngineState::periodicFastCallback() {
#if EFI_LAUNCH_CONTROL
engine->launchController.update();
#endif //EFI_LAUNCH_CONTROL
#if EFI_ANTILAG_SYSTEM
engine->antilagController.update();
#endif //EFI_ANTILAG_SYSTEM
#endif // EFI_ENGINE_CONTROL
}

View File

@ -498,6 +498,14 @@ void onTriggerEventSparkLogic(int rpm, efitick_t edgeTimestamp, float currentPha
}
#endif // EFI_LAUNCH_CONTROL
#if EFI_ANTILAG_SYSTEM
if (engine->ALSsoftSparkLimiter.shouldSkip()) {
continue;
}
auto ALSSkipRatio = engineConfiguration->ALSSkipRatio;
engine->ALSsoftSparkLimiter.setTargetSkipRatio(ALSSkipRatio);
#endif // EFI_ANTILAG_SYSTEM
scheduleSparkEvent(limitedSpark, event, rpm, edgeTimestamp, currentPhase, nextPhase);
}
}

View File

@ -16,6 +16,8 @@
#define EFI_TCU FALSE
#define EFI_ANTILAG_SYSTEM TRUE
#define ENABLE_PERF_TRACE FALSE
#define EFI_PRINTF_FUEL_DETAILS FALSE

View File

@ -9,6 +9,8 @@
#define EFI_ENABLE_ASSERTS TRUE
#define EFI_ANTILAG_SYSTEM TRUE
#define EFI_TUNER_STUDIO TRUE
#define EFI_EMULATE_POSITION_SENSORS TRUE