Pārlūkot izejas kodu

Merge pull request #6777 from bgort/g7

Add `G7` gcode command to move between UBL mesh points
bgort 7 gadus atpakaļ
vecāks
revīzija
47245675fc
1 mainītis faili ar 49 papildinājumiem un 0 dzēšanām
  1. 49
    0
      Marlin/Marlin_main.cpp

+ 49
- 0
Marlin/Marlin_main.cpp Parādīt failu

@@ -51,6 +51,7 @@
51 51
  * G3  - CCW ARC
52 52
  * G4  - Dwell S<seconds> or P<milliseconds>
53 53
  * G5  - Cubic B-spline with XYZE destination and IJPQ offsets
54
+ * G7  - Coordinated move between UBL mesh points (I & J)
54 55
  * G10 - Retract filament according to settings of M207
55 56
  * G11 - Retract recover filament according to settings of M208
56 57
  * G12 - Clean tool
@@ -3395,6 +3396,44 @@ inline void gcode_G4() {
3395 3396
 
3396 3397
 #endif // BEZIER_CURVE_SUPPORT
3397 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 ? pgm_read_float(&ubl.mesh_index_to_xpos[ix]) : current_position[X_AXIS];
3420
+    destination[Y_AXIS] = hasJ ? pgm_read_float(&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
+
3398 3437
 #if ENABLED(FWRETRACT)
3399 3438
 
3400 3439
   /**
@@ -9982,6 +10021,16 @@ void process_next_command() {
9982 10021
           break;
9983 10022
       #endif // BEZIER_CURVE_SUPPORT
9984 10023
 
10024
+      #if ENABLED(AUTO_BED_LEVELING_UBL)
10025
+        case 7:
10026
+          #if IS_SCARA
10027
+            gcode_G7(codenum == 0);
10028
+          #else
10029
+            gcode_G7();
10030
+            #endif
10031
+          break;
10032
+      #endif
10033
+
9985 10034
       #if ENABLED(FWRETRACT)
9986 10035
         case 10: // G10: retract
9987 10036
         case 11: // G11: retract_recover

Notiek ielāde…
Atcelt
Saglabāt