diff --git a/Marlin/G26_Mesh_Validation_Tool.cpp b/Marlin/G26_Mesh_Validation_Tool.cpp index 49a29daa9..4f231c2ae 100644 --- a/Marlin/G26_Mesh_Validation_Tool.cpp +++ b/Marlin/G26_Mesh_Validation_Tool.cpp @@ -152,7 +152,7 @@ bool turn_on_heaters(); bool prime_nozzle(); - static uint16_t circle_flags[16], horizontal_mesh_line_flags[16], vertical_mesh_line_flags[16], continue_with_closest = 0; + static uint16_t circle_flags[16], horizontal_mesh_line_flags[16], vertical_mesh_line_flags[16]; float g26_e_axis_feedrate = 0.020, random_deviation = 0.0, layer_height = LAYER_HEIGHT; @@ -176,7 +176,7 @@ static int8_t prime_flag = 0; - static bool keep_heaters_on = false; + static bool continue_with_closest, keep_heaters_on; static int16_t g26_repeats; @@ -361,7 +361,7 @@ //debug_current_and_destination(PSTR("Done with current circle.")); - } while (location.x_index >= 0 && location.y_index >= 0 && g26_repeats--); + } while (--g26_repeats && location.x_index >= 0 && location.y_index >= 0); LEAVE: lcd_reset_alert_level(); @@ -623,8 +623,8 @@ //if (ubl.g26_debug_flag) SERIAL_ECHOLNPGM(" Z bumping by 0.500 to minimize scraping."); //todo: parameterize the bump height with a define - move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]+0.500, 0.0); // Z bump to minimize scraping - move_to(sx, sy, sz+0.500, 0.0); // Get to the starting point with no extrusion while bumped + move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + 0.500, 0.0); // Z bump to minimize scraping + move_to(sx, sy, sz + 0.500, 0.0); // Get to the starting point with no extrusion while bumped } move_to(sx, sy, sz, 0.0); // Get to the starting point with no extrusion / un-Z bump @@ -655,9 +655,11 @@ prime_length = PRIME_LENGTH; bed_temp = BED_TEMP; hotend_temp = HOTEND_TEMP; - ooze_amount = OOZE_AMOUNT; prime_flag = 0; - keep_heaters_on = false; + + ooze_amount = code_seen('O') && code_has_value() ? code_value_linear_units() : OOZE_AMOUNT; + keep_heaters_on = code_seen('K') && code_value_bool(); + continue_with_closest = code_seen('C') && code_value_bool(); if (code_seen('B')) { bed_temp = code_value_temp_abs(); @@ -667,8 +669,6 @@ } } - if (code_seen('C')) continue_with_closest++; - if (code_seen('L')) { layer_height = code_value_linear_units(); if (!WITHIN(layer_height, 0.0, 2.0)) { @@ -699,11 +699,6 @@ } } - if (code_seen('K')) keep_heaters_on++; - - if (code_seen('O') && code_has_value()) - ooze_amount = code_value_linear_units(); - if (code_seen('P')) { if (!code_has_value()) prime_flag = -1; @@ -740,33 +735,19 @@ if (code_seen('M')) { randomSeed(millis()); + // This setting will persist for the next G26 random_deviation = code_has_value() ? code_value_float() : 50.0; } - if (code_seen('R')) { - g26_repeats = code_has_value() ? code_value_int() : 999; - - if (g26_repeats <= 0) { - SERIAL_PROTOCOLLNPGM("?(R)epeat value not plausible; must be greater than 0."); - return UBL_ERR; - } - - g26_repeats--; - } - - - x_pos = current_position[X_AXIS]; - y_pos = current_position[Y_AXIS]; - - if (code_seen('X')) { - x_pos = code_value_float(); - } - - if (code_seen('Y')) { - y_pos = code_value_float(); + g26_repeats = code_seen('R') ? (code_has_value() ? code_value_int() : 999) : 1; + if (g26_repeats < 1) { + SERIAL_PROTOCOLLNPGM("?(R)epeat value not plausible; must be at least 1."); + return UBL_ERR; } - if ( ! position_is_reachable_xy( x_pos, y_pos )) { + x_pos = code_seen('X') ? code_value_linear_units() : current_position[X_AXIS]; + y_pos = code_seen('Y') ? code_value_linear_units() : current_position[Y_AXIS]; + if (!position_is_reachable_xy(x_pos, y_pos)) { SERIAL_PROTOCOLLNPGM("?Specified X,Y coordinate out of bounds."); return UBL_ERR; }