Browse Source

new retraction calibration
had to add an override from region to ~gcode writer (and gcode),
maybe I have to think about a better system that the current system that will began to transform into a spaghetti monster

supermerill 4 years ago
parent
commit
dd2e3241f8

+ 31 - 0
resources/calibration/retraction/retraction.html

@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html lang="fr">
+<head>
+  <meta charset="utf-8">
+  <title>Retraction Calibration</title>
+</head>
+<body>
+
+<table width="100%">
+<tbody>
+<tr>
+<td style="text-align: center;">
+<h1>Retraction Calibration</h1>
+</td>
+<td style="text-align: right;"><strong>
+	<table><tr><td>needs:</td><td style="text-align: left;">Flow</td><td style="text-align: left;">Temp</td></tr>
+	</table>
+	</strong>
+</tr>
+</tbody>
+</table>
+
+<p>it's preferable to have done the flow and temperature calibration.
+This calibration will help you to choose the right retraction legnth for your extrudr and the current filament.</p>
+<p>This test will print some retraction test patches</h2>
+<p>The goal is to choose the highest temperature possible that doesn't produce artifacts.</p>
+<p>First, you have to analyse the tower. Each floor has the according temperature written on it.</p>
+<h2>Notes</h2>
+<p>The retraction speed should be set to the maximum value your extruder/drivers/firmware can reliably support.</p>
+</body>
+</html>

BIN
resources/calibration/retraction/retraction_calibration.amf


BIN
resources/calibration/retraction/retraction_calibration_pillar.amf


+ 11 - 6
src/libslic3r/GCode.cpp

@@ -234,9 +234,12 @@ std::string Wipe::wipe(GCode &gcodegen, bool toolchange)
     double wipe_speed = gcodegen.writer().config.travel_speed.value * 0.8;
     
     // get the retraction length
-    double length = toolchange
-        ? gcodegen.writer().tool()->retract_length_toolchange()
-        : gcodegen.writer().tool()->retract_length();
+    double length = gcodegen.writer().tool()->retract_length();
+    if (toolchange) {
+        length = gcodegen.writer().tool()->retract_length_toolchange();
+    } else if (gcodegen.writer().config_region && gcodegen.writer().config_region->print_retract_length.value >= 0) {
+        length = gcodegen.writer().config_region->print_retract_length.value;
+    }
     // Shorten the retraction length by the amount already retracted before wipe.
     length *= (1. - gcodegen.writer().tool()->retract_before_wipe());
 
@@ -2501,7 +2504,7 @@ void GCode::process_layer(
                     m_layer = layers[instance_to_print.layer_id].layer();
                 }
                 for (ObjectByExtruder::Island &island : instance_to_print.object_by_extruder.islands) {
-                    const auto& by_region_specific = 
+                    const std::vector<ObjectByExtruder::Island::Region>& by_region_specific =
                         is_anything_overridden ? 
                         island.by_region_per_copy(by_region_per_copy_cache, 
                             static_cast<unsigned int>(instance_to_print.instance_id), 
@@ -3732,8 +3735,9 @@ std::string GCode::extrude_perimeters(const Print &print, const std::vector<Obje
 {
     std::string gcode;
     for (const ObjectByExtruder::Island::Region &region : by_region)
-        if (! region.perimeters.empty()) {
+        if (!region.perimeters.empty()) {
             m_config.apply(print.regions()[&region - &by_region.front()]->config());
+            m_writer.apply_print_region_config(print.regions()[&region - &by_region.front()]->config());
             for (const ExtrusionEntity *ee : region.perimeters)
                 gcode += this->extrude_entity(*ee, "", -1., &lower_layer_edge_grid);
         }
@@ -3745,8 +3749,9 @@ std::string GCode::extrude_infill(const Print &print, const std::vector<ObjectBy
 {
     std::string gcode;
     for (const ObjectByExtruder::Island::Region &region : by_region) {
-        if (print.regions()[&region - &by_region.front()]->config().infill_first == is_infill_first) {
+        if (!region.infills.empty() && print.regions()[&region - &by_region.front()]->config().infill_first == is_infill_first) {
             m_config.apply(print.regions()[&region - &by_region.front()]->config());
+            m_writer.apply_print_region_config(print.regions()[&region - &by_region.front()]->config());
             ExtrusionEntitiesPtr extrusions { region.infills };
             chain_and_reorder_extrusion_entities(extrusions, &m_last_pos);
             for (const ExtrusionEntity *fill : extrusions) {

+ 13 - 0
src/libslic3r/GCodeWriter.cpp

@@ -26,6 +26,11 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config)
         print_config.machine_max_acceleration_extruding.values.front() : 0);
 }
 
+void GCodeWriter::apply_print_region_config(const PrintRegionConfig& print_region_config)
+{
+    config_region = &print_region_config;
+}
+
 void GCodeWriter::set_extruders(std::vector<uint16_t> extruder_ids)
 {
     std::sort(extruder_ids.begin(), extruder_ids.end());
@@ -474,6 +479,14 @@ std::string GCodeWriter::retract(bool before_wipe)
 {
     double factor = before_wipe ? m_tool->retract_before_wipe() : 1.;
     assert(factor >= 0. && factor <= 1. + EPSILON);
+    //check for override
+    if (config_region && config_region->print_retract_length >= 0) {
+        return this->_retract(
+            factor * config_region->print_retract_length,
+            factor * m_tool->retract_restart_extra(),
+            "retract"
+        );
+    }
     return this->_retract(
         factor * m_tool->retract_length(),
         factor * m_tool->retract_restart_extra(),

+ 3 - 0
src/libslic3r/GCodeWriter.hpp

@@ -15,6 +15,8 @@ public:
     static std::string PausePrintCode;
     GCodeConfig config;
     bool multiple_extruders;
+    // override from region
+    const PrintRegionConfig* config_region = nullptr;
     
     GCodeWriter() : 
         multiple_extruders(false), m_extrusion_axis("E"), m_tool(nullptr),
@@ -28,6 +30,7 @@ public:
 
     std::string         extrusion_axis() const { return m_extrusion_axis; }
     void                apply_print_config(const PrintConfig &print_config);
+    void                apply_print_region_config(const PrintRegionConfig& print_region_config);
     // Extruders are expected to be sorted in an increasing order.
     void                set_extruders(std::vector<uint16_t> extruder_ids);
     const std::vector<Extruder>& extruders() const { return m_extruders; }

+ 10 - 0
src/libslic3r/PrintConfig.cpp

@@ -2463,6 +2463,7 @@ void PrintConfigDef::init_fff_params()
     def->tooltip = L("Retraction is not triggered when travel moves are shorter than this length.");
     def->sidetext = L("mm");
     def->mode = comAdvanced;
+    def->min = 0;
     def->set_default_value(new ConfigOptionFloats { 2. });
 
     def = this->add("retract_before_wipe", coPercents);
@@ -2488,8 +2489,16 @@ void PrintConfigDef::init_fff_params()
     def->tooltip = L("When retraction is triggered, filament is pulled back by the specified amount "
                    "(the length is measured on raw filament, before it enters the extruder).");
     def->sidetext = L("mm (zero to disable)");
+    def->min = 0;
     def->set_default_value(new ConfigOptionFloats { 2. });
 
+    def = this->add("print_retract_length", coFloat);
+    def->label = L("Retraction length");
+    def->category = OptionCategory::width;
+    def->tooltip = L("Override the retract_length settign from the printer config. Used for calibration. Set negative to disable");
+    def->mode = comExpert;
+    def->set_default_value(new ConfigOptionFloat( -1.f));
+
     def = this->add("retract_length_toolchange", coFloats);
     def->label = L("Length");
     def->full_label = L("Retraction Length (Toolchange)");
@@ -2498,6 +2507,7 @@ void PrintConfigDef::init_fff_params()
                    "the extruder).");
     def->sidetext = L("mm (zero to disable)");
     def->mode = comExpert;
+    def->min = 0;
     def->set_default_value(new ConfigOptionFloats { 10. });
 
     def = this->add("retract_lift", coFloats);

+ 2 - 0
src/libslic3r/PrintConfig.hpp

@@ -681,6 +681,7 @@ public:
     // Total number of perimeters.
     ConfigOptionInt                 perimeters;
     ConfigOptionPercent             print_extrusion_multiplier;
+    ConfigOptionFloat               print_retract_length;
     ConfigOptionFloatOrPercent      small_perimeter_speed;
     ConfigOptionEnum<InfillPattern> solid_fill_pattern;
     ConfigOptionFloat               solid_infill_below_area;
@@ -768,6 +769,7 @@ protected:
         OPT_PTR(perimeter_speed);
         OPT_PTR(perimeters);
         OPT_PTR(print_extrusion_multiplier);
+        OPT_PTR(print_retract_length);
         OPT_PTR(small_perimeter_speed);
         OPT_PTR(solid_fill_pattern);
         OPT_PTR(solid_infill_below_area);

+ 18 - 4
src/libslic3r/SVG.cpp

@@ -154,16 +154,30 @@ SVG::draw_outline(const Surfaces &surfaces, std::string stroke_outer, std::strin
 }
 
 void
-SVG::draw(const SurfacesPtr &surfaces, std::string fill, const float fill_opacity)
+SVG::draw(const SurfacesPtr& surfaces, std::string fill, const float fill_opacity)
 {
     for (SurfacesPtr::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
         this->draw(*(*it), fill, fill_opacity);
 }
 
-void 
-SVG::draw_outline(const SurfacesPtr &surfaces, std::string stroke_outer, std::string stroke_holes, coordf_t stroke_width)
+void
+SVG::draw_outline(const SurfacesPtr& surfaces, std::string stroke_outer, std::string stroke_holes, coordf_t stroke_width)
+{
+    for (SurfacesPtr::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
+        draw_outline(*(*it), stroke_outer, stroke_holes, stroke_width);
+}
+
+void
+SVG::draw(const SurfacesConstPtr& surfaces, std::string fill, const float fill_opacity)
+{
+    for (SurfacesConstPtr::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
+        this->draw(*(*it), fill, fill_opacity);
+}
+
+void
+SVG::draw_outline(const SurfacesConstPtr& surfaces, std::string stroke_outer, std::string stroke_holes, coordf_t stroke_width)
 {
-    for (SurfacesPtr::const_iterator it = surfaces.begin(); it != surfaces.end(); ++ it)
+    for (SurfacesConstPtr::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
         draw_outline(*(*it), stroke_outer, stroke_holes, stroke_width);
 }
 

+ 4 - 2
src/libslic3r/SVG.hpp

@@ -53,8 +53,10 @@ public:
     void draw_outline(const Surface &surface, std::string stroke_outer = "black", std::string stroke_holes = "blue", coordf_t stroke_width = 0);
     void draw(const Surfaces &surfaces, std::string fill = "grey", const float fill_opacity=1.f);
     void draw_outline(const Surfaces &surfaces, std::string stroke_outer = "black", std::string stroke_holes = "blue", coordf_t stroke_width = 0);
-    void draw(const SurfacesPtr &surfaces, std::string fill = "grey", const float fill_opacity=1.f);
-    void draw_outline(const SurfacesPtr &surfaces, std::string stroke_outer = "black", std::string stroke_holes = "blue", coordf_t stroke_width = 0);
+    void draw(const SurfacesPtr& surfaces, std::string fill = "grey", const float fill_opacity = 1.f);
+    void draw_outline(const SurfacesPtr& surfaces, std::string stroke_outer = "black", std::string stroke_holes = "blue", coordf_t stroke_width = 0);
+    void draw(const SurfacesConstPtr& surfaces, std::string fill = "grey", const float fill_opacity = 1.f);
+    void draw_outline(const SurfacesConstPtr& surfaces, std::string stroke_outer = "black", std::string stroke_holes = "blue", coordf_t stroke_width = 0);
  
     void draw(const Polygon &polygon, std::string fill = "grey");
     void draw_outline(const Polygon &polygon, std::string stroke = "black", coordf_t stroke_width = 0);

Some files were not shown because too many files changed in this diff