Browse Source

Merge pull request #6831 from thinkyhead/bf_move_g7

Move G7 to G42
Scott Lahteine 7 years ago
parent
commit
d252d1b6a2
1 changed files with 74 additions and 73 deletions
  1. 74
    73
      Marlin/Marlin_main.cpp

+ 74
- 73
Marlin/Marlin_main.cpp View File

@@ -45,30 +45,30 @@
45 45
  *
46 46
  * "G" Codes
47 47
  *
48
- * G0  -> G1
49
- * G1  - Coordinated Movement X Y Z E
50
- * G2  - CW ARC
51
- * G3  - CCW ARC
52
- * G4  - Dwell S<seconds> or P<milliseconds>
53
- * G5  - Cubic B-spline with XYZE destination and IJPQ offsets
54
- * G7  - Coordinated move between UBL mesh points (I & J)
55
- * G10 - Retract filament according to settings of M207
56
- * G11 - Retract recover filament according to settings of M208
57
- * G12 - Clean tool
58
- * G20 - Set input units to inches
59
- * G21 - Set input units to millimeters
60
- * G26 - Mesh Validation Pattern (Requires UBL_G26_MESH_VALIDATION)
61
- * G27 - Park Nozzle (Requires NOZZLE_PARK_FEATURE)
62
- * G28 - Home one or more axes
63
- * G29 - Detailed Z probe, probes the bed at 3 or more points.  Will fail if you haven't homed yet.
64
- * G30 - Single Z probe, probes bed at X Y location (defaults to current XY location)
65
- * G31 - Dock sled (Z_PROBE_SLED only)
66
- * G32 - Undock sled (Z_PROBE_SLED only)
67
- * G33 - Delta Auto-Calibration (Requires DELTA_AUTO_CALIBRATION)
68
- * G38 - Probe target - similar to G28 except it uses the Z_MIN_PROBE for all three axes
69
- * G90 - Use Absolute Coordinates
70
- * G91 - Use Relative Coordinates
71
- * G92 - Set current position to coordinates given
48
+ * G0   -> G1
49
+ * G1   - Coordinated Movement X Y Z E
50
+ * G2   - CW ARC
51
+ * G3   - CCW ARC
52
+ * G4   - Dwell S<seconds> or P<milliseconds>
53
+ * G5   - Cubic B-spline with XYZE destination and IJPQ offsets
54
+ * G10  - Retract filament according to settings of M207
55
+ * G11  - Retract recover filament according to settings of M208
56
+ * G12  - Clean tool
57
+ * G20  - Set input units to inches
58
+ * G21  - Set input units to millimeters
59
+ * G26  - Mesh Validation Pattern (Requires UBL_G26_MESH_VALIDATION)
60
+ * G27  - Park Nozzle (Requires NOZZLE_PARK_FEATURE)
61
+ * G28  - Home one or more axes
62
+ * G29  - Detailed Z probe, probes the bed at 3 or more points.  Will fail if you haven't homed yet.
63
+ * G30  - Single Z probe, probes bed at X Y location (defaults to current XY location)
64
+ * G31  - Dock sled (Z_PROBE_SLED only)
65
+ * G32  - Undock sled (Z_PROBE_SLED only)
66
+ * G33  - Delta Auto-Calibration (Requires DELTA_AUTO_CALIBRATION)
67
+ * G38  - Probe target - similar to G28 except it uses the Z_MIN_PROBE for all three axes
68
+ * G42  - Coordinated move to a mesh point (Requires AUTO_BED_LEVELING_UBL)
69
+ * G90  - Use Absolute Coordinates
70
+ * G91  - Use Relative Coordinates
71
+ * G92  - Set current position to coordinates given
72 72
  *
73 73
  * "M" Codes
74 74
  *
@@ -3396,44 +3396,6 @@ inline void gcode_G4() {
3396 3396
 
3397 3397
 #endif // BEZIER_CURVE_SUPPORT
3398 3398
 
3399
-#if ENABLED(AUTO_BED_LEVELING_UBL) //todo:  enable for other leveling systems?
3400
-/**
3401
- * G7: Move X & Y axes to mesh coordinates
3402
- */
3403
-inline void gcode_G7(
3404
-  #if IS_SCARA
3405
-    bool fast_move=false
3406
-  #endif
3407
-) {
3408
-  if (IsRunning()) {
3409
-    const bool hasI = code_seen('I');
3410
-    const int8_t ix = code_has_value() ? code_value_int() : 0;
3411
-    const bool hasJ = code_seen('J');
3412
-    const int8_t iy = code_has_value() ? code_value_int() : 0;
3413
-
3414
-    if ((hasI && !WITHIN(ix, 0, GRID_MAX_POINTS_X - 1)) || (hasJ && !WITHIN(iy, 0, GRID_MAX_POINTS_Y - 1))) {
3415
-      SERIAL_ECHOLNPGM(MSG_ERR_MESH_XY);
3416
-      return;
3417
-    }
3418
-
3419
-    destination[X_AXIS] = hasI ? ubl.mesh_index_to_xpos(ix) : current_position[X_AXIS];
3420
-    destination[Y_AXIS] = hasJ ? ubl.mesh_index_to_ypos(iy) : current_position[Y_AXIS];
3421
-    destination[Z_AXIS] = current_position[Z_AXIS]; //todo: perhaps add Z-move support?
3422
-    destination[E_AXIS] = current_position[E_AXIS];
3423
-
3424
-    if (code_seen('F') && code_value_linear_units() > 0.0)
3425
-      feedrate_mm_s = MMM_TO_MMS(code_value_linear_units());
3426
-
3427
-    #if IS_SCARA
3428
-      fast_move ? prepare_uninterpolated_move_to_destination() : prepare_move_to_destination();
3429
-    #else
3430
-      prepare_move_to_destination();
3431
-    #endif
3432
-  }
3433
-}
3434
-#endif
3435
-
3436
-
3437 3399
 #if ENABLED(FWRETRACT)
3438 3400
 
3439 3401
   /**
@@ -5500,7 +5462,6 @@ void home_all_axes() { gcode_G28(true); }
5500 5462
 
5501 5463
 #endif // HAS_BED_PROBE
5502 5464
 
5503
-
5504 5465
 #if ENABLED(G38_PROBE_TARGET)
5505 5466
 
5506 5467
   static bool G38_run_probe() {
@@ -5590,6 +5551,45 @@ void home_all_axes() { gcode_G28(true); }
5590 5551
 
5591 5552
 #endif // G38_PROBE_TARGET
5592 5553
 
5554
+#if ENABLED(AUTO_BED_LEVELING_UBL)
5555
+
5556
+  /**
5557
+   * G42: Move X & Y axes to mesh coordinates (I & J)
5558
+   */
5559
+  inline void gcode_G42(
5560
+    #if IS_SCARA
5561
+      bool fast_move=false
5562
+    #endif
5563
+  ) {
5564
+    if (IsRunning()) {
5565
+      const bool hasI = code_seen('I');
5566
+      const int8_t ix = code_has_value() ? code_value_int() : 0;
5567
+      const bool hasJ = code_seen('J');
5568
+      const int8_t iy = code_has_value() ? code_value_int() : 0;
5569
+
5570
+      if ((hasI && !WITHIN(ix, 0, GRID_MAX_POINTS_X - 1)) || (hasJ && !WITHIN(iy, 0, GRID_MAX_POINTS_Y - 1))) {
5571
+        SERIAL_ECHOLNPGM(MSG_ERR_MESH_XY);
5572
+        return;
5573
+      }
5574
+
5575
+      destination[X_AXIS] = hasI ? ubl.mesh_index_to_xpos(ix) : current_position[X_AXIS];
5576
+      destination[Y_AXIS] = hasJ ? ubl.mesh_index_to_ypos(iy) : current_position[Y_AXIS];
5577
+      destination[Z_AXIS] = current_position[Z_AXIS]; //todo: perhaps add Z-move support?
5578
+      destination[E_AXIS] = current_position[E_AXIS];
5579
+
5580
+      if (code_seen('F') && code_value_linear_units() > 0.0)
5581
+        feedrate_mm_s = MMM_TO_MMS(code_value_linear_units());
5582
+
5583
+      #if IS_SCARA
5584
+        fast_move ? prepare_uninterpolated_move_to_destination() : prepare_move_to_destination();
5585
+      #else
5586
+        prepare_move_to_destination();
5587
+      #endif
5588
+    }
5589
+  }
5590
+
5591
+#endif // AUTO_BED_LEVELING_UBL
5592
+
5593 5593
 /**
5594 5594
  * G92: Set current position to given X Y Z E
5595 5595
  */
@@ -10061,16 +10061,6 @@ void process_next_command() {
10061 10061
           break;
10062 10062
       #endif // BEZIER_CURVE_SUPPORT
10063 10063
 
10064
-      #if ENABLED(AUTO_BED_LEVELING_UBL)
10065
-        case 7:
10066
-          #if IS_SCARA
10067
-            gcode_G7(codenum == 0);
10068
-          #else
10069
-            gcode_G7();
10070
-            #endif
10071
-          break;
10072
-      #endif
10073
-
10074 10064
       #if ENABLED(FWRETRACT)
10075 10065
         case 10: // G10: retract
10076 10066
         case 11: // G11: retract_recover
@@ -10162,6 +10152,17 @@ void process_next_command() {
10162 10152
       case 92: // G92
10163 10153
         gcode_G92();
10164 10154
         break;
10155
+
10156
+      #if ENABLED(AUTO_BED_LEVELING_UBL)
10157
+        case 42:
10158
+          #if IS_SCARA
10159
+            gcode_G42(codenum == 0);
10160
+          #else
10161
+            gcode_G42();
10162
+          #endif
10163
+          break;
10164
+      #endif
10165
+
10165 10166
     }
10166 10167
     break;
10167 10168
 

Loading…
Cancel
Save