Use H0 by default with UBL_MESH_EDIT_MOVES_Z (#10428)

This commit is contained in:
Scott Lahteine 2018-04-15 20:49:14 -05:00 committed by GitHub
parent 6cb83758d7
commit 0945674ba2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -210,8 +210,8 @@
* adhesion.
*
* P4 moves to the closest Mesh Point (and/or the given X Y), raises the nozzle above the mesh height
* by the given 'H' offset (or default Z_CLEARANCE_BETWEEN_PROBES), and waits while the controller is
* used to adjust the nozzle height. On click the displayed height is saved in the mesh.
* by the given 'H' offset (or default 0), and waits while the controller is used to adjust the nozzle
* height. On click the displayed height is saved in the mesh.
*
* Start Phase 4 at a specific location with X and Y. Adjust a specific number of Mesh Points with
* the 'R' (Repeat) parameter. (If 'R' is left out, the whole matrix is assumed.) This command can be
@ -1351,9 +1351,8 @@
g29_repetition_cnt = 1; // do exactly one mesh location. Otherwise use what the parser decided.
#if ENABLED(UBL_MESH_EDIT_MOVES_Z)
const bool is_offset = parser.seen('H');
const float h_offset = is_offset ? parser.value_linear_units() : Z_CLEARANCE_BETWEEN_PROBES;
if (is_offset && !WITHIN(h_offset, 0, 10)) {
const float h_offset = parser.seenval('H') ? parser.value_linear_units() : 0;
if (!WITHIN(h_offset, 0, 10)) {
SERIAL_PROTOCOLLNPGM("Offset out of bounds. (0 to 10mm)\n");
return;
}
@ -1369,63 +1368,63 @@
save_ubl_active_state_and_disable();
LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH);
lcd_external_control = true; // Take over control of the LCD encoder
do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES);
do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES); // Move to the given XY with probe clearance
#if ENABLED(UBL_MESH_EDIT_MOVES_Z)
do_blocking_move_to_z(h_offset); // Move Z to the given 'H' offset
#endif
uint16_t not_done[16];
memset(not_done, 0xFF, sizeof(not_done));
do {
location = find_closest_mesh_point_of_type(SET_IN_BITMAP, rx, ry, USE_NOZZLE_AS_REFERENCE, not_done);
if (location.x_index < 0) break; // stop when we can't find any more reachable points.
if (location.x_index < 0) break; // Stop when there are no more reachable points
bitmap_clear(not_done, location.x_index, location.y_index); // Mark this location as 'adjusted' so we will find a
// different location the next time through the loop
bitmap_clear(not_done, location.x_index, location.y_index); // Mark this location as 'adjusted' so a new
// location is used on the next loop
const float rawx = mesh_index_to_xpos(location.x_index),
rawy = mesh_index_to_ypos(location.y_index);
if (!position_is_reachable(rawx, rawy)) // SHOULD NOT OCCUR because find_closest_mesh_point_of_type will only return reachable
break;
//if (!position_is_reachable(rawx, rawy)) break; // SHOULD NOT OCCUR because find_closest_mesh_point_of_type will only return reachable
do_blocking_move_to(rawx, rawy, Z_CLEARANCE_BETWEEN_PROBES); // Move the nozzle to the edit point
do_blocking_move_to(rawx, rawy, Z_CLEARANCE_BETWEEN_PROBES); // Move the nozzle to the edit point with probe clearance
#if ENABLED(UBL_MESH_EDIT_MOVES_Z)
do_blocking_move_to_z(h_offset); // Move Z to the given 'H' offset before editing
#endif
KEEPALIVE_STATE(PAUSED_FOR_USER);
lcd_external_control = true;
if (do_ubl_mesh_map) display_map(g29_map_type); // show the user which point is being adjusted
if (do_ubl_mesh_map) display_map(g29_map_type); // Display the current point
lcd_refresh();
float new_z = z_values[location.x_index][location.y_index];
if (isnan(new_z)) new_z = 0.0; // Set invalid mesh points to 0.0 so they can be edited
new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
if (isnan(new_z)) new_z = 0.0; // Invalid points begin at 0
new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
lcd_mesh_edit_setup(new_z);
do {
new_z = lcd_mesh_edit();
#if ENABLED(UBL_MESH_EDIT_MOVES_Z)
do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
#endif
idle();
SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
} while (!is_lcd_clicked());
if (!lcd_map_control) lcd_return_to_status();
if (!lcd_map_control) lcd_return_to_status(); // Just editing a single point? Return to status
// The technique used here generates a race condition for the encoder click.
// It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune) or here.
// Let's work on specifying a proper API for the LCD ASAP, OK?
lcd_external_control = true;
if (click_and_hold(abort_fine_tune)) goto FINE_TUNE_EXIT; // If the click is held down, abort editing
if (click_and_hold(abort_fine_tune))
goto FINE_TUNE_EXIT;
safe_delay(20); // We don't want any switch noise.
z_values[location.x_index][location.y_index] = new_z;
z_values[location.x_index][location.y_index] = new_z; // Save the updated Z value
safe_delay(20); // No switch noise
lcd_refresh();
} while (location.x_index >= 0 && --g29_repetition_cnt > 0);