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) { if (filament_sensor) {
meas_shift_index = filwidth_delay_index[0] - meas_delay_cm; 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 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 // Get the delayed info and add 100 to reconstitute to a percent of
// the nominal filament diameter then square it to get an area // the nominal filament diameter then square it to get an area
meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY); const float vmroot = measurement_delay[meas_shift_index] * 0.01 + 1.0;
float vm = pow((measurement_delay[meas_shift_index] + 100.0) * 0.01, 2); volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vmroot <= 0.1 ? 0.01 : sq(vmroot);
NOLESS(vm, 0.01);
volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vm;
} }
#endif // FILAMENT_WIDTH_SENSOR #endif // FILAMENT_WIDTH_SENSOR