Browse Source

[2.0.x] Add O (optional) flag to G28/G29 (#10913)

Robert Mendon 7 years ago
parent
commit
86170e6a66
2 changed files with 23 additions and 0 deletions
  1. 11
    0
      Marlin/src/gcode/bedlevel/abl/G29.cpp
  2. 12
    0
      Marlin/src/gcode/calibrate/G28.cpp

+ 11
- 0
Marlin/src/gcode/bedlevel/abl/G29.cpp View File

@@ -68,6 +68,8 @@
68 68
  *
69 69
  * Enhanced G29 Auto Bed Leveling Probe Routine
70 70
  *
71
+ *  O  Auto-level only if needed
72
+ *
71 73
  *  D  Dry-Run mode. Just evaluate the bed Topology - Don't apply
72 74
  *     or alter the bed level data. Useful to check the topology
73 75
  *     after a first run of G29.
@@ -174,6 +176,15 @@ void GcodeSuite::G29() {
174 176
   // Don't allow auto-leveling without homing first
175 177
   if (axis_unhomed_error()) return;
176 178
 
179
+  if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed
180
+    #if ENABLED(DEBUG_LEVELING_FEATURE)
181
+      if (DEBUGGING(LEVELING)) {
182
+        SERIAL_ECHOLNPGM("> Auto-level not needed, skip");
183
+        SERIAL_ECHOLNPGM("<<< G29");
184
+      }
185
+    #endif
186
+    return;
187
+  }
177 188
   // Define local vars 'static' for manual probing, 'auto' otherwise
178 189
   #if ENABLED(PROBE_MANUALLY)
179 190
     #define ABL_VAR static

+ 12
- 0
Marlin/src/gcode/calibrate/G28.cpp View File

@@ -152,6 +152,8 @@
152 152
  *  None  Home to all axes with no parameters.
153 153
  *        With QUICK_HOME enabled XY will home together, then Z.
154 154
  *
155
+ *  O   Home only if position is unknown
156
+ *
155 157
  *  Rn  Raise by n mm/inches before homing
156 158
  *
157 159
  * Cartesian/SCARA parameters
@@ -170,6 +172,16 @@ void GcodeSuite::G28(const bool always_home_all) {
170 172
     }
171 173
   #endif
172 174
 
175
+  if ((axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]) && parser.boolval('O')) { // home only if needed
176
+    #if ENABLED(DEBUG_LEVELING_FEATURE)
177
+      if (DEBUGGING(LEVELING)) {
178
+        SERIAL_ECHOLNPGM("> homing not needed, skip");
179
+        SERIAL_ECHOLNPGM("<<< G28");
180
+      }
181
+    #endif
182
+    return;
183
+  }
184
+  
173 185
   // Wait for planner moves to finish!
174 186
   planner.synchronize();
175 187
 

Loading…
Cancel
Save