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:
Noisyfox
2025-07-18 16:01:15 +08:00
committed by GitHub
parent 46c0f19cc9
commit c00502638c
8 changed files with 101 additions and 82 deletions

View File

@@ -66,8 +66,11 @@ struct CoolingLine
TYPE_SUPPORT_INTERFACE_FAN_START = 1 << 15,
TYPE_SUPPORT_INTERFACE_FAN_END = 1 << 16,
// ORCA: Add support for separate internal bridge fan speed control
TYPE_INTERNAL_BRIDGE_FAN_START = 1 << 17,
TYPE_INTERNAL_BRIDGE_FAN_END = 1 << 18,
TYPE_INTERNAL_BRIDGE_FAN_START = 1 << 17,
TYPE_INTERNAL_BRIDGE_FAN_END = 1 << 18,
// ORCA: Add support for ironing fan speed control
TYPE_IRONING_FAN_START = 1 << 19,
TYPE_IRONING_FAN_END = 1 << 20,
};
CoolingLine(unsigned int type, size_t line_start, size_t line_end) :
@@ -522,6 +525,10 @@ std::vector<PerExtruderAdjustments> CoolingBuffer::parse_layer_gcode(const std::
line.type = CoolingLine::TYPE_SUPPORT_INTERFACE_FAN_START;
} else if (boost::starts_with(sline, ";_SUPP_INTERFACE_FAN_END")) {
line.type = CoolingLine::TYPE_SUPPORT_INTERFACE_FAN_END;
} else if (boost::starts_with(sline, ";_IRONING_FAN_START")) { // ORCA: Add support for ironing fan speed control
line.type = CoolingLine::TYPE_IRONING_FAN_START;
} else if (boost::starts_with(sline, ";_IRONING_FAN_END")) { // ORCA: Add support for ironing fan speed control
line.type = CoolingLine::TYPE_IRONING_FAN_END;
} else if (boost::starts_with(sline, "G4 ")) {
// Parse the wait time.
line.type = CoolingLine::TYPE_G4;
@@ -716,7 +723,14 @@ std::string CoolingBuffer::apply_layer_cooldown(
int internal_bridge_fan_speed = 0; // ORCA: Add support for separate internal bridge fan speed control
bool supp_interface_fan_control= false;
int supp_interface_fan_speed = 0;
auto change_extruder_set_fan = [ this, layer_id, layer_time, &new_gcode, &overhang_fan_control, &overhang_fan_speed, &internal_bridge_fan_control, &internal_bridge_fan_speed, &supp_interface_fan_control, &supp_interface_fan_speed](bool immediately_apply) {
bool ironing_fan_control= false; // ORCA: Add support for ironing fan speed control
int ironing_fan_speed = 0; // ORCA: Add support for ironing fan speed control
auto change_extruder_set_fan = [ this, layer_id, layer_time, &new_gcode,
&overhang_fan_control, &overhang_fan_speed,
&internal_bridge_fan_control, &internal_bridge_fan_speed,
&supp_interface_fan_control, &supp_interface_fan_speed,
&ironing_fan_control, &ironing_fan_speed
](bool immediately_apply) {
#define EXTRUDER_CONFIG(OPT) m_config.OPT.get_at(m_current_extruder)
float fan_min_speed = EXTRUDER_CONFIG(fan_min_speed);
float fan_speed_new = EXTRUDER_CONFIG(reduce_fan_stop_start_freq) ? fan_min_speed : 0;
@@ -768,6 +782,10 @@ std::string CoolingBuffer::apply_layer_cooldown(
internal_bridge_fan_speed = overhang_fan_speed;
internal_bridge_fan_control = overhang_fan_control;
}
// ORCA: Add support for ironing fan speed control
ironing_fan_speed = EXTRUDER_CONFIG(ironing_fan_speed);
ironing_fan_control = ironing_fan_speed >= 0;
#undef EXTRUDER_CONFIG
} else {
@@ -779,6 +797,8 @@ std::string CoolingBuffer::apply_layer_cooldown(
supp_interface_fan_speed = 0;
internal_bridge_fan_control = false; // ORCA: Add support for separate internal bridge fan speed control
internal_bridge_fan_speed = 0; // ORCA: Add support for separate internal bridge fan speed control
ironing_fan_control = false; // ORCA: Add support for ironing fan speed control
ironing_fan_speed = 0; // ORCA: Add support for ironing fan speed control
}
if (fan_speed_new != m_fan_speed) {
m_fan_speed = fan_speed_new;
@@ -803,6 +823,7 @@ std::string CoolingBuffer::apply_layer_cooldown(
std::unordered_map<int, bool> fan_speed_change_requests = {{CoolingLine::TYPE_OVERHANG_FAN_START, false},
{CoolingLine::TYPE_INTERNAL_BRIDGE_FAN_START, false}, // ORCA: Add support for separate internal bridge fan speed control
{CoolingLine::TYPE_SUPPORT_INTERFACE_FAN_START, false},
{CoolingLine::TYPE_IRONING_FAN_START, false}, // ORCA: Add support for ironing fan speed control
{CoolingLine::TYPE_FORCE_RESUME_FAN, false}};
bool need_set_fan = false;
@@ -851,6 +872,16 @@ std::string CoolingBuffer::apply_layer_cooldown(
fan_speed_change_requests[CoolingLine::TYPE_SUPPORT_INTERFACE_FAN_START] = false;
}
need_set_fan = true;
} else if (line->type & CoolingLine::TYPE_IRONING_FAN_START) {
if (ironing_fan_control && !fan_speed_change_requests[CoolingLine::TYPE_IRONING_FAN_START]) {
fan_speed_change_requests[CoolingLine::TYPE_IRONING_FAN_START] = true;
need_set_fan = true;
}
} else if (line->type & CoolingLine::TYPE_IRONING_FAN_END && fan_speed_change_requests[CoolingLine::TYPE_IRONING_FAN_START]) {
if (ironing_fan_control) {
fan_speed_change_requests[CoolingLine::TYPE_IRONING_FAN_START] = false;
}
need_set_fan = true;
} else if (line->type & CoolingLine::TYPE_FORCE_RESUME_FAN) {
// check if any fan speed change request is active
if (m_fan_speed != -1 && !std::any_of(fan_speed_change_requests.begin(), fan_speed_change_requests.end(), [](const std::pair<int, bool>& p) { return p.second; })){
@@ -957,6 +988,10 @@ std::string CoolingBuffer::apply_layer_cooldown(
new_gcode += GCodeWriter::set_fan(m_config.gcode_flavor, supp_interface_fan_speed);
m_current_fan_speed = supp_interface_fan_speed;
}
else if (fan_speed_change_requests[CoolingLine::TYPE_IRONING_FAN_START]){
new_gcode += GCodeWriter::set_fan(m_config.gcode_flavor, ironing_fan_speed);
m_current_fan_speed = ironing_fan_speed;
}
else if(fan_speed_change_requests[CoolingLine::TYPE_FORCE_RESUME_FAN] && m_current_fan_speed != -1){
new_gcode += GCodeWriter::set_fan(m_config.gcode_flavor, m_current_fan_speed);
fan_speed_change_requests[CoolingLine::TYPE_FORCE_RESUME_FAN] = false;