Skip to content

Commit

Permalink
Fix cooling slowdown (fix 67b62c2)
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Dec 27, 2023
1 parent 0262730 commit 96d46de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5440,7 +5440,7 @@ double_t GCode::_compute_speed_mm_per_sec(const ExtrusionPath& path, double spee


void GCode::cooldown_marker_init() {
if (!_cooldown_marker_speed[ExtrusionRole::erExternalPerimeter].empty()) {
if (_cooldown_marker_speed[ExtrusionRole::erExternalPerimeter].empty()) {
std::string allow_speed_change = ";CM_extrude_speed;_EXTRUDE_SET_SPEED";
//only change speed on external perimeter (and similar) speed if really necessary.
std::string maybe_allow_speed_change = ";CM_extrude_speed_external;_EXTRUDE_SET_SPEED_MAYBE";
Expand Down
22 changes: 20 additions & 2 deletions src/libslic3r/GCode/CoolingBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void CoolingBuffer::reset(const Vec3d &position)
struct CoolingLine
{
enum Type : uint32_t {
TYPE_NONE = 0,
//first 5 bits are for the extrusiontype (not a flag)

TYPE_SET_TOOL = 1 << 7,
Expand Down Expand Up @@ -79,6 +80,12 @@ struct CoolingLine
length(0.f), has_move(false), feedrate(0.f), time(0.f), time_max(0.f), slowdown(false) {}

bool adjustable(bool slowdown_external_perimeters) const {
std::cout << (this->type & TYPE_ADJUSTABLE) << "=" << (int) this->type << "&" << (int) TYPE_ADJUSTABLE
<< " && "
<< (slowdown_external_perimeters ||
(!(this->type & TYPE_ADJUSTABLE_MAYBE))) << "="
<< slowdown_external_perimeters << "||" << (int) TYPE_ADJUSTABLE_MAYBE
<< " && "<<(this->time < this->time_max) << "\n";
return (this->type & TYPE_ADJUSTABLE) &&
(slowdown_external_perimeters || (!(this->type & TYPE_ADJUSTABLE_MAYBE))) &&
this->time < this->time_max;
Expand Down Expand Up @@ -401,6 +408,8 @@ std::vector<PerExtruderAdjustments> CoolingBuffer::parse_layer_gcode(const std::
// Index of an existing CoolingLine of the current adjustment, which holds the feedrate setting command
// for a sequence of extrusion moves.
size_t active_speed_modifier = size_t(-1);
// type to add to each next G1 (just for adjustable for now)
size_t current_stamp = CoolingLine::TYPE_NONE;

for (; *line_start != 0; line_start = line_end)
{
Expand Down Expand Up @@ -460,10 +469,13 @@ std::vector<PerExtruderAdjustments> CoolingBuffer::parse_layer_gcode(const std::
if (wipe)
line.type |= CoolingLine::TYPE_WIPE;
if (boost::contains(sline, ";_EXTRUDE_SET_SPEED") && ! wipe) {
line.type |= CoolingLine::TYPE_ADJUSTABLE;
active_speed_modifier = adjustment->lines.size();
if (boost::contains(sline, ";_EXTRUDE_SET_SPEED_MAYBE"))
line.type |= CoolingLine::TYPE_ADJUSTABLE;
current_stamp |= CoolingLine::TYPE_ADJUSTABLE;
if (boost::contains(sline, ";_EXTRUDE_SET_SPEED_MAYBE")) {
line.type |= CoolingLine::TYPE_ADJUSTABLE_MAYBE;
current_stamp |= CoolingLine::TYPE_ADJUSTABLE_MAYBE;
}
}
if ((line.type & CoolingLine::TYPE_G92) == 0) {
// G0 or G1. Calculate the duration.
Expand Down Expand Up @@ -494,6 +506,11 @@ std::vector<PerExtruderAdjustments> CoolingBuffer::parse_layer_gcode(const std::
line.length = std::abs(dif[3]);
}
line.feedrate = new_pos[4];
if (line.feedrate > 0.f && line.length > 0.f) {
assert((line.type & CoolingLine::TYPE_ADJUSTABLE) == 0);
assert(active_speed_modifier != size_t(-1));
line.type |= current_stamp;
}
assert((line.type & CoolingLine::TYPE_ADJUSTABLE) == 0 || line.feedrate > 0.f);
if (line.length > 0) {
assert(line.feedrate > 0);
Expand Down Expand Up @@ -546,6 +563,7 @@ std::vector<PerExtruderAdjustments> CoolingBuffer::parse_layer_gcode(const std::
}
}
active_speed_modifier = size_t(-1);
current_stamp = CoolingLine::TYPE_NONE;
} else if (boost::starts_with(sline, ";_TOOLCHANGE")) {
//not using m_toolchange_prefix anymore because there is no use case for it, there is always a _TOOLCHANGE for when a fan change is needed.
int prefix = 13;
Expand Down

0 comments on commit 96d46de

Please sign in to comment.