mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 18:27:58 -06:00
Suggest firmware retraction time (#5926)
* Suggest firmware retraction time
This commit is contained in:
parent
2ee3800a47
commit
4a81fe6134
4 changed files with 21 additions and 14 deletions
|
@ -695,7 +695,9 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
|
||||||
if (!disable_m73 && !processed &&!is_temporary_decoration(gcode_line) &&
|
if (!disable_m73 && !processed &&!is_temporary_decoration(gcode_line) &&
|
||||||
(GCodeReader::GCodeLine::cmd_is(gcode_line, "G1") ||
|
(GCodeReader::GCodeLine::cmd_is(gcode_line, "G1") ||
|
||||||
GCodeReader::GCodeLine::cmd_is(gcode_line, "G2") ||
|
GCodeReader::GCodeLine::cmd_is(gcode_line, "G2") ||
|
||||||
GCodeReader::GCodeLine::cmd_is(gcode_line, "G3"))) {
|
GCodeReader::GCodeLine::cmd_is(gcode_line, "G3") ||
|
||||||
|
GCodeReader::GCodeLine::cmd_is(gcode_line, "G10")||
|
||||||
|
GCodeReader::GCodeLine::cmd_is(gcode_line, "G11"))) {
|
||||||
// remove temporary lines, add lines M73 where needed
|
// remove temporary lines, add lines M73 where needed
|
||||||
unsigned int extra_lines_count = process_line_move(g1_lines_counter ++);
|
unsigned int extra_lines_count = process_line_move(g1_lines_counter ++);
|
||||||
if (extra_lines_count > 0)
|
if (extra_lines_count > 0)
|
||||||
|
@ -3813,14 +3815,18 @@ void GCodeProcessor::process_G29(const GCodeReader::GCodeLine& line)
|
||||||
|
|
||||||
void GCodeProcessor::process_G10(const GCodeReader::GCodeLine& line)
|
void GCodeProcessor::process_G10(const GCodeReader::GCodeLine& line)
|
||||||
{
|
{
|
||||||
// stores retract move
|
GCodeReader::GCodeLine g10;
|
||||||
store_move_vertex(EMoveType::Retract);
|
g10.set(Axis::E, -this->m_parser.config().retraction_length.get_at(m_extruder_id));
|
||||||
|
g10.set(Axis::F, this->m_parser.config().retraction_speed.get_at(m_extruder_id) * 60);
|
||||||
|
process_G1(g10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeProcessor::process_G11(const GCodeReader::GCodeLine& line)
|
void GCodeProcessor::process_G11(const GCodeReader::GCodeLine& line)
|
||||||
{
|
{
|
||||||
// stores unretract move
|
GCodeReader::GCodeLine g11;
|
||||||
store_move_vertex(EMoveType::Unretract);
|
g11.set(Axis::E, this->m_parser.config().retraction_length.get_at(m_extruder_id) + this->m_parser.config().retract_restart_extra.get_at(m_extruder_id));
|
||||||
|
g11.set(Axis::F, this->m_parser.config().deretraction_speed.get_at(m_extruder_id) * 60);
|
||||||
|
process_G1(g11);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeProcessor::process_G20(const GCodeReader::GCodeLine& line)
|
void GCodeProcessor::process_G20(const GCodeReader::GCodeLine& line)
|
||||||
|
|
|
@ -131,7 +131,7 @@ std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer)
|
||||||
if (line.has_z() && !line.retracting(reader)) {
|
if (line.has_z() && !line.retracting(reader)) {
|
||||||
// If this is the initial Z move of the layer, replace it with a
|
// If this is the initial Z move of the layer, replace it with a
|
||||||
// (redundant) move to the last Z of previous layer.
|
// (redundant) move to the last Z of previous layer.
|
||||||
line.set(reader, Z, z);
|
line.set(Z, z);
|
||||||
new_gcode += line.raw() + '\n';
|
new_gcode += line.raw() + '\n';
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -142,17 +142,17 @@ std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer)
|
||||||
float factor = len / total_layer_length;
|
float factor = len / total_layer_length;
|
||||||
if (transition_in)
|
if (transition_in)
|
||||||
// Transition layer, interpolate the amount of extrusion from zero to the final value.
|
// Transition layer, interpolate the amount of extrusion from zero to the final value.
|
||||||
line.set(reader, E, line.e() * factor, 5 /*decimal_digits*/);
|
line.set(E, line.e() * factor, 5 /*decimal_digits*/);
|
||||||
else if (transition_out) {
|
else if (transition_out) {
|
||||||
// We want the last layer to ramp down extrusion, but without changing z height!
|
// We want the last layer to ramp down extrusion, but without changing z height!
|
||||||
// So clone the line before we mess with its Z and duplicate it into a new layer that ramps down E
|
// So clone the line before we mess with its Z and duplicate it into a new layer that ramps down E
|
||||||
// We add this new layer at the very end
|
// We add this new layer at the very end
|
||||||
GCodeReader::GCodeLine transitionLine(line);
|
GCodeReader::GCodeLine transitionLine(line);
|
||||||
transitionLine.set(reader, E, line.e() * (1 - factor), 5 /*decimal_digits*/);
|
transitionLine.set(E, line.e() * (1 - factor), 5 /*decimal_digits*/);
|
||||||
transition_gcode += transitionLine.raw() + '\n';
|
transition_gcode += transitionLine.raw() + '\n';
|
||||||
}
|
}
|
||||||
// This line is the core of Spiral Vase mode, ramp up the Z smoothly
|
// This line is the core of Spiral Vase mode, ramp up the Z smoothly
|
||||||
line.set(reader, Z, z + factor * layer_height);
|
line.set(Z, z + factor * layer_height);
|
||||||
if (smooth_spiral) {
|
if (smooth_spiral) {
|
||||||
// Now we also need to try to interpolate X and Y
|
// Now we also need to try to interpolate X and Y
|
||||||
SpiralVase::SpiralPoint p(line.x(), line.y()); // Get current x/y coordinates
|
SpiralVase::SpiralPoint p(line.x(), line.y()); // Get current x/y coordinates
|
||||||
|
@ -171,10 +171,10 @@ std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer)
|
||||||
if (modified_dist_XY < 0.001)
|
if (modified_dist_XY < 0.001)
|
||||||
line.clear();
|
line.clear();
|
||||||
else {
|
else {
|
||||||
line.set(reader, X, target.x);
|
line.set(X, target.x);
|
||||||
line.set(reader, Y, target.y);
|
line.set(Y, target.y);
|
||||||
// Scale the extrusion amount according to change in length
|
// Scale the extrusion amount according to change in length
|
||||||
line.set(reader, E, line.e() * modified_dist_XY / dist_XY, 5 /*decimal_digits*/);
|
line.set(E, line.e() * modified_dist_XY / dist_XY, 5 /*decimal_digits*/);
|
||||||
last_point = target;
|
last_point = target;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -275,7 +275,7 @@ bool GCodeReader::GCodeLine::has_value(char axis, float &value) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeReader::GCodeLine::set(const GCodeReader &reader, const Axis axis, const float new_value, const int decimal_digits)
|
void GCodeReader::GCodeLine::set(const Axis axis, const float new_value, const int decimal_digits)
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << std::fixed << std::setprecision(decimal_digits) << new_value;
|
ss << std::fixed << std::setprecision(decimal_digits) << new_value;
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
bool extruding(const GCodeReader &reader) const { return (this->cmd_is("G1") || this->cmd_is("G2") || this->cmd_is("G3")) && this->dist_E(reader) > 0; }
|
bool extruding(const GCodeReader &reader) const { return (this->cmd_is("G1") || this->cmd_is("G2") || this->cmd_is("G3")) && this->dist_E(reader) > 0; }
|
||||||
bool retracting(const GCodeReader &reader) const { return (this->cmd_is("G1") || this->cmd_is("G2") || this->cmd_is("G3")) && this->dist_E(reader) < 0; }
|
bool retracting(const GCodeReader &reader) const { return (this->cmd_is("G1") || this->cmd_is("G2") || this->cmd_is("G3")) && this->dist_E(reader) < 0; }
|
||||||
bool travel() const { return (this->cmd_is("G1") || this->cmd_is("G2") || this->cmd_is("G3")) && ! this->has(E); }
|
bool travel() const { return (this->cmd_is("G1") || this->cmd_is("G2") || this->cmd_is("G3")) && ! this->has(E); }
|
||||||
void set(const GCodeReader &reader, const Axis axis, const float new_value, const int decimal_digits = 3);
|
void set(const Axis axis, const float new_value, const int decimal_digits = 3);
|
||||||
|
|
||||||
bool has_x() const { return this->has(X); }
|
bool has_x() const { return this->has(X); }
|
||||||
bool has_y() const { return this->has(Y); }
|
bool has_y() const { return this->has(Y); }
|
||||||
|
@ -93,6 +93,7 @@ public:
|
||||||
void reset() { memset(m_position, 0, sizeof(m_position)); }
|
void reset() { memset(m_position, 0, sizeof(m_position)); }
|
||||||
void apply_config(const GCodeConfig &config);
|
void apply_config(const GCodeConfig &config);
|
||||||
void apply_config(const DynamicPrintConfig &config);
|
void apply_config(const DynamicPrintConfig &config);
|
||||||
|
const GCodeConfig& config() { return m_config; };
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
void parse_buffer(const std::string &buffer, Callback callback)
|
void parse_buffer(const std::string &buffer, Callback callback)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue