auto-sync

This commit is contained in:
rusEfi 2016-03-15 22:03:43 -04:00
parent 0c8d522415
commit bc5e8048a8
3 changed files with 20 additions and 6 deletions

View File

@ -48,7 +48,7 @@ RpmCalculator::RpmCalculator() {
mockRpm = MOCK_UNDEFINED;
#endif
rpmValue = 0;
setRpmValue(0);
assignRpmValue(0);
// we need this initial to have not_running at first invocation
lastRpmEventTimeNt = (efitime_t) -10 * US2NT(US_PER_SECOND_LL);
@ -82,7 +82,9 @@ bool RpmCalculator::isRunning(DECLARE_ENGINE_PARAMETER_F) {
return result;
}
void RpmCalculator::setRpmValue(int value) {
// private method
void RpmCalculator::assignRpmValue(int value) {
previousRpmValue = rpmValue;
rpmValue = value;
if (rpmValue <= 0) {
@ -92,6 +94,17 @@ void RpmCalculator::setRpmValue(int value) {
}
}
void RpmCalculator::setRpmValue(int value DECLARE_ENGINE_PARAMETER_S) {
assignRpmValue(value);
if (previousRpmValue == 0 && rpmValue > 0) {
/**
* this would make sure that we have good numbers for first cranking revolution
* #275 cranking could be improved
*/
engine->periodicFastCallback(PASS_ENGINE_PARAMETER_F);
}
}
void RpmCalculator::onNewEngineCycle() {
revolutionCounterSinceBoot++;
revolutionCounterSinceStart++;
@ -194,11 +207,11 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType,
*
*/
if (diffNt == 0) {
rpmState->setRpmValue(NOISY_RPM);
rpmState->setRpmValue(NOISY_RPM PASS_ENGINE_PARAMETER);
} else {
int mult = getEngineCycle(engineConfiguration->operationMode) / 360;
int rpm = (int) (60 * US2NT(US_PER_SECOND_LL) * mult / diffNt);
rpmState->setRpmValue(rpm > UNREALISTIC_RPM ? NOISY_RPM : rpm);
rpmState->setRpmValue(rpm > UNREALISTIC_RPM ? NOISY_RPM : rpm PASS_ENGINE_PARAMETER);
}
}
rpmState->onNewEngineCycle();

View File

@ -47,7 +47,7 @@ public:
*/
void onNewEngineCycle();
uint32_t getRevolutionCounter(void);
void setRpmValue(int value);
void setRpmValue(int value DECLARE_ENGINE_PARAMETER_S);
uint32_t getRevolutionCounterSinceStart(void);
float getRpmAcceleration();
/**
@ -62,6 +62,7 @@ public:
volatile floatus_t oneDegreeUs;
volatile efitime_t lastRpmEventTimeNt;
private:
void assignRpmValue(int value);
/**
* This counter is incremented with each revolution of one of the shafts. Could be
* crankshaft could be camshaft.

View File

@ -18,7 +18,7 @@ void testAccelEnrichment(void) {
EngineTestHelper eth(FORD_ASPIRE_1996);
EXPAND_EngineTestHelper;
engine->rpmCalculator.setRpmValue(600);
engine->rpmCalculator.setRpmValue(600 PASS_ENGINE_PARAMETER);
engine->periodicFastCallback(PASS_ENGINE_PARAMETER_F);
assertEqualsM("eventsCount", 4, engine->engineConfiguration2->injectionEvents->eventsCount);