Browse Source

Disable ABL when leveling corners (#13471)

Thomas Moore 6 years ago
parent
commit
02dc72acb6
1 changed files with 28 additions and 5 deletions
  1. 28
    5
      Marlin/src/lcd/menu/menu_bed_corners.cpp

+ 28
- 5
Marlin/src/lcd/menu/menu_bed_corners.cpp View File

32
 #include "../../module/motion.h"
32
 #include "../../module/motion.h"
33
 #include "../../module/planner.h"
33
 #include "../../module/planner.h"
34
 
34
 
35
+#if HAS_LEVELING
36
+  #include "../../feature/bedlevel/bedlevel.h"
37
+#endif
38
+
35
 #ifndef LEVEL_CORNERS_Z_HOP
39
 #ifndef LEVEL_CORNERS_Z_HOP
36
   #define LEVEL_CORNERS_Z_HOP 4.0
40
   #define LEVEL_CORNERS_Z_HOP 4.0
37
 #endif
41
 #endif
42
 
46
 
43
 static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration.");
47
 static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration.");
44
 
48
 
49
+#if HAS_LEVELING
50
+  static bool leveling_was_active = false;
51
+#endif
52
+
53
+static inline void _lcd_level_bed_corners_back() {
54
+  #if HAS_LEVELING
55
+    set_bed_leveling_enabled(leveling_was_active);
56
+  #endif
57
+  ui.goto_previous_screen_no_defer();
58
+}
59
+
45
 /**
60
 /**
46
  * Level corners, starting in the front-left corner.
61
  * Level corners, starting in the front-left corner.
47
  */
62
  */
48
 static int8_t bed_corner;
63
 static int8_t bed_corner;
49
-void _lcd_goto_next_corner() {
64
+static inline void _lcd_goto_next_corner() {
50
   line_to_z(LEVEL_CORNERS_Z_HOP);
65
   line_to_z(LEVEL_CORNERS_Z_HOP);
51
   switch (bed_corner) {
66
   switch (bed_corner) {
52
     case 0:
67
     case 0:
78
   ) bed_corner = 0;
93
   ) bed_corner = 0;
79
 }
94
 }
80
 
95
 
81
-void menu_level_bed_corners() {
96
+static inline void menu_level_bed_corners() {
82
   START_MENU();
97
   START_MENU();
83
   MENU_ITEM(function,
98
   MENU_ITEM(function,
84
     #if ENABLED(LEVEL_CENTER_TOO)
99
     #if ENABLED(LEVEL_CENTER_TOO)
86
     #else
101
     #else
87
       MSG_NEXT_CORNER
102
       MSG_NEXT_CORNER
88
     #endif
103
     #endif
89
-    , _lcd_goto_next_corner);
90
-  MENU_ITEM(function, MSG_BACK, ui.goto_previous_screen_no_defer);
104
+    , _lcd_goto_next_corner
105
+  );
106
+  MENU_ITEM(function, MSG_BACK, _lcd_level_bed_corners_back);
91
   END_MENU();
107
   END_MENU();
92
 }
108
 }
93
 
109
 
94
-void _lcd_level_bed_corners_homing() {
110
+static inline void _lcd_level_bed_corners_homing() {
95
   _lcd_draw_homing();
111
   _lcd_draw_homing();
96
   if (all_axes_homed()) {
112
   if (all_axes_homed()) {
97
     bed_corner = 0;
113
     bed_corner = 0;
106
     set_all_unhomed();
122
     set_all_unhomed();
107
     enqueue_and_echo_commands_P(PSTR("G28"));
123
     enqueue_and_echo_commands_P(PSTR("G28"));
108
   }
124
   }
125
+
126
+  // Disable leveling so the planner won't mess with us
127
+  #if HAS_LEVELING
128
+    leveling_was_active = planner.leveling_active;
129
+    set_bed_leveling_enabled(false);
130
+  #endif
131
+
109
   ui.goto_screen(_lcd_level_bed_corners_homing);
132
   ui.goto_screen(_lcd_level_bed_corners_homing);
110
 }
133
 }
111
 
134
 

Loading…
Cancel
Save