Skip to content

Commit

Permalink
Pressure advance Line: support different nozzle sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
SoftFever committed Jan 14, 2024
1 parent f7b92d9 commit d26513e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
8 changes: 5 additions & 3 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2463,9 +2463,11 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato

CalibPressureAdvanceLine pa_test(this);

auto fast_speed = CalibPressureAdvance::find_optimal_PA_speed(print.full_print_config(), pa_test.line_width(), 0.2);
auto slow_speed = std::max(20.0, fast_speed / 10.0);

auto fast_speed = CalibPressureAdvance::find_optimal_PA_speed(print.full_print_config(), pa_test.line_width(), pa_test.height_layer());
auto slow_speed = std::max(10.0, fast_speed / 10.0);
if (fast_speed < slow_speed + 5)
fast_speed = slow_speed + 5;

pa_test.set_speed(fast_speed, slow_speed);
pa_test.draw_numbers() = print.calib_params().print_numbers;
gcode += pa_test.generate_test(params.start, params.step, std::llround(std::ceil((params.end - params.start) / params.step)) + 1);
Expand Down
18 changes: 13 additions & 5 deletions src/libslic3r/calib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,13 @@ std::string CalibPressureAdvance::draw_box(GCodeWriter &writer, double min_x, do

return gcode.str();
}
CalibPressureAdvanceLine::CalibPressureAdvanceLine(GCode* gcodegen)
: CalibPressureAdvance(gcodegen->config()), mp_gcodegen(gcodegen), m_nozzle_diameter(gcodegen->config().nozzle_diameter.get_at(0))
{
m_line_width = m_nozzle_diameter < 0.51 ? m_nozzle_diameter * 1.5 : m_nozzle_diameter * 1.05;
m_height_layer = gcodegen->config().initial_layer_print_height;
m_number_line_width = m_thin_line_width = m_nozzle_diameter;
};

std::string CalibPressureAdvanceLine::generate_test(double start_pa /*= 0*/, double step_pa /*= 0.002*/, int count /*= 10*/)
{
Expand Down Expand Up @@ -496,14 +503,15 @@ std::string CalibPressureAdvanceLine::print_pa_lines(double start_x, double star
// gcode << move_to(Vec2d(start_x + m_length_short + m_length_long, y_pos + (num - 1) * m_space_y + 7), writer);
// gcode << writer.extrude_to_xy(Vec2d(start_x + m_length_short + m_length_long, y_pos + (num - 1) * m_space_y + 2), thin_e_per_mm * 7);

DrawBoxOptArgs default_box_opt_args(2, m_height_layer, 0.6, fast);
const auto box_start_x = start_x + m_length_short + m_length_long + m_length_short;
DrawBoxOptArgs default_box_opt_args(2, m_height_layer, m_line_width, fast);
default_box_opt_args.is_filled = true;
gcode << draw_box(writer, start_x + m_length_short + m_length_long + m_length_short, start_y - m_space_y, number_spacing() * 8,
(num + 1) * m_space_y, default_box_opt_args);
gcode << draw_box(writer, box_start_x, start_y - m_space_y,
number_spacing() * 8, (num + 1) * m_space_y, default_box_opt_args);
gcode << writer.travel_to_z(m_height_layer*2);
for (int i = 0; i < num; i += 2) {
gcode << draw_number(start_x + m_length_short + m_length_long + m_length_short + 3, y_pos + i * m_space_y + m_space_y / 2,
start_pa + i * step_pa, m_draw_digit_mode, m_number_line_width, number_e_per_mm, 3600, writer);
gcode << draw_number(box_start_x + 3 + m_line_width, y_pos + i * m_space_y + m_space_y / 2, start_pa + i * step_pa, m_draw_digit_mode,
m_number_line_width, number_e_per_mm, 3600, writer);
}
}
return gcode.str();
Expand Down
11 changes: 6 additions & 5 deletions src/libslic3r/calib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class CalibPressureAdvance
class CalibPressureAdvanceLine : public CalibPressureAdvance
{
public:
CalibPressureAdvanceLine(GCode *gcodegen) : CalibPressureAdvance(gcodegen->config()), mp_gcodegen(gcodegen),m_nozzle_diameter(gcodegen->config().nozzle_diameter.get_at(0)){};
CalibPressureAdvanceLine(GCode* gcodegen);
~CalibPressureAdvanceLine(){};

std::string generate_test(double start_pa = 0, double step_pa = 0.002, int count = 50);
Expand All @@ -199,6 +199,7 @@ class CalibPressureAdvanceLine : public CalibPressureAdvance
}

const double &line_width() { return m_line_width; };
const double &height_layer() { return m_height_layer; };
bool is_delta() const;
bool &draw_numbers() { return m_draw_numbers; }

Expand All @@ -212,10 +213,10 @@ class CalibPressureAdvanceLine : public CalibPressureAdvance
double m_nozzle_diameter;
double m_slow_speed, m_fast_speed;

const double m_height_layer{0.2};
const double m_line_width{0.6};
const double m_thin_line_width{0.44};
const double m_number_line_width{0.48};
double m_height_layer{0.2};
double m_line_width{0.6};
double m_thin_line_width{0.44};
double m_number_line_width{0.48};
const double m_space_y{3.5};

double m_length_short{20.0}, m_length_long{40.0};
Expand Down

0 comments on commit d26513e

Please sign in to comment.