diff --git a/README.md b/README.md index 777b23008..24d5829c2 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,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 b6ab68a87..6f40e57a3 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/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/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__ 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 878e48764..b3909c8ed 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 { @@ -186,7 +186,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 97c6f1f92..59dc5bfb1 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -467,6 +467,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"); @@ -474,7 +475,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 5deaab951..c672b4669 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, gcfSmoothie, + gcfRepRap, gcfTeacup, gcfMakerWare, gcfSailfish, gcfMach3, gcfMachinekit, gcfNoExtrusion, gcfSmoothie, gcfRepetier, }; enum InfillPattern { @@ -45,6 +45,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;