Browse Source

Add `G7` gcode command to move between UBL mesh points

- can be augmented in the future to enable for other leveling systems

Quite simple, but did not want to modify `G1` as the additional checking would slow it down.

Tested & working.
Brian 7 years ago
parent
commit
13599a73c7
1 changed files with 38 additions and 0 deletions
  1. 38
    0
      Marlin/Marlin_main.cpp

+ 38
- 0
Marlin/Marlin_main.cpp View File

@@ -3395,6 +3395,34 @@ inline void gcode_G4() {
3395 3395
 
3396 3396
 #endif // BEZIER_CURVE_SUPPORT
3397 3397
 
3398
+#if ENABLED(AUTO_BED_LEVELING_UBL) //todo:  enable for other leveling systems?
3399
+/**
3400
+ * G7: Move X & Y axes to mesh coordinates
3401
+ */
3402
+inline void gcode_G7(
3403
+  #if IS_SCARA
3404
+    bool fast_move=false
3405
+  #endif
3406
+) {
3407
+  if (IsRunning()) {
3408
+    destination[X_AXIS] = code_seen('I') ? pgm_read_float(&ubl.mesh_index_to_xpos[code_has_value() ? code_value_int() : 0]) : current_position[X_AXIS];
3409
+    destination[Y_AXIS] = code_seen('J') ? pgm_read_float(&ubl.mesh_index_to_ypos[code_has_value() ? code_value_int() : 0]) : current_position[Y_AXIS];
3410
+    destination[Z_AXIS] = current_position[Z_AXIS]; //todo: perhaps add Z-move support?
3411
+    destination[E_AXIS] = current_position[E_AXIS];
3412
+
3413
+    if (code_seen('F') && code_value_linear_units() > 0.0)
3414
+      feedrate_mm_s = MMM_TO_MMS(code_value_linear_units());
3415
+
3416
+    #if IS_SCARA
3417
+      fast_move ? prepare_uninterpolated_move_to_destination() : prepare_move_to_destination();
3418
+    #else
3419
+      prepare_move_to_destination();
3420
+    #endif
3421
+  }
3422
+}
3423
+#endif
3424
+
3425
+
3398 3426
 #if ENABLED(FWRETRACT)
3399 3427
 
3400 3428
   /**
@@ -9982,6 +10010,16 @@ void process_next_command() {
9982 10010
           break;
9983 10011
       #endif // BEZIER_CURVE_SUPPORT
9984 10012
 
10013
+      #if ENABLED(AUTO_BED_LEVELING_UBL)
10014
+        case 7:
10015
+          #if IS_SCARA
10016
+            gcode_G7(codenum == 0);
10017
+          #else
10018
+            gcode_G7();
10019
+            #endif
10020
+          break;
10021
+      #endif
10022
+
9985 10023
       #if ENABLED(FWRETRACT)
9986 10024
         case 10: // G10: retract
9987 10025
         case 11: // G11: retract_recover

Loading…
Cancel
Save