mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 18:12:10 +00:00
Add ironing fan speed control (#9944)
* Internal bridge fan speed should be applied only if overhang bridge fan control is enabled * Reduce duplicate code * Add ironing fan speed control
This commit is contained in:
@@ -1839,9 +1839,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
m_last_layer_z = 0.f;
|
||||
m_max_layer_z = 0.f;
|
||||
m_last_width = 0.f;
|
||||
m_is_overhang_fan_on = false;
|
||||
m_is_internal_bridge_fan_on = false;
|
||||
m_is_supp_interface_fan_on = false;
|
||||
m_is_role_based_fan_on.fill(false);
|
||||
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||
m_last_mm3_per_mm = 0.;
|
||||
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||
@@ -5602,9 +5600,6 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
||||
|
||||
auto overhang_fan_threshold = EXTRUDER_CONFIG(overhang_fan_threshold);
|
||||
auto enable_overhang_bridge_fan = EXTRUDER_CONFIG(enable_overhang_bridge_fan);
|
||||
|
||||
auto supp_interface_fan_speed = EXTRUDER_CONFIG(support_material_interface_fan_speed);
|
||||
|
||||
|
||||
// { "0%", Overhang_threshold_none },
|
||||
// { "10%", Overhang_threshold_1_4 },
|
||||
@@ -5647,6 +5642,37 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
||||
comment += ";_EXTERNAL_PERIMETER";
|
||||
}
|
||||
|
||||
// Change fan speed based on current extrusion role
|
||||
auto append_role_based_fan_marker = [this, &gcode](const ExtrusionRole role, const std::string_view& marker_prefix, const bool fan_on) {
|
||||
assert(m_enable_cooling_markers);
|
||||
|
||||
if (fan_on) {
|
||||
if (!m_is_role_based_fan_on[role]) {
|
||||
gcode += ";";
|
||||
gcode += marker_prefix;
|
||||
gcode += "_FAN_START\n";
|
||||
m_is_role_based_fan_on[role] = true;
|
||||
}
|
||||
} else {
|
||||
if (m_is_role_based_fan_on[role]) {
|
||||
gcode += ";";
|
||||
gcode += marker_prefix;
|
||||
gcode += "_FAN_END\n";
|
||||
m_is_role_based_fan_on[role] = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
auto apply_role_based_fan_speed = [
|
||||
&path, &append_role_based_fan_marker,
|
||||
supp_interface_fan_speed = EXTRUDER_CONFIG(support_material_interface_fan_speed),
|
||||
ironing_fan_speed = EXTRUDER_CONFIG(ironing_fan_speed)
|
||||
] {
|
||||
append_role_based_fan_marker(erSupportMaterialInterface, "_SUPP_INTERFACE"sv,
|
||||
supp_interface_fan_speed >= 0 && path.role() == erSupportMaterialInterface);
|
||||
append_role_based_fan_marker(erIroning, "_IRONING"sv,
|
||||
ironing_fan_speed >= 0 && path.role() == erIroning);
|
||||
};
|
||||
|
||||
if (!variable_speed) {
|
||||
// F is mm per minute.
|
||||
if( (std::abs(writer().get_current_speed() - F) > EPSILON) || (std::abs(_mm3_per_mm - m_last_mm3_mm) > EPSILON) ){
|
||||
@@ -5703,41 +5729,15 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
||||
if (enable_overhang_bridge_fan) {
|
||||
// BBS: Overhang_threshold_none means Overhang_threshold_1_4 and forcing cooling for all external
|
||||
// perimeter
|
||||
if ((overhang_fan_threshold == Overhang_threshold_none && is_external_perimeter(path.role())) ||
|
||||
(path.role() == erBridgeInfill || path.role() == erOverhangPerimeter)) { // ORCA: Add support for separate internal bridge fan speed control
|
||||
if (!m_is_overhang_fan_on) {
|
||||
gcode += ";_OVERHANG_FAN_START\n";
|
||||
m_is_overhang_fan_on = true;
|
||||
}
|
||||
} else {
|
||||
if (m_is_overhang_fan_on) {
|
||||
m_is_overhang_fan_on = false;
|
||||
gcode += ";_OVERHANG_FAN_END\n";
|
||||
}
|
||||
}
|
||||
if (path.role() == erInternalBridgeInfill) { // ORCA: Add support for separate internal bridge fan speed control
|
||||
if (!m_is_internal_bridge_fan_on) {
|
||||
gcode += ";_INTERNAL_BRIDGE_FAN_START\n";
|
||||
m_is_internal_bridge_fan_on = true;
|
||||
}
|
||||
} else {
|
||||
if (m_is_internal_bridge_fan_on) {
|
||||
m_is_internal_bridge_fan_on = false;
|
||||
gcode += ";_INTERNAL_BRIDGE_FAN_END\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (supp_interface_fan_speed >= 0 && path.role() == erSupportMaterialInterface) {
|
||||
if (!m_is_supp_interface_fan_on) {
|
||||
gcode += ";_SUPP_INTERFACE_FAN_START\n";
|
||||
m_is_supp_interface_fan_on = true;
|
||||
}
|
||||
} else {
|
||||
if (m_is_supp_interface_fan_on) {
|
||||
gcode += ";_SUPP_INTERFACE_FAN_END\n";
|
||||
m_is_supp_interface_fan_on = false;
|
||||
}
|
||||
append_role_based_fan_marker(erOverhangPerimeter, "_OVERHANG"sv,
|
||||
(overhang_fan_threshold == Overhang_threshold_none && is_external_perimeter(path.role())) ||
|
||||
(path.role() == erBridgeInfill || path.role() == erOverhangPerimeter)); // ORCA: Add support for separate internal bridge fan speed control
|
||||
|
||||
// ORCA: Add support for separate internal bridge fan speed control
|
||||
append_role_based_fan_marker(erInternalBridgeInfill, "_INTERNAL_BRIDGE"sv, path.role() == erInternalBridgeInfill);
|
||||
}
|
||||
|
||||
apply_role_based_fan_speed();
|
||||
}
|
||||
// BBS: use G1 if not enable arc fitting or has no arc fitting result or in spiral_mode mode or we are doing sloped extrusion
|
||||
// Attention: G2 and G3 is not supported in spiral_mode mode
|
||||
@@ -5870,43 +5870,14 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
||||
if (m_enable_cooling_markers) {
|
||||
if (enable_overhang_bridge_fan) {
|
||||
cur_fan_enabled = check_overhang_fan(processed_point.overlap, path.role());
|
||||
if (pre_fan_enabled && cur_fan_enabled) {
|
||||
if (!m_is_overhang_fan_on) {
|
||||
gcode += ";_OVERHANG_FAN_START\n";
|
||||
m_is_overhang_fan_on = true;
|
||||
}
|
||||
} else {
|
||||
if (m_is_overhang_fan_on) {
|
||||
m_is_overhang_fan_on = false;
|
||||
gcode += ";_OVERHANG_FAN_END\n";
|
||||
}
|
||||
}
|
||||
append_role_based_fan_marker(erOverhangPerimeter, "_OVERHANG"sv, pre_fan_enabled && cur_fan_enabled);
|
||||
pre_fan_enabled = cur_fan_enabled;
|
||||
|
||||
// ORCA: Add support for separate internal bridge fan speed control
|
||||
append_role_based_fan_marker(erInternalBridgeInfill, "_INTERNAL_BRIDGE"sv, path.role() == erInternalBridgeInfill);
|
||||
}
|
||||
// ORCA: Add support for separate internal bridge fan speed control
|
||||
if (path.role() == erInternalBridgeInfill) {
|
||||
if (!m_is_internal_bridge_fan_on) {
|
||||
gcode += ";_INTERNAL_BRIDGE_FAN_START\n";
|
||||
m_is_internal_bridge_fan_on = true;
|
||||
}
|
||||
} else {
|
||||
if (m_is_internal_bridge_fan_on) {
|
||||
gcode += ";_INTERNAL_BRIDGE_FAN_END\n";
|
||||
m_is_internal_bridge_fan_on = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (supp_interface_fan_speed >= 0 && path.role() == erSupportMaterialInterface) {
|
||||
if (!m_is_supp_interface_fan_on) {
|
||||
gcode += ";_SUPP_INTERFACE_FAN_START\n";
|
||||
m_is_supp_interface_fan_on = true;
|
||||
}
|
||||
} else {
|
||||
if (m_is_supp_interface_fan_on) {
|
||||
gcode += ";_SUPP_INTERFACE_FAN_END\n";
|
||||
m_is_supp_interface_fan_on = false;
|
||||
}
|
||||
}
|
||||
|
||||
apply_role_based_fan_speed();
|
||||
}
|
||||
|
||||
const double line_length = (p - prev).norm();
|
||||
|
||||
Reference in New Issue
Block a user