|
@@ -210,8 +210,8 @@
|
210
|
210
|
* adhesion.
|
211
|
211
|
*
|
212
|
212
|
* P4 moves to the closest Mesh Point (and/or the given X Y), raises the nozzle above the mesh height
|
213
|
|
- * by the given 'H' offset (or default Z_CLEARANCE_BETWEEN_PROBES), and waits while the controller is
|
214
|
|
- * used to adjust the nozzle height. On click the displayed height is saved in the mesh.
|
|
213
|
+ * by the given 'H' offset (or default 0), and waits while the controller is used to adjust the nozzle
|
|
214
|
+ * height. On click the displayed height is saved in the mesh.
|
215
|
215
|
*
|
216
|
216
|
* Start Phase 4 at a specific location with X and Y. Adjust a specific number of Mesh Points with
|
217
|
217
|
* the 'R' (Repeat) parameter. (If 'R' is left out, the whole matrix is assumed.) This command can be
|
|
@@ -1351,9 +1351,8 @@
|
1351
|
1351
|
g29_repetition_cnt = 1; // do exactly one mesh location. Otherwise use what the parser decided.
|
1352
|
1352
|
|
1353
|
1353
|
#if ENABLED(UBL_MESH_EDIT_MOVES_Z)
|
1354
|
|
- const bool is_offset = parser.seen('H');
|
1355
|
|
- const float h_offset = is_offset ? parser.value_linear_units() : Z_CLEARANCE_BETWEEN_PROBES;
|
1356
|
|
- if (is_offset && !WITHIN(h_offset, 0, 10)) {
|
|
1354
|
+ const float h_offset = parser.seenval('H') ? parser.value_linear_units() : 0;
|
|
1355
|
+ if (!WITHIN(h_offset, 0, 10)) {
|
1357
|
1356
|
SERIAL_PROTOCOLLNPGM("Offset out of bounds. (0 to 10mm)\n");
|
1358
|
1357
|
return;
|
1359
|
1358
|
}
|
|
@@ -1369,63 +1368,63 @@
|
1369
|
1368
|
save_ubl_active_state_and_disable();
|
1370
|
1369
|
|
1371
|
1370
|
LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH);
|
|
1371
|
+ lcd_external_control = true; // Take over control of the LCD encoder
|
1372
|
1372
|
|
1373
|
|
- do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES);
|
|
1373
|
+ do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES); // Move to the given XY with probe clearance
|
|
1374
|
+
|
|
1375
|
+ #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
|
|
1376
|
+ do_blocking_move_to_z(h_offset); // Move Z to the given 'H' offset
|
|
1377
|
+ #endif
|
1374
|
1378
|
|
1375
|
1379
|
uint16_t not_done[16];
|
1376
|
1380
|
memset(not_done, 0xFF, sizeof(not_done));
|
1377
|
1381
|
do {
|
1378
|
1382
|
location = find_closest_mesh_point_of_type(SET_IN_BITMAP, rx, ry, USE_NOZZLE_AS_REFERENCE, not_done);
|
1379
|
1383
|
|
1380
|
|
- if (location.x_index < 0) break; // stop when we can't find any more reachable points.
|
|
1384
|
+ if (location.x_index < 0) break; // Stop when there are no more reachable points
|
1381
|
1385
|
|
1382
|
|
- bitmap_clear(not_done, location.x_index, location.y_index); // Mark this location as 'adjusted' so we will find a
|
1383
|
|
- // different location the next time through the loop
|
|
1386
|
+ bitmap_clear(not_done, location.x_index, location.y_index); // Mark this location as 'adjusted' so a new
|
|
1387
|
+ // location is used on the next loop
|
1384
|
1388
|
|
1385
|
1389
|
const float rawx = mesh_index_to_xpos(location.x_index),
|
1386
|
1390
|
rawy = mesh_index_to_ypos(location.y_index);
|
1387
|
1391
|
|
1388
|
|
- if (!position_is_reachable(rawx, rawy)) // SHOULD NOT OCCUR because find_closest_mesh_point_of_type will only return reachable
|
1389
|
|
- break;
|
|
1392
|
+ //if (!position_is_reachable(rawx, rawy)) break; // SHOULD NOT OCCUR because find_closest_mesh_point_of_type will only return reachable
|
1390
|
1393
|
|
1391
|
|
- do_blocking_move_to(rawx, rawy, Z_CLEARANCE_BETWEEN_PROBES); // Move the nozzle to the edit point
|
|
1394
|
+ do_blocking_move_to(rawx, rawy, Z_CLEARANCE_BETWEEN_PROBES); // Move the nozzle to the edit point with probe clearance
|
|
1395
|
+
|
|
1396
|
+ #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
|
|
1397
|
+ do_blocking_move_to_z(h_offset); // Move Z to the given 'H' offset before editing
|
|
1398
|
+ #endif
|
1392
|
1399
|
|
1393
|
1400
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
1394
|
|
- lcd_external_control = true;
|
1395
|
1401
|
|
1396
|
|
- if (do_ubl_mesh_map) display_map(g29_map_type); // show the user which point is being adjusted
|
|
1402
|
+ if (do_ubl_mesh_map) display_map(g29_map_type); // Display the current point
|
1397
|
1403
|
|
1398
|
1404
|
lcd_refresh();
|
1399
|
1405
|
|
1400
|
1406
|
float new_z = z_values[location.x_index][location.y_index];
|
1401
|
|
- if (isnan(new_z)) new_z = 0.0; // Set invalid mesh points to 0.0 so they can be edited
|
1402
|
|
- new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
|
|
1407
|
+ if (isnan(new_z)) new_z = 0.0; // Invalid points begin at 0
|
|
1408
|
+ new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
|
1403
|
1409
|
|
1404
|
1410
|
lcd_mesh_edit_setup(new_z);
|
1405
|
1411
|
|
1406
|
1412
|
do {
|
1407
|
1413
|
new_z = lcd_mesh_edit();
|
1408
|
1414
|
#if ENABLED(UBL_MESH_EDIT_MOVES_Z)
|
1409
|
|
- do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
|
|
1415
|
+ do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
|
1410
|
1416
|
#endif
|
1411
|
1417
|
idle();
|
1412
|
|
- SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
|
|
1418
|
+ SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
|
1413
|
1419
|
} while (!is_lcd_clicked());
|
1414
|
1420
|
|
1415
|
|
- if (!lcd_map_control) lcd_return_to_status();
|
1416
|
|
-
|
1417
|
|
- // The technique used here generates a race condition for the encoder click.
|
1418
|
|
- // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune) or here.
|
1419
|
|
- // Let's work on specifying a proper API for the LCD ASAP, OK?
|
1420
|
|
- lcd_external_control = true;
|
1421
|
|
-
|
1422
|
|
- if (click_and_hold(abort_fine_tune))
|
1423
|
|
- goto FINE_TUNE_EXIT;
|
|
1421
|
+ if (!lcd_map_control) lcd_return_to_status(); // Just editing a single point? Return to status
|
1424
|
1422
|
|
1425
|
|
- safe_delay(20); // We don't want any switch noise.
|
|
1423
|
+ if (click_and_hold(abort_fine_tune)) goto FINE_TUNE_EXIT; // If the click is held down, abort editing
|
1426
|
1424
|
|
1427
|
|
- z_values[location.x_index][location.y_index] = new_z;
|
|
1425
|
+ z_values[location.x_index][location.y_index] = new_z; // Save the updated Z value
|
1428
|
1426
|
|
|
1427
|
+ safe_delay(20); // No switch noise
|
1429
|
1428
|
lcd_refresh();
|
1430
|
1429
|
|
1431
|
1430
|
} while (location.x_index >= 0 && --g29_repetition_cnt > 0);
|