From 2887c20788079451f951f7b2578ace69c6f8334e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 1 May 2017 15:03:13 -0500 Subject: [PATCH 1/5] Add a function to home all axes (i.e., gcode_G28) --- Marlin/G26_Mesh_Validation_Tool.cpp | 3 +-- Marlin/Marlin_main.cpp | 2 ++ Marlin/ubl.h | 3 ++- Marlin/ubl_G29.cpp | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Marlin/G26_Mesh_Validation_Tool.cpp b/Marlin/G26_Mesh_Validation_Tool.cpp index acac6e0873..43e9bcc45f 100644 --- a/Marlin/G26_Mesh_Validation_Tool.cpp +++ b/Marlin/G26_Mesh_Validation_Tool.cpp @@ -131,8 +131,7 @@ #define PLANNER_XY_FEEDRATE() (min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS])) //bob bool prepare_move_to_destination_cartesian(); void line_to_destination(); - void line_to_destination(float ); - void gcode_G28(); + void line_to_destination(float); void sync_plan_position_e(); void un_retract_filament(float where[XYZE]); void retract_filament(float where[XYZE]); diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index ac39f6a73d..5cfb0a52a5 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3928,6 +3928,8 @@ inline void gcode_G28() { #endif } +void home_all_axes() { gcode_G28(); } + #if HAS_PROBING_PROCEDURE void out_of_range_error(const char* p_edge) { diff --git a/Marlin/ubl.h b/Marlin/ubl.h index 843c9d98a3..70ddf6bba9 100644 --- a/Marlin/ubl.h +++ b/Marlin/ubl.h @@ -61,8 +61,9 @@ bool is_bit_set(uint16_t bits[16], uint8_t x, uint8_t y); char *ftostr43sign(const float&, char); + void home_all_axes(); + void gcode_G26(); - void gcode_G28(); void gcode_G29(); extern int ubl_cnt; diff --git a/Marlin/ubl_G29.cpp b/Marlin/ubl_G29.cpp index 79f625370d..c21a1a2eef 100644 --- a/Marlin/ubl_G29.cpp +++ b/Marlin/ubl_G29.cpp @@ -324,7 +324,7 @@ } if (!code_seen('N') && axis_unhomed_error(true, true, true)) // Don't allow auto-leveling without homing first - gcode_G28(); + home_all_axes(); if (g29_parameter_parsing()) return; // abort if parsing the simple parameters causes a problem, From a64e5659cead57b31a6ad4a23504d90ccab50689 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 1 May 2017 15:17:40 -0500 Subject: [PATCH 2/5] Clean up G26 external references, private vars --- Marlin/G26_Mesh_Validation_Tool.cpp | 36 +++++++++++++++-------------- Marlin/Marlin_main.cpp | 2 -- Marlin/planner.h | 2 ++ 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Marlin/G26_Mesh_Validation_Tool.cpp b/Marlin/G26_Mesh_Validation_Tool.cpp index 43e9bcc45f..91d51a7987 100644 --- a/Marlin/G26_Mesh_Validation_Tool.cpp +++ b/Marlin/G26_Mesh_Validation_Tool.cpp @@ -115,24 +115,29 @@ * Y # Y coordinate Specify the starting location of the drawing activity. */ + // External references + extern float feedrate; extern Planner planner; - //#if ENABLED(ULTRA_LCD) + #if ENABLED(ULTRA_LCD) extern char lcd_status_message[]; - //#endif + #endif extern float destination[XYZE]; - extern void set_destination_to_current(); - extern void set_current_to_destination(); - extern float code_value_float(); - extern bool code_value_bool(); - extern bool code_has_value(); - extern void lcd_init(); - extern void lcd_setstatuspgm(const char* const message, const uint8_t level); - #define PLANNER_XY_FEEDRATE() (min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS])) //bob + void set_destination_to_current(); + void set_current_to_destination(); + float code_value_float(); + bool code_value_bool(); + bool code_has_value(); + void lcd_init(); + void lcd_setstatuspgm(const char* const message, const uint8_t level); bool prepare_move_to_destination_cartesian(); void line_to_destination(); void line_to_destination(float); void sync_plan_position_e(); + void chirp_at_user(); + + // Private functions + void un_retract_filament(float where[XYZE]); void retract_filament(float where[XYZE]); void look_for_lines_to_connect(); @@ -141,17 +146,14 @@ void print_line_from_here_to_there(const float&, const float&, const float&, const float&, const float&, const float&); bool turn_on_heaters(); bool prime_nozzle(); - void chirp_at_user(); static uint16_t circle_flags[16], horizontal_mesh_line_flags[16], vertical_mesh_line_flags[16], continue_with_closest = 0; float g26_e_axis_feedrate = 0.020, random_deviation = 0.0, layer_height = LAYER_HEIGHT; - bool g26_retracted = false; // We keep track of the state of the nozzle to know if it - // is currently retracted or not. This allows us to be - // less careful because mis-matched retractions and un-retractions - // won't leave us in a bad state. + static bool g26_retracted = false; // Track the retracted state of the nozzle so mismatched + // retracts/recovers won't result in a bad state. float valid_trig_angle(float); mesh_index_pair find_closest_circle_to_print(const float&, const float&); @@ -166,9 +168,9 @@ hotend_temp = HOTEND_TEMP, ooze_amount = OOZE_AMOUNT; - int8_t prime_flag = 0; + static int8_t prime_flag = 0; - bool keep_heaters_on = false; + static bool keep_heaters_on = false; /** * G26: Mesh Validation Pattern generation. diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 5cfb0a52a5..626ac6fc4d 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -490,8 +490,6 @@ static uint8_t target_extruder; float zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER; #endif -#define PLANNER_XY_FEEDRATE() (min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS])) - #if HAS_ABL float xy_probe_feedrate_mm_s = MMM_TO_MMS(XY_PROBE_SPEED); #define XY_PROBE_FEEDRATE_MM_S xy_probe_feedrate_mm_s diff --git a/Marlin/planner.h b/Marlin/planner.h index fa80feaf90..6018ecfab1 100644 --- a/Marlin/planner.h +++ b/Marlin/planner.h @@ -469,6 +469,8 @@ class Planner { }; +#define PLANNER_XY_FEEDRATE() (min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS])) + extern Planner planner; #endif // PLANNER_H From ed81e9b3d3a859fae1112d897f4d06cae622baa5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 1 May 2017 16:13:09 -0500 Subject: [PATCH 3/5] Adjust leveling conditionals --- Marlin/Conditionals_post.h | 7 +++---- Marlin/Marlin.h | 2 +- Marlin/Marlin_main.cpp | 24 ++++++++++++------------ Marlin/configuration_store.cpp | 2 +- Marlin/planner.cpp | 6 +++--- Marlin/planner.h | 8 ++++---- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Marlin/Conditionals_post.h b/Marlin/Conditionals_post.h index f30e8e8c3b..09c16f3522 100644 --- a/Marlin/Conditionals_post.h +++ b/Marlin/Conditionals_post.h @@ -718,15 +718,14 @@ #endif /** - * Set ABL options based on the specific type of leveling + * Set granular options based on the specific type of leveling */ #define ABL_PLANAR (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_3POINT)) #define ABL_GRID (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR)) #define HAS_ABL (ABL_PLANAR || ABL_GRID || ENABLED(AUTO_BED_LEVELING_UBL)) - - #define PLANNER_LEVELING (HAS_ABL || ENABLED(MESH_BED_LEVELING)) + #define HAS_LEVELING (HAS_ABL || ENABLED(MESH_BED_LEVELING)) + #define PLANNER_LEVELING (ABL_PLANAR || ABL_GRID || ENABLED(MESH_BED_LEVELING)) #define HAS_PROBING_PROCEDURE (HAS_ABL || ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)) - #if HAS_PROBING_PROCEDURE #define PROBE_BED_WIDTH abs(RIGHT_PROBE_BED_POSITION - (LEFT_PROBE_BED_POSITION)) #define PROBE_BED_HEIGHT abs(BACK_PROBE_BED_POSITION - (FRONT_PROBE_BED_POSITION)) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index bc1d682cde..1754a62773 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -324,7 +324,7 @@ float code_value_temp_diff(); linear_fit* lsf_linear_fit(double x[], double y[], double z[], const int); #endif -#if PLANNER_LEVELING +#if HAS_LEVELING void reset_bed_level(); #endif diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 626ac6fc4d..cfc5ea40bd 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2403,7 +2403,7 @@ static void clean_up_after_endstop_or_probe_move() { #endif // HAS_BED_PROBE -#if PLANNER_LEVELING +#if HAS_LEVELING /** * Turn bed leveling on or off, fixing the current * position as-needed. @@ -2511,7 +2511,7 @@ static void clean_up_after_endstop_or_probe_move() { #endif } -#endif // PLANNER_LEVELING +#endif // HAS_LEVELING #if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(MESH_BED_LEVELING) @@ -3747,7 +3747,7 @@ inline void gcode_G28() { #endif // Disable the leveling matrix before homing - #if PLANNER_LEVELING + #if HAS_LEVELING #if ENABLED(AUTO_BED_LEVELING_UBL) const bool bed_leveling_state_at_entry = ubl.state.active; #endif @@ -4368,7 +4368,7 @@ void home_all_axes() { gcode_G28(); } #endif - #if PLANNER_LEVELING + #if HAS_LEVELING // Jettison bed leveling data if (code_seen('J')) { @@ -5034,7 +5034,7 @@ void home_all_axes() { gcode_G28(); } if (!position_is_reachable(pos, true)) return; // Disable leveling so the planner won't mess with us - #if PLANNER_LEVELING + #if HAS_LEVELING set_bed_leveling_enabled(false); #endif @@ -5091,7 +5091,7 @@ void home_all_axes() { gcode_G28(); } stepper.synchronize(); - #if PLANNER_LEVELING + #if HAS_LEVELING set_bed_leveling_enabled(false); #endif @@ -7294,7 +7294,7 @@ inline void gcode_M115() { #endif // MESH_REPORT (M420 V) - #if PLANNER_LEVELING + #if HAS_LEVELING SERIAL_PROTOCOLLNPGM("Cap:LEVELING_DATA:1"); #else SERIAL_PROTOCOLLNPGM("Cap:LEVELING_DATA:0"); @@ -8336,7 +8336,7 @@ void quickstop_stepper() { SYNC_PLAN_POSITION_KINEMATIC(); } -#if PLANNER_LEVELING +#if HAS_LEVELING /** * M420: Enable/Disable Bed Leveling and/or set the Z fade height. * @@ -9857,12 +9857,12 @@ void process_next_command() { gcode_G28(); break; - #if PLANNER_LEVELING || ENABLED(AUTO_BED_LEVELING_UBL) + #if HAS_LEVELING case 29: // G29 Detailed Z probe, probes the bed at 3 or more points, // or provides access to the UBL System if enabled. gcode_G29(); break; - #endif // PLANNER_LEVELING + #endif // HAS_LEVELING #if HAS_BED_PROBE @@ -10363,7 +10363,7 @@ void process_next_command() { break; #endif // FILAMENT_WIDTH_SENSOR - #if PLANNER_LEVELING + #if HAS_LEVELING case 420: // M420: Enable/Disable Bed Leveling gcode_M420(); break; @@ -10917,7 +10917,7 @@ void get_cartesian_from_steppers() { */ void set_current_from_steppers_for_axis(const AxisEnum axis) { get_cartesian_from_steppers(); - #if PLANNER_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL) + #if PLANNER_LEVELING planner.unapply_leveling(cartes); #endif if (axis == ALL_AXES) diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp index 681c01a9a1..2427d2a043 100644 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -1071,7 +1071,7 @@ void MarlinSettings::reset() { #endif // Applies to all MBL and ABL - #if PLANNER_LEVELING + #if HAS_LEVELING reset_bed_level(); #endif diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 2fb9996d43..07e7833cf2 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -530,7 +530,7 @@ void Planner::check_axes_activity() { #endif } -#if PLANNER_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL) +#if PLANNER_LEVELING /** * lx, ly, lz - logical (cartesian, not delta) positions in mm */ @@ -634,7 +634,7 @@ void Planner::check_axes_activity() { #endif } -#endif // PLANNER_LEVELING && !AUTO_BED_LEVELING_UBL +#endif // PLANNER_LEVELING /** * Planner::_buffer_line @@ -1434,7 +1434,7 @@ void Planner::_set_position_mm(const float &a, const float &b, const float &c, c } void Planner::set_position_mm_kinematic(const float position[NUM_AXIS]) { - #if PLANNER_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL) + #if PLANNER_LEVELING float lpos[XYZ] = { position[X_AXIS], position[Y_AXIS], position[Z_AXIS] }; apply_leveling(lpos); #else diff --git a/Marlin/planner.h b/Marlin/planner.h index 6018ecfab1..ca23979fab 100644 --- a/Marlin/planner.h +++ b/Marlin/planner.h @@ -246,7 +246,7 @@ class Planner { static bool is_full() { return (block_buffer_tail == BLOCK_MOD(block_buffer_head + 1)); } - #if PLANNER_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL) + #if PLANNER_LEVELING #define ARG_X float lx #define ARG_Y float ly @@ -296,7 +296,7 @@ class Planner { * extruder - target extruder */ static FORCE_INLINE void buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, const float &fr_mm_s, const uint8_t extruder) { - #if PLANNER_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL) && IS_CARTESIAN + #if PLANNER_LEVELING && IS_CARTESIAN apply_leveling(lx, ly, lz); #endif _buffer_line(lx, ly, lz, e, fr_mm_s, extruder); @@ -312,7 +312,7 @@ class Planner { * extruder - target extruder */ static FORCE_INLINE void buffer_line_kinematic(const float ltarget[XYZE], const float &fr_mm_s, const uint8_t extruder) { - #if PLANNER_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL) + #if PLANNER_LEVELING float lpos[XYZ] = { ltarget[X_AXIS], ltarget[Y_AXIS], ltarget[Z_AXIS] }; apply_leveling(lpos); #else @@ -336,7 +336,7 @@ class Planner { * Clears previous speed values. */ static FORCE_INLINE void set_position_mm(ARG_X, ARG_Y, ARG_Z, const float &e) { - #if PLANNER_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL) && IS_CARTESIAN + #if PLANNER_LEVELING && IS_CARTESIAN apply_leveling(lx, ly, lz); #endif _set_position_mm(lx, ly, lz, e); From 7d5cd7e0d785822ffc0d63ae68b30f98c25911ce Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 1 May 2017 16:16:16 -0500 Subject: [PATCH 4/5] Tweak set_bed_leveling_enabled --- Marlin/Marlin_main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index cfc5ea40bd..023f1f78f5 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2424,7 +2424,12 @@ static void clean_up_after_endstop_or_probe_move() { if (enable && mbl.has_mesh()) planner.unapply_leveling(current_position); } - #elif HAS_ABL && !ENABLED(AUTO_BED_LEVELING_UBL) + #elif ENABLED(AUTO_BED_LEVELING_UBL) + + ubl.state.active = enable; + //set_current_from_steppers_for_axis(Z_AXIS); + + #elif HAS_ABL #if ENABLED(AUTO_BED_LEVELING_BILINEAR) const bool can_change = (!enable || (bilinear_grid_spacing[0] && bilinear_grid_spacing[1])); @@ -2452,9 +2457,6 @@ static void clean_up_after_endstop_or_probe_move() { else planner.unapply_leveling(current_position); } - #elif ENABLED(AUTO_BED_LEVELING_UBL) - ubl.state.active = enable; - //set_current_from_steppers_for_axis(Z_AXIS); #endif } From e79b335367aa0b460343f2ddf845cc7c51e4d7b9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 1 May 2017 17:34:28 -0500 Subject: [PATCH 5/5] Patches for leveling reactivation in G28 / M48 --- Marlin/Marlin_main.cpp | 76 ++++++++++++++++---------------------- Marlin/mesh_bed_leveling.h | 5 +-- Marlin/ultralcd.cpp | 5 ++- 3 files changed, 36 insertions(+), 50 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 023f1f78f5..5a31605383 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2429,7 +2429,7 @@ static void clean_up_after_endstop_or_probe_move() { ubl.state.active = enable; //set_current_from_steppers_for_axis(Z_AXIS); - #elif HAS_ABL + #else #if ENABLED(AUTO_BED_LEVELING_BILINEAR) const bool can_change = (!enable || (bilinear_grid_spacing[0] && bilinear_grid_spacing[1])); @@ -3750,9 +3750,6 @@ inline void gcode_G28() { // Disable the leveling matrix before homing #if HAS_LEVELING - #if ENABLED(AUTO_BED_LEVELING_UBL) - const bool bed_leveling_state_at_entry = ubl.state.active; - #endif set_bed_leveling_enabled(false); #endif @@ -3895,25 +3892,6 @@ inline void gcode_G28() { do_blocking_move_to_z(delta_clip_start_height); #endif - #if ENABLED(AUTO_BED_LEVELING_UBL) - set_bed_leveling_enabled(bed_leveling_state_at_entry); - #endif - - // Enable mesh leveling again - #if ENABLED(MESH_BED_LEVELING) - if (mbl.reactivate()) { - set_bed_leveling_enabled(true); - if (home_all_axis || (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && homeZ)) { - #if ENABLED(MESH_G28_REST_ORIGIN) - current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS); - set_destination_to_current(); - line_to_destination(homing_feedrate_mm_s[Z_AXIS]); - stepper.synchronize(); - #endif - } - } - #endif - clean_up_after_endstop_or_probe_move(); // Restore the active tool after homing @@ -3982,6 +3960,18 @@ void home_all_axes() { gcode_G28(); } ); } + void mesh_probing_done() { + mbl.set_has_mesh(true); + home_all_axes(); + set_bed_leveling_enabled(true); + #if ENABLED(MESH_G28_REST_ORIGIN) + current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS); + set_destination_to_current(); + line_to_destination(homing_feedrate_mm_s[Z_AXIS]); + stepper.synchronize(); + #endif + } + /** * G29: Mesh-based Z probe, probes a grid and produces a * mesh to compensate for variable bed height @@ -4072,14 +4062,12 @@ void home_all_axes() { gcode_G28(); } line_to_current_position(); stepper.synchronize(); - // After recording the last point, activate the mbl and home - SERIAL_PROTOCOLLNPGM("Mesh probing done."); + // After recording the last point, activate home and activate mbl_probe_index = -1; - mbl.set_has_mesh(true); - mbl.set_reactivate(true); - enqueue_and_echo_commands_P(PSTR("G28")); + SERIAL_PROTOCOLLNPGM("Mesh probing done."); BUZZ(100, 659); BUZZ(100, 698); + mesh_probing_done(); } break; @@ -5015,7 +5003,7 @@ void home_all_axes() { gcode_G28(); } SYNC_PLAN_POSITION_KINEMATIC(); } -#endif // HAS_ABL && DISABLED(AUTO_BED_LEVELING_UBL) +#endif // HAS_ABL && !AUTO_BED_LEVELING_UBL #if HAS_BED_PROBE @@ -6200,10 +6188,6 @@ inline void gcode_M42() { * regenerated. */ inline void gcode_M48() { - #if ENABLED(AUTO_BED_LEVELING_UBL) - bool bed_leveling_state_at_entry=0; - bed_leveling_state_at_entry = ubl.state.active; - #endif if (axis_unhomed_error(true, true, true)) return; @@ -6222,8 +6206,8 @@ inline void gcode_M42() { return; } - float X_current = current_position[X_AXIS], - Y_current = current_position[Y_AXIS]; + float X_current = current_position[X_AXIS], + Y_current = current_position[Y_AXIS]; bool stow_probe_after_each = code_seen('E'); @@ -6269,8 +6253,17 @@ inline void gcode_M42() { SERIAL_PROTOCOLLNPGM("Positioning the probe..."); // Disable bed level correction in M48 because we want the raw data when we probe - #if HAS_ABL - const bool abl_was_enabled = planner.abl_enabled; + + #if HAS_LEVELING + const bool was_enabled = + #if ENABLED(AUTO_BED_LEVELING_UBL) + ubl.state.active + #elif ENABLED(MESH_BED_LEVELING) + mbl.active() + #else + planner.abl_enabled + #endif + ; set_bed_leveling_enabled(false); #endif @@ -6422,14 +6415,9 @@ inline void gcode_M42() { clean_up_after_endstop_or_probe_move(); - // Re-enable bed level correction if it has been on + // Re-enable bed level correction if it had been on #if HAS_ABL - set_bed_leveling_enabled(abl_was_enabled); - #endif - - #if ENABLED(AUTO_BED_LEVELING_UBL) - set_bed_leveling_enabled(bed_leveling_state_at_entry); - ubl.state.active = bed_leveling_state_at_entry; + set_bed_leveling_enabled(was_enabled); #endif report_current_position(); diff --git a/Marlin/mesh_bed_leveling.h b/Marlin/mesh_bed_leveling.h index 71274eeeab..b2d503b4b7 100644 --- a/Marlin/mesh_bed_leveling.h +++ b/Marlin/mesh_bed_leveling.h @@ -36,8 +36,7 @@ enum MBLStatus { MBL_STATUS_NONE = 0, MBL_STATUS_HAS_MESH_BIT = 0, - MBL_STATUS_ACTIVE_BIT = 1, - MBL_STATUS_REACTIVATE_BIT = 2 + MBL_STATUS_ACTIVE_BIT = 1 }; #define MESH_X_DIST ((MESH_MAX_X - (MESH_MIN_X)) / (GRID_MAX_POINTS_X - 1)) @@ -61,8 +60,6 @@ static void set_active(const bool onOff) { onOff ? SBI(status, MBL_STATUS_ACTIVE_BIT) : CBI(status, MBL_STATUS_ACTIVE_BIT); } static bool has_mesh() { return TEST(status, MBL_STATUS_HAS_MESH_BIT); } static void set_has_mesh(const bool onOff) { onOff ? SBI(status, MBL_STATUS_HAS_MESH_BIT) : CBI(status, MBL_STATUS_HAS_MESH_BIT); } - static bool reactivate() { bool b = TEST(status, MBL_STATUS_REACTIVATE_BIT); CBI(status, MBL_STATUS_REACTIVATE_BIT); return b; } - static void set_reactivate(const bool onOff) { onOff ? SBI(status, MBL_STATUS_REACTIVATE_BIT) : CBI(status, MBL_STATUS_REACTIVATE_BIT); } static inline void zigzag(const int8_t index, int8_t &px, int8_t &py) { px = index % (GRID_MAX_POINTS_X); diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 53fe8d815b..1f80151039 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -162,6 +162,7 @@ uint16_t max_display_update_time = 0; #if ENABLED(MESH_BED_LEVELING) && ENABLED(LCD_BED_LEVELING) #include "mesh_bed_leveling.h" + extern void mesh_probing_done(); #endif //////////////////////////////////////////// @@ -1539,9 +1540,9 @@ void kill_screen(const char* lcd_msg) { // Enable leveling, if needed #if ENABLED(MESH_BED_LEVELING) + lcd_synchronize(); mbl.set_has_mesh(true); - mbl.set_reactivate(true); - enqueue_and_echo_commands_P(PSTR("G28")); + mesh_probing_done(); #elif ENABLED(AUTO_BED_LEVELING_UBL)