refactoring launch

This commit is contained in:
Andrey 2021-11-15 20:09:03 -05:00
parent 05fa6071dd
commit 928c673695
6 changed files with 16 additions and 25 deletions

View File

@ -649,7 +649,7 @@ static void updateFlags() {
tsOutputChannels.isCylinderCleanupActivated = engine->isCylinderCleanupMode;
#if EFI_LAUNCH_CONTROL
tsOutputChannels.launchTriggered = engine->isLaunchCondition;
tsOutputChannels.launchTriggered = engine->launchController.isLaunchCondition;
#endif
tsOutputChannels.clutchUpState = engine->clutchUpState;

View File

@ -61,7 +61,7 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME
}
#if EFI_LAUNCH_CONTROL
if (engine->isLaunchCondition && CONFIG(enableLaunchRetard)) {
if (engine->launchController.isLaunchCondition && CONFIG(enableLaunchRetard)) {
if (CONFIG(launchSmoothRetard)) {
float launchAngle = CONFIG(launchTimingRetard);
int launchAdvanceRpmRange = CONFIG(launchTimingRpmRange);

View File

@ -147,12 +147,6 @@ public:
bool needTdcCallback = true;
#endif /* EFI_UNIT_TEST */
#if EFI_LAUNCH_CONTROL
bool launchActivatePinState = false;
bool isLaunchCondition = false;
#endif /* EFI_LAUNCH_CONTROL */
/**
* By the way 32-bit value should hold at least 400 hours of events at 6K RPM x 12 events per revolution
*/
@ -162,11 +156,6 @@ public:
// GND input pins instead of leaving them floating
bool hwTriggerInputEnabled = true;
#if !EFI_PROD_CODE
float mockMapValue = 0;
#endif
int getGlobalConfigurationVersion(void) const;
/**
* true if a recent configuration change has changed any of the trigger settings which

View File

@ -19,14 +19,14 @@
* We can have active condition from switch or from clutch.
* In case we are dependent on VSS we just return true.
*/
bool LaunchControlBase::isInsideSwitchCondition() const {
bool LaunchControlBase::isInsideSwitchCondition() {
switch (CONFIG(launchActivationMode)) {
case SWITCH_INPUT_LAUNCH:
if (isBrainPinValid(CONFIG(launchActivatePin))) {
//todo: we should take into consideration if this sw is pulled high or low!
engine->launchActivatePinState = efiReadPin(CONFIG(launchActivatePin));
launchActivatePinState = efiReadPin(CONFIG(launchActivatePin));
}
return engine->launchActivatePinState;
return launchActivatePinState;
case CLUTCH_INPUT_LAUNCH:
if (isBrainPinValid(CONFIG(clutchDownPin))) {
@ -75,7 +75,7 @@ bool LaunchControlBase::isInsideRPMCondition(int rpm) const {
return (launchRpm < rpm);
}
bool LaunchControlBase::isLaunchConditionMet(int rpm) const {
bool LaunchControlBase::isLaunchConditionMet(int rpm) {
bool activateSwitchCondition = isInsideSwitchCondition();
bool rpmCondition = isInsideRPMCondition(rpm);
@ -109,17 +109,17 @@ void LaunchControlBase::update() {
if (!combinedConditions) {
// conditions not met, reset timer
m_launchTimer.reset();
engine->isLaunchCondition = false;
isLaunchCondition = false;
} else {
// If conditions are met...
engine->isLaunchCondition = m_launchTimer.hasElapsedSec(CONFIG(launchActivateDelay));
isLaunchCondition = m_launchTimer.hasElapsedSec(CONFIG(launchActivateDelay));
}
#if EFI_TUNER_STUDIO
if (CONFIG(debugMode) == DBG_LAUNCH) {
tsOutputChannels.debugIntField5 = engine->clutchDownState;
tsOutputChannels.debugFloatField1 = engine->launchActivatePinState;
tsOutputChannels.debugFloatField2 = engine->isLaunchCondition;
tsOutputChannels.debugFloatField1 = launchActivatePinState;
tsOutputChannels.debugFloatField2 = isLaunchCondition;
tsOutputChannels.debugFloatField3 = combinedConditions;
}
#endif /* EFI_TUNER_STUDIO */
@ -144,7 +144,7 @@ void setDefaultLaunchParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
}
bool LaunchControlBase::isLaunchRpmRetardCondition() const {
return engine->isLaunchCondition && (retardThresholdRpm < GET_RPM());
return isLaunchCondition && (retardThresholdRpm < GET_RPM());
}
bool LaunchControlBase::isLaunchSparkRpmRetardCondition() const {

View File

@ -20,14 +20,16 @@ public:
bool isInsideSpeedCondition() const;
bool isInsideTpsCondition() const;
bool isInsideSwitchCondition() const;
bool isInsideSwitchCondition();
bool isInsideRPMCondition(int rpm) const;
bool isLaunchConditionMet(int rpm) const;
bool isLaunchConditionMet(int rpm);
bool isLaunchSparkRpmRetardCondition() const;
bool isLaunchFuelRpmRetardCondition() const;
int retardThresholdRpm;
bool launchActivatePinState = false;
bool isLaunchCondition = false;
private:
bool isLaunchRpmRetardCondition() const;

View File

@ -414,7 +414,7 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp DECLARE
bool limitedFuel = !ENGINE(limpManager).allowInjection();
#if EFI_LAUNCH_CONTROL
if (engine->isLaunchCondition && !limitedSpark && !limitedFuel) {
if (engine->launchController.isLaunchCondition && !limitedSpark && !limitedFuel) {
/* in case we are not already on a limited conditions, check launch as well */
limitedSpark &= engine->launchController.isLaunchSparkRpmRetardCondition();