Limiting the resolution of G-code export for retract/deretract feedrate

to three digits.
Fixes excessive precision in gcode? #5362
This commit is contained in:
Vojtech Bubnik 2020-12-04 13:37:26 +01:00
parent efc1100eb0
commit 9c959d14e0

View File

@ -9,7 +9,7 @@
#define FLAVOR_IS(val) this->config.gcode_flavor == val #define FLAVOR_IS(val) this->config.gcode_flavor == val
#define FLAVOR_IS_NOT(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 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 XYZF_NUM(val) PRECISION(val, 3)
#define E_NUM(val) PRECISION(val, 5) #define E_NUM(val) PRECISION(val, 5)
@ -458,7 +458,7 @@ std::string GCodeWriter::_retract(double length, double restart_extra, const std
gcode << "G10 ; retract\n"; gcode << "G10 ; retract\n";
} else { } else {
gcode << "G1 " << m_extrusion_axis << E_NUM(m_extruder->E()) 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); COMMENT(comment);
gcode << "\n"; gcode << "\n";
} }
@ -488,7 +488,7 @@ std::string GCodeWriter::unretract()
} else { } else {
// use G1 instead of G0 because G0 will blend the restart with the previous travel move // 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()) 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"; if (this->config.gcode_comments) gcode << " ; unretract";
gcode << "\n"; gcode << "\n";
} }