Skip to content

Commit

Permalink
Calculate time for firmware retractions.
Browse files Browse the repository at this point in the history
  • Loading branch information
vovodroid committed Jun 12, 2024
1 parent 5626009 commit 6efed2c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/libslic3r/GCode/GCodeProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3147,14 +3147,19 @@ void GCodeProcessor::process_G10(const GCodeReader::GCodeLine& line)
}
}

// stores retract move
store_move_vertex(EMoveType::Retract);
std::array<std::optional<double>, 4> g1_axes = { std::nullopt, std::nullopt, std::nullopt, std::nullopt };
g1_axes[E] = - this->m_parser.config().retract_length.get_at(m_extruder_id);
float g1_feedrate = this->m_parser.config().retract_speed.get_at(m_extruder_id) * 60;
process_G1(g1_axes, g1_feedrate);
}

void GCodeProcessor::process_G11(const GCodeReader::GCodeLine& line)
{
// stores unretract move
store_move_vertex(EMoveType::Unretract);

std::array<std::optional<double>, 4> g1_axes = { std::nullopt, std::nullopt, std::nullopt, std::nullopt };
g1_axes[E] = this->m_parser.config().retract_length.get_at(m_extruder_id) + this->m_parser.config().retract_restart_extra.get_at(m_extruder_id);
float g1_feedrate = this->m_parser.config().deretract_speed.get_at(m_extruder_id) * 60;
process_G1(g1_axes, g1_feedrate);
}

void GCodeProcessor::process_G20(const GCodeReader::GCodeLine& line)
Expand Down Expand Up @@ -4354,7 +4359,10 @@ void GCodeProcessor::post_process()
if (!processed)
processed = process_used_filament(gcode_line);
if (!processed && !is_temporary_decoration(gcode_line)) {
if (GCodeReader::GCodeLine::cmd_is(gcode_line, "G0") || GCodeReader::GCodeLine::cmd_is(gcode_line, "G1")) {
if (GCodeReader::GCodeLine::cmd_is(gcode_line, "G0") || GCodeReader::GCodeLine::cmd_is(gcode_line, "G1")
|| GCodeReader::GCodeLine::cmd_is(gcode_line, "G10")
|| GCodeReader::GCodeLine::cmd_is(gcode_line, "G11")
) {
export_lines.append_line(gcode_line);
// add lines M73 where needed
process_line_G1(g1_lines_counter++);
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/GCodeReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ class GCodeReader {
char extrusion_axis() const { return m_extrusion_axis; }
// void set_extrusion_axis(char axis) { m_extrusion_axis = axis; }

GCodeConfig& config() { return m_config; };

private:
template<typename ParseLineCallback, typename LineEndCallback>
bool parse_file_raw_internal(const std::string &filename, ParseLineCallback parse_line_callback, LineEndCallback line_end_callback);
Expand Down

0 comments on commit 6efed2c

Please sign in to comment.