From abda05472081e5fe831135ac72b14791bd35fbd1 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sat, 16 Jul 2016 09:52:11 -0500 Subject: [PATCH] Cherry-picked Repetier acceleration fixes, thanks to @lordofhyphens https://github.com/lordofhyphens/Slic3r/commit/e0d8101627659ef2dcf1c49d5c9b512eb4e31a46 https://github.com/lordofhyphens/Slic3r/commit/885f27b8aea0df8be351825b9dd6061696f5edc9 Added a printer settings to enable / disable variable layer height editing. --- README.md | 2 +- lib/Slic3r/GUI/Tab.pm | 3 ++- slic3r.pl | 2 +- utils/zsh/functions/_slic3r | 2 +- xs/src/libslic3r/GCodeWriter.cpp | 11 +++++++++-- xs/src/libslic3r/PrintConfig.cpp | 12 +++++++++++- xs/src/libslic3r/PrintConfig.hpp | 7 +++++-- 7 files changed, 30 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d1254395b..81dfda88a 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ The author of the Silk icon set is Mark James. (default: 100,100) --z-offset Additional height in mm to add to vertical coordinates (+/-, default: 0) - --gcode-flavor The type of G-code to generate (reprap/teacup/makerware/sailfish/mach3/machinekit/no-extrusion, + --gcode-flavor The type of G-code to generate (reprap/teacup/repetier/makerware/sailfish/mach3/machinekit/smoothie/no-extrusion, default: reprap) --use-relative-e-distances Enable this to get relative E values (default: no) --use-firmware-retraction Enable firmware-controlled retraction using G10/G11 (default: no) diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index 80421c991..845c57b84 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -1129,7 +1129,7 @@ sub build { serial_port serial_speed octoprint_host octoprint_apikey use_firmware_retraction pressure_advance - use_volumetric_e + use_volumetric_e variable_layer_height start_gcode end_gcode before_layer_gcode layer_gcode toolchange_gcode nozzle_diameter extruder_offset retract_length retract_lift retract_speed retract_restart_extra retract_before_travel retract_layer_change wipe @@ -1334,6 +1334,7 @@ sub build { $optgroup->append_single_option_line('use_firmware_retraction'); $optgroup->append_single_option_line('use_volumetric_e'); $optgroup->append_single_option_line('pressure_advance'); + $optgroup->append_single_option_line('variable_layer_height'); } } { diff --git a/slic3r.pl b/slic3r.pl index aa6540546..bb7006a25 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -298,7 +298,7 @@ $j (default: 100,100) --z-offset Additional height in mm to add to vertical coordinates (+/-, default: $config->{z_offset}) - --gcode-flavor The type of G-code to generate (reprap/teacup/makerware/sailfish/mach3/machinekit/no-extrusion, + --gcode-flavor The type of G-code to generate (reprap/teacup/repetier/makerware/sailfish/mach3/machinekit/smoothie/no-extrusion, default: $config->{gcode_flavor}) --use-relative-e-distances Enable this to get relative E values (default: no) --use-firmware-retraction Enable firmware-controlled retraction using G10/G11 (default: no) diff --git a/utils/zsh/functions/_slic3r b/utils/zsh/functions/_slic3r index df1cecb03..72957c4eb 100644 --- a/utils/zsh/functions/_slic3r +++ b/utils/zsh/functions/_slic3r @@ -22,7 +22,7 @@ _arguments -S \ '*--nozzle-diameter[specify nozzle diameter]:nozzle diameter in mm' \ '--print-center[specify print center coordinates]:print center coordinates in mm,mm' \ '--z-offset[specify Z-axis offset]:Z-axis offset in mm' \ - '--gcode-flavor[specify the type of G-code to generate]:G-code flavor:(reprap teacup makerware sailfish mach3 machinekit no-extrusion)' \ + '--gcode-flavor[specify the type of G-code to generate]:G-code flavor:(reprap teacup repetier makerware sailfish mach3 machinekit smoothie no-extrusion)' \ '(--use-relative-e-distances --no-use-relative-e-distances)'--{no-,}use-relative-e-distances'[disable/enable relative E values]' \ '--extrusion-axis[specify letter associated with the extrusion axis]:extrusion axis letter' \ '(--gcode-arcs --no-gcode-arcs)'--{no-,}gcode-arcs'[disable/enable G2/G3 commands for native arcs]' \ diff --git a/xs/src/libslic3r/GCodeWriter.cpp b/xs/src/libslic3r/GCodeWriter.cpp index bb74ff124..ab92c6f36 100644 --- a/xs/src/libslic3r/GCodeWriter.cpp +++ b/xs/src/libslic3r/GCodeWriter.cpp @@ -41,7 +41,7 @@ GCodeWriter::preamble() gcode << "G21 ; set units to millimeters\n"; gcode << "G90 ; use absolute coordinates\n"; } - if (FLAVOR_IS(gcfRepRap) || FLAVOR_IS(gcfTeacup)) { + if (FLAVOR_IS(gcfRepRap) || FLAVOR_IS(gcfTeacup) || FLAVOR_IS(gcfRepetier) || FLAVOR_IS(gcfSmoothie)) { if (this->config.use_relative_e_distances) { gcode << "M83 ; use relative distances for extrusion\n"; } else { @@ -172,7 +172,14 @@ GCodeWriter::set_acceleration(unsigned int acceleration) this->_last_acceleration = acceleration; std::ostringstream gcode; - gcode << "M204 S" << acceleration; + if (FLAVOR_IS(gcfRepetier)) { + gcode << "M201 X" << acceleration << " Y" << acceleration; + if (this->config.gcode_comments) gcode << " ; adjust acceleration"; + gcode << "\n"; + gcode << "M202 X" << acceleration << " Y" << acceleration; + } else { + gcode << "M204 S" << acceleration; + } if (this->config.gcode_comments) gcode << " ; adjust acceleration"; gcode << "\n"; diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index a478496ca..8c002aab6 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -526,18 +526,22 @@ PrintConfigDef::PrintConfigDef() def->cli = "gcode-flavor=s"; def->enum_keys_map = ConfigOptionEnum::get_enum_values(); def->enum_values.push_back("reprap"); + def->enum_values.push_back("repetier"); def->enum_values.push_back("teacup"); def->enum_values.push_back("makerware"); def->enum_values.push_back("sailfish"); def->enum_values.push_back("mach3"); def->enum_values.push_back("machinekit"); + def->enum_values.push_back("smoothie"); def->enum_values.push_back("no-extrusion"); - def->enum_labels.push_back("RepRap (Marlin/Sprinter/Repetier)"); + def->enum_labels.push_back("RepRap (Marlin/Sprinter)"); + def->enum_labels.push_back("Repetier"); def->enum_labels.push_back("Teacup"); def->enum_labels.push_back("MakerWare (MakerBot)"); def->enum_labels.push_back("Sailfish (MakerBot)"); def->enum_labels.push_back("Mach3/LinuxCNC"); def->enum_labels.push_back("Machinekit"); + def->enum_labels.push_back("Smoothie"); def->enum_labels.push_back("No extrusion"); def->default_value = new ConfigOptionEnum(gcfRepRap); @@ -1432,6 +1436,12 @@ PrintConfigDef::PrintConfigDef() def->cli = "use-volumetric-e!"; def->default_value = new ConfigOptionBool(false); + def = this->add("variable_layer_height", coBool); + def->label = "Enable variable layer height feature"; + def->tooltip = "Some printers or printer setups may have difficulties printing with a variable layer height. Enabled by default."; + def->cli = "variable-layer-height!"; + def->default_value = new ConfigOptionBool(true); + def = this->add("wipe", coBools); def->label = "Wipe while retracting"; def->tooltip = "This flag will move the nozzle while retracting to minimize the possible blob on leaky extruders."; diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 9964d6f28..5ee787285 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -26,7 +26,7 @@ namespace Slic3r { enum GCodeFlavor { - gcfRepRap, gcfTeacup, gcfMakerWare, gcfSailfish, gcfMach3, gcfMachinekit, gcfNoExtrusion, + gcfRepRap, gcfTeacup, gcfMakerWare, gcfSailfish, gcfMach3, gcfMachinekit, gcfNoExtrusion, gcfSmoothie, gcfRepetier, }; enum InfillPattern { @@ -45,9 +45,11 @@ enum SeamPosition { template<> inline t_config_enum_values ConfigOptionEnum::get_enum_values() { t_config_enum_values keys_map; keys_map["reprap"] = gcfRepRap; + keys_map["repetier"] = gcfRepetier; keys_map["teacup"] = gcfTeacup; keys_map["makerware"] = gcfMakerWare; keys_map["sailfish"] = gcfSailfish; + keys_map["smoothie"] = gcfSmoothie; keys_map["mach3"] = gcfMach3; keys_map["machinekit"] = gcfMachinekit; keys_map["no-extrusion"] = gcfNoExtrusion; @@ -324,6 +326,7 @@ class GCodeConfig : public virtual StaticPrintConfig ConfigOptionBool use_firmware_retraction; ConfigOptionBool use_relative_e_distances; ConfigOptionBool use_volumetric_e; + ConfigOptionBool variable_layer_height; GCodeConfig(bool initialize = true) : StaticPrintConfig() { if (initialize) @@ -361,7 +364,7 @@ class GCodeConfig : public virtual StaticPrintConfig OPT_PTR(use_firmware_retraction); OPT_PTR(use_relative_e_distances); OPT_PTR(use_volumetric_e); - + OPT_PTR(variable_layer_height); return NULL; };