diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 040656d5b9..98c1ab7b2c 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -52,16 +52,16 @@ FsioState::FsioState() { #endif } -void Engine::eInitializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_SUFFIX) { +void Engine::initializeTriggerWaveform(Logging *logger DECLARE_ENGINE_PARAMETER_SUFFIX) { #if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT // we have a confusing threading model so some synchronization would not hurt bool alreadyLocked = lockAnyContext(); - TRIGGER_SHAPE(initializeTriggerShape(logger, + TRIGGER_WAVEFORM(initializeTriggerWaveform(logger, engineConfiguration->ambiguousOperationMode, engineConfiguration->useOnlyRisingEdgeForTrigger, &engineConfiguration->trigger)); - if (TRIGGER_SHAPE(bothFrontsRequired) && engineConfiguration->useOnlyRisingEdgeForTrigger) { + if (TRIGGER_WAVEFORM(bothFrontsRequired) && engineConfiguration->useOnlyRisingEdgeForTrigger) { #if EFI_PROD_CODE || EFI_SIMULATOR firmwareError(CUSTOM_ERR_BOTH_FRONTS_REQUIRED, "Inconsistent trigger setup"); #else @@ -70,9 +70,9 @@ void Engine::eInitializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_SU } - if (!TRIGGER_SHAPE(shapeDefinitionError)) { + if (!TRIGGER_WAVEFORM(shapeDefinitionError)) { /** - * this instance is used only to initialize 'this' TriggerShape instance + * this instance is used only to initialize 'this' TriggerWaveform instance * #192 BUG real hardware trigger events could be coming even while we are initializing trigger */ initState.resetTriggerState(); @@ -82,14 +82,14 @@ void Engine::eInitializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_SU if (engine->triggerCentral.triggerShape.getSize() == 0) { firmwareError(CUSTOM_ERR_TRIGGER_ZERO, "triggerShape size is zero"); } - engine->engineCycleEventCount = TRIGGER_SHAPE(getLength()); + engine->engineCycleEventCount = TRIGGER_WAVEFORM(getLength()); } if (!alreadyLocked) { unlockAnyContext(); } - if (!TRIGGER_SHAPE(shapeDefinitionError)) { + if (!TRIGGER_WAVEFORM(shapeDefinitionError)) { prepareOutputSignals(PASS_ENGINE_PARAMETER_SIGNATURE); } #endif /* EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT */ diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index a303652a8a..0c4c26ff3e 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -194,7 +194,7 @@ public: void periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE); void periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE); void updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE); - void eInitializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_SUFFIX); + void initializeTriggerWaveform(Logging *logger DECLARE_ENGINE_PARAMETER_SUFFIX); bool clutchUpState = false; bool clutchDownState = false; diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index a579a0b690..6269268700 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -1296,7 +1296,7 @@ void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_S assertEngineReference(); #if EFI_ENGINE_CONTROL - ENGINE(eInitializeTriggerShape(logger PASS_ENGINE_PARAMETER_SUFFIX)); + ENGINE(initializeTriggerWaveform(logger PASS_ENGINE_PARAMETER_SUFFIX)); #endif #if EFI_FSIO diff --git a/firmware/controllers/algo/obd_error_codes.h b/firmware/controllers/algo/obd_error_codes.h index a05637781a..a74417f997 100644 --- a/firmware/controllers/algo/obd_error_codes.h +++ b/firmware/controllers/algo/obd_error_codes.h @@ -1831,7 +1831,7 @@ typedef enum { CUSTOM_ERR_PIN_ALREADY_USED_2 = 6134, CUSTOM_ERR_ICU_STATE = 6135, CUSTOM_ERR_TCHARGE_NOT_READY = 6136, - CUSTOM_ERR_TRIGGER_SHAPE_TOO_LONG = 6137, + CUSTOM_ERR_TRIGGER_WAVEFORM_TOO_LONG = 6137, CUSTOM_ERR_FUEL_TABLE_NOT_READY = 6138, CUSTOM_ERR_TCHARGE_NOT_READY2 = 6139, @@ -2093,7 +2093,7 @@ typedef enum { CUSTOM_ERR_TRIGGER_SYNC = 9000, - CUSTOM_OBD_TRIGGER_SHAPE = 9001, + CUSTOM_OBD_TRIGGER_WAVEFORM = 9001, /** * This is not engine miss detection - this is only internal scheduler state validation * Should not happen diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 47e8995567..8d913fa55e 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -103,7 +103,7 @@ typedef enum { // used by unit test // see https://github.com/rusefi/rusefi/issues/898 - // see TriggerShape::bothFrontsRequired + // see TriggerWaveform::bothFrontsRequired ISSUE_898 = 27, MAZDA_626 = 28, diff --git a/firmware/controllers/map_averaging.cpp b/firmware/controllers/map_averaging.cpp index d5970a6207..070408753a 100644 --- a/firmware/controllers/map_averaging.cpp +++ b/firmware/controllers/map_averaging.cpp @@ -236,7 +236,7 @@ void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE) { angle_t start = interpolate2d("mapa", rpm, c->samplingAngleBins, c->samplingAngle); efiAssertVoid(CUSTOM_ERR_MAP_START_ASSERT, !cisnan(start), "start"); - angle_t offsetAngle = TRIGGER_SHAPE(eventAngles[CONFIG(mapAveragingSchedulingAtIndex)]); + angle_t offsetAngle = TRIGGER_WAVEFORM(eventAngles[CONFIG(mapAveragingSchedulingAtIndex)]); efiAssertVoid(CUSTOM_ERR_MAP_AVG_OFFSET, !cisnan(offsetAngle), "offsetAngle"); for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) { diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index e07d8e2ee3..cca8c622ae 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -204,8 +204,8 @@ bool FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_SUFF ev->isSimultanious = isSimultanious; - if (TRIGGER_SHAPE(getSize()) < 1) { - warning(CUSTOM_ERR_NOT_INITIALIZED_TRIGGER, "uninitialized TriggerShape"); + if (TRIGGER_WAVEFORM(getSize()) < 1) { + warning(CUSTOM_ERR_NOT_INITIALIZED_TRIGGER, "uninitialized TriggerWaveform"); return false; } @@ -517,7 +517,7 @@ void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_SIGNATURE) { prepareIgnitionPinIndices(CONFIG(ignitionMode) PASS_ENGINE_PARAMETER_SUFFIX); - TRIGGER_SHAPE(prepareShape()); + TRIGGER_WAVEFORM(prepareShape()); } #endif /* EFI_ENGINE_CONTROL */ diff --git a/firmware/controllers/math/engine_math.h b/firmware/controllers/math/engine_math.h index e66f7521ea..36e8b6081d 100644 --- a/firmware/controllers/math/engine_math.h +++ b/firmware/controllers/math/engine_math.h @@ -67,4 +67,4 @@ void setSingleCoilDwell(DECLARE_CONFIG_PARAMETER_SIGNATURE); // expectation is that for well-known triggers CONFIG(globalTriggerAngleOffset) would usually be zero // while for toothed wheels user would have to provide a value #define tdcPosition() \ - (TRIGGER_SHAPE(tdcPosition) + CONFIG(globalTriggerAngleOffset)) + (TRIGGER_WAVEFORM(tdcPosition) + CONFIG(globalTriggerAngleOffset)) diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index a78a65a324..bf82370028 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -571,7 +571,7 @@ static void setToothedWheel(int total, int skipped DECLARE_ENGINE_PARAMETER_SUFF scheduleMsg(&logger, "toothed: total=%d/skipped=%d", total, skipped); setToothedWheelConfiguration(&engine->triggerCentral.triggerShape, total, skipped, engineConfiguration->ambiguousOperationMode); -// initializeTriggerShape(&logger, engineConfiguration, engineConfiguration2); +// initializeTriggerWaveform(&logger, engineConfiguration, engineConfiguration2); incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); doPrintConfiguration(); } diff --git a/firmware/controllers/trigger/decoders/trigger_bmw.cpp b/firmware/controllers/trigger/decoders/trigger_bmw.cpp index 1e22772f9d..60e10ef343 100644 --- a/firmware/controllers/trigger/decoders/trigger_bmw.cpp +++ b/firmware/controllers/trigger/decoders/trigger_bmw.cpp @@ -7,7 +7,7 @@ #include "trigger_bmw.h" -static inline float addPair(TriggerShape *s, float a, float w) { +static inline float addPair(TriggerWaveform *s, float a, float w) { s->addEvent720(a, T_SECONDARY, TV_RISE); a += w; s->addEvent720(a, T_SECONDARY, TV_FALL); @@ -15,7 +15,7 @@ static inline float addPair(TriggerShape *s, float a, float w) { return a; } -void configureMiniCooperTriggerShape(TriggerShape *s) { +void configureMiniCooperTriggerWaveform(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); // s->initialState[0] = 1; diff --git a/firmware/controllers/trigger/decoders/trigger_bmw.h b/firmware/controllers/trigger/decoders/trigger_bmw.h index ae6ef6a3c1..9c75b8f002 100644 --- a/firmware/controllers/trigger/decoders/trigger_bmw.h +++ b/firmware/controllers/trigger/decoders/trigger_bmw.h @@ -9,5 +9,5 @@ #include "trigger_structure.h" -void configureMiniCooperTriggerShape(TriggerShape *s); +void configureMiniCooperTriggerWaveform(TriggerWaveform *s); diff --git a/firmware/controllers/trigger/decoders/trigger_chrysler.cpp b/firmware/controllers/trigger/decoders/trigger_chrysler.cpp index 3decbd5294..61c4f035e5 100644 --- a/firmware/controllers/trigger/decoders/trigger_chrysler.cpp +++ b/firmware/controllers/trigger/decoders/trigger_chrysler.cpp @@ -8,7 +8,7 @@ #include "trigger_chrysler.h" #include "trigger_universal.h" -void initDodgeRam(TriggerShape *s) { +void initDodgeRam(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); s->useRiseEdge = true; @@ -25,7 +25,7 @@ void initDodgeRam(TriggerShape *s) { s->useOnlyPrimaryForSync = true; } -void configureNeon2003TriggerShapeCrank(TriggerShape *s DECLARE_ENGINE_PARAMETER_SUFFIX) { +void configureNeon2003TriggerWaveformCrank(TriggerWaveform *s DECLARE_ENGINE_PARAMETER_SUFFIX) { s->initialize(FOUR_STROKE_CRANK_SENSOR, false); s->useRiseEdge = true; @@ -99,7 +99,7 @@ void configureNeon2003TriggerShapeCrank(TriggerShape *s DECLARE_ENGINE_PARAMETER s->addEvent720(m * 360, T_PRIMARY, TV_RISE); } -void configureNeon2003TriggerShapeCam(TriggerShape *s) { +void configureNeon2003TriggerWaveformCam(TriggerWaveform *s) { // todo: move sync point so that two channel does not have false trigger issues bool useOnlyPrimary = true; @@ -322,7 +322,7 @@ gap=1.43/0.71 } } -void configureDodgeStratusTriggerShape(TriggerShape *s) { +void configureDodgeStratusTriggerWaveform(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, false); s->isSynchronizationNeeded = true; @@ -388,7 +388,7 @@ void configureDodgeStratusTriggerShape(TriggerShape *s) { s->addEvent720(angle + w, T_PRIMARY, TV_FALL); } -static void configureNeon1995TriggerShapeCommon(bool withCam, TriggerShape *s) { +static void configureNeon1995TriggerWaveformCommon(bool withCam, TriggerWaveform *s) { trigger_wheel_e crank = withCam ? T_SECONDARY : T_PRIMARY; // voodoo magic - we always need 720 at the end @@ -448,17 +448,17 @@ static void configureNeon1995TriggerShapeCommon(bool withCam, TriggerShape *s) { } } -void configureNeon1995TriggerShapeOnlyCrank(TriggerShape *s) { +void configureNeon1995TriggerWaveformOnlyCrank(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CRANK_SENSOR, false); s->setTriggerSynchronizationGap(3.79); s->tdcPosition = 279; - configureNeon1995TriggerShapeCommon(false, s); + configureNeon1995TriggerWaveformCommon(false, s); } -void configureNeon1995TriggerShape(TriggerShape *s) { +void configureNeon1995TriggerWaveform(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); s->setTriggerSynchronizationGap(0.8227); @@ -468,12 +468,12 @@ void configureNeon1995TriggerShape(TriggerShape *s) { s->initialState[T_PRIMARY] = TV_RISE; - configureNeon1995TriggerShapeCommon(true, s); + configureNeon1995TriggerWaveformCommon(true, s); s->useOnlyPrimaryForSync = true; } -void initJeep18_2_2_2(TriggerShape *s) { +void initJeep18_2_2_2(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); s->isSynchronizationNeeded = true; s->setTriggerSynchronizationGap(1); @@ -543,7 +543,7 @@ void initJeep18_2_2_2(TriggerShape *s) { } -static void add4cylblock(int off, TriggerShape *s) { +static void add4cylblock(int off, TriggerWaveform *s) { s->addEvent720(114 + off, T_SECONDARY, TV_RISE); s->addEvent720(114 + off + 2, T_SECONDARY, TV_FALL); @@ -558,7 +558,7 @@ static void add4cylblock(int off, TriggerShape *s) { } // TT_JEEP_4_CYL -void initJeep_XJ_4cyl_2500(TriggerShape *s) { +void initJeep_XJ_4cyl_2500(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); s->isSynchronizationNeeded = true; s->setTriggerSynchronizationGap(1); diff --git a/firmware/controllers/trigger/decoders/trigger_chrysler.h b/firmware/controllers/trigger/decoders/trigger_chrysler.h index c766487ad5..1ebcb1f35e 100644 --- a/firmware/controllers/trigger/decoders/trigger_chrysler.h +++ b/firmware/controllers/trigger/decoders/trigger_chrysler.h @@ -13,16 +13,16 @@ #define CHRYSLER_NGC4_GAP 1 #define CHRYSLER_NGC6_GAP 1.5 -void configureNeon1995TriggerShape(TriggerShape *s); -void configureNeon1995TriggerShapeOnlyCrank(TriggerShape *s); +void configureNeon1995TriggerWaveform(TriggerWaveform *s); +void configureNeon1995TriggerWaveformOnlyCrank(TriggerWaveform *s); -void configureNeon2003TriggerShapeCam(TriggerShape *s); -void configureNeon2003TriggerShapeCrank(TriggerShape *s); -void initDodgeRam(TriggerShape *s); +void configureNeon2003TriggerWaveformCam(TriggerWaveform *s); +void configureNeon2003TriggerWaveformCrank(TriggerWaveform *s); +void initDodgeRam(TriggerWaveform *s); -void configureDodgeStratusTriggerShape(TriggerShape *s); +void configureDodgeStratusTriggerWaveform(TriggerWaveform *s); -void initJeep18_2_2_2(TriggerShape *s); -void initJeep_XJ_4cyl_2500(TriggerShape *s); +void initJeep18_2_2_2(TriggerWaveform *s); +void initJeep_XJ_4cyl_2500(TriggerWaveform *s); #endif /* TRIGGER_CHRYSLER_H_ */ diff --git a/firmware/controllers/trigger/decoders/trigger_gm.cpp b/firmware/controllers/trigger/decoders/trigger_gm.cpp index ac381740f4..5f47bba6d6 100644 --- a/firmware/controllers/trigger/decoders/trigger_gm.cpp +++ b/firmware/controllers/trigger/decoders/trigger_gm.cpp @@ -7,7 +7,7 @@ #include "trigger_gm.h" -void configureGmTriggerShape(TriggerShape *s) { +void configureGmTriggerWaveform(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CRANK_SENSOR, false); // all angles are x2 here - so, 5 degree width is 10 @@ -39,7 +39,7 @@ void configureGmTriggerShape(TriggerShape *s) { s->setTriggerSynchronizationGap(6); } -static int gm_tooth_pair(float startAngle, bool isShortLong, TriggerShape* s, int mult) +static int gm_tooth_pair(float startAngle, bool isShortLong, TriggerWaveform* s, int mult) { int window = (isShortLong ? 5 : 10) * mult; int end = startAngle + mult * 15; @@ -59,7 +59,7 @@ static int gm_tooth_pair(float startAngle, bool isShortLong, TriggerShape* s, in * * based on data in https://rusefi.com/forum/viewtopic.php?f=3&t=936&p=30303#p30285 */ -void initGmLS24(TriggerShape *s) { +void initGmLS24(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CRANK_SENSOR, false); /* diff --git a/firmware/controllers/trigger/decoders/trigger_gm.h b/firmware/controllers/trigger/decoders/trigger_gm.h index 53cca74206..895f3526b9 100644 --- a/firmware/controllers/trigger/decoders/trigger_gm.h +++ b/firmware/controllers/trigger/decoders/trigger_gm.h @@ -10,7 +10,7 @@ #include "trigger_structure.h" -void configureGmTriggerShape(TriggerShape *s); -void initGmLS24(TriggerShape *s); +void configureGmTriggerWaveform(TriggerWaveform *s); +void initGmLS24(TriggerWaveform *s); #endif /* TRIGGER_GM_H_ */ diff --git a/firmware/controllers/trigger/decoders/trigger_honda.cpp b/firmware/controllers/trigger/decoders/trigger_honda.cpp index 8841417cd9..a2b926e8f5 100644 --- a/firmware/controllers/trigger/decoders/trigger_honda.cpp +++ b/firmware/controllers/trigger/decoders/trigger_honda.cpp @@ -10,7 +10,7 @@ #define S24 (720.0f / 24 / 2) -static float addAccordPair(TriggerShape *s, float sb, trigger_wheel_e const channelIndex) { +static float addAccordPair(TriggerWaveform *s, float sb, trigger_wheel_e const channelIndex) { s->addEvent720(sb, channelIndex, TV_RISE); sb += S24; s->addEvent720(sb, channelIndex, TV_FALL); @@ -20,7 +20,7 @@ static float addAccordPair(TriggerShape *s, float sb, trigger_wheel_e const chan } #define DIP 7.5f -static float addAccordPair3(TriggerShape *s, float sb) { +static float addAccordPair3(TriggerWaveform *s, float sb) { sb += DIP; s->addEvent720(sb, T_CHANNEL_3, TV_RISE); sb += DIP; @@ -33,7 +33,7 @@ static float addAccordPair3(TriggerShape *s, float sb) { * Thank you Dip! * http://forum.pgmfi.org/viewtopic.php?f=2&t=15570start=210#p139007 */ -void configureHondaAccordCDDip(TriggerShape *s) { +void configureHondaAccordCDDip(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); s->initialState[T_SECONDARY] = TV_RISE; @@ -102,7 +102,7 @@ void configureHondaAccordCDDip(TriggerShape *s) { * '4' is conditional * '24' is always secondary channel */ -void configureHonda_1_4_24(TriggerShape *s, bool withOneEventSignal, bool withFourEventSignal, +void configureHonda_1_4_24(TriggerWaveform *s, bool withOneEventSignal, bool withFourEventSignal, trigger_wheel_e const oneEventWave, trigger_wheel_e const fourEventWave, float prefix) { @@ -166,7 +166,7 @@ void configureHonda_1_4_24(TriggerShape *s, bool withOneEventSignal, bool withFo s->useOnlyPrimaryForSync = true; } -void configureHondaCbr600(TriggerShape *s) { +void configureHondaCbr600(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); s->useOnlyPrimaryForSync = true; s->isSynchronizationNeeded = true; @@ -209,7 +209,7 @@ void configureHondaCbr600(TriggerShape *s) { s->addEvent720(720.0f, T_PRIMARY, TV_RISE); } -void configureHondaCbr600custom(TriggerShape *s) { +void configureHondaCbr600custom(TriggerWaveform *s) { // w = 15 float w = 720 / 2 / 24; @@ -283,7 +283,7 @@ void configureHondaCbr600custom(TriggerShape *s) { } -void configureHondaAccordShifted(TriggerShape *s) { +void configureHondaAccordShifted(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); float sb = S24; @@ -314,7 +314,7 @@ void configureHondaAccordShifted(TriggerShape *s) { s->isSynchronizationNeeded = false; } -void configureOnePlus16(TriggerShape *s, operation_mode_e operationMode) { +void configureOnePlus16(TriggerWaveform *s, operation_mode_e operationMode) { UNUSED(operationMode); s->initialize(FOUR_STROKE_CAM_SENSOR, true); diff --git a/firmware/controllers/trigger/decoders/trigger_honda.h b/firmware/controllers/trigger/decoders/trigger_honda.h index 365a46b9d8..a469d95661 100644 --- a/firmware/controllers/trigger/decoders/trigger_honda.h +++ b/firmware/controllers/trigger/decoders/trigger_honda.h @@ -10,17 +10,17 @@ #include "trigger_structure.h" -void configureHondaAccordCDDip(TriggerShape *s); -void configureHondaAccordShifted(TriggerShape *s); +void configureHondaAccordCDDip(TriggerWaveform *s); +void configureHondaAccordShifted(TriggerWaveform *s); -void configureHonda_1_4_24(TriggerShape *s, bool withOneEventSignal, bool withFourEventSignal, +void configureHonda_1_4_24(TriggerWaveform *s, bool withOneEventSignal, bool withFourEventSignal, trigger_wheel_e const oneEventWave, trigger_wheel_e const fourEventWave, float d); -void configureOnePlus16(TriggerShape *s, operation_mode_e operationMode); +void configureOnePlus16(TriggerWaveform *s, operation_mode_e operationMode); -void configureHondaCbr600(TriggerShape *s); -void configureHondaCbr600custom(TriggerShape *s); +void configureHondaCbr600(TriggerWaveform *s); +void configureHondaCbr600custom(TriggerWaveform *s); #endif /* CONTROLLERS_TRIGGER_TRIGGER_HONDA_H_ */ diff --git a/firmware/controllers/trigger/decoders/trigger_mazda.cpp b/firmware/controllers/trigger/decoders/trigger_mazda.cpp index cb15e7d0c2..9a4f48dfa6 100644 --- a/firmware/controllers/trigger/decoders/trigger_mazda.cpp +++ b/firmware/controllers/trigger/decoders/trigger_mazda.cpp @@ -20,7 +20,7 @@ #include "trigger_mazda.h" -void initializeMazdaMiataNaShape(TriggerShape *s) { +void initializeMazdaMiataNaShape(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); s->setTriggerSynchronizationGap2(1.4930 * 0.6f, 1.4930 * 1.3f); s->useRiseEdge = false; @@ -56,7 +56,7 @@ void initializeMazdaMiataNaShape(TriggerShape *s) { * by alexander-n8hgeg5e * See https://rusefi.com/forum/viewtopic.php?f=5&t=1447 */ -void initialize_Mazda_Engine_z5_Shape(TriggerShape *s) { +void initialize_Mazda_Engine_z5_Shape(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, false); /** * My Signal is: 60, 60, 102, 60 @@ -87,7 +87,7 @@ void initialize_Mazda_Engine_z5_Shape(TriggerShape *s) { } // TT_MIATA_VVT -void initializeMazdaMiataNb2Crank(TriggerShape *s) { +void initializeMazdaMiataNb2Crank(TriggerWaveform *s) { s->initialize(FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR, false); float o = 160; @@ -101,7 +101,7 @@ void initializeMazdaMiataNb2Crank(TriggerShape *s) { s->addEvent720(o + 4 * 140.0f, T_PRIMARY, TV_RISE); } -static void initializeMazdaMiataNb1ShapeWithOffset(TriggerShape *s, float offset) { +static void initializeMazdaMiataNb1ShapeWithOffset(TriggerWaveform *s, float offset) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); s->setTriggerSynchronizationGap3(0, 0.065, 0.17f); s->useRiseEdge = false; @@ -143,15 +143,15 @@ static void initializeMazdaMiataNb1ShapeWithOffset(TriggerShape *s, float offset s->addEvent720(720.0f, T_PRIMARY, TV_RISE); } -void initializeMazdaMiataNb1Shape(TriggerShape *s) { +void initializeMazdaMiataNb1Shape(TriggerWaveform *s) { initializeMazdaMiataNb1ShapeWithOffset(s, 0); } -void initializeMazdaMiataVVtTestShape(TriggerShape *s) { +void initializeMazdaMiataVVtTestShape(TriggerWaveform *s) { initializeMazdaMiataNb1ShapeWithOffset(s, -22); } -void configureMazdaProtegeSOHC(TriggerShape *s) { +void configureMazdaProtegeSOHC(TriggerWaveform *s) { // todo: move to into configuration definition s->needSecondTriggerInput = FALSE; @@ -181,7 +181,7 @@ void configureMazdaProtegeSOHC(TriggerShape *s) { s->isSynchronizationNeeded = false; } -void configureMazdaProtegeLx(TriggerShape *s) { +void configureMazdaProtegeLx(TriggerWaveform *s) { // todo: move to into configuration definition s->needSecondTriggerInput = FALSE; s->initialize(FOUR_STROKE_CAM_SENSOR, true); s->useOnlyPrimaryForSync = true; diff --git a/firmware/controllers/trigger/decoders/trigger_mazda.h b/firmware/controllers/trigger/decoders/trigger_mazda.h index 4f630cac35..3523bbb725 100644 --- a/firmware/controllers/trigger/decoders/trigger_mazda.h +++ b/firmware/controllers/trigger/decoders/trigger_mazda.h @@ -12,12 +12,12 @@ #define MIATA_NA_GAP 1.4930f -void initializeMazdaMiataNaShape(TriggerShape *s); -void initializeMazdaMiataNb1Shape(TriggerShape *s); -void initializeMazdaMiataNb2Crank(TriggerShape *s); -void initializeMazdaMiataVVtTestShape(TriggerShape *s); -void configureMazdaProtegeSOHC(TriggerShape *s); -void configureMazdaProtegeLx(TriggerShape *s); -void initialize_Mazda_Engine_z5_Shape(TriggerShape *s); +void initializeMazdaMiataNaShape(TriggerWaveform *s); +void initializeMazdaMiataNb1Shape(TriggerWaveform *s); +void initializeMazdaMiataNb2Crank(TriggerWaveform *s); +void initializeMazdaMiataVVtTestShape(TriggerWaveform *s); +void configureMazdaProtegeSOHC(TriggerWaveform *s); +void configureMazdaProtegeLx(TriggerWaveform *s); +void initialize_Mazda_Engine_z5_Shape(TriggerWaveform *s); #endif /* TRIGGER_MAZDA_H_ */ diff --git a/firmware/controllers/trigger/decoders/trigger_misc.cpp b/firmware/controllers/trigger/decoders/trigger_misc.cpp index 2dbea44a5f..dc9b792f38 100644 --- a/firmware/controllers/trigger/decoders/trigger_misc.cpp +++ b/firmware/controllers/trigger/decoders/trigger_misc.cpp @@ -8,7 +8,7 @@ #include "trigger_misc.h" // TT_FIAT_IAW_P8 -void configureFiatIAQ_P8(TriggerShape * s) { +void configureFiatIAQ_P8(TriggerWaveform * s) { s->initialize(FOUR_STROKE_CAM_SENSOR, false); s->isSynchronizationNeeded = true; diff --git a/firmware/controllers/trigger/decoders/trigger_misc.h b/firmware/controllers/trigger/decoders/trigger_misc.h index e56b7f6e9c..c2c4ec0ef0 100644 --- a/firmware/controllers/trigger/decoders/trigger_misc.h +++ b/firmware/controllers/trigger/decoders/trigger_misc.h @@ -10,6 +10,6 @@ #include "trigger_structure.h" -void configureFiatIAQ_P8(TriggerShape * s); +void configureFiatIAQ_P8(TriggerWaveform * s); #endif /* CONTROLLERS_TRIGGER_DECODERS_TRIGGER_MISC_H_ */ diff --git a/firmware/controllers/trigger/decoders/trigger_mitsubishi.cpp b/firmware/controllers/trigger/decoders/trigger_mitsubishi.cpp index cc6a26fb21..aa1c824b9d 100644 --- a/firmware/controllers/trigger/decoders/trigger_mitsubishi.cpp +++ b/firmware/controllers/trigger/decoders/trigger_mitsubishi.cpp @@ -7,7 +7,7 @@ #include "trigger_mitsubishi.h" -void configureFordAspireTriggerShape(TriggerShape * s) { +void configureFordAspireTriggerWaveform(TriggerWaveform * s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); s->isSynchronizationNeeded = false; @@ -31,7 +31,7 @@ void configureFordAspireTriggerShape(TriggerShape * s) { /** * TT_MITSUBISHI = 11 */ -void initializeMitsubishi4g18(TriggerShape *s) { +void initializeMitsubishi4g18(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); s->useRiseEdge = false; diff --git a/firmware/controllers/trigger/decoders/trigger_mitsubishi.h b/firmware/controllers/trigger/decoders/trigger_mitsubishi.h index 0df0b7b33d..984e9d154e 100644 --- a/firmware/controllers/trigger/decoders/trigger_mitsubishi.h +++ b/firmware/controllers/trigger/decoders/trigger_mitsubishi.h @@ -9,7 +9,7 @@ #include "trigger_structure.h" -void initializeMitsubishi4g18(TriggerShape *s); -void configureFordAspireTriggerShape(TriggerShape * s); +void initializeMitsubishi4g18(TriggerWaveform *s); +void configureFordAspireTriggerWaveform(TriggerWaveform * s); #endif /* TRIGGER_MITSUBISHI_H_ */ diff --git a/firmware/controllers/trigger/decoders/trigger_nissan.cpp b/firmware/controllers/trigger/decoders/trigger_nissan.cpp index 9c177b780d..827ac7a47a 100644 --- a/firmware/controllers/trigger/decoders/trigger_nissan.cpp +++ b/firmware/controllers/trigger/decoders/trigger_nissan.cpp @@ -13,7 +13,7 @@ /** * 8,2,2,2 Nissan pattern */ -static void initializeNissanSR20VE_4_optional_360(TriggerShape *s, bool with2nd) { +static void initializeNissanSR20VE_4_optional_360(TriggerWaveform *s, bool with2nd) { s->initialize(FOUR_STROKE_CAM_SENSOR, with2nd); s->isSynchronizationNeeded = true; s->gapBothDirections = true; @@ -99,10 +99,10 @@ static void initializeNissanSR20VE_4_optional_360(TriggerShape *s, bool with2nd) * Nissan Primera p11 year 1995-2002 */ -void initializeNissanSR20VE_4(TriggerShape *s) { +void initializeNissanSR20VE_4(TriggerWaveform *s) { initializeNissanSR20VE_4_optional_360(s, false); } -void initializeNissanSR20VE_4_360(TriggerShape *s) { +void initializeNissanSR20VE_4_360(TriggerWaveform *s) { initializeNissanSR20VE_4_optional_360(s, true); } diff --git a/firmware/controllers/trigger/decoders/trigger_nissan.h b/firmware/controllers/trigger/decoders/trigger_nissan.h index bc5d76bb90..dcfdf85f3b 100644 --- a/firmware/controllers/trigger/decoders/trigger_nissan.h +++ b/firmware/controllers/trigger/decoders/trigger_nissan.h @@ -10,7 +10,7 @@ #include "trigger_structure.h" -void initializeNissanSR20VE_4(TriggerShape *s); -void initializeNissanSR20VE_4_360(TriggerShape *s); +void initializeNissanSR20VE_4(TriggerWaveform *s); +void initializeNissanSR20VE_4_360(TriggerWaveform *s); #endif /* CONTROLLERS_TRIGGER_TRIGGER_NISSAN_H_ */ diff --git a/firmware/controllers/trigger/decoders/trigger_rover.cpp b/firmware/controllers/trigger/decoders/trigger_rover.cpp index 8974cadad4..8535653fc4 100644 --- a/firmware/controllers/trigger/decoders/trigger_rover.cpp +++ b/firmware/controllers/trigger/decoders/trigger_rover.cpp @@ -11,7 +11,7 @@ /** * https://en.wikipedia.org/wiki/Rover_K-series_engine */ -void initializeRoverK(TriggerShape *s) { +void initializeRoverK(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CRANK_SENSOR, false); float tooth = 20; diff --git a/firmware/controllers/trigger/decoders/trigger_rover.h b/firmware/controllers/trigger/decoders/trigger_rover.h index b057770229..5fc9f92dff 100644 --- a/firmware/controllers/trigger/decoders/trigger_rover.h +++ b/firmware/controllers/trigger/decoders/trigger_rover.h @@ -11,6 +11,6 @@ #include "trigger_structure.h" -void initializeRoverK(TriggerShape *s); +void initializeRoverK(TriggerWaveform *s); #endif /* CONTROLLERS_TRIGGER_TRIGGER_ROVER_H_ */ diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index 7fdd9615f1..2a885c3ff5 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -47,7 +47,7 @@ EXTERN_ENGINE; void event_trigger_position_s::setAngle(angle_t angle DECLARE_ENGINE_PARAMETER_SUFFIX) { - TRIGGER_SHAPE(findTriggerPosition(this, angle PASS_CONFIG_PARAM(engineConfiguration->globalTriggerAngleOffset))); + TRIGGER_WAVEFORM(findTriggerPosition(this, angle PASS_CONFIG_PARAM(engineConfiguration->globalTriggerAngleOffset))); } trigger_shape_helper::trigger_shape_helper() { @@ -57,7 +57,7 @@ trigger_shape_helper::trigger_shape_helper() { } } -TriggerShape::TriggerShape() : +TriggerWaveform::TriggerWaveform() : wave(switchTimesBuffer, NULL) { initialize(OM_NONE, false); wave.channels = h.channels; @@ -65,7 +65,7 @@ TriggerShape::TriggerShape() : memset(triggerIndexByAngle, 0, sizeof(triggerIndexByAngle)); } -void TriggerShape::initialize(operation_mode_e operationMode, bool needSecondTriggerInput) { +void TriggerWaveform::initialize(operation_mode_e operationMode, bool needSecondTriggerInput) { isSynchronizationNeeded = true; // that's default value bothFrontsRequired = false; this->needSecondTriggerInput = needSecondTriggerInput; @@ -101,18 +101,18 @@ void TriggerShape::initialize(operation_mode_e operationMode, bool needSecondTri #endif } -int TriggerShape::getSize() const { +int TriggerWaveform::getSize() const { return privateTriggerDefinitionSize; } -int TriggerShape::getTriggerShapeSynchPointIndex() const { +int TriggerWaveform::getTriggerWaveformSynchPointIndex() const { return triggerShapeSynchPointIndex; } /** * physical primary trigger duration */ -angle_t TriggerShape::getCycleDuration() const { +angle_t TriggerWaveform::getCycleDuration() const { switch (operationMode) { case FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR: return 180; @@ -128,7 +128,7 @@ angle_t TriggerShape::getCycleDuration() const { * Trigger event count equals engine cycle event count if we have a cam sensor. * Two trigger cycles make one engine cycle in case of a four stroke engine If we only have a cranksensor. */ -uint32_t TriggerShape::getLength() const { +uint32_t TriggerWaveform::getLength() const { /** * 4 for FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR * 2 for FOUR_STROKE_CRANK_SENSOR @@ -138,7 +138,7 @@ uint32_t TriggerShape::getLength() const { return multiplier * getSize(); } -angle_t TriggerShape::getAngle(int index) const { +angle_t TriggerWaveform::getAngle(int index) const { // todo: why is this check here? looks like the code below could be used universally if (operationMode == FOUR_STROKE_CAM_SENSOR) { return getSwitchAngle(index); @@ -156,7 +156,7 @@ angle_t TriggerShape::getAngle(int index) const { return getCycleDuration() * crankCycle + getSwitchAngle(remainder); } -void TriggerShape::addEventClamped(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const stateParam, float filterLeft, float filterRight) { +void TriggerWaveform::addEventClamped(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const stateParam, float filterLeft, float filterRight) { if (angle > filterLeft && angle < filterRight) { #if EFI_UNIT_TEST // printf("addEventClamped %f %s\r\n", angle, getTrigger_value_e(stateParam)); @@ -165,7 +165,7 @@ void TriggerShape::addEventClamped(angle_t angle, trigger_wheel_e const channelI } } -operation_mode_e TriggerShape::getOperationMode() const { +operation_mode_e TriggerWaveform::getOperationMode() const { return operationMode; } @@ -173,7 +173,7 @@ operation_mode_e TriggerShape::getOperationMode() const { extern bool printTriggerDebug; #endif -void TriggerShape::calculateExpectedEventCounts(bool useOnlyRisingEdgeForTrigger) { +void TriggerWaveform::calculateExpectedEventCounts(bool useOnlyRisingEdgeForTrigger) { UNUSED(useOnlyRisingEdgeForTrigger); // todo: move the following logic from below here // if (!useOnlyRisingEdgeForTrigger || stateParam == TV_RISE) { @@ -182,11 +182,11 @@ void TriggerShape::calculateExpectedEventCounts(bool useOnlyRisingEdgeForTrigger } -void TriggerShape::addEvent720(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const stateParam) { +void TriggerWaveform::addEvent720(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const stateParam) { addEvent(angle / 720, channelIndex, stateParam); } -void TriggerShape::addEvent(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const stateParam) { +void TriggerWaveform::addEvent(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const stateParam) { efiAssertVoid(CUSTOM_OMODE_UNDEF, operationMode != OM_NONE, "operationMode not set"); efiAssertVoid(CUSTOM_ERR_6598, channelIndex!= T_SECONDARY || needSecondTriggerInput, "secondary needed or not?"); @@ -283,26 +283,26 @@ void TriggerShape::addEvent(angle_t angle, trigger_wheel_e const channelIndex, t wave.channels[channelIndex].setState(index, state); } -angle_t TriggerShape::getSwitchAngle(int index) const { +angle_t TriggerWaveform::getSwitchAngle(int index) const { return getCycleDuration() * wave.getSwitchTime(index); } -void setToothedWheelConfiguration(TriggerShape *s, int total, int skipped, +void setToothedWheelConfiguration(TriggerWaveform *s, int total, int skipped, operation_mode_e operationMode) { #if EFI_ENGINE_CONTROL s->useRiseEdge = true; - initializeSkippedToothTriggerShapeExt(s, total, skipped, + initializeSkippedToothTriggerWaveformExt(s, total, skipped, operationMode); #endif } -void TriggerShape::setTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo) { +void TriggerWaveform::setTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo) { setTriggerSynchronizationGap3(/*gapIndex*/0, syncRatioFrom, syncRatioTo); } -void TriggerShape::setTriggerSynchronizationGap3(int gapIndex, float syncRatioFrom, float syncRatioTo) { +void TriggerWaveform::setTriggerSynchronizationGap3(int gapIndex, float syncRatioFrom, float syncRatioTo) { isSynchronizationNeeded = true; this->syncronizationRatioFrom[gapIndex] = syncRatioFrom; this->syncronizationRatioTo[gapIndex] = syncRatioTo; @@ -322,7 +322,7 @@ void TriggerShape::setTriggerSynchronizationGap3(int gapIndex, float syncRatioFr /** * this method is only used on initialization */ -int TriggerShape::findAngleIndex(float target) const { +int TriggerWaveform::findAngleIndex(float target) const { int engineCycleEventCount = getLength(); efiAssert(CUSTOM_ERR_ASSERT, engineCycleEventCount > 0, "engineCycleEventCount", 0); @@ -350,11 +350,11 @@ int TriggerShape::findAngleIndex(float target) const { return left - 1; } -void TriggerShape::setShapeDefinitionError(bool value) { +void TriggerWaveform::setShapeDefinitionError(bool value) { shapeDefinitionError = value; } -void TriggerShape::findTriggerPosition(event_trigger_position_s *position, +void TriggerWaveform::findTriggerPosition(event_trigger_position_s *position, angle_t angle DEFINE_CONFIG_PARAM(angle_t, globalTriggerAngleOffset)) { efiAssertVoid(CUSTOM_ERR_6574, !cisnan(angle), "findAngle#1"); assertAngleRange(angle, "findAngle#a1", CUSTOM_ERR_6545); @@ -381,7 +381,7 @@ void TriggerShape::findTriggerPosition(event_trigger_position_s *position, position->angleOffsetFromTriggerEvent = angle - triggerEventAngle; } -void TriggerShape::prepareShape() { +void TriggerWaveform::prepareShape() { #if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT int engineCycleInt = (int) getEngineCycle(operationMode); for (int angle = 0; angle < engineCycleInt; angle++) { @@ -395,19 +395,19 @@ void TriggerShape::prepareShape() { #endif } -void TriggerShape::setTriggerSynchronizationGap(float syncRatio) { +void TriggerWaveform::setTriggerSynchronizationGap(float syncRatio) { setTriggerSynchronizationGap3(/*gapIndex*/0, syncRatio * 0.75f, syncRatio * 1.25f); } -void TriggerShape::setSecondTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo) { +void TriggerWaveform::setSecondTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo) { setTriggerSynchronizationGap3(/*gapIndex*/1, syncRatioFrom, syncRatioTo); } -void TriggerShape::setThirdTriggerSynchronizationGap(float syncRatio) { +void TriggerWaveform::setThirdTriggerSynchronizationGap(float syncRatio) { setTriggerSynchronizationGap3(/*gapIndex*/2, syncRatio * 0.75f, syncRatio * 1.25f); } -void TriggerShape::setSecondTriggerSynchronizationGap(float syncRatio) { +void TriggerWaveform::setSecondTriggerSynchronizationGap(float syncRatio) { setTriggerSynchronizationGap3(/*gapIndex*/1, syncRatio * 0.75f, syncRatio * 1.25f); } @@ -415,11 +415,11 @@ void TriggerShape::setSecondTriggerSynchronizationGap(float syncRatio) { /** * External logger is needed because at this point our logger is not yet initialized */ -void TriggerShape::initializeTriggerShape(Logging *logger, operation_mode_e ambiguousOperationMode, bool useOnlyRisingEdgeForTrigger, const trigger_config_s *triggerConfig) { +void TriggerWaveform::initializeTriggerWaveform(Logging *logger, operation_mode_e ambiguousOperationMode, bool useOnlyRisingEdgeForTrigger, const trigger_config_s *triggerConfig) { #if EFI_PROD_CODE efiAssertVoid(CUSTOM_ERR_6641, getCurrentRemainingStack() > 256, "init t"); - scheduleMsg(logger, "initializeTriggerShape(%s/%d)", getTrigger_type_e(triggerConfig->type), (int) triggerConfig->type); + scheduleMsg(logger, "initializeTriggerWaveform(%s/%d)", getTrigger_type_e(triggerConfig->type), (int) triggerConfig->type); #endif shapeDefinitionError = false; @@ -429,7 +429,7 @@ void TriggerShape::initializeTriggerShape(Logging *logger, operation_mode_e ambi switch (triggerConfig->type) { case TT_TOOTHED_WHEEL: - initializeSkippedToothTriggerShapeExt(this, triggerConfig->customTotalToothCount, + initializeSkippedToothTriggerWaveformExt(this, triggerConfig->customTotalToothCount, triggerConfig->customSkippedToothCount, ambiguousOperationMode); break; @@ -454,32 +454,32 @@ void TriggerShape::initializeTriggerShape(Logging *logger, operation_mode_e ambi break; case TT_DODGE_NEON_1995: - configureNeon1995TriggerShape(this); + configureNeon1995TriggerWaveform(this); break; case TT_DODGE_NEON_1995_ONLY_CRANK: - configureNeon1995TriggerShapeOnlyCrank(this); + configureNeon1995TriggerWaveformOnlyCrank(this); break; case TT_DODGE_STRATUS: - configureDodgeStratusTriggerShape(this); + configureDodgeStratusTriggerWaveform(this); break; case TT_DODGE_NEON_2003_CAM: - configureNeon2003TriggerShapeCam(this); + configureNeon2003TriggerWaveformCam(this); break; case TT_DODGE_NEON_2003_CRANK: - configureNeon2003TriggerShapeCam(this); -// configureNeon2003TriggerShapeCrank(triggerShape); + configureNeon2003TriggerWaveformCam(this); +// configureNeon2003TriggerWaveformCrank(triggerShape); break; case TT_FORD_ASPIRE: - configureFordAspireTriggerShape(this); + configureFordAspireTriggerWaveform(this); break; case TT_GM_7X: - configureGmTriggerShape(this); + configureGmTriggerWaveform(this); break; case TT_MAZDA_DOHC_1_4: @@ -507,7 +507,7 @@ void TriggerShape::initializeTriggerShape(Logging *logger, operation_mode_e ambi break; case TT_MINI_COOPER_R50: - configureMiniCooperTriggerShape(this); + configureMiniCooperTriggerWaveform(this); break; case TT_TOOTHED_WHEEL_60_2: @@ -604,7 +604,7 @@ void TriggerShape::initializeTriggerShape(Logging *logger, operation_mode_e ambi default: setShapeDefinitionError(true); - warning(CUSTOM_ERR_NO_SHAPE, "initializeTriggerShape() not implemented: %d", triggerConfig->type); + warning(CUSTOM_ERR_NO_SHAPE, "initializeTriggerWaveform() not implemented: %d", triggerConfig->type); } /** * Feb 2019 suggestion: it would be an improvement to remove 'expectedEventCount' logic from 'addEvent' diff --git a/firmware/controllers/trigger/decoders/trigger_structure.h b/firmware/controllers/trigger/decoders/trigger_structure.h index a8d553a113..6176e011d8 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.h +++ b/firmware/controllers/trigger/decoders/trigger_structure.h @@ -72,10 +72,10 @@ class TriggerState; * @brief Trigger shape has all the fields needed to describe and decode trigger signal. * @see TriggerState for trigger decoder state which works based on this trigger shape model */ -class TriggerShape { +class TriggerWaveform { public: - TriggerShape(); - void initializeTriggerShape(Logging *logger, operation_mode_e ambiguousOperationMode, + TriggerWaveform(); + void initializeTriggerWaveform(Logging *logger, operation_mode_e ambiguousOperationMode, bool useOnlyRisingEdgeForTrigger, const trigger_config_s *triggerConfig); void findTriggerPosition(event_trigger_position_s *position, angle_t angle DEFINE_CONFIG_PARAM(angle_t, globalTriggerAngleOffset)); @@ -240,7 +240,7 @@ public: uint32_t getLength() const; int getSize() const; - int getTriggerShapeSynchPointIndex() const; + int getTriggerWaveformSynchPointIndex() const; void prepareShape(); /** @@ -250,7 +250,7 @@ public: angle_t getAngle(int phaseIndex) const; /** - * index of synchronization event within TriggerShape + * index of synchronization event within TriggerWaveform * See findTriggerZeroEventIndex() */ int triggerShapeSynchPointIndex; @@ -283,8 +283,8 @@ private: angle_t getCycleDuration() const; }; -void setToothedWheelConfiguration(TriggerShape *s, int total, int skipped, operation_mode_e operationMode); +void setToothedWheelConfiguration(TriggerWaveform *s, int total, int skipped, operation_mode_e operationMode); -#define TRIGGER_SHAPE(x) ENGINE(triggerCentral.triggerShape.x) +#define TRIGGER_WAVEFORM(x) ENGINE(triggerCentral.triggerShape.x) -#define getTriggerSize() TRIGGER_SHAPE(privateTriggerDefinitionSize) +#define getTriggerSize() TRIGGER_WAVEFORM(privateTriggerDefinitionSize) diff --git a/firmware/controllers/trigger/decoders/trigger_subaru.cpp b/firmware/controllers/trigger/decoders/trigger_subaru.cpp index 9286d2885e..08f25fdb07 100644 --- a/firmware/controllers/trigger/decoders/trigger_subaru.cpp +++ b/firmware/controllers/trigger/decoders/trigger_subaru.cpp @@ -10,7 +10,7 @@ /** * This trigger is also used by Nissan and Mazda */ -void initialize36_2_2_2(TriggerShape *s) { +void initialize36_2_2_2(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); float wide = 30 * 2; @@ -46,7 +46,7 @@ void initialize36_2_2_2(TriggerShape *s) { s->useOnlyPrimaryForSync = true; } -void initializeSubaru7_6(TriggerShape *s) { +void initializeSubaru7_6(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); float magic = 333; diff --git a/firmware/controllers/trigger/decoders/trigger_subaru.h b/firmware/controllers/trigger/decoders/trigger_subaru.h index 12adf5da55..f82b1fce6c 100644 --- a/firmware/controllers/trigger/decoders/trigger_subaru.h +++ b/firmware/controllers/trigger/decoders/trigger_subaru.h @@ -10,7 +10,7 @@ #include "trigger_structure.h" -void initialize36_2_2_2(TriggerShape *s); -void initializeSubaru7_6(TriggerShape *s); +void initialize36_2_2_2(TriggerWaveform *s); +void initializeSubaru7_6(TriggerWaveform *s); #endif /* CONTROLLERS_TRIGGER_TRIGGER_SUBARU_H_ */ diff --git a/firmware/controllers/trigger/decoders/trigger_toyota.cpp b/firmware/controllers/trigger/decoders/trigger_toyota.cpp index 68e44d47b1..37e36ffbd9 100644 --- a/firmware/controllers/trigger/decoders/trigger_toyota.cpp +++ b/firmware/controllers/trigger/decoders/trigger_toyota.cpp @@ -9,7 +9,7 @@ #include "trigger_toyota.h" -void initialize2jzGE1_12(TriggerShape *s) { +void initialize2jzGE1_12(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); float crankD = 360 / 12 / 2; // 15 @@ -43,7 +43,7 @@ void initialize2jzGE1_12(TriggerShape *s) { s->isSynchronizationNeeded = false; } -void initialize2jzGE3_34(TriggerShape *s) { +void initialize2jzGE3_34(TriggerWaveform *s) { setToothedWheelConfiguration(s, 36, 2, FOUR_STROKE_CRANK_SENSOR); // s->initialize(FOUR_STROKE_CAM_SENSOR, true); diff --git a/firmware/controllers/trigger/decoders/trigger_toyota.h b/firmware/controllers/trigger/decoders/trigger_toyota.h index 8b29734398..90fc7cd347 100644 --- a/firmware/controllers/trigger/decoders/trigger_toyota.h +++ b/firmware/controllers/trigger/decoders/trigger_toyota.h @@ -10,7 +10,7 @@ #include "trigger_structure.h" -void initialize2jzGE1_12(TriggerShape *s); -void initialize2jzGE3_34(TriggerShape *s); +void initialize2jzGE1_12(TriggerWaveform *s); +void initialize2jzGE3_34(TriggerWaveform *s); #endif /* CONTROLLERS_TRIGGER_TRIGGER_TOYOTA_H_ */ diff --git a/firmware/controllers/trigger/decoders/trigger_universal.cpp b/firmware/controllers/trigger/decoders/trigger_universal.cpp index 952e243506..3cf56f5957 100644 --- a/firmware/controllers/trigger/decoders/trigger_universal.cpp +++ b/firmware/controllers/trigger/decoders/trigger_universal.cpp @@ -11,7 +11,7 @@ angle_t getEngineCycle(operation_mode_e operationMode) { return operationMode == TWO_STROKE ? 360 : FOUR_STROKE_ENGINE_CYCLE; } -void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s, int totalTeethCount, int skippedCount, +void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerWaveform *s, int totalTeethCount, int skippedCount, float toothWidth, float offset, float engineCycle, float filterLeft, float filterRight) { efiAssertVoid(CUSTOM_ERR_6586, totalTeethCount > 0, "total count"); efiAssertVoid(CUSTOM_ERR_6587, skippedCount >= 0, "skipped count"); @@ -28,14 +28,14 @@ void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s, int to s->addEventClamped(offset + engineCycle, wheel, TV_FALL, filterLeft, filterRight); } -void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount, int skippedCount, +void initializeSkippedToothTriggerWaveformExt(TriggerWaveform *s, int totalTeethCount, int skippedCount, operation_mode_e operationMode) { if (totalTeethCount <= 0) { - warning(CUSTOM_OBD_TRIGGER_SHAPE, "totalTeethCount is zero or less: %d", totalTeethCount); + warning(CUSTOM_OBD_TRIGGER_WAVEFORM, "totalTeethCount is zero or less: %d", totalTeethCount); s->setShapeDefinitionError(true); return; } - efiAssertVoid(CUSTOM_NULL_SHAPE, s != NULL, "TriggerShape is NULL"); + efiAssertVoid(CUSTOM_NULL_SHAPE, s != NULL, "TriggerWaveform is NULL"); s->initialize(operationMode, false); s->setTriggerSynchronizationGap(skippedCount + 1); @@ -46,7 +46,7 @@ void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount, } -void configureOnePlusOne(TriggerShape *s, operation_mode_e operationMode) { +void configureOnePlusOne(TriggerWaveform *s, operation_mode_e operationMode) { UNUSED(operationMode); s->initialize(FOUR_STROKE_CAM_SENSOR, true); @@ -60,7 +60,7 @@ void configureOnePlusOne(TriggerShape *s, operation_mode_e operationMode) { s->useOnlyPrimaryForSync = true; } -void configureOnePlus60_2(TriggerShape *s, operation_mode_e operationMode) { +void configureOnePlus60_2(TriggerWaveform *s, operation_mode_e operationMode) { UNUSED(operationMode); s->initialize(FOUR_STROKE_CAM_SENSOR, true); @@ -79,7 +79,7 @@ void configureOnePlus60_2(TriggerShape *s, operation_mode_e operationMode) { s->useOnlyPrimaryForSync = true; } -void configure3_1_cam(TriggerShape *s, operation_mode_e operationMode) { +void configure3_1_cam(TriggerWaveform *s, operation_mode_e operationMode) { UNUSED(operationMode); s->initialize(FOUR_STROKE_CAM_SENSOR, true); diff --git a/firmware/controllers/trigger/decoders/trigger_universal.h b/firmware/controllers/trigger/decoders/trigger_universal.h index b5ffd92a92..c40db80179 100644 --- a/firmware/controllers/trigger/decoders/trigger_universal.h +++ b/firmware/controllers/trigger/decoders/trigger_universal.h @@ -14,17 +14,17 @@ #define NO_LEFT_FILTER -1 #define NO_RIGHT_FILTER 1000 -void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s, +void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerWaveform *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);; +void initializeSkippedToothTriggerWaveformExt(TriggerWaveform *s, int totalTeethCount, int skippedCount, operation_mode_e operationMode);; -void configureOnePlus60_2(TriggerShape *s, operation_mode_e operationMode); +void configureOnePlus60_2(TriggerWaveform *s, operation_mode_e operationMode); -void configure3_1_cam(TriggerShape *s, operation_mode_e operationMode); +void configure3_1_cam(TriggerWaveform *s, operation_mode_e operationMode); -void configureOnePlusOne(TriggerShape *s, operation_mode_e operationMode); +void configureOnePlusOne(TriggerWaveform *s, operation_mode_e operationMode); #endif /* CONTROLLERS_TRIGGER_DECODERS_TRIGGER_UNIVERSAL_H_ */ diff --git a/firmware/controllers/trigger/decoders/trigger_vw.cpp b/firmware/controllers/trigger/decoders/trigger_vw.cpp index ef92ce973b..53d0db2cb7 100644 --- a/firmware/controllers/trigger/decoders/trigger_vw.cpp +++ b/firmware/controllers/trigger/decoders/trigger_vw.cpp @@ -8,8 +8,8 @@ #include "trigger_vw.h" #include "trigger_universal.h" -void setVwConfiguration(TriggerShape *s) { - efiAssertVoid(CUSTOM_ERR_6660, s != NULL, "TriggerShape is NULL"); +void setVwConfiguration(TriggerWaveform *s) { + efiAssertVoid(CUSTOM_ERR_6660, s != NULL, "TriggerWaveform is NULL"); s->initialize(FOUR_STROKE_CRANK_SENSOR, false); diff --git a/firmware/controllers/trigger/decoders/trigger_vw.h b/firmware/controllers/trigger/decoders/trigger_vw.h index 7ae70a39fd..3dcbb2ed23 100644 --- a/firmware/controllers/trigger/decoders/trigger_vw.h +++ b/firmware/controllers/trigger/decoders/trigger_vw.h @@ -10,6 +10,6 @@ #include "trigger_structure.h" -void setVwConfiguration(TriggerShape *s); +void setVwConfiguration(TriggerWaveform *s); #endif /* CONTROLLERS_TRIGGER_DECODERS_TRIGGER_VW_H_ */ diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index 444d058bdf..647a3ee6c1 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -497,7 +497,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D engine->ignitionEvents.isReady = false; // we need to rebuild complete ignition schedule engine->injectionEvents.isReady = false; // moved 'triggerIndexByAngle' into trigger initialization (why was it invoked from here if it's only about trigger shape & optimization?) - // see initializeTriggerShape() -> prepareOutputSignals(PASS_ENGINE_PARAMETER_SIGNATURE) + // see initializeTriggerWaveform() -> prepareOutputSignals(PASS_ENGINE_PARAMETER_SIGNATURE) // we need this to apply new 'triggerIndexByAngle' values engine->periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE); diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 0adecf84a5..71ab35c636 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -290,12 +290,12 @@ bool TriggerCentral::noiseFilter(efitick_t nowNt, trigger_event_e signal DECLARE efitick_t allowedPeriod = accumSignalPrevPeriods[os]; // but first check if we're expecting a gap - bool isGapExpected = TRIGGER_SHAPE(isSynchronizationNeeded) && triggerState.shaft_is_synchronized && - (triggerState.currentCycle.eventCount[ti] + 1) == TRIGGER_SHAPE(expectedEventCount[ti]); + bool isGapExpected = TRIGGER_WAVEFORM(isSynchronizationNeeded) && triggerState.shaft_is_synchronized && + (triggerState.currentCycle.eventCount[ti] + 1) == TRIGGER_WAVEFORM(expectedEventCount[ti]); if (isGapExpected) { // usually we need to extend the period for gaps, based on the trigger info - allowedPeriod *= TRIGGER_SHAPE(syncRatioAvg); + allowedPeriod *= TRIGGER_WAVEFORM(syncRatioAvg); } // also we need some margin for rapidly changing trigger-wheel speed, @@ -430,9 +430,9 @@ EXTERN_ENGINE static void triggerShapeInfo(void) { #if EFI_PROD_CODE || EFI_SIMULATOR - TriggerShape *s = &engine->triggerCentral.triggerShape; - scheduleMsg(logger, "useRise=%s", boolToString(TRIGGER_SHAPE(useRiseEdge))); - scheduleMsg(logger, "gap from %.2f to %.2f", TRIGGER_SHAPE(syncronizationRatioFrom[0]), TRIGGER_SHAPE(syncronizationRatioTo[0])); + TriggerWaveform *s = &engine->triggerCentral.triggerShape; + scheduleMsg(logger, "useRise=%s", boolToString(TRIGGER_WAVEFORM(useRiseEdge))); + scheduleMsg(logger, "gap from %.2f to %.2f", TRIGGER_WAVEFORM(syncronizationRatioFrom[0]), TRIGGER_WAVEFORM(syncronizationRatioTo[0])); for (int i = 0; i < s->getSize(); i++) { scheduleMsg(logger, "event %d %.2f", i, s->eventAngles[i]); @@ -474,8 +474,8 @@ void printAllTriggers() { engineConfiguration->trigger.type = tt; engineConfiguration->ambiguousOperationMode = FOUR_STROKE_CAM_SENSOR; - TriggerShape *s = &engine->triggerCentral.triggerShape; - engine->eInitializeTriggerShape(NULL PASS_ENGINE_PARAMETER_SUFFIX); + TriggerWaveform *s = &engine->triggerCentral.triggerShape; + engine->initializeTriggerWaveform(NULL PASS_ENGINE_PARAMETER_SUFFIX); if (s->shapeDefinitionError) { printf("Trigger error %d\r\n", triggerId); @@ -488,7 +488,7 @@ void printAllTriggers() { for (int i = 0; i < s->getLength(); i++) { - int triggerDefinitionCoordinate = (s->getTriggerShapeSynchPointIndex() + i) % s->getSize(); + int triggerDefinitionCoordinate = (s->getTriggerWaveformSynchPointIndex() + i) % s->getSize(); fprintf(fp, "event %d %d %.2f\n", i, s->triggerSignals[triggerDefinitionCoordinate], s->eventAngles[i]); @@ -546,7 +546,7 @@ extern int icuWidthPeriodCounter; void triggerInfo(void) { #if EFI_PROD_CODE || EFI_SIMULATOR - TriggerShape *ts = &engine->triggerCentral.triggerShape; + TriggerWaveform *ts = &engine->triggerCentral.triggerShape; #if (HAL_TRIGGER_USE_PAL == TRUE) && (PAL_USE_CALLBACKS == TRUE) @@ -562,8 +562,8 @@ void triggerInfo(void) { scheduleMsg(logger, "Template %s (%d) trigger %s (%d) useRiseEdge=%s onlyFront=%s useOnlyFirstChannel=%s tdcOffset=%.2f", getConfigurationName(engineConfiguration->engineType), engineConfiguration->engineType, getTrigger_type_e(engineConfiguration->trigger.type), engineConfiguration->trigger.type, - boolToString(TRIGGER_SHAPE(useRiseEdge)), boolToString(engineConfiguration->useOnlyRisingEdgeForTrigger), - boolToString(engineConfiguration->trigger.useOnlyFirstChannel), TRIGGER_SHAPE(tdcPosition)); + boolToString(TRIGGER_WAVEFORM(useRiseEdge)), boolToString(engineConfiguration->useOnlyRisingEdgeForTrigger), + boolToString(engineConfiguration->trigger.useOnlyFirstChannel), TRIGGER_WAVEFORM(tdcPosition)); if (engineConfiguration->trigger.type == TT_TOOTHED_WHEEL) { scheduleMsg(logger, "total %d/skipped %d", engineConfiguration->trigger.customTotalToothCount, @@ -577,12 +577,12 @@ void triggerInfo(void) { scheduleMsg(logger, "trigger#2 event counters up=%d/down=%d", engine->triggerCentral.getHwEventCounter(2), engine->triggerCentral.getHwEventCounter(3)); } - scheduleMsg(logger, "expected cycle events %d/%d/%d", TRIGGER_SHAPE(expectedEventCount[0]), - TRIGGER_SHAPE(expectedEventCount[1]), TRIGGER_SHAPE(expectedEventCount[2])); + scheduleMsg(logger, "expected cycle events %d/%d/%d", TRIGGER_WAVEFORM(expectedEventCount[0]), + TRIGGER_WAVEFORM(expectedEventCount[1]), TRIGGER_WAVEFORM(expectedEventCount[2])); scheduleMsg(logger, "trigger type=%d/need2ndChannel=%s", engineConfiguration->trigger.type, - boolToString(TRIGGER_SHAPE(needSecondTriggerInput))); - scheduleMsg(logger, "expected duty #0=%.2f/#1=%.2f", TRIGGER_SHAPE(expectedDutyCycle[0]), TRIGGER_SHAPE(expectedDutyCycle[1])); + boolToString(TRIGGER_WAVEFORM(needSecondTriggerInput))); + scheduleMsg(logger, "expected duty #0=%.2f/#1=%.2f", TRIGGER_WAVEFORM(expectedDutyCycle[0]), TRIGGER_WAVEFORM(expectedDutyCycle[1])); scheduleMsg(logger, "synchronizationNeeded=%s/isError=%s/total errors=%d ord_err=%d/total revolutions=%d/self=%s", boolToString(ts->isSynchronizationNeeded), @@ -590,8 +590,8 @@ void triggerInfo(void) { engine->triggerCentral.triggerState.orderingErrorCounter, engine->triggerCentral.triggerState.getTotalRevolutionCounter(), boolToString(engineConfiguration->directSelfStimulation)); - if (TRIGGER_SHAPE(isSynchronizationNeeded)) { - scheduleMsg(logger, "gap from %.2f to %.2f", TRIGGER_SHAPE(syncronizationRatioFrom[0]), TRIGGER_SHAPE(syncronizationRatioTo[0])); + if (TRIGGER_WAVEFORM(isSynchronizationNeeded)) { + scheduleMsg(logger, "gap from %.2f to %.2f", TRIGGER_WAVEFORM(syncronizationRatioFrom[0]), TRIGGER_WAVEFORM(syncronizationRatioTo[0])); } #endif /* EFI_PROD_CODE || EFI_SIMULATOR */ @@ -699,7 +699,7 @@ void onConfigurationChangeTriggerCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { assertEngineReference(); #if EFI_ENGINE_CONTROL - ENGINE(eInitializeTriggerShape(logger PASS_ENGINE_PARAMETER_SUFFIX)); + ENGINE(initializeTriggerWaveform(logger PASS_ENGINE_PARAMETER_SUFFIX)); engine->triggerCentral.resetAccumSignalData(); #endif } diff --git a/firmware/controllers/trigger/trigger_central.h b/firmware/controllers/trigger/trigger_central.h index 375336da81..792feb997c 100644 --- a/firmware/controllers/trigger/trigger_central.h +++ b/firmware/controllers/trigger/trigger_central.h @@ -41,7 +41,7 @@ public: */ efitick_t timeAtVirtualZeroNt = 0; - TriggerShape triggerShape; + TriggerWaveform triggerShape; efitick_t previousVvtCamTime = 0; efitick_t previousVvtCamDuration = 0; diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index d6d557a3ab..da07d6816b 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -120,7 +120,7 @@ bool isTriggerDecoderError(void) { return errorDetection.sum(6) > 4; } -void calculateTriggerSynchPoint(TriggerShape *shape, TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX) { +void calculateTriggerSynchPoint(TriggerWaveform *shape, TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX) { #if EFI_PROD_CODE efiAssertVoid(CUSTOM_ERR_6642, getCurrentRemainingStack() > 256, "calc s"); #endif @@ -132,7 +132,7 @@ void calculateTriggerSynchPoint(TriggerShape *shape, TriggerState *state DECLARE engine->engineCycleEventCount = length; efiAssertVoid(CUSTOM_SHAPE_LEN_ZERO, length > 0, "shapeLength=0"); if (length >= PWM_PHASE_MAX_COUNT) { - warning(CUSTOM_ERR_TRIGGER_SHAPE_TOO_LONG, "Count above %d", length); + warning(CUSTOM_ERR_TRIGGER_WAVEFORM_TOO_LONG, "Count above %d", length); shape->setShapeDefinitionError(true); return; } @@ -194,7 +194,7 @@ float TriggerStateWithRunningStatistics::calculateInstantRpm(int *prevIndexOut, /** * Here we calculate RPM based on last 90 degrees */ - angle_t currentAngle = TRIGGER_SHAPE(eventAngles[current_index]); + angle_t currentAngle = TRIGGER_WAVEFORM(eventAngles[current_index]); // todo: make this '90' depend on cylinder count or trigger shape? if (cisnan(currentAngle)) { return NOISY_RPM; @@ -202,14 +202,14 @@ float TriggerStateWithRunningStatistics::calculateInstantRpm(int *prevIndexOut, angle_t previousAngle = currentAngle - 90; fixAngle(previousAngle, "prevAngle", CUSTOM_ERR_TRIGGER_ANGLE_RANGE); // todo: prevIndex should be pre-calculated - int prevIndex = TRIGGER_SHAPE(triggerIndexByAngle[(int)previousAngle]); + int prevIndex = TRIGGER_WAVEFORM(triggerIndexByAngle[(int)previousAngle]); if (prevIndexOut != NULL) { *prevIndexOut = prevIndex; } // now let's get precise angle for that event - angle_t prevIndexAngle = TRIGGER_SHAPE(eventAngles[prevIndex]); + angle_t prevIndexAngle = TRIGGER_WAVEFORM(eventAngles[prevIndex]); efitick_t time90ago = timeOfLastEvent[prevIndex]; if (time90ago == 0) { return prevInstantRpmValue; @@ -259,7 +259,7 @@ void TriggerStateWithRunningStatistics::runtimeStatistics(efitime_t nowNt DECLAR instantRpm = calculateInstantRpm(&prevIndex, nowNt PASS_ENGINE_PARAMETER_SUFFIX); #if EFI_SENSOR_CHART - angle_t currentAngle = TRIGGER_SHAPE(eventAngles[currentCycle.current_index]); + angle_t currentAngle = TRIGGER_WAVEFORM(eventAngles[currentCycle.current_index]); if (CONFIGB(sensorChartMode) == SC_DETAILED_RPM) { scAddData(currentAngle, instantRpm); } else { @@ -303,10 +303,10 @@ static trigger_value_e eventType[6] = { TV_FALL, TV_RISE, TV_FALL, TV_RISE, TV_F PRINT_INC_INDEX; \ } -#define considerEventForGap() (!TRIGGER_SHAPE(useOnlyPrimaryForSync) || isPrimary) +#define considerEventForGap() (!TRIGGER_WAVEFORM(useOnlyPrimaryForSync) || isPrimary) -#define needToSkipFall(type) ((!TRIGGER_SHAPE(gapBothDirections)) && (( TRIGGER_SHAPE(useRiseEdge)) && (type != TV_RISE))) -#define needToSkipRise(type) ((!TRIGGER_SHAPE(gapBothDirections)) && ((!TRIGGER_SHAPE(useRiseEdge)) && (type != TV_FALL))) +#define needToSkipFall(type) ((!TRIGGER_WAVEFORM(gapBothDirections)) && (( TRIGGER_WAVEFORM(useRiseEdge)) && (type != TV_RISE))) +#define needToSkipRise(type) ((!TRIGGER_WAVEFORM(gapBothDirections)) && ((!TRIGGER_WAVEFORM(useRiseEdge)) && (type != TV_FALL))) int TriggerState::getCurrentIndex() const { return currentCycle.current_index; @@ -338,16 +338,16 @@ void TriggerState::onSynchronizationLost(DECLARE_ENGINE_PARAMETER_SIGNATURE) { } bool TriggerState::validateEventCounters(DECLARE_ENGINE_PARAMETER_SIGNATURE) const { - bool isDecodingError = currentCycle.eventCount[0] != TRIGGER_SHAPE(expectedEventCount[0]) - || currentCycle.eventCount[1] != TRIGGER_SHAPE(expectedEventCount[1]) - || currentCycle.eventCount[2] != TRIGGER_SHAPE(expectedEventCount[2]); + bool isDecodingError = currentCycle.eventCount[0] != TRIGGER_WAVEFORM(expectedEventCount[0]) + || currentCycle.eventCount[1] != TRIGGER_WAVEFORM(expectedEventCount[1]) + || currentCycle.eventCount[2] != TRIGGER_WAVEFORM(expectedEventCount[2]); #if EFI_UNIT_TEST printf("sync point: isDecodingError=%d\r\n", isDecodingError); if (isDecodingError) { - printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[0], TRIGGER_SHAPE(expectedEventCount[0])); - printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[1], TRIGGER_SHAPE(expectedEventCount[1])); - printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[2], TRIGGER_SHAPE(expectedEventCount[2])); + printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[0], TRIGGER_WAVEFORM(expectedEventCount[0])); + printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[1], TRIGGER_WAVEFORM(expectedEventCount[1])); + printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[2], TRIGGER_WAVEFORM(expectedEventCount[2])); } #endif /* EFI_UNIT_TEST */ @@ -367,9 +367,9 @@ void TriggerState::handleTriggerError(DECLARE_ENGINE_PARAMETER_SIGNATURE) { currentCycle.eventCount[0], currentCycle.eventCount[1], currentCycle.eventCount[2], - TRIGGER_SHAPE(expectedEventCount[0]), - TRIGGER_SHAPE(expectedEventCount[1]), - TRIGGER_SHAPE(expectedEventCount[2])); + TRIGGER_WAVEFORM(expectedEventCount[0]), + TRIGGER_WAVEFORM(expectedEventCount[1]), + TRIGGER_WAVEFORM(expectedEventCount[2])); lastDecodingErrorTime = getTimeNowNt(); someSortOfTriggerError = true; @@ -377,8 +377,8 @@ void TriggerState::handleTriggerError(DECLARE_ENGINE_PARAMETER_SIGNATURE) { if (CONFIG(verboseTriggerSynchDetails) || (someSortOfTriggerError && !CONFIG(silentTriggerError))) { #if EFI_PROD_CODE scheduleMsg(logger, "error: synchronizationPoint @ index %d expected %d/%d/%d got %d/%d/%d", - currentCycle.current_index, TRIGGER_SHAPE(expectedEventCount[0]), - TRIGGER_SHAPE(expectedEventCount[1]), TRIGGER_SHAPE(expectedEventCount[2]), + currentCycle.current_index, TRIGGER_WAVEFORM(expectedEventCount[0]), + TRIGGER_WAVEFORM(expectedEventCount[1]), TRIGGER_WAVEFORM(expectedEventCount[2]), currentCycle.eventCount[0], currentCycle.eventCount[1], currentCycle.eventCount[2]); #endif /* EFI_PROD_CODE */ } @@ -422,8 +422,8 @@ void TriggerState::decodeTriggerEvent(const TriggerStateCallback triggerCycleCal ScopePerf perf(PE::DecodeTriggerEvent, static_cast(signal)); bool useOnlyRisingEdgeForTrigger = CONFIG(useOnlyRisingEdgeForTrigger); - // todo: use 'triggerShape' instead of TRIGGER_SHAPE in order to decouple this method from engine #635 - TriggerShape *triggerShape = &ENGINE(triggerCentral.triggerShape); + // todo: use 'triggerShape' instead of TRIGGER_WAVEFORM in order to decouple this method from engine #635 + TriggerWaveform *triggerShape = &ENGINE(triggerCentral.triggerShape); efiAssertVoid(CUSTOM_ERR_6640, signal <= SHAFT_3RD_RISING, "unexpected signal"); @@ -536,7 +536,7 @@ void TriggerState::decodeTriggerEvent(const TriggerStateCallback triggerCycleCal bool isSync = true; for (int i = 0;isyncronizationRatioFrom[i]) || (toothDurations[i] > toothDurations[i + 1] * TRIGGER_SHAPE(syncronizationRatioFrom[i]) + bool isGapCondition = cisnan(triggerShape->syncronizationRatioFrom[i]) || (toothDurations[i] > toothDurations[i + 1] * TRIGGER_WAVEFORM(syncronizationRatioFrom[i]) && toothDurations[i] < toothDurations[i + 1] * triggerShape->syncronizationRatioTo[i]); isSync &= isGapCondition; @@ -571,8 +571,8 @@ void TriggerState::decodeTriggerEvent(const TriggerStateCallback triggerCycleCal /* cast is needed to make sure we do not put 64 bit value to stack*/ (int)getTimeNowSeconds(), i, gap, - TRIGGER_SHAPE(syncronizationRatioFrom[i]), - TRIGGER_SHAPE(syncronizationRatioTo[i]), + TRIGGER_WAVEFORM(syncronizationRatioFrom[i]), + TRIGGER_WAVEFORM(syncronizationRatioTo[i]), boolToString(someSortOfTriggerError)); } } @@ -585,8 +585,8 @@ void TriggerState::decodeTriggerEvent(const TriggerStateCallback triggerCycleCal print("index=%d: gap=%.2f expected from %.2f to %.2f error=%s\r\n", i, gap, - TRIGGER_SHAPE(syncronizationRatioFrom[i]), - TRIGGER_SHAPE(syncronizationRatioTo[i]), + TRIGGER_WAVEFORM(syncronizationRatioFrom[i]), + TRIGGER_WAVEFORM(syncronizationRatioTo[i]), boolToString(someSortOfTriggerError)); } } @@ -659,8 +659,8 @@ void TriggerState::decodeTriggerEvent(const TriggerStateCallback triggerCycleCal if (isTriggerDecoderError()) { warning(CUSTOM_OBD_TRG_DECODING, "trigger decoding issue. expected %d/%d/%d got %d/%d/%d", - TRIGGER_SHAPE(expectedEventCount[0]), TRIGGER_SHAPE(expectedEventCount[1]), - TRIGGER_SHAPE(expectedEventCount[2]), currentCycle.eventCount[0], currentCycle.eventCount[1], + TRIGGER_WAVEFORM(expectedEventCount[0]), TRIGGER_WAVEFORM(expectedEventCount[1]), + TRIGGER_WAVEFORM(expectedEventCount[2]), currentCycle.eventCount[0], currentCycle.eventCount[1], currentCycle.eventCount[2]); } } @@ -711,9 +711,9 @@ static void onFindIndexCallback(TriggerState *state) { * Trigger shape is defined in a way which is convenient for trigger shape definition * On the other hand, trigger decoder indexing begins from synchronization event. * - * This function finds the index of synchronization event within TriggerShape + * This function finds the index of synchronization event within TriggerWaveform */ -uint32_t findTriggerZeroEventIndex(TriggerState *state, TriggerShape * shape, +uint32_t findTriggerZeroEventIndex(TriggerState *state, TriggerWaveform * shape, trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_SUFFIX) { UNUSED(triggerConfig); #if EFI_PROD_CODE diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index 9bd939c792..53b1a8dc04 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -30,7 +30,7 @@ typedef struct { /** * Number of actual events of each channel within current trigger cycle, these * values are used to detect trigger signal errors. - * see TriggerShape + * see TriggerWaveform */ uint32_t eventCount[PWM_PHASE_MAX_WAVE_PER_PWM]; /** @@ -48,7 +48,7 @@ typedef struct { } current_cycle_state_s; /** - * @see TriggerShape for trigger wheel shape definition + * @see TriggerWaveform for trigger wheel shape definition */ class TriggerState : public trigger_state_s { public: @@ -170,7 +170,7 @@ public: }; angle_t getEngineCycle(operation_mode_e operationMode); -uint32_t findTriggerZeroEventIndex(TriggerState *state, TriggerShape * shape, trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_SUFFIX); +uint32_t findTriggerZeroEventIndex(TriggerState *state, TriggerWaveform * shape, trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_SUFFIX); class Engine; @@ -179,5 +179,5 @@ void initTriggerDecoderLogger(Logging *sharedLogger); bool isTriggerDecoderError(void); -void calculateTriggerSynchPoint(TriggerShape *shape, TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX); +void calculateTriggerSynchPoint(TriggerWaveform *shape, TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX); diff --git a/firmware/controllers/trigger/trigger_emulator_algo.cpp b/firmware/controllers/trigger/trigger_emulator_algo.cpp index 174bed3b37..c022a79f66 100644 --- a/firmware/controllers/trigger/trigger_emulator_algo.cpp +++ b/firmware/controllers/trigger/trigger_emulator_algo.cpp @@ -2,7 +2,7 @@ * @file trigger_emulator_algo.cpp * * This file is about producing real electrical signals which emulate trigger signal based on - * a known TriggerShape. + * a known TriggerWaveform. * * Historically this implementation was implemented based on PwmConfig which is maybe not the * best way to implement it. (todo: why is not the best way?) @@ -115,14 +115,14 @@ void setTriggerEmulatorRPM(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { scheduleMsg(logger, "Emulating position sensor(s). RPM=%d", rpm); } -static void updateTriggerShapeIfNeeded(PwmConfig *state) { +static void updateTriggerWaveformIfNeeded(PwmConfig *state) { if (atTriggerVersion < engine->triggerCentral.triggerShape.version) { atTriggerVersion = engine->triggerCentral.triggerShape.version; scheduleMsg(logger, "Stimulator: updating trigger shape: %d/%d %d", atTriggerVersion, engine->getGlobalConfigurationVersion(), currentTimeMillis()); - TriggerShape *s = &engine->triggerCentral.triggerShape; + TriggerWaveform *s = &engine->triggerCentral.triggerShape; pin_state_t *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.channels[0].pinStates, s->wave.channels[1].pinStates, @@ -164,7 +164,7 @@ static void resumeStimulator() { void initTriggerEmulatorLogic(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { logger = sharedLogger; - TriggerShape *s = &engine->triggerCentral.triggerShape; + TriggerWaveform *s = &engine->triggerCentral.triggerShape; setTriggerEmulatorRPM(engineConfiguration->bc.triggerSimulatorFrequency PASS_ENGINE_PARAMETER_SUFFIX); pin_state_t *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.channels[0].pinStates, @@ -173,7 +173,7 @@ void initTriggerEmulatorLogic(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUF triggerSignal.weComplexInit("position sensor", &engine->executor, s->getSize(), s->wave.switchTimes, PWM_PHASE_MAX_WAVE_PER_PWM, - pinStates, updateTriggerShapeIfNeeded, (pwm_gen_callback*)emulatorApplyPinState); + pinStates, updateTriggerWaveformIfNeeded, (pwm_gen_callback*)emulatorApplyPinState); addConsoleActionI("rpm", setTriggerEmulatorRPM); addConsoleActionI("stop_stimulator_at_index", setEmulatorAtIndex); diff --git a/firmware/controllers/trigger/trigger_simulator.cpp b/firmware/controllers/trigger/trigger_simulator.cpp index 6cd0021674..2596e9846b 100644 --- a/firmware/controllers/trigger/trigger_simulator.cpp +++ b/firmware/controllers/trigger/trigger_simulator.cpp @@ -27,7 +27,7 @@ extern bool printTriggerDebug; #endif /* ! EFI_UNIT_TEST */ void TriggerStimulatorHelper::feedSimulatedEvent(const TriggerStateCallback triggerCycleCallback, - TriggerState *state, TriggerShape * shape, int i + TriggerState *state, TriggerWaveform * shape, int i DECLARE_ENGINE_PARAMETER_SUFFIX) { efiAssertVoid(CUSTOM_ERR_6593, shape->getSize() > 0, "size not zero"); int stateIndex = i % shape->getSize(); @@ -92,7 +92,7 @@ void TriggerStimulatorHelper::feedSimulatedEvent(const TriggerStateCallback trig } void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(const TriggerStateCallback triggerCycleCallback, - const uint32_t syncIndex, TriggerState *state, TriggerShape * shape + const uint32_t syncIndex, TriggerState *state, TriggerWaveform * shape DECLARE_ENGINE_PARAMETER_SUFFIX) { /** @@ -103,7 +103,7 @@ void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(const TriggerSta } int revolutionCounter = state->getTotalRevolutionCounter(); if (revolutionCounter != GAP_TRACKING_LENGTH + 1) { - warning(CUSTOM_OBD_TRIGGER_SHAPE, "sync failed/wrong gap parameters trigger=%s rc=%d", getTrigger_type_e(engineConfiguration->trigger.type), revolutionCounter); + warning(CUSTOM_OBD_TRIGGER_WAVEFORM, "sync failed/wrong gap parameters trigger=%s rc=%d", getTrigger_type_e(engineConfiguration->trigger.type), revolutionCounter); shape->setShapeDefinitionError(true); return; } @@ -117,7 +117,7 @@ void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(const TriggerSta /** * @return trigger synchronization point index, or error code if not found */ -uint32_t TriggerStimulatorHelper::findTriggerSyncPoint(TriggerShape * shape, +uint32_t TriggerStimulatorHelper::findTriggerSyncPoint(TriggerWaveform * shape, TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX) { for (int i = 0; i < 4 * PWM_PHASE_MAX_COUNT; i++) { feedSimulatedEvent(nullptr, state, shape, i PASS_ENGINE_PARAMETER_SUFFIX); diff --git a/firmware/controllers/trigger/trigger_simulator.h b/firmware/controllers/trigger/trigger_simulator.h index 088ee2e4fc..44fa8c0d01 100644 --- a/firmware/controllers/trigger/trigger_simulator.h +++ b/firmware/controllers/trigger/trigger_simulator.h @@ -13,16 +13,16 @@ class TriggerStimulatorHelper { public: - uint32_t findTriggerSyncPoint(TriggerShape * shape, + uint32_t findTriggerSyncPoint(TriggerWaveform * shape, TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX); void assertSyncPositionAndSetDutyCycle(const TriggerStateCallback triggerCycleCallback, - const uint32_t index, TriggerState *state, TriggerShape * shape + const uint32_t index, TriggerState *state, TriggerWaveform * shape DECLARE_ENGINE_PARAMETER_SUFFIX); private: // send next event so that we can see how state reacts - void feedSimulatedEvent(const TriggerStateCallback triggerCycleCallback, TriggerState *state, TriggerShape * shape, int i DECLARE_ENGINE_PARAMETER_SUFFIX); + void feedSimulatedEvent(const TriggerStateCallback triggerCycleCallback, TriggerState *state, TriggerWaveform * shape, int i DECLARE_ENGINE_PARAMETER_SUFFIX); }; bool isUsefulSignal(trigger_event_e signal DECLARE_ENGINE_PARAMETER_SUFFIX); diff --git a/firmware/hw_layer/trigger_input_comp.cpp b/firmware/hw_layer/trigger_input_comp.cpp index ea2eeb6463..c854db0f4f 100644 --- a/firmware/hw_layer/trigger_input_comp.cpp +++ b/firmware/hw_layer/trigger_input_comp.cpp @@ -57,7 +57,7 @@ static void setHysteresis(COMPDriver *comp, int sign) { static void comp_shaft_callback(COMPDriver *comp) { uint32_t status = comp_lld_get_status(comp); int isPrimary = (comp == EFI_COMP_PRIMARY_DEVICE); - if (!isPrimary && !TRIGGER_SHAPE(needSecondTriggerInput)) { + if (!isPrimary && !TRIGGER_WAVEFORM(needSecondTriggerInput)) { return; } trigger_event_e signal; diff --git a/firmware/hw_layer/trigger_input_exti.cpp b/firmware/hw_layer/trigger_input_exti.cpp index fc0995d797..ac136bbdf1 100644 --- a/firmware/hw_layer/trigger_input_exti.cpp +++ b/firmware/hw_layer/trigger_input_exti.cpp @@ -32,7 +32,7 @@ static void shaft_callback(void *arg) { return; bool isPrimary = pal_line == primary_line; - if (!isPrimary && !TRIGGER_SHAPE(needSecondTriggerInput)) { + if (!isPrimary && !TRIGGER_WAVEFORM(needSecondTriggerInput)) { return; } diff --git a/firmware/hw_layer/trigger_input_icu.cpp b/firmware/hw_layer/trigger_input_icu.cpp index 1c06d11374..f3f0eb2260 100644 --- a/firmware/hw_layer/trigger_input_icu.cpp +++ b/firmware/hw_layer/trigger_input_icu.cpp @@ -51,7 +51,7 @@ static void shaftWidthCallback(bool isPrimary) { // todo: start using real event time from HW event, not just software timer? if (hasFirmwareErrorFlag) return; - if (!isPrimary && !TRIGGER_SHAPE(needSecondTriggerInput)) { + if (!isPrimary && !TRIGGER_WAVEFORM(needSecondTriggerInput)) { return; } // icucnt_t last_width = icuGetWidth(icup); so far we are fine with system time @@ -68,7 +68,7 @@ static void shaftPeriodCallback(bool isPrimary) { icuWidthPeriodCounter++; if (hasFirmwareErrorFlag) return; - if (!isPrimary && !TRIGGER_SHAPE(needSecondTriggerInput)) { + if (!isPrimary && !TRIGGER_WAVEFORM(needSecondTriggerInput)) { return; } diff --git a/unit_tests/engine_test_helper.cpp b/unit_tests/engine_test_helper.cpp index 3c416b1eb6..ae3e57da27 100644 --- a/unit_tests/engine_test_helper.cpp +++ b/unit_tests/engine_test_helper.cpp @@ -75,7 +75,7 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType, configuration_callb //todo: reuse initPeriodicEvents(PASS_ENGINE_PARAMETER_SIGNATURE) method engine->periodicSlowCallback(PASS_ENGINE_PARAMETER_SIGNATURE); - engine->eInitializeTriggerShape(NULL PASS_ENGINE_PARAMETER_SUFFIX); + engine->initializeTriggerWaveform(NULL PASS_ENGINE_PARAMETER_SUFFIX); initRpmCalculator(NULL PASS_ENGINE_PARAMETER_SUFFIX); initMainEventListener(NULL PASS_ENGINE_PARAMETER_SUFFIX); } @@ -214,11 +214,11 @@ void EngineTestHelper::assertEvent(const char *msg, int index, void *callback, e } -void EngineTestHelper::applyTriggerShape() { +void EngineTestHelper::applyTriggerWaveform() { Engine *engine = &this->engine; EXPAND_Engine - ENGINE(eInitializeTriggerShape(NULL PASS_ENGINE_PARAMETER_SUFFIX)); + ENGINE(initializeTriggerWaveform(NULL PASS_ENGINE_PARAMETER_SUFFIX)); incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); } @@ -261,7 +261,7 @@ void EngineTestHelper::setTriggerType(trigger_type_e trigger DECLARE_ENGINE_PARA engineConfiguration->trigger.type = trigger; incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); ASSERT_EQ( 1, isTriggerConfigChanged(PASS_ENGINE_PARAMETER_SIGNATURE)) << "trigger #2"; - applyTriggerShape(); + applyTriggerWaveform(); } void setupSimpleTestEngineWithMafAndTT_ONE_trigger(EngineTestHelper *eth, injection_mode_e injectionMode) { diff --git a/unit_tests/engine_test_helper.h b/unit_tests/engine_test_helper.h index 41ff1a6547..7522aea166 100644 --- a/unit_tests/engine_test_helper.h +++ b/unit_tests/engine_test_helper.h @@ -28,7 +28,7 @@ class EngineTestHelper : public EngineTestHelperBase { public: EngineTestHelper(engine_type_e engineType); EngineTestHelper(engine_type_e engineType, configuration_callback_t boardCallback); - void applyTriggerShape(); + void applyTriggerWaveform(); void setTriggerType(trigger_type_e trigger DECLARE_ENGINE_PARAMETER_SUFFIX); void fireRise(float delayMs); void fireFall(float delayMs); diff --git a/unit_tests/tests/test_fuel_map.cpp b/unit_tests/tests/test_fuel_map.cpp index 1ac4ed6d11..4360bc4d5f 100644 --- a/unit_tests/tests/test_fuel_map.cpp +++ b/unit_tests/tests/test_fuel_map.cpp @@ -114,7 +114,7 @@ TEST(misc, testFuelMap) { } -static void confgiureFordAspireTriggerShape(TriggerShape * s) { +static void confgiureFordAspireTriggerWaveform(TriggerWaveform * s) { s->initialize(FOUR_STROKE_CAM_SENSOR, true); s->addEvent720(53.747, T_SECONDARY, TV_RISE); @@ -163,52 +163,52 @@ TEST(misc, testAngleResolver) { engineConfiguration->globalTriggerAngleOffset = 175; - TriggerShape * ts = &engine->triggerCentral.triggerShape; - engine->eInitializeTriggerShape(NULL PASS_ENGINE_PARAMETER_SUFFIX); + TriggerWaveform * ts = &engine->triggerCentral.triggerShape; + engine->initializeTriggerWaveform(NULL PASS_ENGINE_PARAMETER_SUFFIX); assertEqualsM("index 2", 52.76, ts->eventAngles[3]); // this angle is relation to synch point assertEqualsM("time 2", 0.3233, ts->wave.getSwitchTime(2)); assertEqualsM("index 5", 412.76, ts->eventAngles[6]); assertEqualsM("time 5", 0.5733, ts->wave.getSwitchTime(5)); - ASSERT_EQ(4, ts->getTriggerShapeSynchPointIndex()); + ASSERT_EQ(4, ts->getTriggerWaveformSynchPointIndex()); ASSERT_EQ( 10, ts->getSize()) << "shape size"; event_trigger_position_s injectionStart; printf("*************************************************** testAngleResolver 0\r\n"); - TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -122, engineConfiguration->globalTriggerAngleOffset)); + TRIGGER_WAVEFORM(findTriggerPosition(&injectionStart, -122, engineConfiguration->globalTriggerAngleOffset)); ASSERT_EQ( 2, injectionStart.triggerEventIndex) << "eventIndex@0"; ASSERT_NEAR(0.24, injectionStart.angleOffsetFromTriggerEvent, EPS5D); printf("*************************************************** testAngleResolver 0.1\r\n"); - TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -80, engineConfiguration->globalTriggerAngleOffset)); + TRIGGER_WAVEFORM(findTriggerPosition(&injectionStart, -80, engineConfiguration->globalTriggerAngleOffset)); ASSERT_EQ( 2, injectionStart.triggerEventIndex) << "eventIndex@0"; ASSERT_FLOAT_EQ(42.24, injectionStart.angleOffsetFromTriggerEvent); printf("*************************************************** testAngleResolver 0.2\r\n"); - TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -54, engineConfiguration->globalTriggerAngleOffset)); + TRIGGER_WAVEFORM(findTriggerPosition(&injectionStart, -54, engineConfiguration->globalTriggerAngleOffset)); ASSERT_EQ( 2, injectionStart.triggerEventIndex) << "eventIndex@0"; ASSERT_FLOAT_EQ(68.2400, injectionStart.angleOffsetFromTriggerEvent); printf("*************************************************** testAngleResolver 0.3\r\n"); - TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -53, engineConfiguration->globalTriggerAngleOffset)); + TRIGGER_WAVEFORM(findTriggerPosition(&injectionStart, -53, engineConfiguration->globalTriggerAngleOffset)); ASSERT_EQ(2, injectionStart.triggerEventIndex); ASSERT_FLOAT_EQ(69.24, injectionStart.angleOffsetFromTriggerEvent); printf("*************************************************** testAngleResolver 1\r\n"); - TRIGGER_SHAPE(findTriggerPosition(&injectionStart, 0, engineConfiguration->globalTriggerAngleOffset)); + TRIGGER_WAVEFORM(findTriggerPosition(&injectionStart, 0, engineConfiguration->globalTriggerAngleOffset)); ASSERT_EQ(2, injectionStart.triggerEventIndex); ASSERT_FLOAT_EQ(122.24, injectionStart.angleOffsetFromTriggerEvent); printf("*************************************************** testAngleResolver 2\r\n"); - TRIGGER_SHAPE(findTriggerPosition(&injectionStart, 56, engineConfiguration->globalTriggerAngleOffset)); + TRIGGER_WAVEFORM(findTriggerPosition(&injectionStart, 56, engineConfiguration->globalTriggerAngleOffset)); ASSERT_EQ(2, injectionStart.triggerEventIndex); ASSERT_FLOAT_EQ(178.24, injectionStart.angleOffsetFromTriggerEvent); - TriggerShape t; - confgiureFordAspireTriggerShape(&t); + TriggerWaveform t; + confgiureFordAspireTriggerWaveform(&t); } TEST(misc, testPinHelper) { diff --git a/unit_tests/tests/test_speed_density.cpp b/unit_tests/tests/test_speed_density.cpp index 1b4028c2b9..d91a39348d 100644 --- a/unit_tests/tests/test_speed_density.cpp +++ b/unit_tests/tests/test_speed_density.cpp @@ -13,7 +13,7 @@ TEST(big, testSpeedDensity) { WITH_ENGINE_TEST_HELPER(FORD_INLINE_6_1995); engineConfiguration->trigger.customTotalToothCount = 8; - eth.applyTriggerShape(); + eth.applyTriggerWaveform(); eth.fireTriggerEvents(36); ASSERT_EQ( 1500, GET_RPM()) << "RPM"; diff --git a/unit_tests/tests/test_trigger_decoder.cpp b/unit_tests/tests/test_trigger_decoder.cpp index 0dadb5b87e..7908947e6c 100644 --- a/unit_tests/tests/test_trigger_decoder.cpp +++ b/unit_tests/tests/test_trigger_decoder.cpp @@ -49,7 +49,7 @@ static int getTriggerZeroEventIndex(engine_type_e engineType) { initDataStructures(PASS_ENGINE_PARAMETER_SIGNATURE); - TriggerShape * shape = ð.engine.triggerCentral.triggerShape; + TriggerWaveform * shape = ð.engine.triggerCentral.triggerShape; return findTriggerZeroEventIndex(ð.engine.triggerCentral.triggerState, shape, &engineConfiguration->trigger PASS_ENGINE_PARAMETER_SUFFIX); } @@ -60,8 +60,8 @@ static void testDodgeNeonDecoder(void) { WITH_ENGINE_TEST_HELPER(DODGE_NEON_1995); - TriggerShape * shape = ð.engine.triggerCentral.triggerShape; - ASSERT_EQ(8, shape->getTriggerShapeSynchPointIndex()); + TriggerWaveform * shape = ð.engine.triggerCentral.triggerShape; + ASSERT_EQ(8, shape->getTriggerWaveformSynchPointIndex()); TriggerState state; @@ -151,22 +151,22 @@ TEST(misc, test1995FordInline6TriggerDecoder) { WITH_ENGINE_TEST_HELPER(FORD_INLINE_6_1995); - TriggerShape * shape = &engine->triggerCentral.triggerShape; + TriggerWaveform * shape = &engine->triggerCentral.triggerShape; - ASSERT_EQ( 0, shape->getTriggerShapeSynchPointIndex()) << "triggerShapeSynchPointIndex"; + ASSERT_EQ( 0, shape->getTriggerWaveformSynchPointIndex()) << "triggerShapeSynchPointIndex"; event_trigger_position_s position; ASSERT_EQ( 0, engineConfiguration->globalTriggerAngleOffset) << "globalTriggerAngleOffset"; - TRIGGER_SHAPE(findTriggerPosition(&position, 0, engineConfiguration->globalTriggerAngleOffset)); + TRIGGER_WAVEFORM(findTriggerPosition(&position, 0, engineConfiguration->globalTriggerAngleOffset)); assertTriggerPosition(&position, 0, 0); - TRIGGER_SHAPE(findTriggerPosition(&position, 200, engineConfiguration->globalTriggerAngleOffset)); + TRIGGER_WAVEFORM(findTriggerPosition(&position, 200, engineConfiguration->globalTriggerAngleOffset)); assertTriggerPosition(&position, 3, 20); - TRIGGER_SHAPE(findTriggerPosition(&position, 360, engineConfiguration->globalTriggerAngleOffset)); + TRIGGER_WAVEFORM(findTriggerPosition(&position, 360, engineConfiguration->globalTriggerAngleOffset)); assertTriggerPosition(&position, 6, 0); - eth.applyTriggerShape(); + eth.applyTriggerWaveform(); engine->periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE); eth.fireTriggerEvents(48); @@ -203,7 +203,7 @@ TEST(misc, testFordAspire) { WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); - ASSERT_EQ( 4, TRIGGER_SHAPE(getTriggerShapeSynchPointIndex())) << "getTriggerShapeSynchPointIndex"; + ASSERT_EQ( 4, TRIGGER_WAVEFORM(getTriggerWaveformSynchPointIndex())) << "getTriggerWaveformSynchPointIndex"; ASSERT_EQ(800, config->fuelRpmBins[0]); ASSERT_EQ(7000, config->fuelRpmBins[15]); @@ -228,11 +228,11 @@ static void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPo WITH_ENGINE_TEST_HELPER(type); - TriggerShape *t = &ENGINE(triggerCentral.triggerShape); + TriggerWaveform *t = &ENGINE(triggerCentral.triggerShape); ASSERT_FALSE(t->shapeDefinitionError) << "isError"; - assertEqualsM("synchPointIndex", synchPointIndex, t->getTriggerShapeSynchPointIndex()); + assertEqualsM("synchPointIndex", synchPointIndex, t->getTriggerWaveformSynchPointIndex()); ASSERT_NEAR(channel1duty, t->expectedDutyCycle[0], 0.0001) << msg << " channel1duty"; ASSERT_NEAR(channel2duty, t->expectedDutyCycle[1], 0.0001) << msg << " channel2duty"; @@ -307,7 +307,7 @@ TEST(misc, testRpmCalculator) { engineConfiguration->trigger.customTotalToothCount = 8; engineConfiguration->globalFuelCorrection = 3; - eth.applyTriggerShape(); + eth.applyTriggerWaveform(); setFlatInjectorLag(0 PASS_CONFIG_PARAMETER_SUFFIX); @@ -318,8 +318,8 @@ TEST(misc, testRpmCalculator) { ASSERT_EQ(0, GET_RPM()); // triggerIndexByAngle update is now fixed! prepareOutputSignals() wasn't reliably called - ASSERT_EQ(5, TRIGGER_SHAPE(triggerIndexByAngle[240])); - ASSERT_EQ(5, TRIGGER_SHAPE(triggerIndexByAngle[241])); + ASSERT_EQ(5, TRIGGER_WAVEFORM(triggerIndexByAngle[240])); + ASSERT_EQ(5, TRIGGER_WAVEFORM(triggerIndexByAngle[241])); eth.fireTriggerEvents(/* count */ 48); @@ -382,8 +382,8 @@ TEST(misc, testRpmCalculator) { assertEqualsM("3/3", start + 14777, engine->executor.getForUnitTest(2)->momentX); engine->executor.clear(); - ASSERT_EQ(5, TRIGGER_SHAPE(triggerIndexByAngle[240])); - ASSERT_EQ(5, TRIGGER_SHAPE(triggerIndexByAngle[241])); + ASSERT_EQ(5, TRIGGER_WAVEFORM(triggerIndexByAngle[240])); + ASSERT_EQ(5, TRIGGER_WAVEFORM(triggerIndexByAngle[241])); eth.fireFall(5); @@ -448,7 +448,7 @@ TEST(misc, testTriggerDecoder) { persistent_config_s c; Engine e(&c); - TriggerShape * s = &e.triggerCentral.triggerShape; + TriggerWaveform * s = &e.triggerCentral.triggerShape; persistent_config_s *config = &c; @@ -457,7 +457,7 @@ TEST(misc, testTriggerDecoder) { engine_configuration_s *engineConfiguration = &c.engineConfiguration; board_configuration_s *boardConfiguration = &c.engineConfiguration.bc; - initializeSkippedToothTriggerShapeExt(s, 2, 0, FOUR_STROKE_CAM_SENSOR); + initializeSkippedToothTriggerWaveformExt(s, 2, 0, FOUR_STROKE_CAM_SENSOR); assertEqualsM("shape size", s->getSize(), 4); ASSERT_EQ(s->wave.switchTimes[0], 0.25); ASSERT_EQ(s->wave.switchTimes[1], 0.5); @@ -507,7 +507,7 @@ TEST(misc, testTriggerDecoder) { WITH_ENGINE_TEST_HELPER(MITSU_4G93); -// TriggerShape *t = ð.engine.triggerShape; +// TriggerWaveform *t = ð.engine.triggerShape; // ASSERT_EQ(1, t->eventAngles[1]); // ASSERT_EQ( 0, t->triggerIndexByAngle[56]) << "index at 0"; // ASSERT_EQ( 1, t->triggerIndexByAngle[57]) << "index at 1"; diff --git a/unit_tests/tests/test_trigger_multi_sync.cpp b/unit_tests/tests/test_trigger_multi_sync.cpp index 87542c8a8a..1d8ad39258 100644 --- a/unit_tests/tests/test_trigger_multi_sync.cpp +++ b/unit_tests/tests/test_trigger_multi_sync.cpp @@ -9,7 +9,7 @@ #include "trigger_mazda.h" TEST(trigger, miataNA) { - TriggerShape naShape; + TriggerWaveform naShape; initializeMazdaMiataNaShape(&naShape); diff --git a/unit_tests/tests/test_trigger_noiseless.cpp b/unit_tests/tests/test_trigger_noiseless.cpp index f206cf3bf7..285394492b 100644 --- a/unit_tests/tests/test_trigger_noiseless.cpp +++ b/unit_tests/tests/test_trigger_noiseless.cpp @@ -84,7 +84,7 @@ static void fireNoisyCycle60_2(EngineTestHelper *eth, int numCycles, int duratio } static void resetTrigger(EngineTestHelper ð) { - eth.applyTriggerShape(); + eth.applyTriggerWaveform(); eth.engine.triggerCentral.resetAccumSignalData(); // reset error counter eth.engine.triggerCentral.triggerState.totalTriggerErrorCounter = 0;