Fix bug in GCode markers when dynamic overhang speed is enabled

Should fix the following issues: #9594, #9485, #9563, #9588, #9610
Also fixed a problem with zero speed when dynamic speed was percentage based and speeds were set to 0 (auto)
This commit is contained in:
PavelMikus 2023-02-07 17:01:02 +01:00
parent 8472287601
commit a167d43c1d
2 changed files with 6 additions and 5 deletions

View File

@ -2946,10 +2946,10 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string_view de
prev = p;
}
} else {
std::string comment;
std::string marked_comment;
if (m_config.gcode_comments) {
comment = description;
comment += description_bridge;
marked_comment = description;
marked_comment += description_bridge;
}
double last_set_speed = new_points[0].speed * 60.0;
gcode += m_writer.set_speed(last_set_speed, "", comment);
@ -2958,7 +2958,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string_view de
const ProcessedPoint& processed_point = new_points[i];
Vec2d p = this->point_to_gcode_quantized(processed_point.p);
const double line_length = (p - prev).norm();
gcode += m_writer.extrude_to_xy(p, e_per_mm * line_length, comment);
gcode += m_writer.extrude_to_xy(p, e_per_mm * line_length, marked_comment);
prev = p;
double new_speed = processed_point.speed * 60.0;
if (last_set_speed != new_speed) {

View File

@ -264,10 +264,11 @@ public:
float original_speed)
{
size_t speed_sections_count = std::min(overlaps.values.size(), speeds.values.size());
float speed_base = ext_perimeter_speed > 0 ? ext_perimeter_speed : original_speed;
std::vector<std::pair<float, float>> speed_sections;
for (size_t i = 0; i < speed_sections_count; i++) {
float distance = path.width * (1.0 - (overlaps.get_at(i) / 100.0));
float speed = speeds.get_at(i).percent ? (ext_perimeter_speed * speeds.get_at(i).value / 100.0) : speeds.get_at(i).value;
float speed = speeds.get_at(i).percent ? (speed_base * speeds.get_at(i).value / 100.0) : speeds.get_at(i).value;
speed_sections.push_back({distance, speed});
}
std::sort(speed_sections.begin(), speed_sections.end(),