|
@ -203,7 +203,8 @@ |
|
|
|
|
|
|
|
|
float homing_feedrate[] = HOMING_FEEDRATE; |
|
|
float homing_feedrate[] = HOMING_FEEDRATE; |
|
|
#ifdef ENABLE_AUTO_BED_LEVELING |
|
|
#ifdef ENABLE_AUTO_BED_LEVELING |
|
|
int xy_travel_speed = XY_TRAVEL_SPEED; |
|
|
int xy_travel_speed = XY_TRAVEL_SPEED; |
|
|
|
|
|
float zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER; |
|
|
#endif |
|
|
#endif |
|
|
int homing_bump_divisor[] = HOMING_BUMP_DIVISOR; |
|
|
int homing_bump_divisor[] = HOMING_BUMP_DIVISOR; |
|
|
bool axis_relative_modes[] = AXIS_RELATIVE_MODES; |
|
|
bool axis_relative_modes[] = AXIS_RELATIVE_MODES; |
|
@ -255,7 +256,6 @@ float home_offset[3] = { 0, 0, 0 }; |
|
|
float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS }; |
|
|
float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS }; |
|
|
float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS }; |
|
|
float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS }; |
|
|
bool axis_known_position[3] = { false, false, false }; |
|
|
bool axis_known_position[3] = { false, false, false }; |
|
|
float zprobe_zoffset; |
|
|
|
|
|
|
|
|
|
|
|
// Extruder offset
|
|
|
// Extruder offset
|
|
|
#if EXTRUDERS > 1 |
|
|
#if EXTRUDERS > 1 |
|
@ -1097,9 +1097,6 @@ static void set_bed_level_equation_lsq(double *plane_equation_coefficients) |
|
|
current_position[Y_AXIS] = corrected_position.y; |
|
|
current_position[Y_AXIS] = corrected_position.y; |
|
|
current_position[Z_AXIS] = corrected_position.z; |
|
|
current_position[Z_AXIS] = corrected_position.z; |
|
|
|
|
|
|
|
|
// put the bed at 0 so we don't go below it.
|
|
|
|
|
|
current_position[Z_AXIS] = zprobe_zoffset; // in the lsq we reach here after raising the extruder due to the loop structure
|
|
|
|
|
|
|
|
|
|
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); |
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
@ -1113,11 +1110,13 @@ static void set_bed_level_equation_3pts(float z_at_pt_1, float z_at_pt_2, float |
|
|
vector_3 pt1 = vector_3(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, z_at_pt_1); |
|
|
vector_3 pt1 = vector_3(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, z_at_pt_1); |
|
|
vector_3 pt2 = vector_3(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, z_at_pt_2); |
|
|
vector_3 pt2 = vector_3(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, z_at_pt_2); |
|
|
vector_3 pt3 = vector_3(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, z_at_pt_3); |
|
|
vector_3 pt3 = vector_3(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, z_at_pt_3); |
|
|
|
|
|
vector_3 planeNormal = vector_3::cross(pt1 - pt2, pt3 - pt2).get_normal(); |
|
|
|
|
|
|
|
|
vector_3 from_2_to_1 = (pt1 - pt2).get_normal(); |
|
|
if (planeNormal.z < 0) { |
|
|
vector_3 from_2_to_3 = (pt3 - pt2).get_normal(); |
|
|
planeNormal.x = -planeNormal.x; |
|
|
vector_3 planeNormal = vector_3::cross(from_2_to_1, from_2_to_3).get_normal(); |
|
|
planeNormal.y = -planeNormal.y; |
|
|
planeNormal = vector_3(planeNormal.x, planeNormal.y, abs(planeNormal.z)); |
|
|
planeNormal.z = -planeNormal.z; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal); |
|
|
plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal); |
|
|
|
|
|
|
|
@ -1126,11 +1125,7 @@ static void set_bed_level_equation_3pts(float z_at_pt_1, float z_at_pt_2, float |
|
|
current_position[Y_AXIS] = corrected_position.y; |
|
|
current_position[Y_AXIS] = corrected_position.y; |
|
|
current_position[Z_AXIS] = corrected_position.z; |
|
|
current_position[Z_AXIS] = corrected_position.z; |
|
|
|
|
|
|
|
|
// put the bed at 0 so we don't go below it.
|
|
|
|
|
|
current_position[Z_AXIS] = zprobe_zoffset; |
|
|
|
|
|
|
|
|
|
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); |
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#endif // AUTO_BED_LEVELING_GRID
|
|
|
#endif // AUTO_BED_LEVELING_GRID
|
|
@ -2017,8 +2012,19 @@ inline void gcode_G28() { |
|
|
endstops_hit_on_purpose(); |
|
|
endstops_hit_on_purpose(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#if defined(MESH_BED_LEVELING) |
|
|
#ifdef MESH_BED_LEVELING |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* G29: Mesh-based Z-Probe, probes a grid and produces a |
|
|
|
|
|
* mesh to compensate for variable bed height |
|
|
|
|
|
* |
|
|
|
|
|
* Parameters With MESH_BED_LEVELING: |
|
|
|
|
|
* |
|
|
|
|
|
* S0 Produce a mesh report |
|
|
|
|
|
* S1 Start probing mesh points |
|
|
|
|
|
* S2 Probe the next mesh point |
|
|
|
|
|
* |
|
|
|
|
|
*/ |
|
|
inline void gcode_G29() { |
|
|
inline void gcode_G29() { |
|
|
static int probe_point = -1; |
|
|
static int probe_point = -1; |
|
|
int state = 0; |
|
|
int state = 0; |
|
@ -2060,7 +2066,7 @@ inline void gcode_G28() { |
|
|
} else if (state == 2) { // Goto next point
|
|
|
} else if (state == 2) { // Goto next point
|
|
|
|
|
|
|
|
|
if (probe_point < 0) { |
|
|
if (probe_point < 0) { |
|
|
SERIAL_PROTOCOLPGM("Mesh probing not started.\n"); |
|
|
SERIAL_PROTOCOLPGM("Start mesh probing with \"G29 S1\" first.\n"); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
int ix, iy; |
|
|
int ix, iy; |
|
@ -2070,16 +2076,14 @@ inline void gcode_G28() { |
|
|
} else { |
|
|
} else { |
|
|
ix = (probe_point-1) % MESH_NUM_X_POINTS; |
|
|
ix = (probe_point-1) % MESH_NUM_X_POINTS; |
|
|
iy = (probe_point-1) / MESH_NUM_X_POINTS; |
|
|
iy = (probe_point-1) / MESH_NUM_X_POINTS; |
|
|
if (iy&1) { // Zig zag
|
|
|
if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // zig-zag
|
|
|
ix = (MESH_NUM_X_POINTS - 1) - ix; |
|
|
|
|
|
} |
|
|
|
|
|
mbl.set_z(ix, iy, current_position[Z_AXIS]); |
|
|
mbl.set_z(ix, iy, current_position[Z_AXIS]); |
|
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; |
|
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; |
|
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS]/60, active_extruder); |
|
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS]/60, active_extruder); |
|
|
st_synchronize(); |
|
|
st_synchronize(); |
|
|
} |
|
|
} |
|
|
if (probe_point == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS) { |
|
|
if (probe_point == MESH_NUM_X_POINTS * MESH_NUM_Y_POINTS) { |
|
|
SERIAL_PROTOCOLPGM("Mesh done.\n"); |
|
|
SERIAL_PROTOCOLPGM("Mesh probing done.\n"); |
|
|
probe_point = -1; |
|
|
probe_point = -1; |
|
|
mbl.active = 1; |
|
|
mbl.active = 1; |
|
|
enquecommands_P(PSTR("G28")); |
|
|
enquecommands_P(PSTR("G28")); |
|
@ -2087,9 +2091,7 @@ inline void gcode_G28() { |
|
|
} |
|
|
} |
|
|
ix = probe_point % MESH_NUM_X_POINTS; |
|
|
ix = probe_point % MESH_NUM_X_POINTS; |
|
|
iy = probe_point / MESH_NUM_X_POINTS; |
|
|
iy = probe_point / MESH_NUM_X_POINTS; |
|
|
if (iy&1) { // Zig zag
|
|
|
if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // zig-zag
|
|
|
ix = (MESH_NUM_X_POINTS - 1) - ix; |
|
|
|
|
|
} |
|
|
|
|
|
current_position[X_AXIS] = mbl.get_x(ix); |
|
|
current_position[X_AXIS] = mbl.get_x(ix); |
|
|
current_position[Y_AXIS] = mbl.get_y(iy); |
|
|
current_position[Y_AXIS] = mbl.get_y(iy); |
|
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS]/60, active_extruder); |
|
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS]/60, active_extruder); |
|
@ -2098,9 +2100,7 @@ inline void gcode_G28() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#endif |
|
|
#elif defined(ENABLE_AUTO_BED_LEVELING) |
|
|
|
|
|
|
|
|
#ifdef ENABLE_AUTO_BED_LEVELING |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* G29: Detailed Z-Probe, probes the bed at 3 or more points. |
|
|
* G29: Detailed Z-Probe, probes the bed at 3 or more points. |
|
@ -2116,8 +2116,9 @@ inline void gcode_G28() { |
|
|
* |
|
|
* |
|
|
* S Set the XY travel speed between probe points (in mm/min) |
|
|
* S Set the XY travel speed between probe points (in mm/min) |
|
|
* |
|
|
* |
|
|
* D Dry-Run mode. Just evaluate the bed Topology - It does not apply or clean the rotation Matrix |
|
|
* D Dry-Run mode. Just evaluate the bed Topology - Don't apply |
|
|
* Useful to check the topology after a first run of G29. |
|
|
* or clean the rotation Matrix. Useful to check the topology |
|
|
|
|
|
* after a first run of G29. |
|
|
* |
|
|
* |
|
|
* V Set the verbose level (0-4). Example: "G29 V3" |
|
|
* V Set the verbose level (0-4). Example: "G29 V3" |
|
|
* |
|
|
* |
|
@ -2165,9 +2166,9 @@ inline void gcode_G28() { |
|
|
|
|
|
|
|
|
#ifdef AUTO_BED_LEVELING_GRID |
|
|
#ifdef AUTO_BED_LEVELING_GRID |
|
|
|
|
|
|
|
|
#ifndef DELTA |
|
|
#ifndef DELTA |
|
|
bool do_topography_map = verbose_level > 2 || code_seen('T') || code_seen('t'); |
|
|
bool do_topography_map = verbose_level > 2 || code_seen('T') || code_seen('t'); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
if (verbose_level > 0) |
|
|
if (verbose_level > 0) |
|
|
{ |
|
|
{ |
|
@ -2224,7 +2225,7 @@ inline void gcode_G28() { |
|
|
|
|
|
|
|
|
#ifdef Z_PROBE_SLED |
|
|
#ifdef Z_PROBE_SLED |
|
|
dock_sled(false); // engage (un-dock) the probe
|
|
|
dock_sled(false); // engage (un-dock) the probe
|
|
|
#elif defined(Z_PROBE_ALLEN_KEY) |
|
|
#elif defined(Z_PROBE_ALLEN_KEY) //|| defined(SERVO_LEVELING)
|
|
|
engage_z_probe(); |
|
|
engage_z_probe(); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -2234,19 +2235,18 @@ inline void gcode_G28() { |
|
|
{ |
|
|
{ |
|
|
#ifdef DELTA |
|
|
#ifdef DELTA |
|
|
reset_bed_level(); |
|
|
reset_bed_level(); |
|
|
#else |
|
|
#else //!DELTA
|
|
|
|
|
|
|
|
|
// make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
|
|
|
// make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
|
|
|
//vector_3 corrected_position = plan_get_position_mm();
|
|
|
//vector_3 corrected_position = plan_get_position_mm();
|
|
|
//corrected_position.debug("position before G29");
|
|
|
//corrected_position.debug("position before G29");
|
|
|
plan_bed_level_matrix.set_to_identity(); |
|
|
plan_bed_level_matrix.set_to_identity(); |
|
|
vector_3 uncorrected_position = plan_get_position(); |
|
|
vector_3 uncorrected_position = plan_get_position(); |
|
|
// uncorrected_position.debug("position during G29");
|
|
|
//uncorrected_position.debug("position during G29");
|
|
|
|
|
|
current_position[X_AXIS] = uncorrected_position.x; |
|
|
current_position[X_AXIS] = uncorrected_position.x; |
|
|
current_position[Y_AXIS] = uncorrected_position.y; |
|
|
current_position[Y_AXIS] = uncorrected_position.y; |
|
|
current_position[Z_AXIS] = uncorrected_position.z; |
|
|
current_position[Z_AXIS] = uncorrected_position.z; |
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); |
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); |
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
@ -2261,26 +2261,24 @@ inline void gcode_G28() { |
|
|
const int xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points-1); |
|
|
const int xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points-1); |
|
|
const int yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points-1); |
|
|
const int yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points-1); |
|
|
|
|
|
|
|
|
#ifndef DELTA |
|
|
#ifdef DELTA |
|
|
// solve the plane equation ax + by + d = z
|
|
|
delta_grid_spacing[0] = xGridSpacing; |
|
|
// A is the matrix with rows [x y 1] for all the probed points
|
|
|
delta_grid_spacing[1] = yGridSpacing; |
|
|
// B is the vector of the Z positions
|
|
|
float z_offset = Z_PROBE_OFFSET_FROM_EXTRUDER; |
|
|
// the normal vector to the plane is formed by the coefficients of the plane equation in the standard form, which is Vx*x+Vy*y+Vz*z+d = 0
|
|
|
if (code_seen(axis_codes[Z_AXIS])) z_offset += code_value(); |
|
|
// so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
|
|
|
#else // !DELTA
|
|
|
|
|
|
// solve the plane equation ax + by + d = z
|
|
|
int abl2 = auto_bed_leveling_grid_points * auto_bed_leveling_grid_points; |
|
|
// A is the matrix with rows [x y 1] for all the probed points
|
|
|
|
|
|
// B is the vector of the Z positions
|
|
|
double eqnAMatrix[abl2 * 3], // "A" matrix of the linear system of equations
|
|
|
// the normal vector to the plane is formed by the coefficients of the plane equation in the standard form, which is Vx*x+Vy*y+Vz*z+d = 0
|
|
|
eqnBVector[abl2], // "B" vector of Z points
|
|
|
// so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
|
|
|
mean = 0.0; |
|
|
|
|
|
|
|
|
int abl2 = auto_bed_leveling_grid_points * auto_bed_leveling_grid_points; |
|
|
#else |
|
|
|
|
|
delta_grid_spacing[0] = xGridSpacing; |
|
|
double eqnAMatrix[abl2 * 3], // "A" matrix of the linear system of equations
|
|
|
delta_grid_spacing[1] = yGridSpacing; |
|
|
eqnBVector[abl2], // "B" vector of Z points
|
|
|
|
|
|
mean = 0.0; |
|
|
float z_offset = Z_PROBE_OFFSET_FROM_EXTRUDER; |
|
|
#endif // !DELTA
|
|
|
if (code_seen(axis_codes[Z_AXIS])) z_offset += code_value(); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
int probePointCounter = 0; |
|
|
int probePointCounter = 0; |
|
|
bool zig = true; |
|
|
bool zig = true; |
|
@ -2313,12 +2311,12 @@ inline void gcode_G28() { |
|
|
float measured_z, |
|
|
float measured_z, |
|
|
z_before = probePointCounter == 0 ? Z_RAISE_BEFORE_PROBING : current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS; |
|
|
z_before = probePointCounter == 0 ? Z_RAISE_BEFORE_PROBING : current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS; |
|
|
|
|
|
|
|
|
#ifdef DELTA |
|
|
#ifdef DELTA |
|
|
// Avoid probing the corners (outside the round or hexagon print surface) on a delta printer.
|
|
|
// Avoid probing the corners (outside the round or hexagon print surface) on a delta printer.
|
|
|
float distance_from_center = sqrt(xProbe*xProbe + yProbe*yProbe); |
|
|
float distance_from_center = sqrt(xProbe*xProbe + yProbe*yProbe); |
|
|
if (distance_from_center > DELTA_PROBABLE_RADIUS) |
|
|
if (distance_from_center > DELTA_PROBABLE_RADIUS) |
|
|
continue; |
|
|
continue; |
|
|
#endif //DELTA
|
|
|
#endif //DELTA
|
|
|
|
|
|
|
|
|
// Enhanced G29 - Do not retract servo between probes
|
|
|
// Enhanced G29 - Do not retract servo between probes
|
|
|
ProbeAction act; |
|
|
ProbeAction act; |
|
@ -2335,16 +2333,16 @@ inline void gcode_G28() { |
|
|
|
|
|
|
|
|
measured_z = probe_pt(xProbe, yProbe, z_before, act, verbose_level); |
|
|
measured_z = probe_pt(xProbe, yProbe, z_before, act, verbose_level); |
|
|
|
|
|
|
|
|
#ifndef DELTA |
|
|
#ifndef DELTA |
|
|
mean += measured_z; |
|
|
mean += measured_z; |
|
|
|
|
|
|
|
|
eqnBVector[probePointCounter] = measured_z; |
|
|
eqnBVector[probePointCounter] = measured_z; |
|
|
eqnAMatrix[probePointCounter + 0 * abl2] = xProbe; |
|
|
eqnAMatrix[probePointCounter + 0 * abl2] = xProbe; |
|
|
eqnAMatrix[probePointCounter + 1 * abl2] = yProbe; |
|
|
eqnAMatrix[probePointCounter + 1 * abl2] = yProbe; |
|
|
eqnAMatrix[probePointCounter + 2 * abl2] = 1; |
|
|
eqnAMatrix[probePointCounter + 2 * abl2] = 1; |
|
|
#else |
|
|
#else |
|
|
bed_level[xCount][yCount] = measured_z + z_offset; |
|
|
bed_level[xCount][yCount] = measured_z + z_offset; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
probePointCounter++; |
|
|
probePointCounter++; |
|
|
} //xProbe
|
|
|
} //xProbe
|
|
@ -2352,60 +2350,64 @@ inline void gcode_G28() { |
|
|
|
|
|
|
|
|
clean_up_after_endstop_move(); |
|
|
clean_up_after_endstop_move(); |
|
|
|
|
|
|
|
|
#ifndef DELTA |
|
|
#ifdef DELTA |
|
|
// solve lsq problem
|
|
|
|
|
|
double *plane_equation_coefficients = qr_solve(abl2, 3, eqnAMatrix, eqnBVector); |
|
|
if (!dryrun) extrapolate_unprobed_bed_level(); |
|
|
|
|
|
print_bed_level(); |
|
|
mean /= abl2; |
|
|
|
|
|
|
|
|
#else // !DELTA
|
|
|
if (verbose_level) { |
|
|
|
|
|
SERIAL_PROTOCOLPGM("Eqn coefficients: a: "); |
|
|
// solve lsq problem
|
|
|
SERIAL_PROTOCOL_F(plane_equation_coefficients[0], 8); |
|
|
double *plane_equation_coefficients = qr_solve(abl2, 3, eqnAMatrix, eqnBVector); |
|
|
SERIAL_PROTOCOLPGM(" b: "); |
|
|
|
|
|
SERIAL_PROTOCOL_F(plane_equation_coefficients[1], 8); |
|
|
mean /= abl2; |
|
|
SERIAL_PROTOCOLPGM(" d: "); |
|
|
|
|
|
SERIAL_PROTOCOL_F(plane_equation_coefficients[2], 8); |
|
|
if (verbose_level) { |
|
|
SERIAL_EOL; |
|
|
SERIAL_PROTOCOLPGM("Eqn coefficients: a: "); |
|
|
if (verbose_level > 2) { |
|
|
SERIAL_PROTOCOL_F(plane_equation_coefficients[0], 8); |
|
|
SERIAL_PROTOCOLPGM("Mean of sampled points: "); |
|
|
SERIAL_PROTOCOLPGM(" b: "); |
|
|
SERIAL_PROTOCOL_F(mean, 8); |
|
|
SERIAL_PROTOCOL_F(plane_equation_coefficients[1], 8); |
|
|
|
|
|
SERIAL_PROTOCOLPGM(" d: "); |
|
|
|
|
|
SERIAL_PROTOCOL_F(plane_equation_coefficients[2], 8); |
|
|
SERIAL_EOL; |
|
|
SERIAL_EOL; |
|
|
|
|
|
if (verbose_level > 2) { |
|
|
|
|
|
SERIAL_PROTOCOLPGM("Mean of sampled points: "); |
|
|
|
|
|
SERIAL_PROTOCOL_F(mean, 8); |
|
|
|
|
|
SERIAL_EOL; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Show the Topography map if enabled
|
|
|
// Show the Topography map if enabled
|
|
|
if (do_topography_map) { |
|
|
if (do_topography_map) { |
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLPGM(" \nBed Height Topography: \n"); |
|
|
SERIAL_PROTOCOLPGM(" \nBed Height Topography: \n"); |
|
|
SERIAL_PROTOCOLPGM("+-----------+\n"); |
|
|
SERIAL_PROTOCOLPGM("+-----------+\n"); |
|
|
SERIAL_PROTOCOLPGM("|...Back....|\n"); |
|
|
SERIAL_PROTOCOLPGM("|...Back....|\n"); |
|
|
SERIAL_PROTOCOLPGM("|Left..Right|\n"); |
|
|
SERIAL_PROTOCOLPGM("|Left..Right|\n"); |
|
|
SERIAL_PROTOCOLPGM("|...Front...|\n"); |
|
|
SERIAL_PROTOCOLPGM("|...Front...|\n"); |
|
|
SERIAL_PROTOCOLPGM("+-----------+\n"); |
|
|
SERIAL_PROTOCOLPGM("+-----------+\n"); |
|
|
|
|
|
|
|
|
for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) { |
|
|
for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) { |
|
|
for (int xx = 0; xx < auto_bed_leveling_grid_points; xx++) { |
|
|
for (int xx = 0; xx < auto_bed_leveling_grid_points; xx++) { |
|
|
int ind = yy * auto_bed_leveling_grid_points + xx; |
|
|
int ind = yy * auto_bed_leveling_grid_points + xx; |
|
|
float diff = eqnBVector[ind] - mean; |
|
|
float diff = eqnBVector[ind] - mean; |
|
|
if (diff >= 0.0) |
|
|
if (diff >= 0.0) |
|
|
SERIAL_PROTOCOLPGM(" +"); // Include + for column alignment
|
|
|
SERIAL_PROTOCOLPGM(" +"); // Include + for column alignment
|
|
|
else |
|
|
else |
|
|
SERIAL_PROTOCOLPGM(" "); |
|
|
SERIAL_PROTOCOLPGM(" "); |
|
|
SERIAL_PROTOCOL_F(diff, 5); |
|
|
SERIAL_PROTOCOL_F(diff, 5); |
|
|
} // xx
|
|
|
} // xx
|
|
|
|
|
|
SERIAL_EOL; |
|
|
|
|
|
} // yy
|
|
|
SERIAL_EOL; |
|
|
SERIAL_EOL; |
|
|
} // yy
|
|
|
|
|
|
SERIAL_EOL; |
|
|
|
|
|
|
|
|
|
|
|
} //do_topography_map
|
|
|
} //do_topography_map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!dryrun) set_bed_level_equation_lsq(plane_equation_coefficients); |
|
|
|
|
|
free(plane_equation_coefficients); |
|
|
|
|
|
|
|
|
if (!dryrun) set_bed_level_equation_lsq(plane_equation_coefficients); |
|
|
#endif //!DELTA
|
|
|
free(plane_equation_coefficients); |
|
|
|
|
|
#else //Delta
|
|
|
|
|
|
if (!dryrun) extrapolate_unprobed_bed_level(); |
|
|
|
|
|
print_bed_level(); |
|
|
|
|
|
#endif //Delta
|
|
|
|
|
|
|
|
|
|
|
|
#else // !AUTO_BED_LEVELING_GRID
|
|
|
#else // !AUTO_BED_LEVELING_GRID
|
|
|
|
|
|
|
|
@ -2428,35 +2430,36 @@ inline void gcode_G28() { |
|
|
|
|
|
|
|
|
#endif // !AUTO_BED_LEVELING_GRID
|
|
|
#endif // !AUTO_BED_LEVELING_GRID
|
|
|
|
|
|
|
|
|
#ifndef DELTA |
|
|
#ifndef DELTA |
|
|
if (verbose_level > 0) plan_bed_level_matrix.debug(" \n\nBed Level Correction Matrix:"); |
|
|
if (verbose_level > 0) |
|
|
|
|
|
plan_bed_level_matrix.debug(" \n\nBed Level Correction Matrix:"); |
|
|
|
|
|
|
|
|
// Correct the Z height difference from z-probe position and hotend tip position.
|
|
|
// Correct the Z height difference from z-probe position and hotend tip position.
|
|
|
// The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
|
|
|
// The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
|
|
|
// When the bed is uneven, this height must be corrected.
|
|
|
// When the bed is uneven, this height must be corrected.
|
|
|
if (!dryrun) |
|
|
if (!dryrun) |
|
|
{ |
|
|
{ |
|
|
real_z = float(st_get_position(Z_AXIS)) / axis_steps_per_unit[Z_AXIS]; //get the real Z (since the auto bed leveling is already correcting the plane)
|
|
|
real_z = float(st_get_position(Z_AXIS)) / axis_steps_per_unit[Z_AXIS]; //get the real Z (since the auto bed leveling is already correcting the plane)
|
|
|
x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER; |
|
|
x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER; |
|
|
y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER; |
|
|
y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER; |
|
|
z_tmp = current_position[Z_AXIS]; |
|
|
z_tmp = current_position[Z_AXIS]; |
|
|
|
|
|
|
|
|
apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); //Apply the correction sending the probe offset
|
|
|
apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); //Apply the correction sending the probe offset
|
|
|
current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS]; //The difference is added to current position and sent to planner.
|
|
|
current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS]; //The difference is added to current position and sent to planner.
|
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); |
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif // !DELTA
|
|
|
|
|
|
|
|
|
#ifdef Z_PROBE_SLED |
|
|
#ifdef Z_PROBE_SLED |
|
|
dock_sled(true, -SLED_DOCKING_OFFSET); // dock the probe, correcting for over-travel
|
|
|
dock_sled(true, -SLED_DOCKING_OFFSET); // dock the probe, correcting for over-travel
|
|
|
#elif defined(Z_PROBE_ALLEN_KEY) |
|
|
#elif defined(Z_PROBE_ALLEN_KEY) //|| defined(SERVO_LEVELING)
|
|
|
retract_z_probe(); |
|
|
retract_z_probe(); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifdef Z_PROBE_END_SCRIPT |
|
|
#ifdef Z_PROBE_END_SCRIPT |
|
|
enquecommands_P(PSTR(Z_PROBE_END_SCRIPT)); |
|
|
enquecommands_P(PSTR(Z_PROBE_END_SCRIPT)); |
|
|
st_synchronize(); |
|
|
st_synchronize(); |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#ifndef Z_PROBE_SLED |
|
|
#ifndef Z_PROBE_SLED |
|
@ -2919,7 +2922,7 @@ inline void gcode_M42() { |
|
|
do_blocking_move_to( X_probe_location, Y_probe_location, Z_start_location); // Make sure we are at the probe location
|
|
|
do_blocking_move_to( X_probe_location, Y_probe_location, Z_start_location); // Make sure we are at the probe location
|
|
|
|
|
|
|
|
|
if (n_legs) { |
|
|
if (n_legs) { |
|
|
double radius=0.0, theta=0.0, x_sweep, y_sweep; |
|
|
double radius=0.0, theta=0.0; |
|
|
int l; |
|
|
int l; |
|
|
int rotational_direction = (unsigned long) millis() & 0x0001; // clockwise or counter clockwise
|
|
|
int rotational_direction = (unsigned long) millis() & 0x0001; // clockwise or counter clockwise
|
|
|
radius = (unsigned long)millis() % (long)(X_MAX_LENGTH / 4); // limit how far out to go
|
|
|
radius = (unsigned long)millis() % (long)(X_MAX_LENGTH / 4); // limit how far out to go
|
|
@ -3545,7 +3548,6 @@ inline void gcode_M200() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
float area = .0; |
|
|
|
|
|
if (code_seen('D')) { |
|
|
if (code_seen('D')) { |
|
|
float diameter = code_value(); |
|
|
float diameter = code_value(); |
|
|
// setting any extruder filament size disables volumetric on the assumption that
|
|
|
// setting any extruder filament size disables volumetric on the assumption that
|
|
@ -4283,7 +4285,7 @@ inline void gcode_M502() { |
|
|
* M503: print settings currently in memory |
|
|
* M503: print settings currently in memory |
|
|
*/ |
|
|
*/ |
|
|
inline void gcode_M503() { |
|
|
inline void gcode_M503() { |
|
|
Config_PrintSettings(code_seen('S') && code_value == 0); |
|
|
Config_PrintSettings(code_seen('S') && code_value() == 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED |
|
|
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED |
|
@ -4580,9 +4582,14 @@ inline void gcode_T() { |
|
|
SERIAL_ECHOLN(MSG_INVALID_EXTRUDER); |
|
|
SERIAL_ECHOLN(MSG_INVALID_EXTRUDER); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
boolean make_move = false; |
|
|
#if EXTRUDERS > 1 |
|
|
|
|
|
bool make_move = false; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
if (code_seen('F')) { |
|
|
if (code_seen('F')) { |
|
|
make_move = true; |
|
|
#if EXTRUDERS > 1 |
|
|
|
|
|
make_move = true; |
|
|
|
|
|
#endif |
|
|
next_feedrate = code_value(); |
|
|
next_feedrate = code_value(); |
|
|
if (next_feedrate > 0.0) feedrate = next_feedrate; |
|
|
if (next_feedrate > 0.0) feedrate = next_feedrate; |
|
|
} |
|
|
} |
|
@ -5179,20 +5186,22 @@ void ClearToSend() |
|
|
SERIAL_PROTOCOLLNPGM(MSG_OK); |
|
|
SERIAL_PROTOCOLLNPGM(MSG_OK); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void get_coordinates() |
|
|
void get_coordinates() { |
|
|
{ |
|
|
for (int i = 0; i < NUM_AXIS; i++) { |
|
|
bool seen[4]={false,false,false,false}; |
|
|
float dest; |
|
|
for(int8_t i=0; i < NUM_AXIS; i++) { |
|
|
if (code_seen(axis_codes[i])) { |
|
|
if(code_seen(axis_codes[i])) |
|
|
dest = code_value(); |
|
|
{ |
|
|
if (axis_relative_modes[i] || relative_mode) |
|
|
destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i]; |
|
|
dest += current_position[i]; |
|
|
seen[i]=true; |
|
|
|
|
|
} |
|
|
} |
|
|
else destination[i] = current_position[i]; //Are these else lines really needed?
|
|
|
else |
|
|
|
|
|
dest = current_position[i]; |
|
|
|
|
|
|
|
|
|
|
|
destination[i] = dest; |
|
|
} |
|
|
} |
|
|
if(code_seen('F')) { |
|
|
if (code_seen('F')) { |
|
|
next_feedrate = code_value(); |
|
|
next_feedrate = code_value(); |
|
|
if(next_feedrate > 0.0) feedrate = next_feedrate; |
|
|
if (next_feedrate > 0.0) feedrate = next_feedrate; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|