auto-sync

This commit is contained in:
rusEfi 2016-11-28 14:01:52 -05:00
parent f9fe1ff8a4
commit c5a51fe752
3 changed files with 31 additions and 22 deletions

View File

@ -43,6 +43,7 @@ IgnitionEvent::IgnitionEvent() {
memset(outputs, 0, sizeof(outputs)); memset(outputs, 0, sizeof(outputs));
advance = NAN; advance = NAN;
sparkId = 0; sparkId = 0;
cylinderIndex = 0;
} }
IgnitionOutputPin * IgnitionEvent::getOutputForLoggins() { IgnitionOutputPin * IgnitionEvent::getOutputForLoggins() {

View File

@ -56,7 +56,11 @@ public:
event_trigger_position_s dwellPosition; event_trigger_position_s dwellPosition;
event_trigger_position_s sparkPosition; event_trigger_position_s sparkPosition;
IgnitionEvent *next; IgnitionEvent *next;
/**
* @see globalSparkIdCoutner
*/
int sparkId; int sparkId;
int cylinderIndex;
char *name; char *name;
IgnitionOutputPin *getOutputForLoggins(); IgnitionOutputPin *getOutputForLoggins();
}; };

View File

@ -222,16 +222,12 @@ static void addIgnitionEvent(int cylinderIndex, angle_t localAdvance, angle_t dw
} }
static void initializeIgnitionActions(angle_t advance, angle_t dwellAngle, static void prepareIgnitionSchedule(int cylinderIndex, IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) {
IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) {
efiAssertVoid(engineConfiguration->specs.cylindersCount > 0, "cylindersCount");
for (int i = 0; i < CONFIG(specs.cylindersCount); i++) {
// todo: clean up this implementation? does not look too nice as is. // todo: clean up this implementation? does not look too nice as is.
// change of sign here from 'before TDC' to 'after TDC' // change of sign here from 'before TDC' to 'after TDC'
angle_t localAdvance = -advance + ENGINE(angleExtra[i]); angle_t localAdvance = -ENGINE(engineState.timingAdvance) + ENGINE(angleExtra[cylinderIndex]);
const int index = ENGINE(ignitionPin[i]); const int index = ENGINE(ignitionPin[cylinderIndex]);
const int coilIndex = ID2INDEX(getCylinderId(CONFIG(specs.firingOrder), index)); const int coilIndex = ID2INDEX(getCylinderId(CONFIG(specs.firingOrder), index));
IgnitionOutputPin *output = &enginePins.coils[coilIndex]; IgnitionOutputPin *output = &enginePins.coils[coilIndex];
@ -244,7 +240,15 @@ static void initializeIgnitionActions(angle_t advance, angle_t dwellAngle,
secondOutput = NULL; secondOutput = NULL;
} }
addIgnitionEvent(i, localAdvance, dwellAngle, list, output, secondOutput PASS_ENGINE_PARAMETER); addIgnitionEvent(cylinderIndex, localAdvance, ENGINE(engineState.dwellAngle), list, output, secondOutput PASS_ENGINE_PARAMETER);
}
static void initializeIgnitionActions(IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) {
efiAssertVoid(engineConfiguration->specs.cylindersCount > 0, "cylindersCount");
for (int cylinderIndex = 0; cylinderIndex < CONFIG(specs.cylindersCount); cylinderIndex++) {
list->elements[cylinderIndex].cylinderIndex = cylinderIndex;
prepareIgnitionSchedule(cylinderIndex, list PASS_ENGINE_PARAMETER);
} }
list->isReady = true; list->isReady = true;
} }
@ -282,7 +286,7 @@ static ALWAYS_INLINE void prepareIgnitionSchedule(int rpm, int revolutionIndex D
list->isReady = false; list->isReady = false;
return; return;
} }
initializeIgnitionActions(ENGINE(engineState.timingAdvance), ENGINE(engineState.dwellAngle), list PASS_ENGINE_PARAMETER); initializeIgnitionActions(list PASS_ENGINE_PARAMETER);
engine->m.ignitionSchTime = GET_TIMESTAMP() - engine->m.beforeIgnitionSch; engine->m.ignitionSchTime = GET_TIMESTAMP() - engine->m.beforeIgnitionSch;
} }