auto-sync
This commit is contained in:
parent
5a4e277f9e
commit
01cbb67f10
|
@ -83,24 +83,43 @@ void Engine::watchdog() {
|
|||
}
|
||||
|
||||
StartupFuelPumping::StartupFuelPumping() {
|
||||
|
||||
isTpsAbove50 = false;
|
||||
pumpsCounter = 0;
|
||||
}
|
||||
|
||||
void StartupFuelPumping::setPumpsCounter(int newValue) {
|
||||
void StartupFuelPumping::setPumpsCounter(engine_configuration_s *engineConfiguration, int newValue) {
|
||||
if (pumpsCounter != newValue) {
|
||||
pumpsCounter = newValue;
|
||||
|
||||
if(pumpsCounter==PUMPS_TO_PRIME) {
|
||||
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||
scheduleMsg(&logger, "let's squirt prime pulse %f", pumpsCounter);
|
||||
#endif
|
||||
pumpsCounter = 0;
|
||||
} else {
|
||||
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||
scheduleMsg(&logger, "setPumpsCounter %d", pumpsCounter);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StartupFuelPumping::update(Engine *engine) {
|
||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||
if (engine->rpmCalculator->rpm() == 0) {
|
||||
bool isAbove50 = getTPS(engine->engineConfiguration) >= 50;
|
||||
bool isTpsAbove50 = getTPS(engineConfiguration) >= 50;
|
||||
|
||||
if (this->isTpsAbove50 != isTpsAbove50) {
|
||||
setPumpsCounter(engineConfiguration, pumpsCounter + 1);
|
||||
}
|
||||
|
||||
} else {
|
||||
/**
|
||||
* Engine is not stopped - not priming pumping mode
|
||||
*/
|
||||
setPumpsCounter(0);
|
||||
setPumpsCounter(engineConfiguration, 0);
|
||||
isTpsAbove50 = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@ private:
|
|||
bool stopPins();
|
||||
};
|
||||
|
||||
#define PUMPS_TO_PRIME 3
|
||||
|
||||
class StartupFuelPumping {
|
||||
public:
|
||||
StartupFuelPumping();
|
||||
|
@ -55,7 +57,7 @@ public:
|
|||
bool isTpsAbove50;
|
||||
int pumpsCounter;
|
||||
private:
|
||||
void setPumpsCounter(int newValue);
|
||||
void setPumpsCounter(engine_configuration_s *engineConfiguration, int newValue);
|
||||
};
|
||||
|
||||
#endif /* ENGINE_H_ */
|
||||
|
|
|
@ -256,6 +256,8 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_
|
|||
|
||||
engineConfiguration->engineCycle = 720;
|
||||
|
||||
engineConfiguration->primingSquirtDurationMs = 5;
|
||||
|
||||
engineConfiguration->isInjectionEnabled = true;
|
||||
engineConfiguration->isIgnitionEnabled = true;
|
||||
engineConfiguration->isCylinderCleanupEnabled = true;
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "can_header.h"
|
||||
#include "rusefi_enums.h"
|
||||
|
||||
#define MOCK_UNDEFINED -1
|
||||
|
||||
typedef struct {
|
||||
float coolantTempMinC;
|
||||
float coolantTempMaxC;
|
||||
|
@ -463,7 +465,9 @@ typedef struct {
|
|||
short int tpsErrorLowValue;
|
||||
short int tpsErrorHighValue;
|
||||
|
||||
int unused3[24];
|
||||
float primingSquirtDurationMs;
|
||||
|
||||
int unused3[23];
|
||||
|
||||
} engine_configuration_s;
|
||||
|
||||
|
|
|
@ -4,9 +4,14 @@
|
|||
#include "engine_configuration.h"
|
||||
#include "interpolation.h"
|
||||
#include "adc_inputs.h"
|
||||
#include "allsensors.h"
|
||||
|
||||
extern engine_configuration_s *engineConfiguration;
|
||||
|
||||
#if !EFI_PROD_CODE
|
||||
int mockTps;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* We are using one instance for read and another for modification, this is how we get lock-free thread-safety
|
||||
*
|
||||
|
@ -48,12 +53,12 @@ float getTpsRateOfChange(void) {
|
|||
*
|
||||
* */
|
||||
static float getTpsValue(engine_configuration_s *engineConfiguration, int adc) {
|
||||
if (adc < engineConfiguration->tpsMin) {
|
||||
if (adc < engineConfiguration->tpsMin) {
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
if (adc > engineConfiguration->tpsMax) {
|
||||
return 100.0f;
|
||||
}
|
||||
}
|
||||
// todo: double comparison using EPS
|
||||
if (engineConfiguration->tpsMin == engineConfiguration->tpsMax) {
|
||||
firmwareError("Invalid TPS configuration: same value");
|
||||
|
@ -75,6 +80,10 @@ float getTPSVoltage(void) {
|
|||
* wants a TPS value.
|
||||
*/
|
||||
int getTPS10bitAdc(void) {
|
||||
#if !EFI_PROD_CODE
|
||||
if (mockTps != MOCK_UNDEFINED)
|
||||
return mockTps;
|
||||
#endif
|
||||
int adc = getAdcValue(engineConfiguration->tpsAdcChannel);
|
||||
return (int) adc / 4; // Only for TunerStudio compatibility. Max TS adc value in 1023
|
||||
}
|
||||
|
@ -106,5 +115,5 @@ float getTPS(engine_configuration_s *engineConfiguration) {
|
|||
|
||||
int convertVoltageTo10bitADC(float voltage) {
|
||||
// divided by 2 because of voltage divider, then converted into 10bit ADC value (TunerStudio format)
|
||||
return (int)(voltage / 2 * 1024 / 3.3);
|
||||
return (int) (voltage / 2 * 1024 / 3.3);
|
||||
}
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
#ifdef __cplusplus
|
||||
#include "engine.h"
|
||||
|
||||
#define MOCK_UNDEFINED -1
|
||||
|
||||
class RpmCalculator {
|
||||
public:
|
||||
#if !EFI_PROD_CODE
|
||||
|
|
|
@ -342,6 +342,8 @@ extern EventQueue schedulingQueue;
|
|||
// this is a very dirty and sad hack. todo: eliminate
|
||||
extern Engine engine;
|
||||
|
||||
extern int mockTps;
|
||||
|
||||
static void testStartupFuelPumping(void) {
|
||||
EngineTestHelper eth(FORD_INLINE_6_1995);
|
||||
|
||||
|
@ -354,10 +356,35 @@ static void testStartupFuelPumping(void) {
|
|||
engine->rpmCalculator->mockRpm = 0;
|
||||
|
||||
engine->engineConfiguration->tpsMin = 0;
|
||||
engine->engineConfiguration->tpsMin = 5;
|
||||
engine->engineConfiguration->tpsMax = 10;
|
||||
|
||||
mockTps = 6;
|
||||
sf.update(engine);
|
||||
assertEqualsM("pc#1", 1, sf.pumpsCounter);
|
||||
|
||||
mockTps = 3;
|
||||
sf.update(engine);
|
||||
assertEqualsM("pc#2", 1, sf.pumpsCounter);
|
||||
|
||||
sf.update(engine);
|
||||
assertEqualsM("pc#3", 1, sf.pumpsCounter);
|
||||
|
||||
engine->rpmCalculator->mockRpm = 10;
|
||||
sf.update(engine);
|
||||
assertEqualsM("pc#4", 0, sf.pumpsCounter);
|
||||
|
||||
mockTps = 7;
|
||||
engine->rpmCalculator->mockRpm = 0;
|
||||
sf.update(engine);
|
||||
assertEqualsM("pc#5", 1, sf.pumpsCounter);
|
||||
|
||||
mockTps = 3;
|
||||
sf.update(engine);
|
||||
assertEqualsM("pc#6", 1, sf.pumpsCounter);
|
||||
|
||||
mockTps = 7;
|
||||
sf.update(engine);
|
||||
assertEqualsM("pc#7", 2, sf.pumpsCounter);
|
||||
}
|
||||
|
||||
static void testRpmCalculator(void) {
|
||||
|
|
Loading…
Reference in New Issue