From f05a5fcd70add1ac84ce16af8ae17a25231509ce Mon Sep 17 00:00:00 2001 From: rusefillc Date: Thu, 30 Mar 2023 10:01:51 -0400 Subject: [PATCH] refactoring, fancy: extract magic constant --- firmware/controllers/algo/defaults/default_base_engine.cpp | 1 + firmware/init/sensor/init_vehicle_speed_sensor.cpp | 4 ++-- firmware/integration/rusefi_config.txt | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/firmware/controllers/algo/defaults/default_base_engine.cpp b/firmware/controllers/algo/defaults/default_base_engine.cpp index a32bc641d4..b280537afa 100644 --- a/firmware/controllers/algo/defaults/default_base_engine.cpp +++ b/firmware/controllers/algo/defaults/default_base_engine.cpp @@ -28,6 +28,7 @@ void setDefaultBaseEngine() { engineConfiguration->specs.firingOrder = FO_1_3_4_2; engineConfiguration->compressionRatio = 9; + engineConfiguration->vssFilterReciprocal = VSS_FILTER_MIN; engineConfiguration->turbochargerFilter = 0.01f; diff --git a/firmware/init/sensor/init_vehicle_speed_sensor.cpp b/firmware/init/sensor/init_vehicle_speed_sensor.cpp index f64beff3db..c9908e3217 100644 --- a/firmware/init/sensor/init_vehicle_speed_sensor.cpp +++ b/firmware/init/sensor/init_vehicle_speed_sensor.cpp @@ -11,8 +11,8 @@ static VehicleSpeedConverter vehicleSpeedConverter; void initVehicleSpeedSensor() { int parameter = engineConfiguration->vssFilterReciprocal; - if (parameter < 3 || parameter > 200) { - parameter = 3; + if (parameter < VSS_FILTER_MIN || parameter > VSS_FILTER_MAX) { + parameter = VSS_FILTER_MIN; } float filterParameter = 1.0f / parameter; diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index de7ffb42da..0ed6ba5ec7 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -123,6 +123,9 @@ struct_no_prefix engine_configuration_s #define GEARS_COUNT 8 +#define VSS_FILTER_MIN 3 +#define VSS_FILTER_MAX 200 + #define CAM_INPUTS_COUNT @@BANKS_COUNT@@*@@CAMS_PER_BANK@@ ! https://github.com/rusefi/rusefi/issues/2010 shows the corner case wheel with huge depth requirement @@ -668,7 +671,7 @@ uint8_t autoscale knockRetardReapplyRate;After a knock event, reapply timing at custom engineSyncCam_e 1 bits, S08, @OFFSET@, [0:1], @@engineSyncCam_enum@@ engineSyncCam_e engineSyncCam;Select which cam is used for engine sync. Other cams will be used only for VVT measurement, but not engine sync. - uint8_t vssFilterReciprocal;Set this so your vehicle speed signal is responsive, but not noisy. Larger value give smoother but slower response.;"", 1, 0, 2, 200, 0 + uint8_t vssFilterReciprocal;Set this so your vehicle speed signal is responsive, but not noisy. Larger value give smoother but slower response.;"", 1, 0, @@VSS_FILTER_MIN@@, @@VSS_FILTER_MAX@@ 0 uint16_t autoscale vssGearRatio;Number of turns of your vehicle speed sensor per turn of the wheels. For example if your sensor is on the transmission output, enter your axle/differential ratio. If you are using a hub-mounted sensor, enter a value of 1.0.;"ratio", 0.001, 0, 0, 60, 3 uint8_t vssToothCount;Number of pulses output per revolution of the shaft where your VSS is mounted. For example, GM applications of the T56 output 17 pulses per revolution of the transmission output shaft.;"count", 1, 0, 1, 100, 0