Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/libslic3r/GCodeWriter.cpp')
-rw-r--r--src/libslic3r/GCodeWriter.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/libslic3r/GCodeWriter.cpp b/src/libslic3r/GCodeWriter.cpp
index 38a1c3ebe..b35387762 100644
--- a/src/libslic3r/GCodeWriter.cpp
+++ b/src/libslic3r/GCodeWriter.cpp
@@ -9,7 +9,7 @@
#define FLAVOR_IS(val) this->config.gcode_flavor == val
#define FLAVOR_IS_NOT(val) this->config.gcode_flavor != val
#define COMMENT(comment) if (this->config.gcode_comments && !comment.empty()) gcode << " ; " << comment;
-#define PRECISION(val, precision) std::fixed << std::setprecision(precision) << val
+#define PRECISION(val, precision) std::fixed << std::setprecision(precision) << (val)
#define XYZF_NUM(val) PRECISION(val, 3)
#define E_NUM(val) PRECISION(val, 5)
@@ -20,7 +20,7 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config)
this->config.apply(print_config, true);
m_extrusion_axis = this->config.get_extrusion_axis();
m_single_extruder_multi_material = print_config.single_extruder_multi_material.value;
- m_max_acceleration = std::lrint((print_config.gcode_flavor.value == gcfMarlin) ?
+ m_max_acceleration = std::lrint((print_config.gcode_flavor.value == gcfMarlin && print_config.machine_limits_usage.value == MachineLimitsUsage::EmitToGCode) ?
print_config.machine_max_acceleration_extruding.values.front() : 0);
}
@@ -46,7 +46,13 @@ std::string GCodeWriter::preamble()
gcode << "G21 ; set units to millimeters\n";
gcode << "G90 ; use absolute coordinates\n";
}
- if (FLAVOR_IS(gcfRepRap) || FLAVOR_IS(gcfMarlin) || FLAVOR_IS(gcfTeacup) || FLAVOR_IS(gcfRepetier) || FLAVOR_IS(gcfSmoothie)) {
+ if (FLAVOR_IS(gcfRepRapSprinter) ||
+ FLAVOR_IS(gcfRepRapFirmware) ||
+ FLAVOR_IS(gcfMarlin) ||
+ 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 {
@@ -72,11 +78,15 @@ std::string GCodeWriter::set_temperature(unsigned int temperature, bool wait, in
return "";
std::string code, comment;
- if (wait && FLAVOR_IS_NOT(gcfTeacup)) {
+ if (wait && FLAVOR_IS_NOT(gcfTeacup) && FLAVOR_IS_NOT(gcfRepRapFirmware)) {
code = "M109";
comment = "set temperature and wait for it to be reached";
} else {
- code = "M104";
+ if (FLAVOR_IS(gcfRepRapFirmware)) { // M104 is deprecated on RepRapFirmware
+ code = "G10";
+ } else {
+ code = "M104";
+ }
comment = "set temperature";
}
@@ -88,14 +98,17 @@ std::string GCodeWriter::set_temperature(unsigned int temperature, bool wait, in
gcode << "S";
}
gcode << temperature;
- if (tool != -1 &&
- ( (this->multiple_extruders && ! m_single_extruder_multi_material) ||
- FLAVOR_IS(gcfMakerWare) || FLAVOR_IS(gcfSailfish)) ) {
- gcode << " T" << tool;
+ bool multiple_tools = this->multiple_extruders && ! m_single_extruder_multi_material;
+ if (tool != -1 && (multiple_tools || FLAVOR_IS(gcfMakerWare) || FLAVOR_IS(gcfSailfish)) ) {
+ if (FLAVOR_IS(gcfRepRapFirmware)) {
+ gcode << " P" << tool;
+ } else {
+ gcode << " T" << tool;
+ }
}
gcode << " ; " << comment << "\n";
- if (FLAVOR_IS(gcfTeacup) && wait)
+ if ((FLAVOR_IS(gcfTeacup) || FLAVOR_IS(gcfRepRapFirmware)) && wait)
gcode << "M116 ; wait for temperature to be reached\n";
return gcode.str();
@@ -445,7 +458,7 @@ std::string GCodeWriter::_retract(double length, double restart_extra, const std
gcode << "G10 ; retract\n";
} else {
gcode << "G1 " << m_extrusion_axis << E_NUM(m_extruder->E())
- << " F" << float(m_extruder->retract_speed() * 60.);
+ << " F" << XYZF_NUM(m_extruder->retract_speed() * 60.);
COMMENT(comment);
gcode << "\n";
}
@@ -475,7 +488,7 @@ std::string GCodeWriter::unretract()
} else {
// use G1 instead of G0 because G0 will blend the restart with the previous travel move
gcode << "G1 " << m_extrusion_axis << E_NUM(m_extruder->E())
- << " F" << float(m_extruder->deretract_speed() * 60.);
+ << " F" << XYZF_NUM(m_extruder->deretract_speed() * 60.);
if (this->config.gcode_comments) gcode << " ; unretract";
gcode << "\n";
}