From e0d8101627659ef2dcf1c49d5c9b512eb4e31a46 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sat, 16 Jul 2016 09:52:11 -0500 Subject: [PATCH 1/3] Added Repetier FW flavor, fixed accel gcode generation for it. Addresses #3426 --- README.md | 2 +- slic3r.pl | 2 +- utils/zsh/functions/_slic3r | 2 +- xs/src/libslic3r/GCodeWriter.cpp | 9 +++++++-- xs/src/libslic3r/PrintConfig.cpp | 4 +++- xs/src/libslic3r/PrintConfig.hpp | 3 ++- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9c34e7be7..f84b6edac 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,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/smoothie/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/slic3r.pl b/slic3r.pl index c634e7272..1893de033 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -296,7 +296,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/smoothie/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..a78da948a 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 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 d256ab2af..7c2b17a14 100644 --- a/xs/src/libslic3r/GCodeWriter.cpp +++ b/xs/src/libslic3r/GCodeWriter.cpp @@ -54,7 +54,7 @@ GCodeWriter::preamble() gcode << "G21 ; set units to millimeters\n"; gcode << "G90 ; use absolute coordinates\n"; } - if (FLAVOR_IS(gcfRepRap) || FLAVOR_IS(gcfTeacup) || FLAVOR_IS(gcfSmoothie)) { + 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 { @@ -185,7 +185,12 @@ 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; + 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 90af82fbd..03efad703 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -463,6 +463,7 @@ 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"); @@ -470,7 +471,8 @@ PrintConfigDef::PrintConfigDef() 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)"); diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 442af51c2..9b43070c5 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -9,7 +9,7 @@ namespace Slic3r { enum GCodeFlavor { - gcfRepRap, gcfTeacup, gcfMakerWare, gcfSailfish, gcfMach3, gcfMachinekit, gcfNoExtrusion, gcfSmoothie, + gcfRepRap, gcfTeacup, gcfMakerWare, gcfSailfish, gcfMach3, gcfMachinekit, gcfNoExtrusion, gcfSmoothie, gcfRepetier, }; enum InfillPattern { @@ -28,6 +28,7 @@ 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; From 885f27b8aea0df8be351825b9dd6061696f5edc9 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sat, 16 Jul 2016 09:56:41 -0500 Subject: [PATCH 2/3] Oops, forgot to add newline. --- xs/src/libslic3r/GCodeWriter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xs/src/libslic3r/GCodeWriter.cpp b/xs/src/libslic3r/GCodeWriter.cpp index 7c2b17a14..e894f382a 100644 --- a/xs/src/libslic3r/GCodeWriter.cpp +++ b/xs/src/libslic3r/GCodeWriter.cpp @@ -187,6 +187,8 @@ GCodeWriter::set_acceleration(unsigned int acceleration) std::ostringstream gcode; 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; From e56a29aaf3d9f67bfe9a0bae5c85356b3db4c40c Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Wed, 20 Jul 2016 18:15:24 -0500 Subject: [PATCH 3/3] Test to ensure that the repetier firmware returns the correct acceleration M code and that the values are set properly. --- t/gcode.t | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/t/gcode.t b/t/gcode.t index ef2209a80..9e7bd354a 100644 --- a/t/gcode.t +++ b/t/gcode.t @@ -1,4 +1,4 @@ -use Test::More tests => 23; +use Test::More tests => 25; use strict; use warnings; @@ -215,4 +215,31 @@ use Slic3r::Test; ok !$spiral, 'spiral vase is correctly disabled on layers with multiple loops'; } + +{ + # Tests that the Repetier flavor produces M201 Xnnn Ynnn for resetting + # acceleration, also that M204 Snnn syntax is not generated. + my $config = Slic3r::Config->new_from_defaults; + $config->set('gcode_flavor', 'repetier'); + $config->set('default_acceleration', 1337); + my $print = Slic3r::Test::init_print('cube_with_hole', config => $config); + + my $has_accel = 0; + my $has_m204 = 0; + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if ($cmd eq 'M201' && exists $args->{X} && exists $args->{Y}) { + if ($args->{X} == 1337 && $args->{Y} == 1337) { + $has_accel = 1; + } + } + if ($cmd eq 'M204' && exists $args->{S}) { + $has_m204 = 1; + } + }); + ok $has_accel, 'M201 is generated for repetier firmware.'; + ok !$has_m204, 'M204 is not generated for repetier firmware'; +} + __END__