Fixed a bug in cooling buffer resulting in G-codes setting fan to more than 100 %

This commit is contained in:
Lukas Matena 2023-06-28 15:04:37 +02:00
parent 4981b33b01
commit d907a004cf

View File

@ -783,8 +783,8 @@ std::string CoolingBuffer::apply_layer_cooldown(
if (int(layer_id) >= disable_fan_first_layers && int(layer_id) + 1 < full_fan_speed_layer) {
// Ramp up the fan speed from disable_fan_first_layers to full_fan_speed_layer.
float factor = float(int(layer_id + 1) - disable_fan_first_layers) / float(full_fan_speed_layer - disable_fan_first_layers);
fan_speed_new = std::clamp(int(float(fan_speed_new) * factor + 0.5f), 0, 255);
bridge_fan_speed = std::clamp(int(float(bridge_fan_speed) * factor + 0.5f), 0, 255);
fan_speed_new = std::clamp(int(float(fan_speed_new) * factor + 0.5f), 0, 100);
bridge_fan_speed = std::clamp(int(float(bridge_fan_speed) * factor + 0.5f), 0, 100);
custom_fan_speed_limits.second = fan_speed_new;
}
#undef EXTRUDER_CONFIG