refactoring launch

This commit is contained in:
Andrey 2021-11-15 14:40:35 -05:00
parent 16c459120d
commit 34015eceee
4 changed files with 13 additions and 10 deletions

View File

@ -17,9 +17,7 @@
static bool isInit = false;
static LaunchControlBase launchInstance;
static int retardThresholdRpm;
LaunchControlBase launchInstance;
/**
* We can have active condition from switch or from clutch.
@ -174,7 +172,7 @@ void setDefaultLaunchParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
}
void 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() )) {
*limitedSpark = engineConfiguration->launchSparkCutEnable;
*limitedFuel = engineConfiguration->launchFuelCutEnable;

View File

@ -12,7 +12,7 @@
void initLaunchControl(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void setDefaultLaunchParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE);
void applyLaunchControlLimiting(bool *limitedSpark, bool *limitedFuel DECLARE_ENGINE_PARAMETER_SUFFIX);
void updateLaunchConditions(DECLARE_ENGINE_PARAMETER_SIGNATURE);
class LaunchControlBase : public EnginePtr {
@ -25,6 +25,8 @@ public:
bool isInsideSwitchCondition() const;
bool isInsideRPMCondition(int rpm) const;
bool isLaunchConditionMet(int rpm) const;
int retardThresholdRpm;
void applyLaunchControlLimiting(bool *limitedSpark, bool *limitedFuel DECLARE_ENGINE_PARAMETER_SUFFIX);
private:
Timer m_launchTimer;

View File

@ -49,6 +49,8 @@
#include "backup_ram.h"
extern LaunchControlBase launchInstance;
// todo: figure out if this even helps?
//#if defined __GNUC__
//#define RAM_METHOD_PREFIX __attribute__((section(".ram")))
@ -416,7 +418,7 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp DECLARE
#if EFI_LAUNCH_CONTROL
if (engine->isLaunchCondition && !limitedSpark && !limitedFuel) {
/* in case we are not already on a limited conditions, check launch as well */
applyLaunchControlLimiting(&limitedSpark, &limitedFuel PASS_ENGINE_PARAMETER_SUFFIX);
launchInstance.applyLaunchControlLimiting(&limitedSpark, &limitedFuel PASS_ENGINE_PARAMETER_SUFFIX);
}
#endif
if (trgEventIndex == 0) {

View File

@ -130,6 +130,7 @@ TEST(LaunchControl, CompleteRun) {
bool spark, fuel;
WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
extern LaunchControlBase launchInstance;
initLaunchControl(PASS_ENGINE_PARAMETER_SIGNATURE);
//load default config
@ -154,7 +155,7 @@ TEST(LaunchControl, CompleteRun) {
//check if we have some sort of cut? we should not have at this point
spark = false;
fuel = false;
applyLaunchControlLimiting(&spark, &fuel PASS_ENGINE_PARAMETER_SUFFIX);
launchInstance.applyLaunchControlLimiting(&spark, &fuel PASS_ENGINE_PARAMETER_SUFFIX);
EXPECT_FALSE(spark);
EXPECT_FALSE(fuel);
@ -169,7 +170,7 @@ TEST(LaunchControl, CompleteRun) {
updateLaunchConditions(PASS_ENGINE_PARAMETER_SIGNATURE);
spark = false;
fuel = false;
applyLaunchControlLimiting(&spark, &fuel PASS_ENGINE_PARAMETER_SUFFIX);
launchInstance.applyLaunchControlLimiting(&spark, &fuel PASS_ENGINE_PARAMETER_SUFFIX);
EXPECT_FALSE(spark);
EXPECT_FALSE(fuel);
@ -178,7 +179,7 @@ TEST(LaunchControl, CompleteRun) {
updateLaunchConditions(PASS_ENGINE_PARAMETER_SIGNATURE);
spark = false;
fuel = false;
applyLaunchControlLimiting(&spark, &fuel PASS_ENGINE_PARAMETER_SUFFIX);
launchInstance.applyLaunchControlLimiting(&spark, &fuel PASS_ENGINE_PARAMETER_SUFFIX);
EXPECT_TRUE(spark);
EXPECT_FALSE(fuel);
@ -187,7 +188,7 @@ TEST(LaunchControl, CompleteRun) {
updateLaunchConditions(PASS_ENGINE_PARAMETER_SIGNATURE);
spark = false;
fuel = false;
applyLaunchControlLimiting(&spark, &fuel PASS_ENGINE_PARAMETER_SUFFIX);
launchInstance.applyLaunchControlLimiting(&spark, &fuel PASS_ENGINE_PARAMETER_SUFFIX);
EXPECT_FALSE(spark);
EXPECT_FALSE(fuel);