|
@@ -203,7 +203,8 @@
|
203
|
203
|
|
204
|
204
|
float homing_feedrate[] = HOMING_FEEDRATE;
|
205
|
205
|
#ifdef ENABLE_AUTO_BED_LEVELING
|
206
|
|
-int xy_travel_speed = XY_TRAVEL_SPEED;
|
|
206
|
+ int xy_travel_speed = XY_TRAVEL_SPEED;
|
|
207
|
+ float zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
|
207
|
208
|
#endif
|
208
|
209
|
int homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
|
209
|
210
|
bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
|
|
@@ -255,7 +256,6 @@ float home_offset[3] = { 0, 0, 0 };
|
255
|
256
|
float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
|
256
|
257
|
float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
|
257
|
258
|
bool axis_known_position[3] = { false, false, false };
|
258
|
|
-float zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
|
259
|
259
|
|
260
|
260
|
// Extruder offset
|
261
|
261
|
#if EXTRUDERS > 1
|
|
@@ -1162,6 +1162,7 @@ static void run_z_probe() {
|
1162
|
1162
|
zPosition += home_retract_mm(Z_AXIS);
|
1163
|
1163
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
|
1164
|
1164
|
st_synchronize();
|
|
1165
|
+ endstops_hit_on_purpose();
|
1165
|
1166
|
|
1166
|
1167
|
// move back down slowly to find bed
|
1167
|
1168
|
|
|
@@ -1179,6 +1180,7 @@ static void run_z_probe() {
|
1179
|
1180
|
zPosition -= home_retract_mm(Z_AXIS) * 2;
|
1180
|
1181
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
|
1181
|
1182
|
st_synchronize();
|
|
1183
|
+ endstops_hit_on_purpose();
|
1182
|
1184
|
|
1183
|
1185
|
current_position[Z_AXIS] = st_get_position_mm(Z_AXIS);
|
1184
|
1186
|
// make sure the planner knows where we are as it may be a bit different than we last said to move to
|
|
@@ -1383,11 +1385,11 @@ static float probe_pt(float x, float y, float z_before, ProbeAction retract_acti
|
1383
|
1385
|
if (verbose_level > 2) {
|
1384
|
1386
|
SERIAL_PROTOCOLPGM(MSG_BED);
|
1385
|
1387
|
SERIAL_PROTOCOLPGM(" X: ");
|
1386
|
|
- SERIAL_PROTOCOL(x + 0.0001);
|
|
1388
|
+ SERIAL_PROTOCOL_F(x, 3);
|
1387
|
1389
|
SERIAL_PROTOCOLPGM(" Y: ");
|
1388
|
|
- SERIAL_PROTOCOL(y + 0.0001);
|
|
1390
|
+ SERIAL_PROTOCOL_F(y, 3);
|
1389
|
1391
|
SERIAL_PROTOCOLPGM(" Z: ");
|
1390
|
|
- SERIAL_PROTOCOL(measured_z + 0.0001);
|
|
1392
|
+ SERIAL_PROTOCOL_F(measured_z, 3);
|
1391
|
1393
|
SERIAL_EOL;
|
1392
|
1394
|
}
|
1393
|
1395
|
return measured_z;
|
|
@@ -2108,6 +2110,10 @@ inline void gcode_G28() {
|
2108
|
2110
|
*
|
2109
|
2111
|
* S Set the XY travel speed between probe points (in mm/min)
|
2110
|
2112
|
*
|
|
2113
|
+ * D Dry-Run mode. Just evaluate the bed Topology - Don't apply
|
|
2114
|
+ * or clean the rotation Matrix. Useful to check the topology
|
|
2115
|
+ * after a first run of G29.
|
|
2116
|
+ *
|
2111
|
2117
|
* V Set the verbose level (0-4). Example: "G29 V3"
|
2112
|
2118
|
*
|
2113
|
2119
|
* T Generate a Bed Topology Report. Example: "G29 P5 T" for a detailed report.
|
|
@@ -2149,6 +2155,7 @@ inline void gcode_G28() {
|
2149
|
2155
|
}
|
2150
|
2156
|
}
|
2151
|
2157
|
|
|
2158
|
+ bool dryrun = code_seen('D') || code_seen('d');
|
2152
|
2159
|
bool enhanced_g29 = code_seen('E') || code_seen('e');
|
2153
|
2160
|
|
2154
|
2161
|
#ifdef AUTO_BED_LEVELING_GRID
|
|
@@ -2158,7 +2165,10 @@ inline void gcode_G28() {
|
2158
|
2165
|
#endif
|
2159
|
2166
|
|
2160
|
2167
|
if (verbose_level > 0)
|
|
2168
|
+ {
|
2161
|
2169
|
SERIAL_PROTOCOLPGM("G29 Auto Bed Leveling\n");
|
|
2170
|
+ if (dryrun) SERIAL_ECHOLN("Running in DRY-RUN mode");
|
|
2171
|
+ }
|
2162
|
2172
|
|
2163
|
2173
|
int auto_bed_leveling_grid_points = AUTO_BED_LEVELING_GRID_POINTS;
|
2164
|
2174
|
#ifndef DELTA
|
|
@@ -2215,21 +2225,26 @@ inline void gcode_G28() {
|
2215
|
2225
|
|
2216
|
2226
|
st_synchronize();
|
2217
|
2227
|
|
2218
|
|
- #ifdef DELTA
|
2219
|
|
- reset_bed_level();
|
2220
|
|
- #else //!DELTA
|
2221
|
|
- // make sure the bed_level_rotation_matrix is identity or the planner will get it wrong
|
2222
|
|
- //vector_3 corrected_position = plan_get_position_mm();
|
2223
|
|
- //corrected_position.debug("position before G29");
|
2224
|
|
- plan_bed_level_matrix.set_to_identity();
|
2225
|
|
- vector_3 uncorrected_position = plan_get_position();
|
2226
|
|
- //uncorrected_position.debug("position during G29");
|
2227
|
|
- current_position[X_AXIS] = uncorrected_position.x;
|
2228
|
|
- current_position[Y_AXIS] = uncorrected_position.y;
|
2229
|
|
- current_position[Z_AXIS] = uncorrected_position.z;
|
2230
|
|
- plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
2231
|
|
- #endif //!DELTA
|
|
2228
|
+ if (!dryrun)
|
|
2229
|
+ {
|
|
2230
|
+ #ifdef DELTA
|
|
2231
|
+ reset_bed_level();
|
|
2232
|
+ #else //!DELTA
|
|
2233
|
+
|
|
2234
|
+ // make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
|
|
2235
|
+ //vector_3 corrected_position = plan_get_position_mm();
|
|
2236
|
+ //corrected_position.debug("position before G29");
|
|
2237
|
+ plan_bed_level_matrix.set_to_identity();
|
|
2238
|
+ vector_3 uncorrected_position = plan_get_position();
|
|
2239
|
+ //uncorrected_position.debug("position during G29");
|
|
2240
|
+ current_position[X_AXIS] = uncorrected_position.x;
|
|
2241
|
+ current_position[Y_AXIS] = uncorrected_position.y;
|
|
2242
|
+ current_position[Z_AXIS] = uncorrected_position.z;
|
|
2243
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
2232
|
2244
|
|
|
2245
|
+ #endif
|
|
2246
|
+ }
|
|
2247
|
+
|
2233
|
2248
|
setup_for_endstop_move();
|
2234
|
2249
|
|
2235
|
2250
|
feedrate = homing_feedrate[Z_AXIS];
|
|
@@ -2330,9 +2345,12 @@ inline void gcode_G28() {
|
2330
|
2345
|
clean_up_after_endstop_move();
|
2331
|
2346
|
|
2332
|
2347
|
#ifdef DELTA
|
2333
|
|
- extrapolate_unprobed_bed_level();
|
|
2348
|
+
|
|
2349
|
+ if (!dryrun) extrapolate_unprobed_bed_level();
|
2334
|
2350
|
print_bed_level();
|
|
2351
|
+
|
2335
|
2352
|
#else // !DELTA
|
|
2353
|
+
|
2336
|
2354
|
// solve lsq problem
|
2337
|
2355
|
double *plane_equation_coefficients = qr_solve(abl2, 3, eqnAMatrix, eqnBVector);
|
2338
|
2356
|
|
|
@@ -2380,10 +2398,10 @@ inline void gcode_G28() {
|
2380
|
2398
|
} //do_topography_map
|
2381
|
2399
|
|
2382
|
2400
|
|
2383
|
|
- set_bed_level_equation_lsq(plane_equation_coefficients);
|
|
2401
|
+ if (!dryrun) set_bed_level_equation_lsq(plane_equation_coefficients);
|
2384
|
2402
|
free(plane_equation_coefficients);
|
2385
|
2403
|
|
2386
|
|
- #endif // !DELTA
|
|
2404
|
+ #endif //!DELTA
|
2387
|
2405
|
|
2388
|
2406
|
#else // !AUTO_BED_LEVELING_GRID
|
2389
|
2407
|
|
|
@@ -2402,7 +2420,7 @@ inline void gcode_G28() {
|
2402
|
2420
|
z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, ProbeEngageAndRetract, verbose_level);
|
2403
|
2421
|
}
|
2404
|
2422
|
clean_up_after_endstop_move();
|
2405
|
|
- set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
|
|
2423
|
+ if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
|
2406
|
2424
|
|
2407
|
2425
|
#endif // !AUTO_BED_LEVELING_GRID
|
2408
|
2426
|
|
|
@@ -2413,15 +2431,18 @@ inline void gcode_G28() {
|
2413
|
2431
|
// Correct the Z height difference from z-probe position and hotend tip position.
|
2414
|
2432
|
// The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
|
2415
|
2433
|
// When the bed is uneven, this height must be corrected.
|
2416
|
|
- 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)
|
2417
|
|
- x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
|
2418
|
|
- y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
|
2419
|
|
- z_tmp = current_position[Z_AXIS];
|
|
2434
|
+ if (!dryrun)
|
|
2435
|
+ {
|
|
2436
|
+ 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)
|
|
2437
|
+ x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER;
|
|
2438
|
+ y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
|
|
2439
|
+ z_tmp = current_position[Z_AXIS];
|
2420
|
2440
|
|
2421
|
|
- apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); //Apply the correction sending the probe offset
|
2422
|
|
- current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS]; //The difference is added to current position and sent to planner.
|
2423
|
|
- plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
2424
|
|
- #endif
|
|
2441
|
+ apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); //Apply the correction sending the probe offset
|
|
2442
|
+ current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS]; //The difference is added to current position and sent to planner.
|
|
2443
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
2444
|
+ }
|
|
2445
|
+ #endif // !DELTA
|
2425
|
2446
|
|
2426
|
2447
|
#ifdef Z_PROBE_SLED
|
2427
|
2448
|
dock_sled(true, -SLED_DOCKING_OFFSET); // dock the probe, correcting for over-travel
|