From aec382a946ba6aa48ebadfcf067b488dc717b572 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sun, 13 Sep 2015 18:01:23 -0400 Subject: [PATCH] auto-sync --- firmware/controllers/trigger/trigger_decoder.cpp | 14 ++++++++------ .../ui/src/com/rusefi/SensorSnifferPane.java | 4 ++-- unit_tests/test_trigger_decoder.cpp | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 4f346ee838..53bedac211 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -265,15 +265,13 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no toothed_previous_duration = currentDuration; toothed_previous_time = nowNt; } - if (boardConfiguration->sensorChartMode == SC_RPM_ACCEL) { + if (boardConfiguration->sensorChartMode == SC_RPM_ACCEL || boardConfiguration->sensorChartMode == SC_DETAILED_RPM) { angle_t currentAngle = TRIGGER_SHAPE(eventAngles[currentCycle.current_index]); // todo: make this '90' depend on cylinder count? angle_t prevAngle = currentAngle - 90; fixAngle(prevAngle); -// int prevIndex = TRIGGER_SHAPE(triggerIndexByAngle[(int)prevAngle]); - int prevIndex = currentCycle.current_index - 1; - if (prevIndex == -1) - prevIndex = engine->triggerShape.getSize() - 1; + // todo: prevIndex should be pre-calculated + int prevIndex = TRIGGER_SHAPE(triggerIndexByAngle[(int)prevAngle]); // now let's get precise angle for that event prevAngle = TRIGGER_SHAPE(eventAngles[prevIndex]); uint32_t time = nowNt - timeOfLastEvent[prevIndex]; @@ -284,7 +282,11 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no float r = (60000000.0 / 360 * US_TO_NT_MULTIPLIER) * angleDiff / time; #if EFI_SENSOR_CHART || defined(__DOXYGEN__) - scAddData(currentAngle, r); + if (boardConfiguration->sensorChartMode == SC_DETAILED_RPM) { + scAddData(currentAngle, r); + } else { + scAddData(currentAngle, r / instantRpmValue[prevIndex]); + } #endif instantRpmValue[currentCycle.current_index] = r; timeOfLastEvent[currentCycle.current_index] = nowNt; diff --git a/java_console/ui/src/com/rusefi/SensorSnifferPane.java b/java_console/ui/src/com/rusefi/SensorSnifferPane.java index 5ad424b4fd..79404424fd 100644 --- a/java_console/ui/src/com/rusefi/SensorSnifferPane.java +++ b/java_console/ui/src/com/rusefi/SensorSnifferPane.java @@ -28,7 +28,7 @@ public class SensorSnifferPane { private static final String HELP_URL = "http://rusefi.com/wiki/index.php?title=Manual:DevConsole#Analog_Chart"; private final TreeMap values = new TreeMap<>(); - private final AnalogChartCanvas canvas = new AnalogChartCanvas(); + private final SensorSnifferCanvas canvas = new SensorSnifferCanvas(); private double minX; private double maxX; @@ -134,7 +134,7 @@ public class SensorSnifferPane { return content; } - private class AnalogChartCanvas extends JComponent { + private class SensorSnifferCanvas extends JComponent { @Override public void paint(Graphics g) { super.paint(g); diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index 8cc51ba074..7ff4544c3c 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -479,7 +479,7 @@ void testTriggerDecoder(void) { eth.persistentConfig.engineConfiguration.useOnlyFrontForTrigger = false; - eth.persistentConfig.engineConfiguration.bc.sensorChartMode = SC_RPM_ACCEL; + eth.persistentConfig.engineConfiguration.bc.sensorChartMode = SC_DETAILED_RPM; applyNonPersistentConfiguration(NULL PASS_ENGINE_PARAMETER); assertEqualsM2("rpm#1", 16666.9746, eth.engine.triggerCentral.triggerState.instantRpmValue[0], 0.5);