diff --git a/firmware/config/boards/hellen/hellen128/board_configuration.cpp b/firmware/config/boards/hellen/hellen128/board_configuration.cpp index 3272b03255..efca7e23dd 100644 --- a/firmware/config/boards/hellen/hellen128/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen128/board_configuration.cpp @@ -115,7 +115,6 @@ void setBoardConfigOverrides(void) { engineConfiguration->canTxPin = GPIOD_1; engineConfiguration->canRxPin = GPIOD_0; - setHellenDefaultVrThresholds(PASS_CONFIG_PARAMETER_SIGNATURE); engineConfiguration->vrThreshold[0].pin = GPIOD_14; } diff --git a/firmware/config/engines/custom_engine.cpp b/firmware/config/engines/custom_engine.cpp index 1ebf8f605e..b67cd8f54d 100644 --- a/firmware/config/engines/custom_engine.cpp +++ b/firmware/config/engines/custom_engine.cpp @@ -765,6 +765,6 @@ void setHellen72etb(DECLARE_CONFIG_PARAMETER_SIGNATURE) { void setHellenDefaultVrThresholds(DECLARE_CONFIG_PARAMETER_SIGNATURE) { for (int i = 0;ivrThreshold[i].rpmBins, 600, 7000, 100); - setLinearCurve(engineConfiguration->vrThreshold[i].values, 0.6, 1.2, 0.1); + setLinearCurve(engineConfiguration->vrThreshold[i].values, PACK_PERCENT_BYTE_MULT * 0.6, PACK_PERCENT_BYTE_MULT * 1.2, PACK_PERCENT_BYTE_MULT * 0.1); } } diff --git a/firmware/config/engines/mercedes.cpp b/firmware/config/engines/mercedes.cpp index 25253a653b..3b44e6fed3 100644 --- a/firmware/config/engines/mercedes.cpp +++ b/firmware/config/engines/mercedes.cpp @@ -6,9 +6,19 @@ */ #include "pch.h" +#include "custom_engine.h" + +static void common(DECLARE_CONFIG_PARAMETER_SIGNATURE) { + setHellenDefaultVrThresholds(PASS_CONFIG_PARAMETER_SIGNATURE); +} + +void setHellenMercedes128_4_cyl(DECLARE_CONFIG_PARAMETER_SIGNATURE) { + common(PASS_CONFIG_PARAMETER_SIGNATURE); +} // is this M104 or M112 or both? void setHellenMercedes128_6_cyl(DECLARE_CONFIG_PARAMETER_SIGNATURE) { + common(PASS_CONFIG_PARAMETER_SIGNATURE); engineConfiguration->specs.cylindersCount = 6; // 1-4-2-5-3-6 M104 engineConfiguration->specs.firingOrder = FO_1_4_3_6_2_5; // M112 @@ -16,6 +26,7 @@ void setHellenMercedes128_6_cyl(DECLARE_CONFIG_PARAMETER_SIGNATURE) { // M113 void setHellenMercedes128_8_cyl(DECLARE_CONFIG_PARAMETER_SIGNATURE) { + common(PASS_CONFIG_PARAMETER_SIGNATURE); engineConfiguration->specs.cylindersCount = 8; engineConfiguration->specs.firingOrder = FO_1_5_4_2_6_3_7_8; } diff --git a/firmware/config/engines/mercedes.h b/firmware/config/engines/mercedes.h index d5920382a4..79f5e8fbc2 100644 --- a/firmware/config/engines/mercedes.h +++ b/firmware/config/engines/mercedes.h @@ -9,5 +9,6 @@ #include "engine_configuration.h" +void setHellenMercedes128_4_cyl(DECLARE_CONFIG_PARAMETER_SIGNATURE); void setHellenMercedes128_6_cyl(DECLARE_CONFIG_PARAMETER_SIGNATURE); void setHellenMercedes128_8_cyl(DECLARE_CONFIG_PARAMETER_SIGNATURE); diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index c7f0403edd..e2a5cb22cd 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -859,7 +859,6 @@ void resetConfigurationExt(configuration_callback_t boardCallback, engine_type_e // todo: is it time to replace MICRO_RUS_EFI, PROTEUS, PROMETHEUS_DEFAULTS with MINIMAL_PINS? maybe rename MINIMAL_PINS to DEFAULT? case PROTEUS_DEFAULTS: case PROMETHEUS_DEFAULTS: - case HELLEN_128_MERCEDES_4_CYL: case MINIMAL_PINS: // all basic settings are already set in prepareVoidConfiguration(), no need to set anything here // nothing to do - we do it all in setBoardDefaultConfiguration @@ -938,6 +937,9 @@ void resetConfigurationExt(configuration_callback_t boardCallback, engine_type_e #endif // HARDWARE_CI #endif // HW_PROTEUS #if HW_HELLEN + case HELLEN_128_MERCEDES_4_CYL: + setHellenMercedes128_4_cyl(PASS_CONFIG_PARAMETER_SIGNATURE); + break; case HELLEN_128_MERCEDES_6_CYL: setHellenMercedes128_6_cyl(PASS_CONFIG_PARAMETER_SIGNATURE); break; diff --git a/firmware/controllers/sensors/vr_pwm.cpp b/firmware/controllers/sensors/vr_pwm.cpp index 3d81f27ec8..98eb91714d 100644 --- a/firmware/controllers/sensors/vr_pwm.cpp +++ b/firmware/controllers/sensors/vr_pwm.cpp @@ -12,7 +12,7 @@ static void updateVrPwm(int rpm, size_t index DECLARE_ENGINE_PARAMETER_SUFFIX) { return; } - float thresholdVoltage = interpolate2d(rpm / RPM_1_BYTE_PACKING_MULT, cfg.rpmBins, cfg.values) / 100.0f; + float thresholdVoltage = interpolate2d(rpm / RPM_1_BYTE_PACKING_MULT, cfg.rpmBins, cfg.values) / PACK_PERCENT_BYTE_MULT; // 0v threshold voltage = 3.3v output from mcu = 100% duty // 2.5v threshold voltage = 0v output from mcu = 0% duty diff --git a/unit_tests/tests/test_sensors.cpp b/unit_tests/tests/test_sensors.cpp index 25e13da5fe..2310847549 100644 --- a/unit_tests/tests/test_sensors.cpp +++ b/unit_tests/tests/test_sensors.cpp @@ -7,6 +7,13 @@ #include "pch.h" +TEST(sensors, vrThreshold) { + WITH_ENGINE_TEST_HELPER(HELLEN_128_MERCEDES_4_CYL); + + auto& cfg = CONFIG(vrThreshold)[0]; + ASSERT_FLOAT_EQ(0.8 * PACK_PERCENT_BYTE_MULT, cfg.values[2]); +} + TEST(sensors, mapDecoding) { WITH_ENGINE_TEST_HELPER(FORD_INLINE_6_1995);