auto-sync

This commit is contained in:
rusEfi 2015-04-28 22:04:41 -04:00
parent 9176d0be3e
commit ce30439d68
2 changed files with 9 additions and 6 deletions

View File

@ -179,20 +179,23 @@ static void mapAveragingCallback(trigger_event_e ckpEventType, uint32_t index DE
perRevolution = perRevolutionCounter; perRevolution = perRevolutionCounter;
perRevolutionCounter = 0; perRevolutionCounter = 0;
MAP_sensor_config_s * config = &engineConfiguration->map;
angle_t currentAngle = TRIGGER_SHAPE(eventAngles[index]); angle_t currentAngle = TRIGGER_SHAPE(eventAngles[index]);
angle_t samplingStart = interpolate2d(rpm, config->samplingAngleBins, config->samplingAngle, MAP_ANGLE_SIZE) - currentAngle; angle_t samplingStart = engine->engineState.mapAveragingStart - currentAngle;
angle_t samplingDuration = interpolate2d(rpm, config->samplingWindowBins, config->samplingWindow, MAP_WINDOW_SIZE); fixAngle(samplingStart);
angle_t samplingDuration = engine->engineState.mapAveragingDuration;
if (samplingDuration <= 0) { if (samplingDuration <= 0) {
firmwareError("map sampling angle should be positive"); firmwareError("map sampling angle should be positive");
return; return;
} }
fixAngle(samplingStart);
angle_t samplingEnd = samplingStart + samplingDuration; angle_t samplingEnd = samplingStart + samplingDuration;
fixAngle(samplingEnd); fixAngle(samplingEnd);
if (cisnan(samplingEnd)) {
// value is not yet prepared
return;
}
int structIndex = getRevolutionCounter() % 2; int structIndex = getRevolutionCounter() % 2;
// todo: schedule this based on closest trigger event, same as ignition works // todo: schedule this based on closest trigger event, same as ignition works

View File

@ -111,7 +111,7 @@ void rusEfiFunctionalTest(void) {
} }
#endif #endif
initPeriodicEvents(engine); initPeriodicEvents(PASS_ENGINE_PARAMETER_F);
} }
void printPendingMessages(void) { void printPendingMessages(void) {