From 558b03ea69433f35c1e9da33b6860e475839c78f Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sun, 12 Apr 2015 10:10:37 -0500 Subject: [PATCH] auto-sync --- firmware/controllers/algo/engine.h | 4 ++++ firmware/controllers/math/engine_math.cpp | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 0335e66c1b..82a3b3a754 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -41,6 +41,10 @@ public: * TODO: better data structure? better algorithm? */ uint8_t hasEvents[PWM_PHASE_MAX_COUNT]; + /** + * How many trigger events have injection? This depends on fuel strategy & trigger shape + */ + int eventsCount; private: void clear(); void registerInjectionEvent(OutputSignalList *sourceList, NamedOutputPin *output, float angle, bool_t isSimultanious DECLARE_ENGINE_PARAMETER_S); diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index 27fb983d48..1e9fb769fb 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -133,7 +133,10 @@ void FuelSchedule::registerInjectionEvent(OutputSignalList *sourceList, NamedOut ev->actuator = actuator; findTriggerPosition(&ev->position, angle PASS_ENGINE_PARAMETER); - hasEvents[ev->position.eventIndex] = true; + if(!hasEvents[ev->position.eventIndex]) { + hasEvents[ev->position.eventIndex] = true; + eventsCount++; + } } FuelSchedule::FuelSchedule() { @@ -141,6 +144,7 @@ FuelSchedule::FuelSchedule() { void FuelSchedule::clear() { memset(hasEvents, 0, sizeof(hasEvents)); + eventsCount = 0; } void FuelSchedule::addFuelEvents(OutputSignalList *sourceList, injection_mode_e mode DECLARE_ENGINE_PARAMETER_S) {