mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-01 22:37:03 +00:00
Fix overhang fan control when overhang slowdown is enabled (#15158)
This commit is contained in:
@@ -8197,9 +8197,10 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
||||
}
|
||||
variable_speed = std::any_of(new_points.begin(), new_points.end(),
|
||||
[speed](const ProcessedPoint &p) { return fabs(double(p.speed) - speed) > 1; }); // Ignore small speed variations (under 1mm/sec)
|
||||
if (!NOZZLE_CONFIG(enable_overhang_speed) && FILAMENT_CONFIG(enable_overhang_bridge_fan) && m_enable_cooling_markers) {
|
||||
for (ProcessedPoint &point : new_points)
|
||||
point.speed = speed;
|
||||
if (FILAMENT_CONFIG(enable_overhang_bridge_fan) && m_enable_cooling_markers) {
|
||||
if (!NOZZLE_CONFIG(enable_overhang_speed))
|
||||
for (ProcessedPoint &point : new_points)
|
||||
point.speed = speed;
|
||||
variable_speed = new_points.size() > 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1024,28 +1024,29 @@ std::string CoolingBuffer::apply_layer_cooldown(
|
||||
}
|
||||
|
||||
if (need_set_fan) {
|
||||
const auto set_fan = [&](int speed) {
|
||||
if (m_current_fan_speed != speed) {
|
||||
new_gcode += GCodeWriter::set_fan(m_config.gcode_flavor, speed, part_cooling_fan_min_pwm);
|
||||
m_current_fan_speed = speed;
|
||||
}
|
||||
};
|
||||
if (fan_speed_change_requests[CoolingLine::TYPE_OVERHANG_FAN_START]){
|
||||
new_gcode += GCodeWriter::set_fan(m_config.gcode_flavor, overhang_fan_speed, part_cooling_fan_min_pwm);
|
||||
m_current_fan_speed = overhang_fan_speed;
|
||||
set_fan(overhang_fan_speed);
|
||||
} else if (fan_speed_change_requests[CoolingLine::TYPE_INTERNAL_BRIDGE_FAN_START]){ // ORCA: Add support for separate internal bridge fan speed control
|
||||
new_gcode += GCodeWriter::set_fan(m_config.gcode_flavor, internal_bridge_fan_speed, part_cooling_fan_min_pwm);
|
||||
m_current_fan_speed = internal_bridge_fan_speed;
|
||||
set_fan(internal_bridge_fan_speed);
|
||||
}
|
||||
else if (fan_speed_change_requests[CoolingLine::TYPE_SUPPORT_INTERFACE_FAN_START]){
|
||||
new_gcode += GCodeWriter::set_fan(m_config.gcode_flavor, supp_interface_fan_speed, part_cooling_fan_min_pwm);
|
||||
m_current_fan_speed = supp_interface_fan_speed;
|
||||
set_fan(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, part_cooling_fan_min_pwm);
|
||||
m_current_fan_speed = ironing_fan_speed;
|
||||
set_fan(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, part_cooling_fan_min_pwm);
|
||||
fan_speed_change_requests[CoolingLine::TYPE_FORCE_RESUME_FAN] = false;
|
||||
}
|
||||
else {
|
||||
new_gcode += GCodeWriter::set_fan(m_config.gcode_flavor, m_fan_speed, part_cooling_fan_min_pwm);
|
||||
m_current_fan_speed = m_fan_speed;
|
||||
set_fan(m_fan_speed);
|
||||
}
|
||||
need_set_fan = false;
|
||||
}
|
||||
|
||||
@@ -170,14 +170,13 @@ void FanMover::_put_in_middle_G1(std::list<BufferData>::iterator item_to_split,
|
||||
|
||||
void FanMover::_print_in_middle_G1(BufferData& line_to_split, float nb_sec, const std::string &line_to_write) {
|
||||
if (nb_sec < line_to_split.time * 0.1) {
|
||||
// doesn't really need to be split, print it after
|
||||
m_process_output += line_to_split.raw + "\n";
|
||||
// Doesn't need to be split: the insertion point is at the start.
|
||||
m_process_output += line_to_write + (line_to_write.back() == '\n'?"":"\n");
|
||||
} else if (nb_sec > line_to_split.time * 0.9) {
|
||||
// doesn't really need to be split, print it before
|
||||
//will also print before if line_to_split.time == 0
|
||||
m_process_output += line_to_write + (line_to_write.back() == '\n' ? "" : "\n");
|
||||
m_process_output += line_to_split.raw + "\n";
|
||||
} else if (nb_sec > line_to_split.time * 0.9) {
|
||||
// Doesn't need to be split: the insertion point is at the end.
|
||||
m_process_output += line_to_split.raw + "\n";
|
||||
m_process_output += line_to_write + (line_to_write.back() == '\n' ? "" : "\n");
|
||||
}else if(line_to_split.raw.size() > 2
|
||||
&& line_to_split.raw[0] == 'G' && line_to_split.raw[1] == '1' && line_to_split.raw[2] == ' ') {
|
||||
float percent = nb_sec / line_to_split.time;
|
||||
|
||||
@@ -532,7 +532,7 @@ void GCodeProcessor::TimeMachine::calculate_time(GCodeProcessorResult& result, P
|
||||
const float height = interpolate ? lerp(prev_move.height, curr_move.height, t) : curr_move.height;
|
||||
// ORCA: Fix issue with flow rate changes being visualized incorrectly
|
||||
const float mm3_per_mm = curr_move.mm3_per_mm;
|
||||
const float fan_speed = interpolate ? lerp(prev_move.fan_speed, curr_move.fan_speed, t) : curr_move.fan_speed;
|
||||
const float fan_speed = curr_move.fan_speed;
|
||||
const float temperature = interpolate ? lerp(prev_move.temperature, curr_move.temperature, t) : curr_move.temperature;
|
||||
actual_speed_moves.push_back({
|
||||
block.move_id,
|
||||
@@ -563,7 +563,7 @@ void GCodeProcessor::TimeMachine::calculate_time(GCodeProcessorResult& result, P
|
||||
const float height = interpolate ? lerp(prev_move.height, curr_move.height, t) : curr_move.height;
|
||||
// ORCA: Fix issue with flow rate changes being visualized incorrectly
|
||||
const float mm3_per_mm = curr_move.mm3_per_mm;
|
||||
const float fan_speed = interpolate ? lerp(prev_move.fan_speed, curr_move.fan_speed, t) : curr_move.fan_speed;
|
||||
const float fan_speed = curr_move.fan_speed;
|
||||
const float temperature = interpolate ? lerp(prev_move.temperature, curr_move.temperature, t) : curr_move.temperature;
|
||||
actual_speed_moves.push_back({
|
||||
block.move_id,
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
|
||||
#include "test_helpers.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace Slic3r;
|
||||
using namespace Slic3r::Test;
|
||||
@@ -25,3 +28,68 @@ TEST_CASE("Cooling consumes its internal speed markers", "[Cooling]")
|
||||
const std::string gcode = slice({ cube(20) }, { { "layer_height", 0.2 } });
|
||||
CHECK(gcode.find(";_EXTRUDE_SET_SPEED") == std::string::npos);
|
||||
}
|
||||
|
||||
TEST_CASE("Overhang fan transitions do not depend on overhang speed", "[Cooling][Regression]")
|
||||
{
|
||||
DynamicPrintConfig config = DynamicPrintConfig::full_print_config();
|
||||
config.set_deserialize_strict({
|
||||
{ "bridge_speed", 2.0 },
|
||||
{ "enable_arc_fitting", false },
|
||||
{ "enable_overhang_bridge_fan", true },
|
||||
{ "enable_overhang_speed", false },
|
||||
{ "initial_layer_print_height", 0.3 },
|
||||
{ "inner_wall_speed", 30.0 },
|
||||
{ "layer_height", 0.3 },
|
||||
{ "outer_wall_speed", 30.0 },
|
||||
{ "overhang_1_4_speed", "30" },
|
||||
{ "overhang_2_4_speed", "29" },
|
||||
{ "overhang_3_4_speed", "6" },
|
||||
{ "overhang_4_4_speed", "3" },
|
||||
{ "slow_down_for_layer_cooling", false },
|
||||
{ "slowdown_for_curled_perimeters", false },
|
||||
});
|
||||
config.set_key_value("fan_max_speed", new ConfigOptionFloats{20.0});
|
||||
config.set_key_value("fan_min_speed", new ConfigOptionFloats{20.0});
|
||||
config.set_key_value("overhang_fan_speed", new ConfigOptionInts{100});
|
||||
config.set_key_value("overhang_fan_threshold", new ConfigOptionEnumsGeneric{Overhang_threshold_2_4});
|
||||
config.set_key_value("layer_change_gcode", new ConfigOptionString{";TEST_LAYER_Z=[layer_z]"});
|
||||
|
||||
const auto fan_commands = [](const std::string &gcode) {
|
||||
std::vector<std::pair<std::string, std::string>> commands;
|
||||
std::istringstream input(gcode);
|
||||
std::string layer;
|
||||
std::string line;
|
||||
while (std::getline(input, line)) {
|
||||
if (line.rfind(";TEST_LAYER_Z=", 0) == 0)
|
||||
layer = line;
|
||||
else if (!layer.empty() && (line.rfind("M106", 0) == 0 || line.rfind("M107", 0) == 0))
|
||||
commands.emplace_back(layer, line);
|
||||
}
|
||||
return commands;
|
||||
};
|
||||
const auto feedrates = [](const std::string &gcode) {
|
||||
std::vector<std::string> values;
|
||||
std::istringstream input(gcode);
|
||||
std::string word;
|
||||
while (input >> word)
|
||||
if (!word.empty() && word.front() == 'F')
|
||||
values.push_back(word);
|
||||
return values;
|
||||
};
|
||||
|
||||
constexpr double sphere_radius = 50.0; // 100 mm diameter.
|
||||
const std::string without_speed_gcode = slice({make_sphere(sphere_radius, PI / 24.0)}, config);
|
||||
config.set_deserialize_strict({{"enable_overhang_speed", true}});
|
||||
const std::string with_speed_gcode = slice({make_sphere(sphere_radius, PI / 24.0)}, config);
|
||||
|
||||
const auto without_speed_fan = fan_commands(without_speed_gcode);
|
||||
const auto with_speed_fan = fan_commands(with_speed_gcode);
|
||||
const auto without_speed_feedrates = feedrates(without_speed_gcode);
|
||||
const auto with_speed_feedrates = feedrates(with_speed_gcode);
|
||||
|
||||
REQUIRE_FALSE(without_speed_fan.empty());
|
||||
REQUIRE(std::any_of(without_speed_fan.begin(), without_speed_fan.end(),
|
||||
[](const auto &command) { return command.second.find("S255") != std::string::npos; }));
|
||||
REQUIRE(with_speed_feedrates != without_speed_feedrates);
|
||||
CHECK(with_speed_fan == without_speed_fan);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user