Merge pull request #2508 from strahlex/machinekit-gcode

added support Machinekit flavour GCode
This commit is contained in:
Alessandro Ranellucci 2015-02-15 17:00:08 +01:00
commit 1180a6d83f
11 changed files with 38 additions and 15 deletions

View file

@ -83,7 +83,7 @@ GCodeWriter::set_temperature(unsigned int temperature, bool wait, int tool)
std::ostringstream gcode;
gcode << code << " ";
if (FLAVOR_IS(gcfMach3)) {
if (FLAVOR_IS(gcfMach3) || FLAVOR_IS(gcfMachinekit)) {
gcode << "P";
} else {
gcode << "S";
@ -118,7 +118,7 @@ GCodeWriter::set_bed_temperature(unsigned int temperature, bool wait)
std::ostringstream gcode;
gcode << code << " ";
if (FLAVOR_IS(gcfMach3)) {
if (FLAVOR_IS(gcfMach3) || FLAVOR_IS(gcfMachinekit)) {
gcode << "P";
} else {
gcode << "S";
@ -153,7 +153,7 @@ GCodeWriter::set_fan(unsigned int speed, bool dont_save)
gcode << "M126";
} else {
gcode << "M106 ";
if (FLAVOR_IS(gcfMach3)) {
if (FLAVOR_IS(gcfMach3) || FLAVOR_IS(gcfMachinekit)) {
gcode << "P";
} else {
gcode << "S";
@ -434,7 +434,10 @@ GCodeWriter::_retract(double length, double restart_extra, const std::string &co
double dE = this->_extruder->retract(length, restart_extra);
if (dE != 0) {
if (this->config.use_firmware_retraction) {
gcode << "G10 ; retract\n";
if (FLAVOR_IS(gcfMachinekit))
gcode << "G22 ; retract\n";
else
gcode << "G10 ; retract\n";
} else {
gcode << "G1 " << this->_extrusion_axis << E_NUM(this->_extruder->E)
<< " F" << this->_extruder->retract_speed_mm_min;
@ -460,7 +463,10 @@ GCodeWriter::unretract()
double dE = this->_extruder->unretract();
if (dE != 0) {
if (this->config.use_firmware_retraction) {
gcode << "G11 ; unretract\n";
if (FLAVOR_IS(gcfMachinekit))
gcode << "G23 ; unretract\n";
else
gcode << "G11 ; unretract\n";
gcode << this->reset_e();
} else {
// use G1 instead of G0 because G0 will blend the restart with the previous travel move
@ -505,8 +511,17 @@ GCodeWriter::get_position() const
return this->_pos;
}
std::string
GCodeWriter::end_program()
{
std::ostringstream gcode;
if (FLAVOR_IS(gcfMachinekit))
gcode << "M2 ; end of program\n";
return gcode.str();
}
#ifdef SLIC3RXS
REGISTER_CLASS(GCodeWriter, "GCode::Writer");
#endif
}
}

View file

@ -46,6 +46,7 @@ class GCodeWriter {
std::string lift();
std::string unlift();
Pointf3 get_position() const;
std::string end_program();
private:
std::string _extrusion_axis;

View file

@ -380,12 +380,14 @@ PrintConfigDef::build_def() {
Options["gcode_flavor"].enum_values.push_back("makerware");
Options["gcode_flavor"].enum_values.push_back("sailfish");
Options["gcode_flavor"].enum_values.push_back("mach3");
Options["gcode_flavor"].enum_values.push_back("machinekit");
Options["gcode_flavor"].enum_values.push_back("no-extrusion");
Options["gcode_flavor"].enum_labels.push_back("RepRap (Marlin/Sprinter/Repetier)");
Options["gcode_flavor"].enum_labels.push_back("Teacup");
Options["gcode_flavor"].enum_labels.push_back("MakerWare (MakerBot)");
Options["gcode_flavor"].enum_labels.push_back("Sailfish (MakerBot)");
Options["gcode_flavor"].enum_labels.push_back("Mach3/LinuxCNC");
Options["gcode_flavor"].enum_labels.push_back("Machinekit");
Options["gcode_flavor"].enum_labels.push_back("No extrusion");
Options["infill_acceleration"].type = coFloat;

View file

@ -6,7 +6,7 @@
namespace Slic3r {
enum GCodeFlavor {
gcfRepRap, gcfTeacup, gcfMakerWare, gcfSailfish, gcfMach3, gcfNoExtrusion,
gcfRepRap, gcfTeacup, gcfMakerWare, gcfSailfish, gcfMach3, gcfMachinekit, gcfNoExtrusion,
};
enum InfillPattern {
@ -29,6 +29,7 @@ template<> inline t_config_enum_values ConfigOptionEnum<GCodeFlavor>::get_enum_v
keys_map["makerware"] = gcfMakerWare;
keys_map["sailfish"] = gcfSailfish;
keys_map["mach3"] = gcfMach3;
keys_map["machinekit"] = gcfMachinekit;
keys_map["no-extrusion"] = gcfNoExtrusion;
return keys_map;
}
@ -410,7 +411,7 @@ class GCodeConfig : public virtual StaticPrintConfig
std::string get_extrusion_axis() const
{
if (this->gcode_flavor.value == gcfMach3) {
if ((this->gcode_flavor.value == gcfMach3) || (this->gcode_flavor.value == gcfMachinekit)) {
return "A";
} else if (this->gcode_flavor.value == gcfNoExtrusion) {
return "";

View file

@ -4,7 +4,7 @@ use strict;
use warnings;
use Slic3r::XS;
use Test::More tests => 108;
use Test::More tests => 110;
foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
$config->set('layer_height', 0.3);
@ -51,6 +51,8 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
is $config->serialize('gcode_flavor'), 'teacup', 'serialize enum';
$config->set_deserialize('gcode_flavor', 'mach3');
is $config->get('gcode_flavor'), 'mach3', 'deserialize enum (gcode_flavor)';
$config->set_deserialize('gcode_flavor', 'machinekit');
is $config->get('gcode_flavor'), 'machinekit', 'deserialize enum (gcode_flavor)';
$config->set_deserialize('fill_pattern', 'line');
is $config->get('fill_pattern'), 'line', 'deserialize enum (fill_pattern)';

View file

@ -45,6 +45,7 @@
std::string lift();
std::string unlift();
Clone<Pointf3> get_position() const;
std::string end_program();
%{
SV*