From 9ec3d46b8ffe5e03ac6c0a711d9efb8b31f0f75f Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sat, 2 May 2015 14:10:17 -0400 Subject: [PATCH] auto-sync --- firmware/config/engines/dodge_ram.cpp | 2 ++ firmware/controllers/trigger/trigger_chrysler.cpp | 10 ++++++++-- firmware/controllers/trigger/trigger_decoder.cpp | 15 +++++++++------ firmware/controllers/trigger/trigger_decoder.h | 5 +++++ .../models/src/com/rusefi/config/Field.java | 9 +++++++++ java_console/ui/src/com/rusefi/Launcher.java | 2 +- .../src/com/rusefi/ui/config/EnumConfigField.java | 2 ++ unit_tests/test_trigger_decoder.cpp | 2 +- 8 files changed, 37 insertions(+), 10 deletions(-) diff --git a/firmware/config/engines/dodge_ram.cpp b/firmware/config/engines/dodge_ram.cpp index c398d5aada..db7fe13913 100644 --- a/firmware/config/engines/dodge_ram.cpp +++ b/firmware/config/engines/dodge_ram.cpp @@ -25,4 +25,6 @@ void setDodgeRam1996(DECLARE_ENGINE_PARAMETER_F) { boardConfiguration->triggerInputPins[0] = GPIOC_6; boardConfiguration->triggerInputPins[1] = GPIOA_8; + + engineConfiguration->vbattAdcChannel = EFI_ADC_NONE; // todo: conflict with what? } diff --git a/firmware/controllers/trigger/trigger_chrysler.cpp b/firmware/controllers/trigger/trigger_chrysler.cpp index acefb46017..80a0fc1663 100644 --- a/firmware/controllers/trigger/trigger_chrysler.cpp +++ b/firmware/controllers/trigger/trigger_chrysler.cpp @@ -6,15 +6,21 @@ */ #include "trigger_chrysler.h" +#include "trigger_decoder.h" void initDodgeRam(TriggerShape *s) { - s->reset(FOUR_STROKE_CAM_SENSOR, false); + s->reset(FOUR_STROKE_CAM_SENSOR, true); s->useRiseEdge = true; s->isSynchronizationNeeded = false; - s->addEvent(540, T_PRIMARY, TV_HIGH); + addSkippedToothTriggerEvents(T_SECONDARY, s, 8, 0, 0.9, -1, 360, 0, 720); + + s->addEvent(360, T_PRIMARY, TV_HIGH); + + addSkippedToothTriggerEvents(T_SECONDARY, s, 8, 0, 0.9, 360 - 1, 360, 0, 720); + s->addEvent(720, T_PRIMARY, TV_LOW); } diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 9ef9b2f60a..fb36803df6 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -236,9 +236,12 @@ float getEngineCycle(operation_mode_e operationMode) { return operationMode == TWO_STROKE ? 360 : 720; } -void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s, int totalTeethCount, int skippedCount, +void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s, + int totalTeethCount, int skippedCount, + float toothWidth, float offset, float engineCycle, float filterLeft, float filterRight) { - float toothWidth = 0.5; + efiAssertVoid(totalTeethCount > 0, "total count"); + efiAssertVoid(skippedCount >= 0, "skipped count"); for (int i = 0; i < totalTeethCount - skippedCount - 1; i++) { float angleDown = engineCycle / totalTeethCount * (i + toothWidth); @@ -265,7 +268,7 @@ void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount, efiAssertVoid(s != NULL, "TriggerShape is NULL"); s->reset(operationMode, false); - addSkippedToothTriggerEvents(T_PRIMARY, s, totalTeethCount, skippedCount, 0, getEngineCycle(operationMode), + addSkippedToothTriggerEvents(T_PRIMARY, s, totalTeethCount, skippedCount, 0.5, 0, getEngineCycle(operationMode), NO_LEFT_FILTER, NO_RIGHT_FILTER); } @@ -290,11 +293,11 @@ static void configureOnePlus60_2(TriggerShape *s, operation_mode_e operationMode int skippedCount = 2; s->addEvent(2, T_PRIMARY, TV_HIGH); - addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 0, 360, 2, 20); + addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 0.5, 0, 360, 2, 20); s->addEvent(20, T_PRIMARY, TV_LOW); - addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 0, 360, 20, NO_RIGHT_FILTER); + addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 0.5, 0, 360, 20, NO_RIGHT_FILTER); - addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 360, 360, NO_LEFT_FILTER, + addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 0.5, 360, 360, NO_LEFT_FILTER, NO_RIGHT_FILTER); s->isSynchronizationNeeded = false; diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index 7691ca3e48..a5b5e9006d 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -8,6 +8,7 @@ #ifndef TRIGGER_DECODER_H_ #define TRIGGER_DECODER_H_ +#include "main.h" #include "trigger_structure.h" #include "engine_configuration.h" @@ -86,6 +87,10 @@ public: }; float getEngineCycle(operation_mode_e operationMode); +void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s, + int totalTeethCount, int skippedCount, + float toothWidth, + float offset, float engineCycle, float filterLeft, float filterRight); void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount, int skippedCount, operation_mode_e operationMode); uint32_t findTriggerZeroEventIndex(TriggerShape * shape, trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_S); diff --git a/java_console/models/src/com/rusefi/config/Field.java b/java_console/models/src/com/rusefi/config/Field.java index 8d10575096..1bc714d254 100644 --- a/java_console/models/src/com/rusefi/config/Field.java +++ b/java_console/models/src/com/rusefi/config/Field.java @@ -100,5 +100,14 @@ public class Field { } catch (NumberFormatException e) { return null; } + + } + + @Override + public String toString() { + return "Field{" + + "offset=" + offset + + ", type=" + type + + '}'; } } \ No newline at end of file diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index 97ac734d37..ddc26502eb 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -31,7 +31,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see com.rusefi.StartupFrame */ public class Launcher { - public static final int CONSOLE_VERSION = 20150501; + public static final int CONSOLE_VERSION = 20150502; public static final boolean SHOW_STIMULATOR = false; private static final String TAB_INDEX = "main_tab"; protected static final String PORT_KEY = "port"; diff --git a/java_console/ui/src/com/rusefi/ui/config/EnumConfigField.java b/java_console/ui/src/com/rusefi/ui/config/EnumConfigField.java index 2e5548df83..bda21eb7f5 100644 --- a/java_console/ui/src/com/rusefi/ui/config/EnumConfigField.java +++ b/java_console/ui/src/com/rusefi/ui/config/EnumConfigField.java @@ -39,6 +39,8 @@ public class EnumConfigField extends BaseConfigField { Pair p = Field.parseResponse(message); if (p != null && p.first == field.getOffset()) { int ordinal = (Integer) p.second; + if (ordinal >= options.length) + throw new IllegalStateException("Unexpected ordinal " + ordinal + " for " + field); ec = true; view.setEnabled(true); view.setSelectedItem(options[ordinal]); diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index bb12f1cbc8..8c5c8aebea 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -512,7 +512,7 @@ void testTriggerDecoder(void) { // lame duty cycle implementation! testTriggerDecoder2("ford aspire", FORD_ASPIRE_1996, 4, 0.0, 0.5); - testTriggerDecoder2("dodge ram", DODGE_RAM, 0, 0.7500, 0); + testTriggerDecoder2("dodge ram", DODGE_RAM, 16, 0.5000, 0.100); //testTriggerDecoder2("bmw", BMW_E34, 0, 0.9750, 0.5167); testTriggerDecoder2("bmw", BMW_E34, 0, 0.4667, 0.0);