From 78a3a6f2722c2a163b804e765bbdb6844fc94326 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Thu, 5 Feb 2015 09:04:08 -0600 Subject: [PATCH] auto-sync --- firmware/controllers/trigger/trigger_chrysler.cpp | 4 ++-- firmware/controllers/trigger/trigger_decoder.cpp | 5 +---- firmware/controllers/trigger/trigger_mazda.cpp | 4 ++-- .../controllers/trigger/trigger_mitsubishi.cpp | 2 +- firmware/controllers/trigger/trigger_structure.cpp | 14 ++++++++------ firmware/controllers/trigger/trigger_structure.h | 2 ++ firmware/rusefi.cpp | 2 +- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/firmware/controllers/trigger/trigger_chrysler.cpp b/firmware/controllers/trigger/trigger_chrysler.cpp index 464a1a1654..a915231179 100644 --- a/firmware/controllers/trigger/trigger_chrysler.cpp +++ b/firmware/controllers/trigger/trigger_chrysler.cpp @@ -18,7 +18,7 @@ void configureNeon2003TriggerShape(TriggerShape *s) { s->gapBothDirections = true; // are these non-default values really needed here now that the gap is finally precise? - setTriggerSynchronizationGap2(s, 0.8 * CHRYSLER_NGC_GAP, 1.55 * CHRYSLER_NGC_GAP); + s->setTriggerSynchronizationGap2(0.8 * CHRYSLER_NGC_GAP, 1.55 * CHRYSLER_NGC_GAP); s->addEvent(base + 26, T_PRIMARY, TV_HIGH); s->addEvent(base + 62, T_PRIMARY, TV_LOW); @@ -45,7 +45,7 @@ void configureNeon2003TriggerShape(TriggerShape *s) { void configureNeon1995TriggerShape(TriggerShape *s) { s->reset(FOUR_STROKE_CAM_SENSOR, true); - setTriggerSynchronizationGap(s, 0.72); + s->setTriggerSynchronizationGap(0.72); s->useRiseEdge = false; diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index aa5ba7c4d2..be2bcecd6b 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -279,9 +279,6 @@ void initializeTriggerShape(Logging *logger, engine_configuration_s const *engin triggerShape->clear(); - setTriggerSynchronizationGap(triggerShape, 2); - triggerShape->useRiseEdge = true; - switch (triggerConfig->type) { case TT_TOOTHED_WHEEL: @@ -335,7 +332,7 @@ void initializeTriggerShape(Logging *logger, engine_configuration_s const *engin case TT_TOOTHED_WHEEL_60_2: setToothedWheelConfiguration(triggerShape, 60, 2, engineConfiguration); - setTriggerSynchronizationGap(triggerShape, 3); + triggerShape->setTriggerSynchronizationGap(3); break; case TT_TOOTHED_WHEEL_36_1: diff --git a/firmware/controllers/trigger/trigger_mazda.cpp b/firmware/controllers/trigger/trigger_mazda.cpp index 68c1a497ce..8b420e5c4c 100644 --- a/firmware/controllers/trigger/trigger_mazda.cpp +++ b/firmware/controllers/trigger/trigger_mazda.cpp @@ -22,7 +22,7 @@ void initializeMazdaMiataNaShape(TriggerShape *s) { s->reset(FOUR_STROKE_CAM_SENSOR, true); - setTriggerSynchronizationGap(s, MIATA_NA_GAP); + s->setTriggerSynchronizationGap(MIATA_NA_GAP); s->useRiseEdge = false; s->isSynchronizationNeeded = true; @@ -48,7 +48,7 @@ void initializeMazdaMiataNaShape(TriggerShape *s) { } void initializeMazdaMiataNbShape(TriggerShape *s) { - setTriggerSynchronizationGap(s, 0.11f); + s->setTriggerSynchronizationGap(0.11f); s->useRiseEdge = false; s->reset(FOUR_STROKE_CAM_SENSOR, true); diff --git a/firmware/controllers/trigger/trigger_mitsubishi.cpp b/firmware/controllers/trigger/trigger_mitsubishi.cpp index 93a7285ed5..d4b00204b3 100644 --- a/firmware/controllers/trigger/trigger_mitsubishi.cpp +++ b/firmware/controllers/trigger/trigger_mitsubishi.cpp @@ -32,7 +32,7 @@ void initializeMitsubishi4g18(TriggerShape *s) { s->reset(FOUR_STROKE_CAM_SENSOR, true); s->useRiseEdge = false; - setTriggerSynchronizationGap(s, 1.6666); + s->setTriggerSynchronizationGap(1.6666); int secondaryWidth = 70; diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index a6a617e2c7..ea43352b87 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -77,6 +77,8 @@ void TriggerShape::setTriggerShapeSynchPointIndex(engine_configuration_s *engine void TriggerShape::clear() { tdcPosition = 0; + setTriggerSynchronizationGap(2); + useRiseEdge = true; } void TriggerShape::reset(operation_mode_e operationMode, bool needSecondTriggerInput) { @@ -288,14 +290,14 @@ void setToothedWheelConfiguration(TriggerShape *s, int total, int skipped, #endif } -void setTriggerSynchronizationGap2(TriggerShape *s, float syncGapFrom, float syncRatioTo) { - s->isSynchronizationNeeded = true; - s->syncRatioFrom = syncGapFrom; - s->syncRatioTo = syncRatioTo; +void TriggerShape::setTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo) { + isSynchronizationNeeded = true; + this->syncRatioFrom = syncRatioFrom; + this->syncRatioTo = syncRatioTo; } -void setTriggerSynchronizationGap(TriggerShape *s, float synchGap) { - setTriggerSynchronizationGap2(s, synchGap * 0.75f, synchGap * 1.25f); +void TriggerShape::setTriggerSynchronizationGap(float synchRatio) { + setTriggerSynchronizationGap2(synchRatio * 0.75f, synchRatio * 1.25f); } #define S24 (720.0f / 24 / 2) diff --git a/firmware/controllers/trigger/trigger_structure.h b/firmware/controllers/trigger/trigger_structure.h index 8abe40481a..4099b551f5 100644 --- a/firmware/controllers/trigger/trigger_structure.h +++ b/firmware/controllers/trigger/trigger_structure.h @@ -73,6 +73,8 @@ public: // todo: these two methods here, something could be improved void clear(); void reset(operation_mode_e operationMode, bool needSecondTriggerInput); + void setTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo); + void setTriggerSynchronizationGap(float synchRatio); int getSize() const; multi_wave_s wave; diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 9aad2f8b9f..73f8f525b9 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -259,5 +259,5 @@ int getRusEfiVersion(void) { return 1; // this is here to make the compiler happy about the unused array if (UNUSED_CCM_SIZE == 0) return 1; // this is here to make the compiler happy about the unused array - return 20150204; + return 20150205; }