diff --git a/firmware/config/engines/custom_engine.cpp b/firmware/config/engines/custom_engine.cpp index 3895f080f9..59fc61d58b 100644 --- a/firmware/config/engines/custom_engine.cpp +++ b/firmware/config/engines/custom_engine.cpp @@ -793,8 +793,8 @@ void setHellen72etb() { void setHellenDefaultVrThresholds() { for (int i = 0;ivrThreshold[i].rpmBins, 600 / RPM_1_BYTE_PACKING_MULT, 7000 / RPM_1_BYTE_PACKING_MULT, 100 / RPM_1_BYTE_PACKING_MULT); - setLinearCurve(engineConfiguration->vrThreshold[i].values, PACK_PERCENT_BYTE_MULT * 0.6, PACK_PERCENT_BYTE_MULT * 1.2, PACK_PERCENT_BYTE_MULT * 0.1); + setLinearCurve(engineConfiguration->vrThreshold[i].rpmBins, 600, 7000, 100); + setLinearCurve(engineConfiguration->vrThreshold[i].values, 0.6, 1.2, 0.1); } } diff --git a/firmware/controllers/sensors/vr_pwm.cpp b/firmware/controllers/sensors/vr_pwm.cpp index a599b7c5da..c52ebabd66 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) { return; } - float thresholdVoltage = interpolate2d(rpm / RPM_1_BYTE_PACKING_MULT, cfg.rpmBins, cfg.values) / PACK_PERCENT_BYTE_MULT; + float thresholdVoltage = interpolate2d(rpm, cfg.rpmBins, cfg.values); // 0v threshold voltage = 3.3v output from mcu = 100% duty // 2.5v threshold voltage = 0v output from mcu = 0% duty diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 90918290e5..44a6452d8b 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -983,8 +983,8 @@ custom maf_sensor_type_e 4 bits, S32, @OFFSET@, [0:1], @@maf_sensor_type_e_enum@ struct vr_threshold_s brain_pin_e pin; uint8_t[3] pad;;"",1,0,0,0,0 - uint8_t[6] rpmBins;;"rpm", {@@RPM_1_BYTE_PACKING_MULT@@}, 0, 0, 12000, 0 - uint8_t[6] values;;"volts", {1/@@PACK_PERCENT_BYTE_MULT@@}, 0, 0, 2.5, 2 + uint8_t[6] autoscale rpmBins;;"rpm", @@RPM_1_BYTE_PACKING_MULT@@, 0, 0, 12000, 0 + uint8_t[6] autoscale values;;"volts", {1/@@PACK_PERCENT_BYTE_MULT@@}, 0, 0, 2.5, 2 end_struct ! todo: should be '3' since we are dreaming of Honda triple-channel distributor diff --git a/unit_tests/tests/test_sensors.cpp b/unit_tests/tests/test_sensors.cpp index 6cc85b4551..1d55c05fe9 100644 --- a/unit_tests/tests/test_sensors.cpp +++ b/unit_tests/tests/test_sensors.cpp @@ -11,7 +11,7 @@ TEST(sensors, vrThreshold) { EngineTestHelper eth(HELLEN_128_MERCEDES_4_CYL); auto& cfg = engineConfiguration->vrThreshold[0]; - ASSERT_FLOAT_EQ(0.8 * PACK_PERCENT_BYTE_MULT, cfg.values[2]); + ASSERT_FLOAT_EQ(0.8, cfg.values[2]); } TEST(sensors, mapDecoding) {