diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 5680d69b25..4a64e5c8a6 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -1133,6 +1133,24 @@ void TriggerCentral::updateWaveform() { initState); } + if (engineConfiguration->overrideVvtTriggerGaps) { + int gapIndex = 0; + + TriggerWaveform *shape = &vvtShape[0]; + + for (; gapIndex < engineConfiguration->gapVvtTrackingLengthOverride; gapIndex++) { + float gapOverrideFrom = engineConfiguration->triggerVVTGapOverrideFrom[gapIndex]; + float gapOverrideTo = engineConfiguration->triggerVVTGapOverrideTo[gapIndex]; + shape->synchronizationRatioFrom[gapIndex] = gapOverrideFrom; + shape->synchronizationRatioTo[gapIndex] = gapOverrideTo; + } + // fill the remainder with the default gaps + for (; gapIndex < VVT_TRACKING_LENGTH; gapIndex++) { + shape->synchronizationRatioFrom[gapIndex] = NAN; + shape->synchronizationRatioTo[gapIndex] = NAN; + } + } + for (int camIndex = 0; camIndex < CAMS_PER_BANK; camIndex++) { // todo: should 'vvtWithRealDecoder' be used here? if (engineConfiguration->vvtMode[camIndex] != VVT_INACTIVE) { diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 00f16b8a33..04b7020b64 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -126,6 +126,7 @@ struct_no_prefix engine_configuration_s ! https://github.com/rusefi/rusefi/issues/2010 shows the corner case wheel with huge depth requirement #define GAP_TRACKING_LENGTH 18 +#define VVT_TRACKING_LENGTH 4 #define CONSOLE_DATA_PROTOCOL_TAG " @" #define MAIN_HELP_URL "http://www.rusefi.com/" @@ -457,6 +458,9 @@ bit useFordRedundantPps;On some Ford and Toyota vehicles one of the pedal sensor bit cltSensorPulldown bit iatSensorPulldown bit allowIdenticalPps +bit overrideVvtTriggerGaps +bit unused30 +bit unused31 int16_t tpsMin;Closed throttle, 1 volt = 200 units.\nSee also tps1_1AdcChannel\nset tps_min X;"ADC", 1, 0, 0, 1023, 0 int16_t tpsMax;Full throttle.\nSee also tps1_1AdcChannel\nset tps_max X;"ADC", 1, 0, 0, 1023, 0 @@ -655,7 +659,7 @@ engineSyncCam_e engineSyncCam;Select which cam is used for engine sync. Other ca output_pin_e fuelPumpPin; pin_output_mode_e fuelPumpPinMode; - !unused 1 + int8_t gapVvtTrackingLengthOverride;How many consecutive VVT gap rations have to match expected ranges for sync to happen;"count", 1, 0, 1, @@VVT_TRACKING_LENGTH@@, 0 output_pin_e malfunctionIndicatorPin;Check engine light, also malfunction indicator light. Always blinks once on boot. pin_output_mode_e malfunctionIndicatorPinMode; @@ -1590,7 +1594,12 @@ pin_input_mode_e[LUA_DIGITAL_INPUT_COUNT iterate] luaDigitalInputPinModes; uint8_t[CAM_INPUTS_COUNT iterate] simulatorCamPosition; -uint8_t[242] mainUnusedEnd;;"units", 1, 0, 0, 1, 0 +uint16_t unusedExplicitFilling2 + + float[VVT_TRACKING_LENGTH iterate] triggerVVTGapOverrideFrom;;"ratio", 1, 0, 0, 20, 3 + float[VVT_TRACKING_LENGTH iterate] triggerVVTGapOverrideTo;;"ratio", 1, 0, 0, 20, 3 + +uint8_t[208] mainUnusedEnd;;"units", 1, 0, 0, 1, 0 ! end of engine_configuration_s end_struct diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 0b9ffc41b6..f9fdf08a13 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -2416,6 +2416,16 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_ field = "Gap #4 to", triggerGapOverrideTo4, { overrideTriggerGaps == 1 && gapTrackingLengthOverride >= 4 } field = "Gap #5 from", triggerGapOverrideFrom5, { overrideTriggerGaps == 1 && gapTrackingLengthOverride >= 5 } field = "Gap #5 to", triggerGapOverrideTo5, { overrideTriggerGaps == 1 && gapTrackingLengthOverride >= 5 } + field = "Override well known VVT gaps", overrideVvtTriggerGaps + field = gapVvtTrackingLengthOverride, gapVvtTrackingLengthOverride, { overrideVvtTriggerGaps == 1 } + field = "First VVT gap from", triggerVVTGapOverrideFrom1 + field = "First VVT gap to", triggerVVTGapOverrideTo1 + field = "Second VVT gap from", triggerVVTGapOverrideFrom2 + field = "Second VVT gap to", triggerVVTGapOverrideTo2 + field = "VVT gap #3 from", triggerVVTGapOverrideFrom3 + field = "VVT gap #3 to", triggerVVTGapOverrideTo3 + field = "VVT gap #4 from", triggerVVTGapOverrideFrom4 + field = "VVT gap #4 to", triggerVVTGapOverrideTo4 dialog = trigger_advanced, "Advanced Trigger" field = "Require cam/VVT sync for ignition", isPhaseSyncRequiredForIgnition diff --git a/java_tools/configuration_definition/src/test/java/com/rusefi/test/ConfigFieldParserTest.java b/java_tools/configuration_definition/src/test/java/com/rusefi/test/ConfigFieldParserTest.java index fe7c33f0a2..acbc283422 100644 --- a/java_tools/configuration_definition/src/test/java/com/rusefi/test/ConfigFieldParserTest.java +++ b/java_tools/configuration_definition/src/test/java/com/rusefi/test/ConfigFieldParserTest.java @@ -272,6 +272,59 @@ public class ConfigFieldParserTest { javaFieldsConsumer.getContent()); } + @Test + public void alignmentTestJava() { + ReaderStateImpl state = new ReaderStateImpl(); + String test = "struct pid_s\n" + + "\tint16_t periodMs;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" + + "\tint8_t periodByte;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" + + "\tfloat periodFloat;PID dTime;\"ms\", 1, 0, 0, 3000, 0\n" + + "end_struct\n" + + ""; + + JavaFieldsConsumer javaFieldsConsumer = new TestJavaFieldsConsumer(state); + BaseCHeaderConsumer cConsumer = new BaseCHeaderConsumer(); + + state.readBufferedReader(test, javaFieldsConsumer, cConsumer); + + assertEquals("\tpublic static final Field PERIODMS = Field.create(\"PERIODMS\", 0, FieldType.INT16).setScale(1.0).setBaseOffset(0);\n" + + "\tpublic static final Field PERIODBYTE = Field.create(\"PERIODBYTE\", 2, FieldType.INT8).setScale(1.0).setBaseOffset(0);\n" + + "\tpublic static final Field ALIGNMENTFILL_AT_3 = Field.create(\"ALIGNMENTFILL_AT_3\", 3, FieldType.INT8).setScale(1.0).setBaseOffset(0);\n" + + "\tpublic static final Field PERIODFLOAT = Field.create(\"PERIODFLOAT\", 4, FieldType.FLOAT).setBaseOffset(0);\n", + javaFieldsConsumer.getContent()); + + assertEquals("// start of pid_s\n" + + "struct pid_s {\n" + + "\t/**\n" + + "\t * PID dTime\n" + + "\tms\n" + + "\t * offset 0\n" + + "\t */\n" + + "\tint16_t periodMs = (int16_t)0;\n" + + "\t/**\n" + + "\t * PID dTime\n" + + "\tms\n" + + "\t * offset 2\n" + + "\t */\n" + + "\tint8_t periodByte = (int8_t)0;\n" + + "\t/**\n" + + "\t * need 4 byte alignment\n" + + "\tunits\n" + + "\t * offset 3\n" + + "\t */\n" + + "\tuint8_t alignmentFill_at_3[1];\n" + + "\t/**\n" + + "\t * PID dTime\n" + + "\tms\n" + + "\t * offset 4\n" + + "\t */\n" + + "\tfloat periodFloat = (float)0;\n" + + "};\n" + + "static_assert(sizeof(pid_s) == 8);\n" + + "\n", + cConsumer.getContent()); + } + @Test public void testDefineChar() { ReaderStateImpl state = new ReaderStateImpl();