From 72621800fc97873b48589a9b8e19d231186ee420 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Mon, 3 Nov 2014 13:03:05 -0600 Subject: [PATCH] auto-sync --- firmware/controllers/trigger/trigger_chrysler.cpp | 6 ++---- firmware/controllers/trigger/trigger_structure.cpp | 12 +++++++++++- firmware/controllers/trigger/trigger_structure.h | 4 +++- firmware/iar/ch.ewp | 2 +- unit_tests/test_trigger_decoder.cpp | 2 +- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/firmware/controllers/trigger/trigger_chrysler.cpp b/firmware/controllers/trigger/trigger_chrysler.cpp index 0d92a6d390..1ed7d8dbd0 100644 --- a/firmware/controllers/trigger/trigger_chrysler.cpp +++ b/firmware/controllers/trigger/trigger_chrysler.cpp @@ -13,13 +13,11 @@ void configureNeon2003TriggerShape(trigger_shape_s *s) { // voodoo magic - we always need 720 at the end int base = 10; s->useRiseEdge = true; + s->invertOnAdd = true; s->gapBothDirections = true; - /** - * Theoretical gap is 4, but in reality it's - */ - setTriggerSynchronizationGap2(s, 2.7, 5); + setTriggerSynchronizationGap(s, 2.91); s->addEvent(base + 26, T_PRIMARY, TV_HIGH); s->addEvent(base + 62, T_PRIMARY, TV_LOW); diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index fa89e0d383..3da1856834 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -35,6 +35,8 @@ trigger_shape_s::trigger_shape_s() : wave.waves = h.waves; useRiseEdge = false; gapBothDirections = false; + isSynchronizationNeeded = false; + invertOnAdd = false; } void trigger_shape_s::assignSize() { @@ -194,8 +196,16 @@ float trigger_shape_s::getAngle(int index) const { } } -void trigger_shape_s::addEvent(float angle, trigger_wheel_e const waveIndex, trigger_value_e const state) { +void trigger_shape_s::addEvent(float angle, trigger_wheel_e const waveIndex, trigger_value_e const stateParam) { efiAssertVoid(operationMode != OM_NONE, "operationMode not set"); + + trigger_value_e state; + if (invertOnAdd) { + state = (stateParam == TV_LOW) ? TV_HIGH : TV_LOW; + } else { + state = stateParam; + } + /** * While '720' value works perfectly it has not much sense for crank sensor-only scenario. * todo: accept angle as a value in the 0..1 range? diff --git a/firmware/controllers/trigger/trigger_structure.h b/firmware/controllers/trigger/trigger_structure.h index d2b16db80c..ce22908961 100644 --- a/firmware/controllers/trigger/trigger_structure.h +++ b/firmware/controllers/trigger/trigger_structure.h @@ -29,7 +29,9 @@ public: class trigger_shape_s { public: trigger_shape_s(); - int isSynchronizationNeeded; + bool_t isSynchronizationNeeded; + + bool_t invertOnAdd; int totalToothCount; int skippedToothCount; diff --git a/firmware/iar/ch.ewp b/firmware/iar/ch.ewp index 45ea850201..a3ab47ac98 100644 --- a/firmware/iar/ch.ewp +++ b/firmware/iar/ch.ewp @@ -2546,7 +2546,7 @@ - $PROJ_DIR$\..\emulation\analog_chart.c + $PROJ_DIR$\..\emulation\analog_chart.cpp $PROJ_DIR$\..\emulation\analog_chart.h diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index 90933eb712..aa3d1f97f0 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -531,7 +531,7 @@ void testTriggerDecoder(void) { testTriggerDecoder2("citroen", CITROEN_TU3JP, 0, 0.4833, 0.0); printGapRatio = true; - testTriggerDecoder2("neon NGC", DODGE_NEON_2003, 12, 0.5139, 0.0); + testTriggerDecoder2("neon NGC", DODGE_NEON_2003, 5, 0.4861, 0.0); printGapRatio = false; testMazda323();