From 096b927102b694d6f962d43a68b0dcf02a1f67a0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 26 Apr 2017 02:52:51 -0500 Subject: [PATCH] Minor optimization of FILAMENT_WIDTH_SENSOR --- Marlin/temperature.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 245739da11..03b39de03d 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -766,13 +766,12 @@ void Temperature::manage_heater() { if (filament_sensor) { meas_shift_index = filwidth_delay_index[0] - meas_delay_cm; if (meas_shift_index < 0) meas_shift_index += MAX_MEASUREMENT_DELAY + 1; //loop around buffer if needed + meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY); // Get the delayed info and add 100 to reconstitute to a percent of // the nominal filament diameter then square it to get an area - meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY); - float vm = pow((measurement_delay[meas_shift_index] + 100.0) * 0.01, 2); - NOLESS(vm, 0.01); - volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vm; + const float vmroot = measurement_delay[meas_shift_index] * 0.01 + 1.0; + volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vmroot <= 0.1 ? 0.01 : sq(vmroot); } #endif // FILAMENT_WIDTH_SENSOR