Fixed an Pressure Advance calibration issue(line) for delta machines #803

(cherry picked from commit 27f92f12dc)
This commit is contained in:
SoftFever 2023-04-22 17:27:41 +08:00 committed by SoftFever
parent 6ee076ab5e
commit 338aa0a6ae

View file

@ -9,16 +9,30 @@ namespace Slic3r {
calib_pressure_advance::calib_pressure_advance(GCode* gcodegen) :mp_gcodegen(gcodegen), m_length_short(20.0), m_length_long(40.0), m_space_y(3.5), m_line_width(0.6), m_draw_numbers(true) {} calib_pressure_advance::calib_pressure_advance(GCode* gcodegen) :mp_gcodegen(gcodegen), m_length_short(20.0), m_length_long(40.0), m_space_y(3.5), m_line_width(0.6), m_draw_numbers(true) {}
std::string calib_pressure_advance::generate_test(double start_pa/*= 0*/, double step_pa /*= 0.002*/, int count/*= 10*/) { std::string calib_pressure_advance::generate_test(double start_pa /*= 0*/, double step_pa /*= 0.002*/,
auto bed_sizes = mp_gcodegen->config().printable_area.values; int count /*= 10*/) {
auto w = bed_sizes[2].x() - bed_sizes[0].x(); BoundingBoxf bed_ext = get_extents(mp_gcodegen->config().printable_area.values);
auto h = bed_sizes[2].y() - bed_sizes[0].y(); bool is_delta = false;
count = std::min(count, int((h - 10) / m_space_y)); if (mp_gcodegen->config().printable_area.values.size() > 4) {
is_delta = true;
bed_ext.scale(1.0f / 1.41421f);
}
auto startx = (w - 100) / 2; auto bed_sizes = mp_gcodegen->config().printable_area.values;
auto starty = (h - count * m_space_y) / 2; const auto &w = bed_ext.size().x();
m_length_long = 40 + std::min(w - 120.0, 30.0); const auto &h = bed_ext.size().y();
return print_pa_lines(startx, starty, start_pa, step_pa, count); count = std::min(count, int((h - 10) / m_space_y));
m_length_long = 40 + std::min(w - 120.0, 0.0);
auto startx = (w - m_length_short * 2 - m_length_long - 20) / 2;
auto starty = (h - count * m_space_y) / 2;
if (is_delta) {
startx = -startx;
starty = -(count * m_space_y) / 2;
}
return print_pa_lines(startx, starty, start_pa, step_pa, count);
} }
std::string calib_pressure_advance::move_to(Vec2d pt) { std::string calib_pressure_advance::move_to(Vec2d pt) {
@ -45,7 +59,7 @@ namespace Slic3r {
double y_pos = start_y; double y_pos = start_y;
// prime line // prime line
auto prime_x = std::max(start_x - 5, 0.5); auto prime_x = start_x - 2;
gcode << move_to(Vec2d(prime_x, y_pos + (num - 4) * m_space_y)); gcode << move_to(Vec2d(prime_x, y_pos + (num - 4) * m_space_y));
gcode << writer.set_speed(slow); gcode << writer.set_speed(slow);
gcode << writer.extrude_to_xy(Vec2d(prime_x, y_pos + 3 * m_space_y), e_calib * m_space_y * num * 1.1); gcode << writer.extrude_to_xy(Vec2d(prime_x, y_pos + 3 * m_space_y), e_calib * m_space_y * num * 1.1);