From 49fab25b14b4e56970dafa7efe457cd09de79a37 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 3 Apr 2022 01:38:52 -0400 Subject: [PATCH] Trigger setup in TS is highly confusing: hide operation mode from users? #4031 --- firmware/controllers/algo/engine.cpp | 10 +++++++--- firmware/controllers/settings.cpp | 2 -- .../controllers/trigger/decoders/trigger_structure.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index cb734efe2a..c41f232fb9 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -99,6 +99,10 @@ trigger_type_e getVvtTriggerType(vvt_mode_e vvtMode) { } } +static operation_mode_e lookupOperationMode() { + return engineConfiguration->ambiguousOperationMode; +} + static void initVvtShape(int camIndex, TriggerState &initState) { vvt_mode_e vvtMode = engineConfiguration->vvtMode[camIndex]; @@ -109,7 +113,7 @@ static void initVvtShape(int camIndex, TriggerState &initState) { auto& shape = engine->triggerCentral.vvtShape[camIndex]; shape.initializeTriggerWaveform( - engineConfiguration->ambiguousOperationMode, + lookupOperationMode(), engineConfiguration->vvtCamSensorUseRise, &config); shape.initializeSyncPoint(initState, @@ -132,7 +136,7 @@ void Engine::updateTriggerWaveform() { chibios_rt::CriticalSectionLocker csl; TRIGGER_WAVEFORM(initializeTriggerWaveform( - engineConfiguration->ambiguousOperationMode, + lookupOperationMode(), engineConfiguration->useOnlyRisingEdgeForTrigger, &engineConfiguration->trigger)); /** @@ -612,7 +616,7 @@ operation_mode_e Engine::getOperationMode() { * here we ignore user-provided setting for well known triggers. * For instance for Miata NA, there is no reason to allow user to set FOUR_STROKE_CRANK_SENSOR */ - return doesTriggerImplyOperationMode(engineConfiguration->trigger.type) ? triggerCentral.triggerShape.getOperationMode() : engineConfiguration->ambiguousOperationMode; + return doesTriggerImplyOperationMode(engineConfiguration->trigger.type) ? triggerCentral.triggerShape.getOperationMode() : lookupOperationMode(); } /** diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 40ed81910d..5749421f8b 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -1148,8 +1148,6 @@ static void setValue(const char *paramStr, const char *valueStr) { engineConfiguration->vvtOffsets[0] = valueF; } else if (strEqualCaseInsensitive(paramStr, "vvt_mode")) { engineConfiguration->vvtMode[0] = (vvt_mode_e)valueI; - } else if (strEqualCaseInsensitive(paramStr, "operation_mode")) { - engineConfiguration->ambiguousOperationMode = (operation_mode_e)valueI; } else if (strEqualCaseInsensitive(paramStr, "vvtCamSensorUseRise")) { engineConfiguration->vvtCamSensorUseRise = valueI; } else if (strEqualCaseInsensitive(paramStr, "wwaeTau")) { diff --git a/firmware/controllers/trigger/decoders/trigger_structure.h b/firmware/controllers/trigger/decoders/trigger_structure.h index 8f374f00ee..b25663f4ff 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.h +++ b/firmware/controllers/trigger/decoders/trigger_structure.h @@ -73,7 +73,7 @@ class TriggerConfiguration; class TriggerWaveform { public: TriggerWaveform(); - void initializeTriggerWaveform(operation_mode_e ambiguousOperationMode, + void initializeTriggerWaveform(operation_mode_e triggerOperationMode, bool useOnlyRisingEdgeForTrigger, const trigger_config_s *triggerConfig); void setShapeDefinitionError(bool value);