瀏覽代碼

M421: Add 'adjust closest point' capability

- Split M421 into separate versions for bilinear and ubl
- Fix minor issue in G26
Brian 8 年之前
父節點
當前提交
ae676490c9
共有 4 個檔案被更改,包括 61 行新增21 行删除
  1. 3
    1
      Marlin/G26_Mesh_Validation_Tool.cpp
  2. 55
    17
      Marlin/Marlin_main.cpp
  3. 3
    0
      Marlin/ubl.h
  4. 0
    3
      Marlin/ubl_G29.cpp

+ 3
- 1
Marlin/G26_Mesh_Validation_Tool.cpp 查看文件

740
     }
740
     }
741
 
741
 
742
     if (code_seen('R')) {
742
     if (code_seen('R')) {
743
-      g26_repeats = code_has_value() ? code_value_int() - 1 : 999;
743
+      g26_repeats = code_has_value() ? code_value_int() : 999;
744
 
744
 
745
       if (g26_repeats <= 0) {
745
       if (g26_repeats <= 0) {
746
         SERIAL_PROTOCOLLNPGM("?(R)epeat value not plausible; must be greater than 0.");
746
         SERIAL_PROTOCOLLNPGM("?(R)epeat value not plausible; must be greater than 0.");
747
         return UBL_ERR;
747
         return UBL_ERR;
748
       }
748
       }
749
+
750
+      g26_repeats--;
749
     }
751
     }
750
 
752
 
751
 
753
 

+ 55
- 17
Marlin/Marlin_main.cpp 查看文件

8477
     }
8477
     }
8478
   }
8478
   }
8479
 
8479
 
8480
-#elif ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(AUTO_BED_LEVELING_UBL)
8480
+#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
8481
 
8481
 
8482
   /**
8482
   /**
8483
    * M421: Set a single Mesh Bed Leveling Z coordinate
8483
    * M421: Set a single Mesh Bed Leveling Z coordinate
8490
     int8_t px = 0, py = 0;
8490
     int8_t px = 0, py = 0;
8491
     float z = 0;
8491
     float z = 0;
8492
     bool hasI, hasJ, hasZ, hasQ;
8492
     bool hasI, hasJ, hasZ, hasQ;
8493
-    if ((hasI = code_seen('I'))) px = code_value_linear_units();
8494
-    if ((hasJ = code_seen('J'))) py = code_value_linear_units();
8493
+    if ((hasI = code_seen('I'))) px = code_value_int();
8494
+    if ((hasJ = code_seen('J'))) py = code_value_int();
8495
     if ((hasZ = code_seen('Z'))) z = code_value_linear_units();
8495
     if ((hasZ = code_seen('Z'))) z = code_value_linear_units();
8496
     if ((hasQ = code_seen('Q'))) z = code_value_linear_units();
8496
     if ((hasQ = code_seen('Q'))) z = code_value_linear_units();
8497
 
8497
 
8503
 
8503
 
8504
     if (WITHIN(px, 0, GRID_MAX_POINTS_X - 1) && WITHIN(py, 0, GRID_MAX_POINTS_Y - 1)) {
8504
     if (WITHIN(px, 0, GRID_MAX_POINTS_X - 1) && WITHIN(py, 0, GRID_MAX_POINTS_Y - 1)) {
8505
       if (hasZ) { // doing an absolute mesh value
8505
       if (hasZ) { // doing an absolute mesh value
8506
-        #if ENABLED(AUTO_BED_LEVELING_UBL)
8507
-          ubl.z_values[px][py] = z;
8508
-        #else
8509
-          z_values[px][py] = z;
8510
-          #if ENABLED(ABL_BILINEAR_SUBDIVISION)
8511
-            bed_level_virt_interpolate();
8512
-          #endif
8506
+        z_values[px][py] = z;
8507
+        #if ENABLED(ABL_BILINEAR_SUBDIVISION)
8508
+          bed_level_virt_interpolate();
8513
         #endif
8509
         #endif
8514
       } 
8510
       } 
8515
       else { // doing an offset of a mesh value
8511
       else { // doing an offset of a mesh value
8516
-        #if ENABLED(AUTO_BED_LEVELING_UBL)
8517
-          ubl.z_values[px][py] += z;
8518
-        #else
8519
-          z_values[px][py] += z;
8520
-          #if ENABLED(ABL_BILINEAR_SUBDIVISION)
8521
-            bed_level_virt_interpolate();
8522
-          #endif
8512
+        z_values[px][py] += z;
8513
+        #if ENABLED(ABL_BILINEAR_SUBDIVISION)
8514
+          bed_level_virt_interpolate();
8523
         #endif
8515
         #endif
8524
       }
8516
       }
8525
     }
8517
     }
8528
       SERIAL_ERRORLNPGM(MSG_ERR_MESH_XY);
8520
       SERIAL_ERRORLNPGM(MSG_ERR_MESH_XY);
8529
     }
8521
     }
8530
   }
8522
   }
8523
+
8524
+#elif ENABLED(AUTO_BED_LEVELING_UBL)
8525
+
8526
+  /**
8527
+   * M421: Set a single Mesh Bed Leveling Z coordinate
8528
+   *
8529
+   *   M421 I<xindex> J<yindex> Z<linear>
8530
+   *   or
8531
+   *   M421 I<xindex> J<yindex> Q<offset>
8532
+   */
8533
+
8534
+  //todo:  change multiple points simultaneously?
8535
+
8536
+  inline void gcode_M421() {
8537
+    int8_t px = 0, py = 0;
8538
+    float z = 0;
8539
+    bool hasI, hasJ, hasZ, hasQ, hasC;
8540
+    if ((hasI = code_seen('I'))) px = code_value_int();
8541
+    if ((hasJ = code_seen('J'))) py = code_value_int();
8542
+    if ((hasZ = code_seen('Z'))) z = code_value_linear_units();
8543
+    if ((hasQ = code_seen('Q'))) z = code_value_linear_units();
8544
+    hasC = code_seen('C');
8545
+
8546
+    if ( (!(hasI && hasJ) && !hasC) || (hasQ && hasZ) || (!hasQ && !hasZ)) {
8547
+      SERIAL_ERROR_START;
8548
+      SERIAL_ERRORLNPGM(MSG_ERR_M421_PARAMETERS);
8549
+      return;
8550
+    }
8551
+
8552
+    if (hasC) { // get closest position
8553
+      const mesh_index_pair location = find_closest_mesh_point_of_type(REAL, current_position[X_AXIS], current_position[Y_AXIS], USE_NOZZLE_AS_REFERENCE, NULL, false);
8554
+      px = location.x_index;
8555
+      py = location.y_index;
8556
+    }
8557
+
8558
+    if (WITHIN(px, 0, GRID_MAX_POINTS_X - 1) && WITHIN(py, 0, GRID_MAX_POINTS_Y - 1)) {
8559
+      if (hasZ) // doing an absolute mesh value
8560
+        ubl.z_values[px][py] = z;
8561
+      else // doing an offset of a mesh value
8562
+        ubl.z_values[px][py] += z;
8563
+    }
8564
+    else { // bad indexes were specified for the mesh point
8565
+      SERIAL_ERROR_START;
8566
+      SERIAL_ERRORLNPGM(MSG_ERR_MESH_XY);
8567
+    }
8568
+  }
8531
 #endif
8569
 #endif
8532
 
8570
 
8533
 #if HAS_M206_COMMAND
8571
 #if HAS_M206_COMMAND

+ 3
- 0
Marlin/ubl.h 查看文件

35
   #define UBL_OK false
35
   #define UBL_OK false
36
   #define UBL_ERR true
36
   #define UBL_ERR true
37
 
37
 
38
+  #define USE_NOZZLE_AS_REFERENCE 0
39
+  #define USE_PROBE_AS_REFERENCE 1
40
+
38
   typedef struct {
41
   typedef struct {
39
     int8_t x_index, y_index;
42
     int8_t x_index, y_index;
40
     float distance; // When populated, the distance from the search location
43
     float distance; // When populated, the distance from the search location

+ 0
- 3
Marlin/ubl_G29.cpp 查看文件

311
    *   we now have the functionality and features of all three systems combined.
311
    *   we now have the functionality and features of all three systems combined.
312
    */
312
    */
313
 
313
 
314
-  #define USE_NOZZLE_AS_REFERENCE 0
315
-  #define USE_PROBE_AS_REFERENCE 1
316
-
317
   // The simple parameter flags and values are 'static' so parameter parsing can be in a support routine.
314
   // The simple parameter flags and values are 'static' so parameter parsing can be in a support routine.
318
   static int g29_verbose_level, phase_value, repetition_cnt,
315
   static int g29_verbose_level, phase_value, repetition_cnt,
319
              storage_slot = 0, map_type, grid_size;
316
              storage_slot = 0, map_type, grid_size;

Loading…
取消
儲存