From a00206aebe980e85d7c521b8ab7047e54cc4fbe7 Mon Sep 17 00:00:00 2001 From: wmariz <11435639+wmariz@users.noreply.github.com> Date: Sat, 21 Nov 2020 00:58:06 -0300 Subject: [PATCH 01/13] Use probe to level corners --- Marlin/Configuration.h | 4 + Marlin/src/inc/SanityCheck.h | 2 + Marlin/src/lcd/language/language_en.h | 3 + Marlin/src/lcd/menu/menu_bed_corners.cpp | 199 +++++++++++++++++++---- 4 files changed, 177 insertions(+), 31 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 9d2dd0b710ba..9af162bfd9a9 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1376,6 +1376,10 @@ #define LEVEL_CORNERS_HEIGHT 0.0 // (mm) Z height of nozzle at leveling points #define LEVEL_CORNERS_Z_HOP 4.0 // (mm) Z height of nozzle between leveling points //#define LEVEL_CENTER_TOO // Move to the center after the last corner + //#define LEVEL_CORNERS_USE_PROBE + #if ENABLED(LEVEL_CORNERS_USE_PROBE) + #define LEVEL_CORNERS_USE_PROBE_TOLERANCE 0.1 + #endif #endif /** diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 4215f225e3eb..c4e4eb20ebe6 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -357,6 +357,8 @@ #error "LEVEL_CORNERS_INSET is now LEVEL_CORNERS_INSET_LFRB." #elif ENABLED(LEVEL_BED_CORNERS) && !defined(LEVEL_CORNERS_INSET_LFRB) #error "LEVEL_BED_CORNERS requires LEVEL_CORNERS_INSET_LFRB values." +#elif ENABLED(LEVEL_CORNERS_USE_PROBE) && ENABLED(SENSORLESS_PROBING) + #error "LEVEL_CORNERS_USE_PROBE and SENSORLESS_PROBING are incompatible." #elif defined(BEZIER_JERK_CONTROL) #error "BEZIER_JERK_CONTROL is now S_CURVE_ACCELERATION." #elif HAS_JUNCTION_DEVIATION && defined(JUNCTION_DEVIATION_FACTOR) diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 0355f2f51249..fa3bd9674fde 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -125,6 +125,8 @@ namespace Language_en { PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Bed Leveling"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Level Bed"); PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Level Corners"); + PROGMEM Language_Str MSG_LEVEL_CORNERS_RAISE = _UxGT("Raise Bed Until Probe Triggered"); + PROGMEM Language_Str MSG_LEVEL_CORNERS_IN_RANGE = _UxGT("All Corners Within Tolerance. Level Bed"); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Next Corner"); PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Mesh Editor"); PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Edit Mesh"); @@ -376,6 +378,7 @@ namespace Language_en { PROGMEM Language_Str MSG_BUTTON_DONE = _UxGT("Done"); PROGMEM Language_Str MSG_BUTTON_BACK = _UxGT("Back"); PROGMEM Language_Str MSG_BUTTON_PROCEED = _UxGT("Proceed"); + PROGMEM Language_Str MSG_BUTTON_SKIP = _UxGT("Skip"); PROGMEM Language_Str MSG_PAUSING = _UxGT("Pausing..."); PROGMEM Language_Str MSG_PAUSE_PRINT = _UxGT("Pause Print"); PROGMEM Language_Str MSG_RESUME_PRINT = _UxGT("Resume Print"); diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 16f9992c1852..7a94a3104fdf 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -44,6 +44,29 @@ #define LEVEL_CORNERS_HEIGHT 0.0 #endif +#if ENABLED(LEVEL_CORNERS_USE_PROBE) + #include "../../module/probe.h" + #include "../../module/endstops.h" + #if ENABLED(BLTOUCH) + #include "../../feature/bltouch.h" + #endif + #ifndef LEVEL_CORNERS_USE_PROBE_TOLERANCE + #define LEVEL_CORNERS_USE_PROBE_TOLERANCE 0.1 + #endif + static float last_z = LEVEL_CORNERS_HEIGHT; + bool wait_for_probe = false; + bool probe_triggered = false; + bool corner_probing_done = false; + int count_points_in_tolerance = 0; + #ifndef TEST_PROBE_PIN + #if HAS_CUSTOM_PROBE_PIN + #define TEST_PROBE_PIN (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING) + #else + #define TEST_PROBE_PIN (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) + #endif + #endif +#endif + static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration."); #if HAS_LEVELING @@ -54,43 +77,157 @@ static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Pleas * Level corners, starting in the front-left corner. */ static int8_t bed_corner; -static inline void _lcd_goto_next_corner() { - constexpr float lfrb[4] = LEVEL_CORNERS_INSET_LFRB; - constexpr xy_pos_t lf { (X_MIN_BED) + lfrb[0], (Y_MIN_BED) + lfrb[1] }, - rb { (X_MAX_BED) - lfrb[2], (Y_MAX_BED) - lfrb[3] }; - line_to_z(LEVEL_CORNERS_Z_HOP); - switch (bed_corner) { - case 0: current_position = lf; break; // copy xy - case 1: current_position.x = rb.x; break; - case 2: current_position.y = rb.y; break; - case 3: current_position.x = lf.x; break; - #if ENABLED(LEVEL_CENTER_TOO) - case 4: current_position.set(X_CENTER, Y_CENTER); break; - #endif +#if DISABLED(LEVEL_CORNERS_USE_PROBE) + static inline void _lcd_goto_next_corner() { + constexpr float lfrb[4] = LEVEL_CORNERS_INSET_LFRB; + constexpr xy_pos_t lf { (X_MIN_BED) + lfrb[0], (Y_MIN_BED) + lfrb[1] }, + rb { (X_MAX_BED) - lfrb[2], (Y_MAX_BED) - lfrb[3] }; + line_to_z(LEVEL_CORNERS_Z_HOP); + switch (bed_corner) { + case 0: current_position = lf; break; // copy xy + case 1: current_position.x = rb.x; break; + case 2: current_position.y = rb.y; break; + case 3: current_position.x = lf.x; break; + #if ENABLED(LEVEL_CENTER_TOO) + case 4: current_position.set(X_CENTER, Y_CENTER); break; + #endif + } + line_to_current_position(manual_feedrate_mm_s.x); + line_to_z(LEVEL_CORNERS_HEIGHT); + if (++bed_corner > 3 + ENABLED(LEVEL_CENTER_TOO)) bed_corner = 0; } - line_to_current_position(manual_feedrate_mm_s.x); - line_to_z(LEVEL_CORNERS_HEIGHT); - if (++bed_corner > 3 + ENABLED(LEVEL_CENTER_TOO)) bed_corner = 0; -} +#else + + static inline void _lcd_level_bed_corners_probing() { -static inline void _lcd_level_bed_corners_homing() { - _lcd_draw_homing(); - if (all_axes_homed()) { - bed_corner = 0; ui.goto_screen([]{ - MenuItem_confirm::select_screen( - GET_TEXT(MSG_BUTTON_NEXT), GET_TEXT(MSG_BUTTON_DONE) - , _lcd_goto_next_corner - , []{ + MenuItem_static::draw( + (LCD_HEIGHT - 1) / 2 + , GET_TEXT(MSG_PROBING_MESH) + ); + }); + + float lfrb[4] = LEVEL_CORNERS_INSET_LFRB; + xy_pos_t lf { (X_MIN_BED) + lfrb[0] - probe.offset_xy.x , (Y_MIN_BED) + lfrb[1] - probe.offset_xy.y }, + rb { (X_MAX_BED) - lfrb[2] - probe.offset_xy.x , (Y_MAX_BED) - lfrb[3] - probe.offset_xy.y }; + + do_blocking_move_to_z(LEVEL_CORNERS_Z_HOP - probe.offset.z); + + switch (bed_corner) { + case 0: current_position = lf; break; // copy xy + case 1: current_position.x = rb.x; break; + case 2: current_position.y = rb.y; break; + case 3: current_position.x = lf.x; break; + #if ENABLED(LEVEL_CENTER_TOO) + case 4: current_position.set(X_CENTER - probe.offset_xy.x, Y_CENTER - probe.offset_xy.y); count_points_in_tolerance--; break; + #endif + } + + do_blocking_move_to_xy(current_position); + + #if ENABLED(BLTOUCH) && DISABLED(BLTOUCH_HS_MODE) + bltouch.deploy(); // DEPLOY in LOW SPEED MODE on every probe action + #endif + TERN_(QUIET_PROBING, probe.set_probing_paused(true)); + + do_blocking_move_to_z(last_z - LEVEL_CORNERS_USE_PROBE_TOLERANCE, manual_feedrate_mm_s.z);// Move down until the probe is triggered + probe_triggered = TEST(endstops.trigger_state(), TERN(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, Z_MIN, Z_MIN_PROBE));// Check to see if the probe was triggered + + if (!probe_triggered) { + ui.goto_screen([]{ + MenuItem_confirm::select_screen( + GET_TEXT(MSG_BUTTON_DONE), GET_TEXT(MSG_BUTTON_SKIP) + , []{ + corner_probing_done = true; + wait_for_probe = false; TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active)); ui.goto_previous_screen_no_defer(); } - , GET_TEXT(TERN(LEVEL_CENTER_TOO, MSG_LEVEL_BED_NEXT_POINT, MSG_NEXT_CORNER)) - , (const char*)nullptr, PSTR("?") - ); - }); - ui.set_selection(true); - _lcd_goto_next_corner(); + , []{ + wait_for_probe = false; + } + , GET_TEXT(MSG_LEVEL_CORNERS_RAISE) + , (const char*)nullptr, PSTR("") + ); + }); + ui.set_selection(true); + + wait_for_probe = true; + while (wait_for_probe && !probe_triggered) { + probe_triggered = TEST_PROBE_PIN; + idle(); + } + wait_for_probe = false; + + } + + TERN_(QUIET_PROBING, probe.set_probing_paused(false)); + + #if ENABLED(BLTOUCH) && DISABLED(BLTOUCH_HS_MODE) + bltouch.stow(); + #endif + + if (probe_triggered) { + endstops.hit_on_purpose(); + if (!WITHIN(current_position.z, current_position.z - LEVEL_CORNERS_USE_PROBE_TOLERANCE, current_position.z + LEVEL_CORNERS_USE_PROBE_TOLERANCE)){ + last_z = current_position.z; + count_points_in_tolerance = 1; + } + count_points_in_tolerance++; + } + + if (!corner_probing_done){ + if (++bed_corner > 3 ) bed_corner = 0; + if (count_points_in_tolerance < 4){ + _lcd_level_bed_corners_probing(); + } else { + ui.goto_screen([]{ + MenuItem_confirm::confirm_screen( + []{ + ui.goto_previous_screen_no_defer(); + queue.inject_P(PSTR("G28\nG29")); + } + , []{ + ui.goto_previous_screen_no_defer(); + } + , GET_TEXT(MSG_LEVEL_CORNERS_IN_RANGE) + , (const char*)nullptr, PSTR("?") + ); + }); + ui.set_selection(true); + } + } + } +#endif + +static inline void _lcd_level_bed_corners_homing() { + _lcd_draw_homing(); + if (all_axes_homed()) { + #if ENABLED(LEVEL_CORNERS_USE_PROBE) + endstops.enable_z_probe(true); + #endif + #if ENABLED(LEVEL_CORNERS_USE_PROBE) + #if ENABLED(LEVEL_CENTER_TOO) + bed_corner = 4; + #endif + ui.goto_screen(_lcd_level_bed_corners_probing); + #else + bed_corner = 0; + ui.goto_screen([]{ + MenuItem_confirm::select_screen( + GET_TEXT(MSG_BUTTON_NEXT), GET_TEXT(MSG_BUTTON_DONE) + , _lcd_goto_next_corner + , []{ + TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active)); + ui.goto_previous_screen_no_defer(); + } + , GET_TEXT(TERN(LEVEL_CENTER_TOO, MSG_LEVEL_BED_NEXT_POINT, MSG_NEXT_CORNER)) + , (const char*)nullptr, PSTR("?") + ); + }); + ui.set_selection(true); + _lcd_goto_next_corner(); + #endif } } From bc1cbe8af7a07aa7db4c881fff9dd56319514190 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 21 Nov 2020 18:39:46 -0600 Subject: [PATCH 02/13] Some cleanup --- Marlin/Configuration.h | 4 +- Marlin/src/inc/SanityCheck.h | 6 +- Marlin/src/lcd/menu/menu_bed_corners.cpp | 98 ++++++++++++------------ 3 files changed, 53 insertions(+), 55 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 9af162bfd9a9..591b11b12f96 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1378,8 +1378,8 @@ //#define LEVEL_CENTER_TOO // Move to the center after the last corner //#define LEVEL_CORNERS_USE_PROBE #if ENABLED(LEVEL_CORNERS_USE_PROBE) - #define LEVEL_CORNERS_USE_PROBE_TOLERANCE 0.1 - #endif + #define LEVEL_CORNERS_PROBE_TOLERANCE 0.1 + #endif #endif /** diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index c4e4eb20ebe6..39acb43dd629 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -357,8 +357,8 @@ #error "LEVEL_CORNERS_INSET is now LEVEL_CORNERS_INSET_LFRB." #elif ENABLED(LEVEL_BED_CORNERS) && !defined(LEVEL_CORNERS_INSET_LFRB) #error "LEVEL_BED_CORNERS requires LEVEL_CORNERS_INSET_LFRB values." -#elif ENABLED(LEVEL_CORNERS_USE_PROBE) && ENABLED(SENSORLESS_PROBING) - #error "LEVEL_CORNERS_USE_PROBE and SENSORLESS_PROBING are incompatible." +#elif BOTH(LEVEL_CORNERS_USE_PROBE, SENSORLESS_PROBING) + #error "LEVEL_CORNERS_USE_PROBE is incompatible with SENSORLESS_PROBING." #elif defined(BEZIER_JERK_CONTROL) #error "BEZIER_JERK_CONTROL is now S_CURVE_ACCELERATION." #elif HAS_JUNCTION_DEVIATION && defined(JUNCTION_DEVIATION_FACTOR) @@ -1576,7 +1576,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal * Allen Key * Deploying the Allen Key probe uses big moves in z direction. Too dangerous for an unhomed z-axis. */ -#if ENABLED(Z_PROBE_ALLEN_KEY) && (Z_HOME_DIR < 0) && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) +#if BOTH(Z_PROBE_ALLEN_KEY, Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && (Z_HOME_DIR < 0) #error "You can't home to a Z min endstop with a Z_PROBE_ALLEN_KEY." #endif diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 7a94a3104fdf..58aeb2e68562 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -49,9 +49,9 @@ #include "../../module/endstops.h" #if ENABLED(BLTOUCH) #include "../../feature/bltouch.h" - #endif - #ifndef LEVEL_CORNERS_USE_PROBE_TOLERANCE - #define LEVEL_CORNERS_USE_PROBE_TOLERANCE 0.1 + #endif + #ifndef LEVEL_CORNERS_PROBE_TOLERANCE + #define LEVEL_CORNERS_PROBE_TOLERANCE 0.1 #endif static float last_z = LEVEL_CORNERS_HEIGHT; bool wait_for_probe = false; @@ -69,37 +69,20 @@ static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration."); +extern const char G28_STR[]; + #if HAS_LEVELING static bool leveling_was_active = false; #endif +static int8_t bed_corner; + /** * Level corners, starting in the front-left corner. */ -static int8_t bed_corner; -#if DISABLED(LEVEL_CORNERS_USE_PROBE) - static inline void _lcd_goto_next_corner() { - constexpr float lfrb[4] = LEVEL_CORNERS_INSET_LFRB; - constexpr xy_pos_t lf { (X_MIN_BED) + lfrb[0], (Y_MIN_BED) + lfrb[1] }, - rb { (X_MAX_BED) - lfrb[2], (Y_MAX_BED) - lfrb[3] }; - line_to_z(LEVEL_CORNERS_Z_HOP); - switch (bed_corner) { - case 0: current_position = lf; break; // copy xy - case 1: current_position.x = rb.x; break; - case 2: current_position.y = rb.y; break; - case 3: current_position.x = lf.x; break; - #if ENABLED(LEVEL_CENTER_TOO) - case 4: current_position.set(X_CENTER, Y_CENTER); break; - #endif - } - line_to_current_position(manual_feedrate_mm_s.x); - line_to_z(LEVEL_CORNERS_HEIGHT); - if (++bed_corner > 3 + ENABLED(LEVEL_CENTER_TOO)) bed_corner = 0; - } -#else - - static inline void _lcd_level_bed_corners_probing() { +#if ENABLED(LEVEL_CORNERS_USE_PROBE) + static inline void _lcd_level_bed_corners_probing() { ui.goto_screen([]{ MenuItem_static::draw( (LCD_HEIGHT - 1) / 2 @@ -110,9 +93,9 @@ static int8_t bed_corner; float lfrb[4] = LEVEL_CORNERS_INSET_LFRB; xy_pos_t lf { (X_MIN_BED) + lfrb[0] - probe.offset_xy.x , (Y_MIN_BED) + lfrb[1] - probe.offset_xy.y }, rb { (X_MAX_BED) - lfrb[2] - probe.offset_xy.x , (Y_MAX_BED) - lfrb[3] - probe.offset_xy.y }; - + do_blocking_move_to_z(LEVEL_CORNERS_Z_HOP - probe.offset.z); - + switch (bed_corner) { case 0: current_position = lf; break; // copy xy case 1: current_position.x = rb.x; break; @@ -129,8 +112,8 @@ static int8_t bed_corner; bltouch.deploy(); // DEPLOY in LOW SPEED MODE on every probe action #endif TERN_(QUIET_PROBING, probe.set_probing_paused(true)); - - do_blocking_move_to_z(last_z - LEVEL_CORNERS_USE_PROBE_TOLERANCE, manual_feedrate_mm_s.z);// Move down until the probe is triggered + + do_blocking_move_to_z(last_z - (LEVEL_CORNERS_PROBE_TOLERANCE), manual_feedrate_mm_s.z);// Move down until the probe is triggered probe_triggered = TEST(endstops.trigger_state(), TERN(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, Z_MIN, Z_MIN_PROBE));// Check to see if the probe was triggered if (!probe_triggered) { @@ -145,7 +128,7 @@ static int8_t bed_corner; } , []{ wait_for_probe = false; - } + } , GET_TEXT(MSG_LEVEL_CORNERS_RAISE) , (const char*)nullptr, PSTR("") ); @@ -160,36 +143,33 @@ static int8_t bed_corner; wait_for_probe = false; } - + TERN_(QUIET_PROBING, probe.set_probing_paused(false)); - + #if ENABLED(BLTOUCH) && DISABLED(BLTOUCH_HS_MODE) bltouch.stow(); #endif if (probe_triggered) { endstops.hit_on_purpose(); - if (!WITHIN(current_position.z, current_position.z - LEVEL_CORNERS_USE_PROBE_TOLERANCE, current_position.z + LEVEL_CORNERS_USE_PROBE_TOLERANCE)){ + if (!WITHIN(current_position.z, current_position.z - (LEVEL_CORNERS_PROBE_TOLERANCE), current_position.z + (LEVEL_CORNERS_PROBE_TOLERANCE))) { last_z = current_position.z; count_points_in_tolerance = 1; } count_points_in_tolerance++; } - if (!corner_probing_done){ - if (++bed_corner > 3 ) bed_corner = 0; - if (count_points_in_tolerance < 4){ + if (!corner_probing_done) { + if (++bed_corner > 3) bed_corner = 0; + if (count_points_in_tolerance < 4) _lcd_level_bed_corners_probing(); - } else { + else { ui.goto_screen([]{ MenuItem_confirm::confirm_screen( - []{ - ui.goto_previous_screen_no_defer(); - queue.inject_P(PSTR("G28\nG29")); - } - , []{ - ui.goto_previous_screen_no_defer(); - } + []{ ui.goto_previous_screen_no_defer(); + queue.inject_P(TERN(HAS_LEVELING, PSTR("G28\nG29"), G28_STR); + } + , []{ ui.goto_previous_screen_no_defer(); } , GET_TEXT(MSG_LEVEL_CORNERS_IN_RANGE) , (const char*)nullptr, PSTR("?") ); @@ -198,18 +178,36 @@ static int8_t bed_corner; } } } + +#else + + static inline void _lcd_goto_next_corner() { + constexpr float lfrb[4] = LEVEL_CORNERS_INSET_LFRB; + constexpr xy_pos_t lf { (X_MIN_BED) + lfrb[0], (Y_MIN_BED) + lfrb[1] }, + rb { (X_MAX_BED) - lfrb[2], (Y_MAX_BED) - lfrb[3] }; + line_to_z(LEVEL_CORNERS_Z_HOP); + switch (bed_corner) { + case 0: current_position = lf; break; // copy xy + case 1: current_position.x = rb.x; break; + case 2: current_position.y = rb.y; break; + case 3: current_position.x = lf.x; break; + #if ENABLED(LEVEL_CENTER_TOO) + case 4: current_position.set(X_CENTER, Y_CENTER); break; + #endif + } + line_to_current_position(manual_feedrate_mm_s.x); + line_to_z(LEVEL_CORNERS_HEIGHT); + if (++bed_corner > 3 + ENABLED(LEVEL_CENTER_TOO)) bed_corner = 0; + } + #endif static inline void _lcd_level_bed_corners_homing() { _lcd_draw_homing(); if (all_axes_homed()) { #if ENABLED(LEVEL_CORNERS_USE_PROBE) + TERN_(LEVEL_CENTER_TOO, bed_corner = 4); endstops.enable_z_probe(true); - #endif - #if ENABLED(LEVEL_CORNERS_USE_PROBE) - #if ENABLED(LEVEL_CENTER_TOO) - bed_corner = 4; - #endif ui.goto_screen(_lcd_level_bed_corners_probing); #else bed_corner = 0; From 3034378bb04369ba2a99bfe7f71e5c5a71b5fb05 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 21 Nov 2020 18:45:20 -0600 Subject: [PATCH 03/13] whitespace --- Marlin/src/lcd/menu/menu_bed_corners.cpp | 25 ++++++++---------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 58aeb2e68562..15972d775dfa 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -83,12 +83,7 @@ static int8_t bed_corner; #if ENABLED(LEVEL_CORNERS_USE_PROBE) static inline void _lcd_level_bed_corners_probing() { - ui.goto_screen([]{ - MenuItem_static::draw( - (LCD_HEIGHT - 1) / 2 - , GET_TEXT(MSG_PROBING_MESH) - ); - }); + ui.goto_screen([]{ MenuItem_static::draw((LCD_HEIGHT - 1) / 2, GET_TEXT(MSG_PROBING_MESH)); }); float lfrb[4] = LEVEL_CORNERS_INSET_LFRB; xy_pos_t lf { (X_MIN_BED) + lfrb[0] - probe.offset_xy.x , (Y_MIN_BED) + lfrb[1] - probe.offset_xy.y }, @@ -120,15 +115,12 @@ static int8_t bed_corner; ui.goto_screen([]{ MenuItem_confirm::select_screen( GET_TEXT(MSG_BUTTON_DONE), GET_TEXT(MSG_BUTTON_SKIP) - , []{ - corner_probing_done = true; - wait_for_probe = false; - TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active)); - ui.goto_previous_screen_no_defer(); - } - , []{ - wait_for_probe = false; - } + , []{ corner_probing_done = true; + wait_for_probe = false; + TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active)); + ui.goto_previous_screen_no_defer(); + } + , []{ wait_for_probe = false; } , GET_TEXT(MSG_LEVEL_CORNERS_RAISE) , (const char*)nullptr, PSTR("") ); @@ -141,7 +133,6 @@ static int8_t bed_corner; idle(); } wait_for_probe = false; - } TERN_(QUIET_PROBING, probe.set_probing_paused(false)); @@ -184,7 +175,7 @@ static int8_t bed_corner; static inline void _lcd_goto_next_corner() { constexpr float lfrb[4] = LEVEL_CORNERS_INSET_LFRB; constexpr xy_pos_t lf { (X_MIN_BED) + lfrb[0], (Y_MIN_BED) + lfrb[1] }, - rb { (X_MAX_BED) - lfrb[2], (Y_MAX_BED) - lfrb[3] }; + rb { (X_MAX_BED) - lfrb[2], (Y_MAX_BED) - lfrb[3] }; line_to_z(LEVEL_CORNERS_Z_HOP); switch (bed_corner) { case 0: current_position = lf; break; // copy xy From 511c6e792449832c2f7d07d47996bdb3669efa36 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 21 Nov 2020 19:05:36 -0600 Subject: [PATCH 04/13] Unify PROBE_TRIGGERED --- Marlin/src/feature/backlash.cpp | 10 ++++------ Marlin/src/feature/bltouch.cpp | 11 ++--------- Marlin/src/gcode/calibrate/G425.cpp | 8 +++++--- Marlin/src/lcd/menu/menu_bed_corners.cpp | 9 +-------- Marlin/src/module/endstops.cpp | 2 +- Marlin/src/module/probe.cpp | 20 +++----------------- Marlin/src/module/probe.h | 6 ++++++ 7 files changed, 22 insertions(+), 44 deletions(-) diff --git a/Marlin/src/feature/backlash.cpp b/Marlin/src/feature/backlash.cpp index 867e9cdd217c..b848214f0c46 100644 --- a/Marlin/src/feature/backlash.cpp +++ b/Marlin/src/feature/backlash.cpp @@ -123,24 +123,22 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const } #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) - #if HAS_CUSTOM_PROBE_PIN - #define TEST_PROBE_PIN (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING) - #else - #define TEST_PROBE_PIN (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) - #endif + + #include "../module/probe.h" // Measure Z backlash by raising nozzle in increments until probe deactivates void Backlash::measure_with_probe() { if (measured_count.z == 255) return; const float start_height = current_position.z; - while (current_position.z < (start_height + BACKLASH_MEASUREMENT_LIMIT) && TEST_PROBE_PIN) + while (current_position.z < (start_height + BACKLASH_MEASUREMENT_LIMIT) && PROBE_TRIGGERED()) do_blocking_move_to_z(current_position.z + BACKLASH_MEASUREMENT_RESOLUTION, MMM_TO_MMS(BACKLASH_MEASUREMENT_FEEDRATE)); // The backlash from all probe points is averaged, so count the number of measurements measured_mm.z += current_position.z - start_height; measured_count.z++; } + #endif #endif // BACKLASH_COMPENSATION diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index d6b1f99c16b9..48eaf9efc400 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -31,6 +31,7 @@ BLTouch bltouch; bool BLTouch::last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain #include "../module/servo.h" +#include "../module/probe.h" void stop(); @@ -90,15 +91,7 @@ void BLTouch::clear() { _stow(); // STOW to be ready for meaningful work. Could fail, don't care } -bool BLTouch::triggered() { - return ( - #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) - READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING - #else - READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING - #endif - ); -} +bool BLTouch::triggered() { return PROBE_TRIGGERED(); } bool BLTouch::deploy_proc() { // Do a DEPLOY diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index 6517e6b4bdc4..9510da7740ef 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -143,14 +143,16 @@ inline void park_above_object(measurements_t &m, const float uncertainty) { #endif +#if !PIN_EXISTS(CALIBRATION) + #include "../../module/probe.h" +#endif + inline bool read_calibration_pin() { return ( #if PIN_EXISTS(CALIBRATION) READ(CALIBRATION_PIN) != CALIBRATION_PIN_INVERTING - #elif HAS_CUSTOM_PROBE_PIN - READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING #else - READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING + PROBE_TRIGGERED() #endif ); } diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 15972d775dfa..4b0ebadb77a0 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -58,13 +58,6 @@ bool probe_triggered = false; bool corner_probing_done = false; int count_points_in_tolerance = 0; - #ifndef TEST_PROBE_PIN - #if HAS_CUSTOM_PROBE_PIN - #define TEST_PROBE_PIN (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING) - #else - #define TEST_PROBE_PIN (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) - #endif - #endif #endif static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration."); @@ -129,7 +122,7 @@ static int8_t bed_corner; wait_for_probe = true; while (wait_for_probe && !probe_triggered) { - probe_triggered = TEST_PROBE_PIN; + probe_triggered = PROBE_TRIGGERED(); idle(); } wait_for_probe = false; diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 697ced783379..ccb83483bd80 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -455,7 +455,7 @@ void _O2 Endstops::report_states() { ES_REPORT(Z4_MAX); #endif #if HAS_CUSTOM_PROBE_PIN - print_es_state(READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING, PSTR(STR_Z_PROBE)); + print_es_state(PROBE_TRIGGERED(), PSTR(STR_Z_PROBE)); #endif #if HAS_FILAMENT_SENSOR #if NUM_RUNOUT_SENSORS == 1 diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index ff80063d658d..ac91b2337268 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -270,13 +270,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { #if ENABLED(PAUSE_BEFORE_DEPLOY_STOW) do { #if ENABLED(PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED) - if (deploy == ( - #if HAS_CUSTOM_PROBE_PIN - READ(Z_MIN_PROBE_PIN) == Z_MIN_PROBE_ENDSTOP_INVERTING - #else - READ(Z_MIN_PIN) == Z_MIN_ENDSTOP_INVERTING - #endif - )) break; + if (deploy == PROBE_TRIGGERED()) break; #endif BUZZ(100, 659); @@ -375,23 +369,15 @@ bool Probe::set_deployed(const bool deploy) { const xy_pos_t old_xy = current_position; #if ENABLED(PROBE_TRIGGERED_WHEN_STOWED_TEST) - #if HAS_CUSTOM_PROBE_PIN - #define PROBE_STOWED() (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING) - #else - #define PROBE_STOWED() (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) - #endif - #endif - - #ifdef PROBE_STOWED // Only deploy/stow if needed - if (PROBE_STOWED() == deploy) { + if (PROBE_TRIGGERED() == deploy) { if (!deploy) endstops.enable_z_probe(false); // Switch off triggered when stowed probes early // otherwise an Allen-Key probe can't be stowed. probe_specific_action(deploy); } - if (PROBE_STOWED() == deploy) { // Unchanged after deploy/stow action? + if (PROBE_TRIGGERED() == deploy) { // Unchanged after deploy/stow action? if (IsRunning()) { SERIAL_ERROR_MSG("Z-Probe failed"); LCD_ALERTMESSAGEPGM_P(PSTR("Err: ZPROBE")); diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index 63229242b5da..703f9689e924 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -38,6 +38,12 @@ }; #endif +#if HAS_CUSTOM_PROBE_PIN + #define PROBE_TRIGGERED() (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING) +#else + #define PROBE_TRIGGERED() (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) +#endif + class Probe { public: From 04a41f86326ae3e676e4b9dd86f7ac28ca997cf1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 21 Nov 2020 19:29:46 -0600 Subject: [PATCH 05/13] Compare current Z to last --- Marlin/src/lcd/menu/menu_bed_corners.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 4b0ebadb77a0..a69c0c2c1bbb 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -57,7 +57,7 @@ bool wait_for_probe = false; bool probe_triggered = false; bool corner_probing_done = false; - int count_points_in_tolerance = 0; + int good_points = 0; #endif static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration."); @@ -90,7 +90,7 @@ static int8_t bed_corner; case 2: current_position.y = rb.y; break; case 3: current_position.x = lf.x; break; #if ENABLED(LEVEL_CENTER_TOO) - case 4: current_position.set(X_CENTER - probe.offset_xy.x, Y_CENTER - probe.offset_xy.y); count_points_in_tolerance--; break; + case 4: current_position.set(X_CENTER - probe.offset_xy.x, Y_CENTER - probe.offset_xy.y); good_points--; break; #endif } @@ -136,16 +136,16 @@ static int8_t bed_corner; if (probe_triggered) { endstops.hit_on_purpose(); - if (!WITHIN(current_position.z, current_position.z - (LEVEL_CORNERS_PROBE_TOLERANCE), current_position.z + (LEVEL_CORNERS_PROBE_TOLERANCE))) { + if (!WITHIN(current_position.z, last_z - (LEVEL_CORNERS_PROBE_TOLERANCE), last_z + (LEVEL_CORNERS_PROBE_TOLERANCE))) { last_z = current_position.z; - count_points_in_tolerance = 1; + good_points = 1; } - count_points_in_tolerance++; + good_points++; } if (!corner_probing_done) { if (++bed_corner > 3) bed_corner = 0; - if (count_points_in_tolerance < 4) + if (good_points < 4) _lcd_level_bed_corners_probing(); else { ui.goto_screen([]{ From 92ec8f80489e210ab5a7ff85281c18816827ea92 Mon Sep 17 00:00:00 2001 From: wmariz <11435639+wmariz@users.noreply.github.com> Date: Sun, 22 Nov 2020 02:19:13 -0300 Subject: [PATCH 06/13] Set variables every run --- Marlin/src/lcd/menu/menu_bed_corners.cpp | 20 ++++++++++++++------ Marlin/src/module/endstops.cpp | 4 ++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index a69c0c2c1bbb..fd1997a44220 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -53,11 +53,11 @@ #ifndef LEVEL_CORNERS_PROBE_TOLERANCE #define LEVEL_CORNERS_PROBE_TOLERANCE 0.1 #endif - static float last_z = LEVEL_CORNERS_HEIGHT; - bool wait_for_probe = false; - bool probe_triggered = false; - bool corner_probing_done = false; - int good_points = 0; + static float last_z; + bool wait_for_probe; + bool probe_triggered; + bool corner_probing_done; + int good_points; #endif static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration."); @@ -151,7 +151,7 @@ static int8_t bed_corner; ui.goto_screen([]{ MenuItem_confirm::confirm_screen( []{ ui.goto_previous_screen_no_defer(); - queue.inject_P(TERN(HAS_LEVELING, PSTR("G28\nG29"), G28_STR); + queue.inject_P(TERN(HAS_LEVELING, PSTR("G28\nG29"), G28_STR)); } , []{ ui.goto_previous_screen_no_defer(); } , GET_TEXT(MSG_LEVEL_CORNERS_IN_RANGE) @@ -226,6 +226,14 @@ void _lcd_level_bed_corners() { set_bed_leveling_enabled(false); #endif + #if ENABLED(LEVEL_CORNERS_USE_PROBE) + last_z = LEVEL_CORNERS_HEIGHT; + wait_for_probe = false; + probe_triggered = false; + corner_probing_done = false; + good_points = 0; + #endif + ui.goto_screen(_lcd_level_bed_corners_homing); } diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index ccb83483bd80..ef0b92a7ee05 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -48,6 +48,10 @@ #include "../feature/joystick.h" #endif +#if HAS_BED_PROBE + #include "probe.h" +#endif + Endstops endstops; // private: From 67e513732d1398535d77cbb9dbce8379e30cafcf Mon Sep 17 00:00:00 2001 From: wmariz <11435639+wmariz@users.noreply.github.com> Date: Sun, 22 Nov 2020 13:59:43 -0300 Subject: [PATCH 07/13] Probe feedback --- Marlin/Configuration.h | 2 ++ Marlin/src/lcd/menu/menu_bed_corners.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 8c4bb25fc3d4..16ae02933e49 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1395,6 +1395,8 @@ //#define LEVEL_CORNERS_USE_PROBE #if ENABLED(LEVEL_CORNERS_USE_PROBE) #define LEVEL_CORNERS_PROBE_TOLERANCE 0.1 + //#define LEVEL_CORNERS_FEEDBACK_FREQUENCY_DURATION_MS 50 //0 to disable + //#define LEVEL_CORNERS_FEEDBACK_FREQUENCY_HZ 600 #endif #endif diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index fd1997a44220..81426d58f48e 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -53,6 +53,18 @@ #ifndef LEVEL_CORNERS_PROBE_TOLERANCE #define LEVEL_CORNERS_PROBE_TOLERANCE 0.1 #endif + #ifndef LEVEL_CORNERS_FEEDBACK_FREQUENCY_DURATION_MS + #define LEVEL_CORNERS_FEEDBACK_FREQUENCY_DURATION_MS 0 + #endif + #if LEVEL_CORNERS_FEEDBACK_FREQUENCY_DURATION_MS > 0 + #ifndef LEVEL_CORNERS_FEEDBACK_FREQUENCY_HZ + #define LEVEL_CORNERS_FEEDBACK_FREQUENCY_HZ 600 + #endif + #include "../../libs/buzzer.h" + #define PROBE_BUZZ() (BUZZ(LEVEL_CORNERS_FEEDBACK_FREQUENCY_DURATION_MS, LEVEL_CORNERS_FEEDBACK_FREQUENCY_HZ)) + #else + #define PROBE_BUZZ() NOOP + #endif static float last_z; bool wait_for_probe; bool probe_triggered; @@ -123,6 +135,7 @@ static int8_t bed_corner; wait_for_probe = true; while (wait_for_probe && !probe_triggered) { probe_triggered = PROBE_TRIGGERED(); + if (probe_triggered) PROBE_BUZZ(); idle(); } wait_for_probe = false; From d8179928c6b461b332ef68cb726cb64fa102115d Mon Sep 17 00:00:00 2001 From: wmariz <11435639+wmariz@users.noreply.github.com> Date: Wed, 25 Nov 2020 23:34:08 -0300 Subject: [PATCH 08/13] LEVEL_CORNERS_VERIFY_RAISED option to immediate probe the raised corner --- Marlin/Configuration.h | 1 + Marlin/src/lcd/menu/menu_bed_corners.cpp | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 16ae02933e49..be06908c1786 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1395,6 +1395,7 @@ //#define LEVEL_CORNERS_USE_PROBE #if ENABLED(LEVEL_CORNERS_USE_PROBE) #define LEVEL_CORNERS_PROBE_TOLERANCE 0.1 + #define LEVEL_CORNERS_VERIFY_RAISED // probe raised corner after trigger to verify //#define LEVEL_CORNERS_FEEDBACK_FREQUENCY_DURATION_MS 50 //0 to disable //#define LEVEL_CORNERS_FEEDBACK_FREQUENCY_HZ 600 #endif diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 81426d58f48e..a7edcddceff8 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -69,6 +69,7 @@ bool wait_for_probe; bool probe_triggered; bool corner_probing_done; + bool verify_corner; int good_points; #endif @@ -139,6 +140,11 @@ static int8_t bed_corner; idle(); } wait_for_probe = false; + + #if ENABLED(LEVEL_CORNERS_VERIFY_RAISED) + verify_corner = true; + #endif + } TERN_(QUIET_PROBING, probe.set_probing_paused(false)); @@ -151,13 +157,15 @@ static int8_t bed_corner; endstops.hit_on_purpose(); if (!WITHIN(current_position.z, last_z - (LEVEL_CORNERS_PROBE_TOLERANCE), last_z + (LEVEL_CORNERS_PROBE_TOLERANCE))) { last_z = current_position.z; - good_points = 1; + good_points = 0; } - good_points++; + if (!verify_corners) good_points++; } if (!corner_probing_done) { - if (++bed_corner > 3) bed_corner = 0; + if (!verify_corners) bed_corner++; + if (bed_corner > 3) bed_corner = 0; + verify_corner = false; if (good_points < 4) _lcd_level_bed_corners_probing(); else { @@ -244,6 +252,7 @@ void _lcd_level_bed_corners() { wait_for_probe = false; probe_triggered = false; corner_probing_done = false; + verify_corner = false; good_points = 0; #endif From a4ec5ec7910853b4c1411872c124529d192f88c1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 26 Nov 2020 00:42:53 -0600 Subject: [PATCH 09/13] Add test, fix typo --- Marlin/src/lcd/menu/menu_bed_corners.cpp | 9 +++------ buildroot/tests/LPC1769-tests | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index a7edcddceff8..04073192eb9b 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -141,10 +141,7 @@ static int8_t bed_corner; } wait_for_probe = false; - #if ENABLED(LEVEL_CORNERS_VERIFY_RAISED) - verify_corner = true; - #endif - + TERN_(LEVEL_CORNERS_VERIFY_RAISED, verify_corner = true); } TERN_(QUIET_PROBING, probe.set_probing_paused(false)); @@ -159,11 +156,11 @@ static int8_t bed_corner; last_z = current_position.z; good_points = 0; } - if (!verify_corners) good_points++; + if (!verify_corner) good_points++; } if (!corner_probing_done) { - if (!verify_corners) bed_corner++; + if (!verify_corner) bed_corner++; if (bed_corner > 3) bed_corner = 0; verify_corner = false; if (good_points < 4) diff --git a/buildroot/tests/LPC1769-tests b/buildroot/tests/LPC1769-tests index e4787f82daf6..3e2040c7e6a7 100755 --- a/buildroot/tests/LPC1769-tests +++ b/buildroot/tests/LPC1769-tests @@ -19,6 +19,7 @@ opt_set TEMP_SENSOR_1 -1 opt_set TEMP_SENSOR_BED 5 opt_enable VIKI2 SDSUPPORT ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \ FIX_MOUNTED_PROBE AUTO_BED_LEVELING_BILINEAR G29_RETRY_AND_RECOVER Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ + LEVEL_BED_CORNERS LEVEL_CORNERS_USE_PROBE LEVEL_CORNERS_VERIFY_RAISED \ BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \ PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT \ Z_SAFE_HOMING ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE \ From f96ffb54a7f89d6721e396e16c1c086a7ec82e61 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 26 Nov 2020 06:30:23 -0600 Subject: [PATCH 10/13] Update Configuration.h --- Marlin/Configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index be06908c1786..7b19f363eadf 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1395,7 +1395,7 @@ //#define LEVEL_CORNERS_USE_PROBE #if ENABLED(LEVEL_CORNERS_USE_PROBE) #define LEVEL_CORNERS_PROBE_TOLERANCE 0.1 - #define LEVEL_CORNERS_VERIFY_RAISED // probe raised corner after trigger to verify + #define LEVEL_CORNERS_VERIFY_RAISED // After adjustment triggers the probe, re-probe to verify //#define LEVEL_CORNERS_FEEDBACK_FREQUENCY_DURATION_MS 50 //0 to disable //#define LEVEL_CORNERS_FEEDBACK_FREQUENCY_HZ 600 #endif From 71ec0b1bf48f15e634ee96b99f2a9ddc03d4681d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 26 Nov 2020 06:33:48 -0600 Subject: [PATCH 11/13] Fewer things --- Marlin/Configuration.h | 3 +-- Marlin/src/lcd/menu/menu_bed_corners.cpp | 10 ++-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 7b19f363eadf..3320e18abc3d 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1396,8 +1396,7 @@ #if ENABLED(LEVEL_CORNERS_USE_PROBE) #define LEVEL_CORNERS_PROBE_TOLERANCE 0.1 #define LEVEL_CORNERS_VERIFY_RAISED // After adjustment triggers the probe, re-probe to verify - //#define LEVEL_CORNERS_FEEDBACK_FREQUENCY_DURATION_MS 50 //0 to disable - //#define LEVEL_CORNERS_FEEDBACK_FREQUENCY_HZ 600 + //#define LEVEL_CORNERS_AUDIO_FEEDBACK #endif #endif diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 04073192eb9b..b6668e32c9f7 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -53,15 +53,9 @@ #ifndef LEVEL_CORNERS_PROBE_TOLERANCE #define LEVEL_CORNERS_PROBE_TOLERANCE 0.1 #endif - #ifndef LEVEL_CORNERS_FEEDBACK_FREQUENCY_DURATION_MS - #define LEVEL_CORNERS_FEEDBACK_FREQUENCY_DURATION_MS 0 - #endif - #if LEVEL_CORNERS_FEEDBACK_FREQUENCY_DURATION_MS > 0 - #ifndef LEVEL_CORNERS_FEEDBACK_FREQUENCY_HZ - #define LEVEL_CORNERS_FEEDBACK_FREQUENCY_HZ 600 - #endif + #if ENABLED(LEVEL_CORNERS_AUDIO_FEEDBACK) #include "../../libs/buzzer.h" - #define PROBE_BUZZ() (BUZZ(LEVEL_CORNERS_FEEDBACK_FREQUENCY_DURATION_MS, LEVEL_CORNERS_FEEDBACK_FREQUENCY_HZ)) + #define PROBE_BUZZ() BUZZ(200, 600) #else #define PROBE_BUZZ() NOOP #endif From 801032638792addbb51fee84033e08e40dbe9614 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 26 Nov 2020 06:37:34 -0600 Subject: [PATCH 12/13] static hints --- Marlin/src/lcd/menu/menu_bed_corners.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index b6668e32c9f7..a33455977f73 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -60,11 +60,11 @@ #define PROBE_BUZZ() NOOP #endif static float last_z; - bool wait_for_probe; - bool probe_triggered; - bool corner_probing_done; - bool verify_corner; - int good_points; + static bool wait_for_probe; + static bool probe_triggered; + static bool corner_probing_done; + static bool verify_corner; + static int good_points; #endif static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration."); From 9f87810120a8b629669d870fea55d3ea51df74cc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 26 Nov 2020 06:48:57 -0600 Subject: [PATCH 13/13] localize some statics --- Marlin/src/lcd/menu/menu_bed_corners.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index a33455977f73..52d2d0ec3db6 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -60,8 +60,6 @@ #define PROBE_BUZZ() NOOP #endif static float last_z; - static bool wait_for_probe; - static bool probe_triggered; static bool corner_probing_done; static bool verify_corner; static int good_points; @@ -108,10 +106,15 @@ static int8_t bed_corner; #endif TERN_(QUIET_PROBING, probe.set_probing_paused(true)); - do_blocking_move_to_z(last_z - (LEVEL_CORNERS_PROBE_TOLERANCE), manual_feedrate_mm_s.z);// Move down until the probe is triggered - probe_triggered = TEST(endstops.trigger_state(), TERN(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, Z_MIN, Z_MIN_PROBE));// Check to see if the probe was triggered + // Move down until the probe is triggered + do_blocking_move_to_z(last_z - (LEVEL_CORNERS_PROBE_TOLERANCE), manual_feedrate_mm_s.z); + // Check to see if the probe was triggered + bool probe_triggered = TEST(endstops.trigger_state(), TERN(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, Z_MIN, Z_MIN_PROBE)); if (!probe_triggered) { + + static bool wait_for_probe; + ui.goto_screen([]{ MenuItem_confirm::select_screen( GET_TEXT(MSG_BUTTON_DONE), GET_TEXT(MSG_BUTTON_SKIP) @@ -240,8 +243,6 @@ void _lcd_level_bed_corners() { #if ENABLED(LEVEL_CORNERS_USE_PROBE) last_z = LEVEL_CORNERS_HEIGHT; - wait_for_probe = false; - probe_triggered = false; corner_probing_done = false; verify_corner = false; good_points = 0;