From 204ac3961b74613c4fefdeef3e45a770e9f8e421 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 3 Apr 2022 02:30:43 -0400 Subject: [PATCH] Trigger setup in TS is highly confusing: hide operation mode from users? #4031 WOW it works?! --- firmware/controllers/algo/engine.cpp | 6 +++++- .../controllers/algo/engine_configuration.cpp | 3 --- firmware/controllers/settings.cpp | 4 +++- .../controllers/trigger/trigger_central.cpp | 1 - .../tests/trigger/test_rpm_multiplier.cpp | 18 ++++++------------ 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index c41f232fb9..6925e2b3ea 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -100,7 +100,11 @@ trigger_type_e getVvtTriggerType(vvt_mode_e vvtMode) { } static operation_mode_e lookupOperationMode() { - return engineConfiguration->ambiguousOperationMode; + if (engineConfiguration->twoStroke) { + return TWO_STROKE; + } else { + return engineConfiguration->skippedWheelOnCam ? FOUR_STROKE_CAM_SENSOR : FOUR_STROKE_CRANK_SENSOR; + } } static void initVvtShape(int camIndex, TriggerState &initState) { diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 7e1b859572..b90ae18d36 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -1175,17 +1175,14 @@ void prepareShapes() { #endif void setTwoStrokeOperationMode() { - engineConfiguration->ambiguousOperationMode = TWO_STROKE; engineConfiguration->twoStroke = true; } void setCamOperationMode() { - engineConfiguration->ambiguousOperationMode = FOUR_STROKE_CAM_SENSOR; engineConfiguration->skippedWheelOnCam = true; } void setCrankOperationMode() { - engineConfiguration->ambiguousOperationMode = FOUR_STROKE_CRANK_SENSOR; engineConfiguration->skippedWheelOnCam = false; } diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 5749421f8b..0a253b6e32 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -350,6 +350,7 @@ static void setInjectorLag(float voltage, float value) { setCurveValue(INJECTOR_LAG_CURVE, voltage, value); } +/* static void setToothedWheel(int total, int skipped) { if (total < 1 || skipped >= total) { efiPrintf("invalid parameters %d %d", total, skipped); @@ -364,6 +365,7 @@ static void setToothedWheel(int total, int skipped) { incrementGlobalConfigurationVersion(); doPrintConfiguration(); } +*/ static void setGlobalFuelCorrection(float value) { if (value < 0.01 || value > 50) @@ -1207,7 +1209,7 @@ void initSettings(void) { addConsoleActionS(CMD_ENABLE, enable); addConsoleActionS(CMD_DISABLE, disable); - addConsoleActionII("set_toothed_wheel", setToothedWheel); +// addConsoleActionII("set_toothed_wheel", setToothedWheel); addConsoleActionFF("set_injector_lag", setInjectorLag); diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 581a10ec47..03c6ea9ddd 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -872,7 +872,6 @@ void onConfigurationChangeTriggerCallback() { } changed |= isConfigurationChanged(trigger.type); - changed |= isConfigurationChanged(ambiguousOperationMode); changed |= isConfigurationChanged(skippedWheelOnCam); changed |= isConfigurationChanged(twoStroke); changed |= isConfigurationChanged(useOnlyRisingEdgeForTrigger); diff --git a/unit_tests/tests/trigger/test_rpm_multiplier.cpp b/unit_tests/tests/trigger/test_rpm_multiplier.cpp index 81ed779b19..02c4d3b978 100644 --- a/unit_tests/tests/trigger/test_rpm_multiplier.cpp +++ b/unit_tests/tests/trigger/test_rpm_multiplier.cpp @@ -9,9 +9,10 @@ #include "pch.h" -static void runRpmTest(operation_mode_e mode, int expected) { +static void runRpmTest(bool isTwoStroke, bool isCam, int expected) { EngineTestHelper eth(TEST_ENGINE); - engineConfiguration->ambiguousOperationMode = mode; + engineConfiguration->twoStroke = isTwoStroke; + engineConfiguration->skippedWheelOnCam = isCam; eth.setTriggerType(TT_ONE); eth.smartFireTriggerEvents2(/*count*/200, /*delay*/ 40); @@ -21,21 +22,14 @@ static void runRpmTest(operation_mode_e mode, int expected) { // todo: google test profiles one day? TEST(engine, testRpmOfCamSensor) { - runRpmTest(FOUR_STROKE_CAM_SENSOR, 1500); -} - -TEST(engine, testRpmOfSymmetricalCrank) { - runRpmTest(FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR, 375); + runRpmTest(false, true, 1500); } TEST(engine, testRpmOfTwoStroke) { - runRpmTest(TWO_STROKE, 750); + runRpmTest(true, false, 750); } TEST(engine, testRpmOfCrankOnly) { - runRpmTest(FOUR_STROKE_CRANK_SENSOR, 750); + runRpmTest(false, false, 750); } -TEST(engine, testRpmOfThreeTimesCrank) { - runRpmTest(FOUR_STROKE_THREE_TIMES_CRANK_SENSOR, 250); -}