diff --git a/firmware/controllers/trigger/trigger_bmw.cpp b/firmware/controllers/trigger/trigger_bmw.cpp index 6e18bf1555..7401b78118 100644 --- a/firmware/controllers/trigger/trigger_bmw.cpp +++ b/firmware/controllers/trigger/trigger_bmw.cpp @@ -66,7 +66,6 @@ void configureMiniCooperTriggerShape(trigger_shape_s *s) { s->addEvent(720.0, T_PRIMARY, TV_LOW); - s->shaftPositionEventCount = s->getSize(); /** * With just one tooth on camshaft synchronization is not needed */ diff --git a/firmware/controllers/trigger/trigger_chrysler.cpp b/firmware/controllers/trigger/trigger_chrysler.cpp index 0768909d77..7f44b99111 100644 --- a/firmware/controllers/trigger/trigger_chrysler.cpp +++ b/firmware/controllers/trigger/trigger_chrysler.cpp @@ -35,8 +35,6 @@ void configureNeon2003TriggerShape(trigger_shape_s *s) { s->addEvent(base + 674, T_PRIMARY, TV_HIGH); s->addEvent(base + 710, T_PRIMARY, TV_LOW); - - s->assignSize(); } void configureNeon1995TriggerShape(trigger_shape_s *s) { @@ -95,7 +93,5 @@ void configureNeon1995TriggerShape(trigger_shape_s *s) { s->addEvent(base + 497, T_SECONDARY, TV_LOW); s->addEvent(base + 560, T_PRIMARY, TV_HIGH); // width = - - s->shaftPositionEventCount = 4 + 8 + 8 + 8 + 8; } diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 32c9dc0392..e8e042eedf 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -185,8 +185,7 @@ void initializeSkippedToothTriggerShapeExt(trigger_shape_s *s, int totalTeethCou s->skippedToothCount = skippedCount; initializeSkippedToothTriggerShape(s, totalTeethCount, skippedCount, operationMode); - s->shaftPositionEventCount = ((totalTeethCount - skippedCount) * 2); - s->wave.checkSwitchTimes(s->getSize()); + s->assignSize(); } /** @@ -213,71 +212,73 @@ void initializeTriggerShape(Logging *logger, engine_configuration_s const *engin initializeSkippedToothTriggerShapeExt(triggerShape, triggerConfig->customTotalToothCount, triggerConfig->customSkippedToothCount, getOperationMode(engineConfiguration)); - return; + break; case TT_MAZDA_MIATA_NA: initializeMazdaMiataNaShape(triggerShape); - return; + break; case TT_MAZDA_MIATA_NB: initializeMazdaMiataNbShape(triggerShape); - return; + break; case TT_DODGE_NEON_1995: configureNeon1995TriggerShape(triggerShape); - return; + break; case TT_DODGE_NEON_2003: configureNeon2003TriggerShape(triggerShape); - return; + break; case TT_FORD_ASPIRE: configureFordAspireTriggerShape(triggerShape); - return; + break; case TT_GM_7X: configureGmTriggerShape(triggerShape); - return; + break; case TT_FORD_ESCORT_GT: configureMazdaProtegeLx(triggerShape); - return; + break; case TT_MINI_COOPER_R50: configureMiniCooperTriggerShape(triggerShape); - return; + break; case TT_TOOTHED_WHEEL_60_2: setToothedWheelConfiguration(triggerShape, 60, 2, engineConfiguration); setTriggerSynchronizationGap(triggerShape, 2.5); - return; + break; case TT_TOOTHED_WHEEL_36_1: setToothedWheelConfiguration(triggerShape, 36, 1, engineConfiguration); - return; + break; case TT_HONDA_ACCORD_CD_TWO_WIRES: configureHondaAccordCD(triggerShape, false); - return; + break; case TT_HONDA_ACCORD_CD: configureHondaAccordCD(triggerShape, true); - return; + break; case TT_HONDA_ACCORD_CD_DIP: configureHondaAccordCDDip(triggerShape); - return; + break; case TT_MITSU: initializeMitsubishi4g18(triggerShape); - return; + break; default: firmwareError("initializeTriggerShape() not implemented: %d", triggerConfig->triggerType); ; + return; } - if (engineConfiguration2->triggerShape.shaftPositionEventCount != engineConfiguration2->triggerShape.getSize()) - firmwareError("trigger size or shaftPositionEventCount?"); + trigger_shape_s *s = &engineConfiguration2->triggerShape; + s->assignSize(); + s->wave.checkSwitchTimes(s->getSize()); } TriggerStimulatorHelper::TriggerStimulatorHelper() { diff --git a/firmware/controllers/trigger/trigger_gm.cpp b/firmware/controllers/trigger/trigger_gm.cpp index 982a2d3b60..117fe3b863 100644 --- a/firmware/controllers/trigger/trigger_gm.cpp +++ b/firmware/controllers/trigger/trigger_gm.cpp @@ -13,8 +13,6 @@ void configureGmTriggerShape(trigger_shape_s *s) { // all angles are x2 here - so, 5 degree width is 10 float w = 10; - s->shaftPositionEventCount = 14; - s->addEvent(120 - w, T_PRIMARY, TV_HIGH); s->addEvent(120.0, T_PRIMARY, TV_LOW); @@ -36,5 +34,6 @@ void configureGmTriggerShape(trigger_shape_s *s) { s->addEvent(720 - w, T_PRIMARY, TV_HIGH); s->addEvent(720.0, T_PRIMARY, TV_LOW); + s->assignSize(); } diff --git a/firmware/controllers/trigger/trigger_mazda.cpp b/firmware/controllers/trigger/trigger_mazda.cpp index 25a9de2585..cdbc9f8dc8 100644 --- a/firmware/controllers/trigger/trigger_mazda.cpp +++ b/firmware/controllers/trigger/trigger_mazda.cpp @@ -43,8 +43,7 @@ void initializeMazdaMiataNaShape(trigger_shape_s *s) { s->addEvent(656.5125, T_SECONDARY, TV_LOW); s->addEvent(720.0f, T_PRIMARY, TV_LOW); - s->shaftPositionEventCount = s->getSize(); - + s->assignSize(); } void initializeMazdaMiataNbShape(trigger_shape_s *s) { @@ -84,7 +83,7 @@ void initializeMazdaMiataNbShape(trigger_shape_s *s) { s->addEvent(720.0f, T_PRIMARY, TV_LOW); - s->shaftPositionEventCount = 6 + 16; + s->assignSize(); } void configureMazdaProtegeLx(trigger_shape_s *s) { @@ -128,7 +127,6 @@ void configureMazdaProtegeLx(trigger_shape_s *s) { s->addEvent(a, T_PRIMARY, TV_LOW); -// s->shaftPositionEventCount = 2 + 8; - s->shaftPositionEventCount = s->getSize(); + s->assignSize(); s->isSynchronizationNeeded = false; } diff --git a/firmware/controllers/trigger/trigger_mitsubishi.cpp b/firmware/controllers/trigger/trigger_mitsubishi.cpp index 7eeb28ef84..f15e1c1c2f 100644 --- a/firmware/controllers/trigger/trigger_mitsubishi.cpp +++ b/firmware/controllers/trigger/trigger_mitsubishi.cpp @@ -27,7 +27,7 @@ void configureFordAspireTriggerShape(trigger_shape_s * s) { s->addEvent(x + 540, T_SECONDARY, TV_LOW); s->addEvent(720, T_PRIMARY, TV_LOW); - s->shaftPositionEventCount = s->getSize(); + s->assignSize(); } void initializeMitsubishi4g18(trigger_shape_s *s) { diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index 8ae96c52fe..4822b7df15 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -375,7 +375,7 @@ void configureHondaAccordCDDip(trigger_shape_s *s) { s->isSynchronizationNeeded = false; - s->shaftPositionEventCount = s->getSize(); + s->assignSize(); } void configureHondaAccordCD(trigger_shape_s *s, bool with3rdSignal) { @@ -424,5 +424,5 @@ void configureHondaAccordCD(trigger_shape_s *s, bool with3rdSignal) { s->addEvent(i * 180.0f, T_PRIMARY, TV_LOW); } - s->shaftPositionEventCount = s->getSize(); + s->assignSize(); } diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index 2f770509c8..4f0fba5630 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -131,7 +131,7 @@ int main(void) { testFLStack(); // resizeMap(); - printf("Success 20130926\r\n"); + printf("Success 20131001\r\n"); return EXIT_SUCCESS; } diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index 36d84aa598..56f948caaf 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -30,6 +30,8 @@ Engine engine; extern int timeNow; +extern bool printGapRatio; + extern "C" { void sendOutConfirmation(char *value, int i); } @@ -476,6 +478,9 @@ void testTriggerDecoder(void) { testTriggerDecoder2("miata 1994", MIATA_1994, 11, 0.2917, 0.3716); testTriggerDecoder2("citroen", CITROEN_TU3JP, 0, 0.4833, 0.0); + printGapRatio = true; + testTriggerDecoder2("neon NGC", DODGE_NEON_2003, 6, 0.2139, 0.0); + testMazda323(); testRpmCalculator();