Minor optimization of FILAMENT_WIDTH_SENSOR

This commit is contained in:
Scott Lahteine 2017-04-26 02:52:51 -05:00
parent 5bdb0b567d
commit 096b927102

View file

@ -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