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
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23

View file

@ -210,8 +210,8 @@
* adhesion. * adhesion.
* *
* P4 moves to the closest Mesh Point (and/or the given X Y), raises the nozzle above the mesh height * 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 * by the given 'H' offset (or default 0), and waits while the controller is used to adjust the nozzle
* used to adjust the nozzle height. On click the displayed height is saved in the mesh. * 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 * 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 * 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. g29_repetition_cnt = 1; // do exactly one mesh location. Otherwise use what the parser decided.
#if ENABLED(UBL_MESH_EDIT_MOVES_Z) #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
const bool is_offset = parser.seen('H'); const float h_offset = parser.seenval('H') ? parser.value_linear_units() : 0;
const float h_offset = is_offset ? parser.value_linear_units() : Z_CLEARANCE_BETWEEN_PROBES; if (!WITHIN(h_offset, 0, 10)) {
if (is_offset && !WITHIN(h_offset, 0, 10)) {
SERIAL_PROTOCOLLNPGM("Offset out of bounds. (0 to 10mm)\n"); SERIAL_PROTOCOLLNPGM("Offset out of bounds. (0 to 10mm)\n");
return; return;
} }
@ -1369,63 +1368,63 @@
save_ubl_active_state_and_disable(); save_ubl_active_state_and_disable();
LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH); 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]; uint16_t not_done[16];
memset(not_done, 0xFF, sizeof(not_done)); memset(not_done, 0xFF, sizeof(not_done));
do { do {
location = find_closest_mesh_point_of_type(SET_IN_BITMAP, rx, ry, USE_NOZZLE_AS_REFERENCE, not_done); 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 bitmap_clear(not_done, location.x_index, location.y_index); // Mark this location as 'adjusted' so a new
// different location the next time through the loop // location is used on the next loop
const float rawx = mesh_index_to_xpos(location.x_index), const float rawx = mesh_index_to_xpos(location.x_index),
rawy = mesh_index_to_ypos(location.y_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 //if (!position_is_reachable(rawx, rawy)) break; // SHOULD NOT OCCUR because find_closest_mesh_point_of_type will only return reachable
break;
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); 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(); lcd_refresh();
float new_z = z_values[location.x_index][location.y_index]; 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 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 new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
lcd_mesh_edit_setup(new_z); lcd_mesh_edit_setup(new_z);
do { do {
new_z = lcd_mesh_edit(); new_z = lcd_mesh_edit();
#if ENABLED(UBL_MESH_EDIT_MOVES_Z) #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 #endif
idle(); idle();
SERIAL_FLUSH(); // Prevent host M105 buffer overrun. SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
} while (!is_lcd_clicked()); } 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. if (click_and_hold(abort_fine_tune)) goto FINE_TUNE_EXIT; // If the click is held down, abort editing
// 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)) z_values[location.x_index][location.y_index] = new_z; // Save the updated Z value
goto FINE_TUNE_EXIT;
safe_delay(20); // We don't want any switch noise.
z_values[location.x_index][location.y_index] = new_z;
safe_delay(20); // No switch noise
lcd_refresh(); lcd_refresh();
} while (location.x_index >= 0 && --g29_repetition_cnt > 0); } while (location.x_index >= 0 && --g29_repetition_cnt > 0);