diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index 03ea9b2168..23cd11340a 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -303,11 +303,11 @@ static NamedOutputPin * getIgnitionPinForIndex(int i DECLARE_ENGINE_PARAMETER_S) case IM_WASTED_SPARK: { int wastedIndex = i % (CONFIG(cylindersCount) / 2); int id = getCylinderId(CONFIG(firingOrder), wastedIndex); - return &enginePins.coils[id]; + return &enginePins.coils[ID2INDEX(id)]; } break; case IM_INDIVIDUAL_COILS: - return &enginePins.coils[getCylinderId(CONFIG(firingOrder), i)]; + return &enginePins.coils[ID2INDEX(getCylinderId(CONFIG(firingOrder), i))]; break; default: diff --git a/firmware/util/efilib.h b/firmware/util/efilib.h index 04d24201b2..4610e7da2b 100644 --- a/firmware/util/efilib.h +++ b/firmware/util/efilib.h @@ -17,6 +17,8 @@ #define SWAP_UINT32(x) (((x) >> 24) & 0xff) | (((x) << 8) & 0xff0000) | (((x) >> 8) & 0xff00) | (((x) << 24) & 0xff000000) +// human-readable IDs start from 1 while computer-readbale indexes start from 0 +#define ID2INDEX(id) ((id) - 1) // number of milliseconds in one period of given frequency (per second) #define frequency2periodMs(freq) ((1000.0f) / (freq)) diff --git a/java_console/autotest/src/com/rusefi/AutoTest.java b/java_console/autotest/src/com/rusefi/AutoTest.java index 905f307e1c..49d33239c8 100644 --- a/java_console/autotest/src/com/rusefi/AutoTest.java +++ b/java_console/autotest/src/com/rusefi/AutoTest.java @@ -27,7 +27,6 @@ public class AutoTest { sendCommand("set_engine_type 7"); testFord6(); - sendCommand("set_engine_type 4"); testFordFiesta(); } @@ -61,14 +60,17 @@ public class AutoTest { } private static void testFordFiesta() { + sendCommand("set_engine_type 4"); WaveChart chart; IoUtil.changeRpm(2000); chart = nextChart(); String msg = "Fiesta"; double x = 312; - assertWave(msg, chart, WaveChart.SPARK_1, 0.1333333, x, x + 360); - assertWave(msg, chart, WaveChart.SPARK_3, 0.1333333, x + 180, x + 540); + assertWave("wasted spark #1 with Fiesta", chart, WaveChart.SPARK_1, 0.1333333, x, x + 360); + assertNull(msg, chart.get(WaveChart.SPARK_2)); + assertWave("wasted spark #3 with Fiesta", chart, WaveChart.SPARK_3, 0.1333333, x + 180, x + 540); + assertNull(msg, chart.get(WaveChart.SPARK_4)); } private static void testFord6() { @@ -172,7 +174,7 @@ public class AutoTest { // let's enable more channels dynamically sendCommand("set_ignition_mode 1"); chart = nextChart(); - assertWave(chart, WaveChart.SPARK_2, 0.133, x); + assertWave("Switching Aspire into INDIVIDUAL_COILS mode", chart, WaveChart.SPARK_2, 0.133, x); assertWave(chart, WaveChart.SPARK_3, 0.133, x + 360); sendCommand("set_whole_timing_map 520");