refactoring launch

This commit is contained in:
Andrey 2021-11-15 19:34:42 -05:00
parent f510cb8b29
commit c18204325c
3 changed files with 4 additions and 20 deletions

View File

@ -151,9 +151,6 @@ public:
#if EFI_LAUNCH_CONTROL #if EFI_LAUNCH_CONTROL
bool launchActivatePinState = false; bool launchActivatePinState = false;
bool isLaunchCondition = false; bool isLaunchCondition = false;
bool applyLaunchExtraFuel = false;
bool setLaunchBoostDuty = false;
bool applyLaunchControlRetard = false;
#endif /* EFI_LAUNCH_CONTROL */ #endif /* EFI_LAUNCH_CONTROL */
/** /**

View File

@ -101,7 +101,6 @@ void LaunchControlBase::update() {
int rpm = GET_RPM(); int rpm = GET_RPM();
bool combinedConditions = isLaunchConditionMet(rpm); bool combinedConditions = isLaunchConditionMet(rpm);
float timeDelay = CONFIG(launchActivateDelay);
//recalculate in periodic task, this way we save time in applyLaunchControlLimiting //recalculate in periodic task, this way we save time in applyLaunchControlLimiting
//and still recalculat in case user changed the values //and still recalculat in case user changed the values
@ -112,21 +111,9 @@ void LaunchControlBase::update() {
// conditions not met, reset timer // conditions not met, reset timer
m_launchTimer.reset(); m_launchTimer.reset();
engine->isLaunchCondition = false; engine->isLaunchCondition = false;
engine->setLaunchBoostDuty = false;
engine->applyLaunchControlRetard = false;
engine->applyLaunchExtraFuel = false;
} else { } else {
// If conditions are met... // If conditions are met...
if (m_launchTimer.hasElapsedMs(timeDelay*1000) && combinedConditions) { engine->isLaunchCondition = m_launchTimer.hasElapsedSec(CONFIG(launchActivateDelay));
engine->isLaunchCondition = true; // ...enable launch!
engine->applyLaunchExtraFuel = true;
}
if (CONFIG(enableLaunchBoost)) {
engine->setLaunchBoostDuty = true; // ...enable boost!
}
if (CONFIG(enableLaunchRetard)) {
engine->applyLaunchControlRetard = true; // ...enable retard!
}
} }
#if EFI_TUNER_STUDIO #if EFI_TUNER_STUDIO
@ -158,7 +145,7 @@ void setDefaultLaunchParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
} }
void LaunchControlBase::applyLaunchControlLimiting(bool *limitedSpark, bool *limitedFuel DECLARE_ENGINE_PARAMETER_SUFFIX) { void LaunchControlBase::applyLaunchControlLimiting(bool *limitedSpark, bool *limitedFuel DECLARE_ENGINE_PARAMETER_SUFFIX) {
if (( engine->isLaunchCondition ) && ( retardThresholdRpm < GET_RPM() )) { if (engine->isLaunchCondition && ( retardThresholdRpm < GET_RPM() )) {
*limitedSpark = engineConfiguration->launchSparkCutEnable; *limitedSpark = engineConfiguration->launchSparkCutEnable;
*limitedFuel = engineConfiguration->launchFuelCutEnable; *limitedFuel = engineConfiguration->launchFuelCutEnable;
} }

View File

@ -11,11 +11,11 @@ void Timer::reset(efitick_t nowNt) {
} }
bool Timer::hasElapsedSec(float seconds) const { bool Timer::hasElapsedSec(float seconds) const {
return hasElapsedMs(seconds * 1e3); return hasElapsedMs(seconds * 1000);
} }
bool Timer::hasElapsedMs(float milliseconds) const { bool Timer::hasElapsedMs(float milliseconds) const {
return hasElapsedUs(milliseconds * 1e3); return hasElapsedUs(milliseconds * 1000);
} }
bool Timer::hasElapsedUs(float microseconds) const { bool Timer::hasElapsedUs(float microseconds) const {