Przeglądaj źródła

Merge pull request #8234 from thinkyhead/bf2_native_operation

[2.0.x] Operate in Native Machine Space
Scott Lahteine 7 lat temu
rodzic
commit
4df024d7b9
No account linked to committer's email address
36 zmienionych plików z 449 dodań i 489 usunięć
  1. 3
    3
      Marlin/src/core/utility.cpp
  2. 15
    15
      Marlin/src/feature/bedlevel/abl/abl.cpp
  3. 1
    1
      Marlin/src/feature/bedlevel/abl/abl.h
  4. 4
    4
      Marlin/src/feature/bedlevel/bedlevel.cpp
  5. 6
    6
      Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp
  6. 18
    18
      Marlin/src/feature/bedlevel/ubl/G26_Mesh_Validation_Tool.cpp
  7. 21
    21
      Marlin/src/feature/bedlevel/ubl/ubl.h
  8. 44
    47
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  9. 62
    71
      Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp
  10. 2
    2
      Marlin/src/gcode/bedlevel/G42.cpp
  11. 32
    32
      Marlin/src/gcode/bedlevel/abl/G29.cpp
  12. 2
    2
      Marlin/src/gcode/bedlevel/mbl/G29.cpp
  13. 5
    5
      Marlin/src/gcode/calibrate/G28.cpp
  14. 1
    1
      Marlin/src/gcode/calibrate/G33.cpp
  15. 4
    4
      Marlin/src/gcode/calibrate/M48.cpp
  16. 1
    1
      Marlin/src/gcode/gcode.cpp
  17. 1
    1
      Marlin/src/gcode/geometry/M206_M428.cpp
  18. 7
    3
      Marlin/src/gcode/host/M114.cpp
  19. 7
    7
      Marlin/src/gcode/motion/G2_G3.cpp
  20. 1
    1
      Marlin/src/gcode/probe/G30.cpp
  21. 2
    2
      Marlin/src/gcode/scara/M360-M364.cpp
  22. 17
    20
      Marlin/src/lcd/ultralcd.cpp
  23. 1
    1
      Marlin/src/lcd/ultralcd.h
  24. 3
    3
      Marlin/src/lcd/ultralcd_impl_DOGM.h
  25. 9
    7
      Marlin/src/lcd/ultralcd_impl_HD44780.h
  26. 5
    9
      Marlin/src/module/delta.cpp
  27. 2
    11
      Marlin/src/module/delta.h
  28. 68
    72
      Marlin/src/module/motion.cpp
  29. 14
    23
      Marlin/src/module/motion.h
  30. 34
    38
      Marlin/src/module/planner.cpp
  31. 32
    33
      Marlin/src/module/planner.h
  32. 11
    11
      Marlin/src/module/probe.cpp
  33. 1
    1
      Marlin/src/module/probe.h
  34. 8
    8
      Marlin/src/module/scara.cpp
  35. 1
    1
      Marlin/src/module/scara.h
  36. 4
    4
      Marlin/src/module/tool_change.cpp

+ 3
- 3
Marlin/src/core/utility.cpp Wyświetl plik

365
 
365
 
366
       SERIAL_ECHOPGM("Mesh Bed Leveling");
366
       SERIAL_ECHOPGM("Mesh Bed Leveling");
367
       if (planner.leveling_active) {
367
       if (planner.leveling_active) {
368
-        float lz = current_position[Z_AXIS];
369
-        planner.apply_leveling(current_position[X_AXIS], current_position[Y_AXIS], lz);
368
+        float rz = current_position[Z_AXIS];
369
+        planner.apply_leveling(current_position[X_AXIS], current_position[Y_AXIS], rz);
370
         SERIAL_ECHOLNPGM(" (enabled)");
370
         SERIAL_ECHOLNPGM(" (enabled)");
371
-        SERIAL_ECHOPAIR("MBL Adjustment Z", lz);
371
+        SERIAL_ECHOPAIR("MBL Adjustment Z", rz);
372
       }
372
       }
373
       else
373
       else
374
         SERIAL_ECHOPGM(" (disabled)");
374
         SERIAL_ECHOPGM(" (disabled)");

+ 15
- 15
Marlin/src/feature/bedlevel/abl/abl.cpp Wyświetl plik

259
 #endif
259
 #endif
260
 
260
 
261
 // Get the Z adjustment for non-linear bed leveling
261
 // Get the Z adjustment for non-linear bed leveling
262
-float bilinear_z_offset(const float logical[XYZ]) {
262
+float bilinear_z_offset(const float raw[XYZ]) {
263
 
263
 
264
   static float z1, d2, z3, d4, L, D, ratio_x, ratio_y,
264
   static float z1, d2, z3, d4, L, D, ratio_x, ratio_y,
265
                last_x = -999.999, last_y = -999.999;
265
                last_x = -999.999, last_y = -999.999;
269
                 last_gridx = -99, last_gridy = -99;
269
                 last_gridx = -99, last_gridy = -99;
270
 
270
 
271
   // XY relative to the probed area
271
   // XY relative to the probed area
272
-  const float x = RAW_X_POSITION(logical[X_AXIS]) - bilinear_start[X_AXIS],
273
-              y = RAW_Y_POSITION(logical[Y_AXIS]) - bilinear_start[Y_AXIS];
272
+  const float rx = raw[X_AXIS] - bilinear_start[X_AXIS],
273
+              ry = raw[Y_AXIS] - bilinear_start[Y_AXIS];
274
 
274
 
275
   #if ENABLED(EXTRAPOLATE_BEYOND_GRID)
275
   #if ENABLED(EXTRAPOLATE_BEYOND_GRID)
276
     // Keep using the last grid box
276
     // Keep using the last grid box
280
     #define FAR_EDGE_OR_BOX 1
280
     #define FAR_EDGE_OR_BOX 1
281
   #endif
281
   #endif
282
 
282
 
283
-  if (last_x != x) {
284
-    last_x = x;
285
-    ratio_x = x * ABL_BG_FACTOR(X_AXIS);
283
+  if (last_x != rx) {
284
+    last_x = rx;
285
+    ratio_x = rx * ABL_BG_FACTOR(X_AXIS);
286
     const float gx = constrain(FLOOR(ratio_x), 0, ABL_BG_POINTS_X - FAR_EDGE_OR_BOX);
286
     const float gx = constrain(FLOOR(ratio_x), 0, ABL_BG_POINTS_X - FAR_EDGE_OR_BOX);
287
     ratio_x -= gx;      // Subtract whole to get the ratio within the grid box
287
     ratio_x -= gx;      // Subtract whole to get the ratio within the grid box
288
 
288
 
295
     nextx = min(gridx + 1, ABL_BG_POINTS_X - 1);
295
     nextx = min(gridx + 1, ABL_BG_POINTS_X - 1);
296
   }
296
   }
297
 
297
 
298
-  if (last_y != y || last_gridx != gridx) {
298
+  if (last_y != ry || last_gridx != gridx) {
299
 
299
 
300
-    if (last_y != y) {
301
-      last_y = y;
302
-      ratio_y = y * ABL_BG_FACTOR(Y_AXIS);
300
+    if (last_y != ry) {
301
+      last_y = ry;
302
+      ratio_y = ry * ABL_BG_FACTOR(Y_AXIS);
303
       const float gy = constrain(FLOOR(ratio_y), 0, ABL_BG_POINTS_Y - FAR_EDGE_OR_BOX);
303
       const float gy = constrain(FLOOR(ratio_y), 0, ABL_BG_POINTS_Y - FAR_EDGE_OR_BOX);
304
       ratio_y -= gy;
304
       ratio_y -= gy;
305
 
305
 
322
       d4 = ABL_BG_GRID(nextx, nexty) - z3;  // right-back (delta)
322
       d4 = ABL_BG_GRID(nextx, nexty) - z3;  // right-back (delta)
323
     }
323
     }
324
 
324
 
325
-    // Bilinear interpolate. Needed since y or gridx has changed.
325
+    // Bilinear interpolate. Needed since ry or gridx has changed.
326
                 L = z1 + d2 * ratio_y;   // Linear interp. LF -> LB
326
                 L = z1 + d2 * ratio_y;   // Linear interp. LF -> LB
327
     const float R = z3 + d4 * ratio_y;   // Linear interp. RF -> RB
327
     const float R = z3 + d4 * ratio_y;   // Linear interp. RF -> RB
328
 
328
 
335
   static float last_offset = 0;
335
   static float last_offset = 0;
336
   if (FABS(last_offset - offset) > 0.2) {
336
   if (FABS(last_offset - offset) > 0.2) {
337
     SERIAL_ECHOPGM("Sudden Shift at ");
337
     SERIAL_ECHOPGM("Sudden Shift at ");
338
-    SERIAL_ECHOPAIR("x=", x);
338
+    SERIAL_ECHOPAIR("x=", rx);
339
     SERIAL_ECHOPAIR(" / ", bilinear_grid_spacing[X_AXIS]);
339
     SERIAL_ECHOPAIR(" / ", bilinear_grid_spacing[X_AXIS]);
340
     SERIAL_ECHOLNPAIR(" -> gridx=", gridx);
340
     SERIAL_ECHOLNPAIR(" -> gridx=", gridx);
341
-    SERIAL_ECHOPAIR(" y=", y);
341
+    SERIAL_ECHOPAIR(" y=", ry);
342
     SERIAL_ECHOPAIR(" / ", bilinear_grid_spacing[Y_AXIS]);
342
     SERIAL_ECHOPAIR(" / ", bilinear_grid_spacing[Y_AXIS]);
343
     SERIAL_ECHOLNPAIR(" -> gridy=", gridy);
343
     SERIAL_ECHOLNPAIR(" -> gridy=", gridy);
344
     SERIAL_ECHOPAIR(" ratio_x=", ratio_x);
344
     SERIAL_ECHOPAIR(" ratio_x=", ratio_x);
390
     const int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
390
     const int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
391
     if (cx2 != cx1 && TEST(x_splits, gcx)) {
391
     if (cx2 != cx1 && TEST(x_splits, gcx)) {
392
       COPY(end, destination);
392
       COPY(end, destination);
393
-      destination[X_AXIS] = LOGICAL_X_POSITION(bilinear_start[X_AXIS] + ABL_BG_SPACING(X_AXIS) * gcx);
393
+      destination[X_AXIS] = bilinear_start[X_AXIS] + ABL_BG_SPACING(X_AXIS) * gcx;
394
       normalized_dist = (destination[X_AXIS] - current_position[X_AXIS]) / (end[X_AXIS] - current_position[X_AXIS]);
394
       normalized_dist = (destination[X_AXIS] - current_position[X_AXIS]) / (end[X_AXIS] - current_position[X_AXIS]);
395
       destination[Y_AXIS] = LINE_SEGMENT_END(Y);
395
       destination[Y_AXIS] = LINE_SEGMENT_END(Y);
396
       CBI(x_splits, gcx);
396
       CBI(x_splits, gcx);
397
     }
397
     }
398
     else if (cy2 != cy1 && TEST(y_splits, gcy)) {
398
     else if (cy2 != cy1 && TEST(y_splits, gcy)) {
399
       COPY(end, destination);
399
       COPY(end, destination);
400
-      destination[Y_AXIS] = LOGICAL_Y_POSITION(bilinear_start[Y_AXIS] + ABL_BG_SPACING(Y_AXIS) * gcy);
400
+      destination[Y_AXIS] = bilinear_start[Y_AXIS] + ABL_BG_SPACING(Y_AXIS) * gcy;
401
       normalized_dist = (destination[Y_AXIS] - current_position[Y_AXIS]) / (end[Y_AXIS] - current_position[Y_AXIS]);
401
       normalized_dist = (destination[Y_AXIS] - current_position[Y_AXIS]) / (end[Y_AXIS] - current_position[Y_AXIS]);
402
       destination[X_AXIS] = LINE_SEGMENT_END(X);
402
       destination[X_AXIS] = LINE_SEGMENT_END(X);
403
       CBI(y_splits, gcy);
403
       CBI(y_splits, gcy);

+ 1
- 1
Marlin/src/feature/bedlevel/abl/abl.h Wyświetl plik

32
   extern int bilinear_grid_spacing[2], bilinear_start[2];
32
   extern int bilinear_grid_spacing[2], bilinear_start[2];
33
   extern float bilinear_grid_factor[2],
33
   extern float bilinear_grid_factor[2],
34
                z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
34
                z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
35
-  float bilinear_z_offset(const float logical[XYZ]);
35
+  float bilinear_z_offset(const float raw[XYZ]);
36
 
36
 
37
   void extrapolate_unprobed_bed_level();
37
   void extrapolate_unprobed_bed_level();
38
   void print_bilinear_leveling_grid();
38
   void print_bilinear_leveling_grid();

+ 4
- 4
Marlin/src/feature/bedlevel/bedlevel.cpp Wyświetl plik

256
 
256
 
257
 #if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
257
 #if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
258
 
258
 
259
-  void _manual_goto_xy(const float &x, const float &y) {
259
+  void _manual_goto_xy(const float &rx, const float &ry) {
260
     const float old_feedrate_mm_s = feedrate_mm_s;
260
     const float old_feedrate_mm_s = feedrate_mm_s;
261
     #if MANUAL_PROBE_HEIGHT > 0
261
     #if MANUAL_PROBE_HEIGHT > 0
262
       const float prev_z = current_position[Z_AXIS];
262
       const float prev_z = current_position[Z_AXIS];
263
       feedrate_mm_s = homing_feedrate(Z_AXIS);
263
       feedrate_mm_s = homing_feedrate(Z_AXIS);
264
-      current_position[Z_AXIS] = LOGICAL_Z_POSITION(MANUAL_PROBE_HEIGHT);
264
+      current_position[Z_AXIS] = MANUAL_PROBE_HEIGHT;
265
       line_to_current_position();
265
       line_to_current_position();
266
     #endif
266
     #endif
267
 
267
 
268
     feedrate_mm_s = MMM_TO_MMS(XY_PROBE_SPEED);
268
     feedrate_mm_s = MMM_TO_MMS(XY_PROBE_SPEED);
269
-    current_position[X_AXIS] = LOGICAL_X_POSITION(x);
270
-    current_position[Y_AXIS] = LOGICAL_Y_POSITION(y);
269
+    current_position[X_AXIS] = rx;
270
+    current_position[Y_AXIS] = ry;
271
     line_to_current_position();
271
     line_to_current_position();
272
 
272
 
273
     #if MANUAL_PROBE_HEIGHT > 0
273
     #if MANUAL_PROBE_HEIGHT > 0

+ 6
- 6
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp Wyświetl plik

57
    * splitting the move where it crosses mesh borders.
57
    * splitting the move where it crosses mesh borders.
58
    */
58
    */
59
   void mesh_line_to_destination(const float fr_mm_s, uint8_t x_splits, uint8_t y_splits) {
59
   void mesh_line_to_destination(const float fr_mm_s, uint8_t x_splits, uint8_t y_splits) {
60
-    int cx1 = mbl.cell_index_x(RAW_CURRENT_POSITION(X)),
61
-        cy1 = mbl.cell_index_y(RAW_CURRENT_POSITION(Y)),
62
-        cx2 = mbl.cell_index_x(RAW_X_POSITION(destination[X_AXIS])),
63
-        cy2 = mbl.cell_index_y(RAW_Y_POSITION(destination[Y_AXIS]));
60
+    int cx1 = mbl.cell_index_x(current_position[X_AXIS]),
61
+        cy1 = mbl.cell_index_y(current_position[Y_AXIS]),
62
+        cx2 = mbl.cell_index_x(destination[X_AXIS]),
63
+        cy2 = mbl.cell_index_y(destination[Y_AXIS]);
64
     NOMORE(cx1, GRID_MAX_POINTS_X - 2);
64
     NOMORE(cx1, GRID_MAX_POINTS_X - 2);
65
     NOMORE(cy1, GRID_MAX_POINTS_Y - 2);
65
     NOMORE(cy1, GRID_MAX_POINTS_Y - 2);
66
     NOMORE(cx2, GRID_MAX_POINTS_X - 2);
66
     NOMORE(cx2, GRID_MAX_POINTS_X - 2);
81
     const int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
81
     const int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
82
     if (cx2 != cx1 && TEST(x_splits, gcx)) {
82
     if (cx2 != cx1 && TEST(x_splits, gcx)) {
83
       COPY(end, destination);
83
       COPY(end, destination);
84
-      destination[X_AXIS] = LOGICAL_X_POSITION(mbl.index_to_xpos[gcx]);
84
+      destination[X_AXIS] = mbl.index_to_xpos[gcx];
85
       normalized_dist = (destination[X_AXIS] - current_position[X_AXIS]) / (end[X_AXIS] - current_position[X_AXIS]);
85
       normalized_dist = (destination[X_AXIS] - current_position[X_AXIS]) / (end[X_AXIS] - current_position[X_AXIS]);
86
       destination[Y_AXIS] = MBL_SEGMENT_END(Y);
86
       destination[Y_AXIS] = MBL_SEGMENT_END(Y);
87
       CBI(x_splits, gcx);
87
       CBI(x_splits, gcx);
88
     }
88
     }
89
     else if (cy2 != cy1 && TEST(y_splits, gcy)) {
89
     else if (cy2 != cy1 && TEST(y_splits, gcy)) {
90
       COPY(end, destination);
90
       COPY(end, destination);
91
-      destination[Y_AXIS] = LOGICAL_Y_POSITION(mbl.index_to_ypos[gcy]);
91
+      destination[Y_AXIS] = mbl.index_to_ypos[gcy];
92
       normalized_dist = (destination[Y_AXIS] - current_position[Y_AXIS]) / (end[Y_AXIS] - current_position[Y_AXIS]);
92
       normalized_dist = (destination[Y_AXIS] - current_position[Y_AXIS]) / (end[Y_AXIS] - current_position[Y_AXIS]);
93
       destination[X_AXIS] = MBL_SEGMENT_END(X);
93
       destination[X_AXIS] = MBL_SEGMENT_END(X);
94
       CBI(y_splits, gcy);
94
       CBI(y_splits, gcy);

+ 18
- 18
Marlin/src/feature/bedlevel/ubl/G26_Mesh_Validation_Tool.cpp Wyświetl plik

276
 
276
 
277
       // If this mesh location is outside the printable_radius, skip it.
277
       // If this mesh location is outside the printable_radius, skip it.
278
 
278
 
279
-      if (!position_is_reachable_raw_xy(circle_x, circle_y)) continue;
279
+      if (!position_is_reachable(circle_x, circle_y)) continue;
280
 
280
 
281
       xi = location.x_index;  // Just to shrink the next few lines and make them easier to understand
281
       xi = location.x_index;  // Just to shrink the next few lines and make them easier to understand
282
       yi = location.y_index;
282
       yi = location.y_index;
325
         if (tmp_div_30 < 0) tmp_div_30 += 360 / 30;
325
         if (tmp_div_30 < 0) tmp_div_30 += 360 / 30;
326
         if (tmp_div_30 > 11) tmp_div_30 -= 360 / 30;
326
         if (tmp_div_30 > 11) tmp_div_30 -= 360 / 30;
327
 
327
 
328
-        float x = circle_x + cos_table[tmp_div_30],    // for speed, these are now a lookup table entry
329
-              y = circle_y + sin_table[tmp_div_30],
328
+        float rx = circle_x + cos_table[tmp_div_30],    // for speed, these are now a lookup table entry
329
+              ry = circle_y + sin_table[tmp_div_30],
330
               xe = circle_x + cos_table[tmp_div_30 + 1],
330
               xe = circle_x + cos_table[tmp_div_30 + 1],
331
               ye = circle_y + sin_table[tmp_div_30 + 1];
331
               ye = circle_y + sin_table[tmp_div_30 + 1];
332
         #if IS_KINEMATIC
332
         #if IS_KINEMATIC
333
           // Check to make sure this segment is entirely on the bed, skip if not.
333
           // Check to make sure this segment is entirely on the bed, skip if not.
334
-          if (!position_is_reachable_raw_xy(x, y) || !position_is_reachable_raw_xy(xe, ye)) continue;
334
+          if (!position_is_reachable(rx, ry) || !position_is_reachable(xe, ye)) continue;
335
         #else                                              // not, we need to skip
335
         #else                                              // not, we need to skip
336
-          x  = constrain(x, X_MIN_POS + 1, X_MAX_POS - 1); // This keeps us from bumping the endstops
337
-          y  = constrain(y, Y_MIN_POS + 1, Y_MAX_POS - 1);
336
+          rx = constrain(rx, X_MIN_POS + 1, X_MAX_POS - 1); // This keeps us from bumping the endstops
337
+          ry = constrain(ry, Y_MIN_POS + 1, Y_MAX_POS - 1);
338
           xe = constrain(xe, X_MIN_POS + 1, X_MAX_POS - 1);
338
           xe = constrain(xe, X_MIN_POS + 1, X_MAX_POS - 1);
339
           ye = constrain(ye, Y_MIN_POS + 1, Y_MAX_POS - 1);
339
           ye = constrain(ye, Y_MIN_POS + 1, Y_MAX_POS - 1);
340
         #endif
340
         #endif
350
         //  debug_current_and_destination(seg_msg);
350
         //  debug_current_and_destination(seg_msg);
351
         //}
351
         //}
352
 
352
 
353
-        print_line_from_here_to_there(LOGICAL_X_POSITION(x), LOGICAL_Y_POSITION(y), g26_layer_height, LOGICAL_X_POSITION(xe), LOGICAL_Y_POSITION(ye), g26_layer_height);
353
+        print_line_from_here_to_there(rx, ry, g26_layer_height, xe, ye, g26_layer_height);
354
 
354
 
355
       }
355
       }
356
       if (look_for_lines_to_connect())
356
       if (look_for_lines_to_connect())
456
             sy = ey = constrain(mesh_index_to_ypos(j), Y_MIN_POS + 1, Y_MAX_POS - 1);
456
             sy = ey = constrain(mesh_index_to_ypos(j), Y_MIN_POS + 1, Y_MAX_POS - 1);
457
             ex = constrain(ex, X_MIN_POS + 1, X_MAX_POS - 1);
457
             ex = constrain(ex, X_MIN_POS + 1, X_MAX_POS - 1);
458
 
458
 
459
-            if (position_is_reachable_raw_xy(sx, sy) && position_is_reachable_raw_xy(ex, ey)) {
459
+            if (position_is_reachable(sx, sy) && position_is_reachable(ex, ey)) {
460
 
460
 
461
               if (g26_debug_flag) {
461
               if (g26_debug_flag) {
462
                 SERIAL_ECHOPAIR(" Connecting with horizontal line (sx=", sx);
462
                 SERIAL_ECHOPAIR(" Connecting with horizontal line (sx=", sx);
468
                 //debug_current_and_destination(PSTR("Connecting horizontal line."));
468
                 //debug_current_and_destination(PSTR("Connecting horizontal line."));
469
               }
469
               }
470
 
470
 
471
-              print_line_from_here_to_there(LOGICAL_X_POSITION(sx), LOGICAL_Y_POSITION(sy), g26_layer_height, LOGICAL_X_POSITION(ex), LOGICAL_Y_POSITION(ey), g26_layer_height);
471
+              print_line_from_here_to_there(sx, sy, g26_layer_height, ex, ey, g26_layer_height);
472
             }
472
             }
473
             bit_set(horizontal_mesh_line_flags, i, j);   // Mark it as done so we don't do it again, even if we skipped it
473
             bit_set(horizontal_mesh_line_flags, i, j);   // Mark it as done so we don't do it again, even if we skipped it
474
           }
474
           }
490
               sy = constrain(sy, Y_MIN_POS + 1, Y_MAX_POS - 1);
490
               sy = constrain(sy, Y_MIN_POS + 1, Y_MAX_POS - 1);
491
               ey = constrain(ey, Y_MIN_POS + 1, Y_MAX_POS - 1);
491
               ey = constrain(ey, Y_MIN_POS + 1, Y_MAX_POS - 1);
492
 
492
 
493
-              if (position_is_reachable_raw_xy(sx, sy) && position_is_reachable_raw_xy(ex, ey)) {
493
+              if (position_is_reachable(sx, sy) && position_is_reachable(ex, ey)) {
494
 
494
 
495
                 if (g26_debug_flag) {
495
                 if (g26_debug_flag) {
496
                   SERIAL_ECHOPAIR(" Connecting with vertical line (sx=", sx);
496
                   SERIAL_ECHOPAIR(" Connecting with vertical line (sx=", sx);
501
                   SERIAL_EOL();
501
                   SERIAL_EOL();
502
                   debug_current_and_destination(PSTR("Connecting vertical line."));
502
                   debug_current_and_destination(PSTR("Connecting vertical line."));
503
                 }
503
                 }
504
-                print_line_from_here_to_there(LOGICAL_X_POSITION(sx), LOGICAL_Y_POSITION(sy), g26_layer_height, LOGICAL_X_POSITION(ex), LOGICAL_Y_POSITION(ey), g26_layer_height);
504
+                print_line_from_here_to_there(sx, sy, g26_layer_height, ex, ey, g26_layer_height);
505
               }
505
               }
506
               bit_set(vertical_mesh_line_flags, i, j);   // Mark it as done so we don't do it again, even if skipped
506
               bit_set(vertical_mesh_line_flags, i, j);   // Mark it as done so we don't do it again, even if skipped
507
             }
507
             }
513
   return false;
513
   return false;
514
 }
514
 }
515
 
515
 
516
-void unified_bed_leveling::move_to(const float &x, const float &y, const float &z, const float &e_delta) {
516
+void unified_bed_leveling::move_to(const float &rx, const float &ry, const float &z, const float &e_delta) {
517
   float feed_value;
517
   float feed_value;
518
   static float last_z = -999.99;
518
   static float last_z = -999.99;
519
 
519
 
520
-  bool has_xy_component = (x != current_position[X_AXIS] || y != current_position[Y_AXIS]); // Check if X or Y is involved in the movement.
520
+  bool has_xy_component = (rx != current_position[X_AXIS] || ry != current_position[Y_AXIS]); // Check if X or Y is involved in the movement.
521
 
521
 
522
   if (z != last_z) {
522
   if (z != last_z) {
523
     last_z = z;
523
     last_z = z;
540
 
540
 
541
   if (g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to() feed_value for XY:", feed_value);
541
   if (g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to() feed_value for XY:", feed_value);
542
 
542
 
543
-  destination[X_AXIS] = x;
544
-  destination[Y_AXIS] = y;
543
+  destination[X_AXIS] = rx;
544
+  destination[Y_AXIS] = ry;
545
   destination[E_AXIS] += e_delta;
545
   destination[E_AXIS] += e_delta;
546
 
546
 
547
   G26_line_to_destination(feed_value);
547
   G26_line_to_destination(feed_value);
734
     return UBL_ERR;
734
     return UBL_ERR;
735
   }
735
   }
736
 
736
 
737
-  g26_x_pos = parser.linearval('X', current_position[X_AXIS]);
738
-  g26_y_pos = parser.linearval('Y', current_position[Y_AXIS]);
739
-  if (!position_is_reachable_xy(g26_x_pos, g26_y_pos)) {
737
+  g26_x_pos = parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : current_position[X_AXIS];
738
+  g26_y_pos = parser.seenval('Y') ? RAW_X_POSITION(parser.value_linear_units()) : current_position[Y_AXIS];
739
+  if (!position_is_reachable(g26_x_pos, g26_y_pos)) {
740
     SERIAL_PROTOCOLLNPGM("?Specified X,Y coordinate out of bounds.");
740
     SERIAL_PROTOCOLLNPGM("?Specified X,Y coordinate out of bounds.");
741
     return UBL_ERR;
741
     return UBL_ERR;
742
   }
742
   }

+ 21
- 21
Marlin/src/feature/bedlevel/ubl/ubl.h Wyświetl plik

108
     static bool g29_parameter_parsing();
108
     static bool g29_parameter_parsing();
109
     static void find_mean_mesh_height();
109
     static void find_mean_mesh_height();
110
     static void shift_mesh_height();
110
     static void shift_mesh_height();
111
-    static void probe_entire_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest);
111
+    static void probe_entire_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest);
112
     static void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
112
     static void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
113
     static void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3);
113
     static void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3);
114
     static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map);
114
     static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map);
115
     static void g29_what_command();
115
     static void g29_what_command();
116
     static void g29_eeprom_dump();
116
     static void g29_eeprom_dump();
117
     static void g29_compare_current_mesh_to_stored_mesh();
117
     static void g29_compare_current_mesh_to_stored_mesh();
118
-    static void fine_tune_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map);
118
+    static void fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map);
119
     static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
119
     static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
120
     static void smart_fill_mesh();
120
     static void smart_fill_mesh();
121
 
121
 
243
      * z_correction_for_x_on_horizontal_mesh_line is an optimization for
243
      * z_correction_for_x_on_horizontal_mesh_line is an optimization for
244
      * the case where the printer is making a vertical line that only crosses horizontal mesh lines.
244
      * the case where the printer is making a vertical line that only crosses horizontal mesh lines.
245
      */
245
      */
246
-    inline static float z_correction_for_x_on_horizontal_mesh_line(const float &lx0, const int x1_i, const int yi) {
246
+    inline static float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi) {
247
       if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 2) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
247
       if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 2) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
248
         #if ENABLED(DEBUG_LEVELING_FEATURE)
248
         #if ENABLED(DEBUG_LEVELING_FEATURE)
249
           if (DEBUGGING(LEVELING)) {
249
           if (DEBUGGING(LEVELING)) {
250
             serialprintPGM( !WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) ? PSTR("x1l_i") : PSTR("yi") );
250
             serialprintPGM( !WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) ? PSTR("x1l_i") : PSTR("yi") );
251
-            SERIAL_ECHOPAIR(" out of bounds in z_correction_for_x_on_horizontal_mesh_line(lx0=", lx0);
251
+            SERIAL_ECHOPAIR(" out of bounds in z_correction_for_x_on_horizontal_mesh_line(rx0=", rx0);
252
             SERIAL_ECHOPAIR(",x1_i=", x1_i);
252
             SERIAL_ECHOPAIR(",x1_i=", x1_i);
253
             SERIAL_ECHOPAIR(",yi=", yi);
253
             SERIAL_ECHOPAIR(",yi=", yi);
254
             SERIAL_CHAR(')');
254
             SERIAL_CHAR(')');
258
         return NAN;
258
         return NAN;
259
       }
259
       }
260
 
260
 
261
-      const float xratio = (RAW_X_POSITION(lx0) - mesh_index_to_xpos(x1_i)) * (1.0 / (MESH_X_DIST)),
261
+      const float xratio = (rx0 - mesh_index_to_xpos(x1_i)) * (1.0 / (MESH_X_DIST)),
262
                   z1 = z_values[x1_i][yi];
262
                   z1 = z_values[x1_i][yi];
263
 
263
 
264
       return z1 + xratio * (z_values[x1_i + 1][yi] - z1);
264
       return z1 + xratio * (z_values[x1_i + 1][yi] - z1);
267
     //
267
     //
268
     // See comments above for z_correction_for_x_on_horizontal_mesh_line
268
     // See comments above for z_correction_for_x_on_horizontal_mesh_line
269
     //
269
     //
270
-    inline static float z_correction_for_y_on_vertical_mesh_line(const float &ly0, const int xi, const int y1_i) {
270
+    inline static float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i) {
271
       if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 2)) {
271
       if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 2)) {
272
         #if ENABLED(DEBUG_LEVELING_FEATURE)
272
         #if ENABLED(DEBUG_LEVELING_FEATURE)
273
           if (DEBUGGING(LEVELING)) {
273
           if (DEBUGGING(LEVELING)) {
274
             serialprintPGM( !WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) ? PSTR("xi") : PSTR("yl_i") );
274
             serialprintPGM( !WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) ? PSTR("xi") : PSTR("yl_i") );
275
-            SERIAL_ECHOPAIR(" out of bounds in z_correction_for_y_on_vertical_mesh_line(ly0=", ly0);
275
+            SERIAL_ECHOPAIR(" out of bounds in z_correction_for_y_on_vertical_mesh_line(ry0=", ry0);
276
             SERIAL_ECHOPAIR(", xi=", xi);
276
             SERIAL_ECHOPAIR(", xi=", xi);
277
             SERIAL_ECHOPAIR(", y1_i=", y1_i);
277
             SERIAL_ECHOPAIR(", y1_i=", y1_i);
278
             SERIAL_CHAR(')');
278
             SERIAL_CHAR(')');
282
         return NAN;
282
         return NAN;
283
       }
283
       }
284
 
284
 
285
-      const float yratio = (RAW_Y_POSITION(ly0) - mesh_index_to_ypos(y1_i)) * (1.0 / (MESH_Y_DIST)),
285
+      const float yratio = (ry0 - mesh_index_to_ypos(y1_i)) * (1.0 / (MESH_Y_DIST)),
286
                   z1 = z_values[xi][y1_i];
286
                   z1 = z_values[xi][y1_i];
287
 
287
 
288
       return z1 + yratio * (z_values[xi][y1_i + 1] - z1);
288
       return z1 + yratio * (z_values[xi][y1_i + 1] - z1);
294
      * Z-Height at both ends. Then it does a linear interpolation of these heights based
294
      * Z-Height at both ends. Then it does a linear interpolation of these heights based
295
      * on the Y position within the cell.
295
      * on the Y position within the cell.
296
      */
296
      */
297
-    static float get_z_correction(const float &lx0, const float &ly0) {
298
-      const int8_t cx = get_cell_index_x(RAW_X_POSITION(lx0)),
299
-                   cy = get_cell_index_y(RAW_Y_POSITION(ly0));
297
+    static float get_z_correction(const float &rx0, const float &ry0) {
298
+      const int8_t cx = get_cell_index_x(rx0),
299
+                   cy = get_cell_index_y(ry0);
300
 
300
 
301
       if (!WITHIN(cx, 0, GRID_MAX_POINTS_X - 2) || !WITHIN(cy, 0, GRID_MAX_POINTS_Y - 2)) {
301
       if (!WITHIN(cx, 0, GRID_MAX_POINTS_X - 2) || !WITHIN(cy, 0, GRID_MAX_POINTS_Y - 2)) {
302
 
302
 
303
-        SERIAL_ECHOPAIR("? in get_z_correction(lx0=", lx0);
304
-        SERIAL_ECHOPAIR(", ly0=", ly0);
303
+        SERIAL_ECHOPAIR("? in get_z_correction(rx0=", rx0);
304
+        SERIAL_ECHOPAIR(", ry0=", ry0);
305
         SERIAL_CHAR(')');
305
         SERIAL_CHAR(')');
306
         SERIAL_EOL();
306
         SERIAL_EOL();
307
 
307
 
312
         return NAN;
312
         return NAN;
313
       }
313
       }
314
 
314
 
315
-      const float z1 = calc_z0(RAW_X_POSITION(lx0),
315
+      const float z1 = calc_z0(rx0,
316
                                mesh_index_to_xpos(cx), z_values[cx][cy],
316
                                mesh_index_to_xpos(cx), z_values[cx][cy],
317
                                mesh_index_to_xpos(cx + 1), z_values[cx + 1][cy]);
317
                                mesh_index_to_xpos(cx + 1), z_values[cx + 1][cy]);
318
 
318
 
319
-      const float z2 = calc_z0(RAW_X_POSITION(lx0),
319
+      const float z2 = calc_z0(rx0,
320
                                mesh_index_to_xpos(cx), z_values[cx][cy + 1],
320
                                mesh_index_to_xpos(cx), z_values[cx][cy + 1],
321
                                mesh_index_to_xpos(cx + 1), z_values[cx + 1][cy + 1]);
321
                                mesh_index_to_xpos(cx + 1), z_values[cx + 1][cy + 1]);
322
 
322
 
323
-      float z0 = calc_z0(RAW_Y_POSITION(ly0),
323
+      float z0 = calc_z0(ry0,
324
                          mesh_index_to_ypos(cy), z1,
324
                          mesh_index_to_ypos(cy), z1,
325
                          mesh_index_to_ypos(cy + 1), z2);
325
                          mesh_index_to_ypos(cy + 1), z2);
326
 
326
 
327
       #if ENABLED(DEBUG_LEVELING_FEATURE)
327
       #if ENABLED(DEBUG_LEVELING_FEATURE)
328
         if (DEBUGGING(MESH_ADJUST)) {
328
         if (DEBUGGING(MESH_ADJUST)) {
329
-          SERIAL_ECHOPAIR(" raw get_z_correction(", lx0);
329
+          SERIAL_ECHOPAIR(" raw get_z_correction(", rx0);
330
           SERIAL_CHAR(',');
330
           SERIAL_CHAR(',');
331
-          SERIAL_ECHO(ly0);
331
+          SERIAL_ECHO(ry0);
332
           SERIAL_ECHOPGM(") = ");
332
           SERIAL_ECHOPGM(") = ");
333
           SERIAL_ECHO_F(z0, 6);
333
           SERIAL_ECHO_F(z0, 6);
334
         }
334
         }
350
 
350
 
351
         #if ENABLED(DEBUG_LEVELING_FEATURE)
351
         #if ENABLED(DEBUG_LEVELING_FEATURE)
352
           if (DEBUGGING(MESH_ADJUST)) {
352
           if (DEBUGGING(MESH_ADJUST)) {
353
-            SERIAL_ECHOPAIR("??? Yikes!  NAN in get_z_correction(", lx0);
353
+            SERIAL_ECHOPAIR("??? Yikes!  NAN in get_z_correction(", rx0);
354
             SERIAL_CHAR(',');
354
             SERIAL_CHAR(',');
355
-            SERIAL_ECHO(ly0);
355
+            SERIAL_ECHO(ry0);
356
             SERIAL_CHAR(')');
356
             SERIAL_CHAR(')');
357
             SERIAL_EOL();
357
             SERIAL_EOL();
358
           }
358
           }
369
       return i < GRID_MAX_POINTS_Y ? pgm_read_float(&_mesh_index_to_ypos[i]) : MESH_MIN_Y + i * (MESH_Y_DIST);
369
       return i < GRID_MAX_POINTS_Y ? pgm_read_float(&_mesh_index_to_ypos[i]) : MESH_MIN_Y + i * (MESH_Y_DIST);
370
     }
370
     }
371
 
371
 
372
-    static bool prepare_segmented_line_to(const float ltarget[XYZE], const float &feedrate);
372
+    static bool prepare_segmented_line_to(const float rtarget[XYZE], const float &feedrate);
373
     static void line_to_destination_cartesian(const float &fr, uint8_t e);
373
     static void line_to_destination_cartesian(const float &fr, uint8_t e);
374
 
374
 
375
     #define _CMPZ(a,b) (z_values[a][b] == z_values[a][b+1])
375
     #define _CMPZ(a,b) (z_values[a][b] == z_values[a][b+1])

+ 44
- 47
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Wyświetl plik

393
           restore_ubl_active_state_and_leave();
393
           restore_ubl_active_state_and_leave();
394
         }
394
         }
395
         else { // grid_size == 0 : A 3-Point leveling has been requested
395
         else { // grid_size == 0 : A 3-Point leveling has been requested
396
-          float z3, z2, z1 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_1_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_1_Y), false, g29_verbose_level);
396
+          float z3, z2, z1 = probe_pt(UBL_PROBE_PT_1_X, UBL_PROBE_PT_1_Y, false, g29_verbose_level);
397
           if (!isnan(z1)) {
397
           if (!isnan(z1)) {
398
-            z2 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_2_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_2_Y), false, g29_verbose_level);
398
+            z2 = probe_pt(UBL_PROBE_PT_2_X, UBL_PROBE_PT_2_Y, false, g29_verbose_level);
399
             if (!isnan(z2))
399
             if (!isnan(z2))
400
-              z3 = probe_pt(LOGICAL_X_POSITION(UBL_PROBE_PT_3_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_3_Y), true, g29_verbose_level);
400
+              z3 = probe_pt(UBL_PROBE_PT_3_X, UBL_PROBE_PT_3_Y, true, g29_verbose_level);
401
           }
401
           }
402
 
402
 
403
           if (isnan(z1) || isnan(z2) || isnan(z3)) { // probe_pt will return NAN if unreachable
403
           if (isnan(z1) || isnan(z2) || isnan(z3)) { // probe_pt will return NAN if unreachable
411
           // its height is.)
411
           // its height is.)
412
 
412
 
413
           save_ubl_active_state_and_disable();
413
           save_ubl_active_state_and_disable();
414
-          z1 -= get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_1_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_1_Y)) /* + zprobe_zoffset */ ;
415
-          z2 -= get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_2_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_2_Y)) /* + zprobe_zoffset */ ;
416
-          z3 -= get_z_correction(LOGICAL_X_POSITION(UBL_PROBE_PT_3_X), LOGICAL_Y_POSITION(UBL_PROBE_PT_3_Y)) /* + zprobe_zoffset */ ;
414
+          z1 -= get_z_correction(UBL_PROBE_PT_1_X, UBL_PROBE_PT_1_Y) /* + zprobe_zoffset */ ;
415
+          z2 -= get_z_correction(UBL_PROBE_PT_2_X, UBL_PROBE_PT_2_Y) /* + zprobe_zoffset */ ;
416
+          z3 -= get_z_correction(UBL_PROBE_PT_3_X, UBL_PROBE_PT_3_Y) /* + zprobe_zoffset */ ;
417
 
417
 
418
           do_blocking_move_to_xy(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)));
418
           do_blocking_move_to_xy(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)));
419
           tilt_mesh_based_on_3pts(z1, z2, z3);
419
           tilt_mesh_based_on_3pts(z1, z2, z3);
497
               }
497
               }
498
             }
498
             }
499
 
499
 
500
-            if (!position_is_reachable_xy(g29_x_pos, g29_y_pos)) {
500
+            if (!position_is_reachable(g29_x_pos, g29_y_pos)) {
501
               SERIAL_PROTOCOLLNPGM("XY outside printable radius.");
501
               SERIAL_PROTOCOLLNPGM("XY outside printable radius.");
502
               return;
502
               return;
503
             }
503
             }
734
      * Probe all invalidated locations of the mesh that can be reached by the probe.
734
      * Probe all invalidated locations of the mesh that can be reached by the probe.
735
      * This attempts to fill in locations closest to the nozzle's start location first.
735
      * This attempts to fill in locations closest to the nozzle's start location first.
736
      */
736
      */
737
-    void unified_bed_leveling::probe_entire_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map, const bool stow_probe, bool close_or_far) {
737
+    void unified_bed_leveling::probe_entire_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map, const bool stow_probe, bool close_or_far) {
738
       mesh_index_pair location;
738
       mesh_index_pair location;
739
 
739
 
740
       has_control_of_lcd_panel = true;
740
       has_control_of_lcd_panel = true;
762
         if (close_or_far)
762
         if (close_or_far)
763
           location = find_furthest_invalid_mesh_point();
763
           location = find_furthest_invalid_mesh_point();
764
         else
764
         else
765
-          location = find_closest_mesh_point_of_type(INVALID, lx, ly, USE_PROBE_AS_REFERENCE, NULL);
765
+          location = find_closest_mesh_point_of_type(INVALID, rx, ry, USE_PROBE_AS_REFERENCE, NULL);
766
 
766
 
767
         if (location.x_index >= 0) {    // mesh point found and is reachable by probe
767
         if (location.x_index >= 0) {    // mesh point found and is reachable by probe
768
           const float rawx = mesh_index_to_xpos(location.x_index),
768
           const float rawx = mesh_index_to_xpos(location.x_index),
769
                       rawy = mesh_index_to_ypos(location.y_index);
769
                       rawy = mesh_index_to_ypos(location.y_index);
770
 
770
 
771
-          const float measured_z = probe_pt(LOGICAL_X_POSITION(rawx), LOGICAL_Y_POSITION(rawy), stow_probe, g29_verbose_level); // TODO: Needs error handling
771
+          const float measured_z = probe_pt(rawx, rawy, stow_probe, g29_verbose_level); // TODO: Needs error handling
772
           z_values[location.x_index][location.y_index] = measured_z;
772
           z_values[location.x_index][location.y_index] = measured_z;
773
         }
773
         }
774
 
774
 
778
       restore_ubl_active_state_and_leave();
778
       restore_ubl_active_state_and_leave();
779
 
779
 
780
       do_blocking_move_to_xy(
780
       do_blocking_move_to_xy(
781
-        constrain(lx - (X_PROBE_OFFSET_FROM_EXTRUDER), MESH_MIN_X, MESH_MAX_X),
782
-        constrain(ly - (Y_PROBE_OFFSET_FROM_EXTRUDER), MESH_MIN_Y, MESH_MAX_Y)
781
+        constrain(rx - (X_PROBE_OFFSET_FROM_EXTRUDER), MESH_MIN_X, MESH_MAX_X),
782
+        constrain(ry - (Y_PROBE_OFFSET_FROM_EXTRUDER), MESH_MIN_Y, MESH_MAX_Y)
783
       );
783
       );
784
     }
784
     }
785
 
785
 
953
       return thickness;
953
       return thickness;
954
     }
954
     }
955
 
955
 
956
-    void unified_bed_leveling::manually_probe_remaining_mesh(const float &lx, const float &ly, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) {
956
+    void unified_bed_leveling::manually_probe_remaining_mesh(const float &rx, const float &ry, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) {
957
 
957
 
958
       has_control_of_lcd_panel = true;
958
       has_control_of_lcd_panel = true;
959
 
959
 
960
       save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
960
       save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
961
       do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
961
       do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
962
-      do_blocking_move_to_xy(lx, ly);
962
+      do_blocking_move_to_xy(rx, ry);
963
 
963
 
964
       lcd_return_to_status();
964
       lcd_return_to_status();
965
 
965
 
966
       mesh_index_pair location;
966
       mesh_index_pair location;
967
       do {
967
       do {
968
-        location = find_closest_mesh_point_of_type(INVALID, lx, ly, USE_NOZZLE_AS_REFERENCE, NULL);
968
+        location = find_closest_mesh_point_of_type(INVALID, rx, ry, USE_NOZZLE_AS_REFERENCE, NULL);
969
         // It doesn't matter if the probe can't reach the NAN location. This is a manual probe.
969
         // It doesn't matter if the probe can't reach the NAN location. This is a manual probe.
970
         if (location.x_index < 0 && location.y_index < 0) continue;
970
         if (location.x_index < 0 && location.y_index < 0) continue;
971
 
971
 
972
-        const float rawx = mesh_index_to_xpos(location.x_index),
973
-                    rawy = mesh_index_to_ypos(location.y_index),
974
-                    xProbe = LOGICAL_X_POSITION(rawx),
975
-                    yProbe = LOGICAL_Y_POSITION(rawy);
972
+        const float xProbe = mesh_index_to_xpos(location.x_index),
973
+                    yProbe = mesh_index_to_ypos(location.y_index);
976
 
974
 
977
-        if (!position_is_reachable_raw_xy(rawx, rawy)) break; // SHOULD NOT OCCUR (find_closest_mesh_point only returns reachable points)
975
+        if (!position_is_reachable(xProbe, yProbe)) break; // SHOULD NOT OCCUR (find_closest_mesh_point only returns reachable points)
978
 
976
 
979
         do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
977
         do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
980
 
978
 
1038
       restore_ubl_active_state_and_leave();
1036
       restore_ubl_active_state_and_leave();
1039
       KEEPALIVE_STATE(IN_HANDLER);
1037
       KEEPALIVE_STATE(IN_HANDLER);
1040
       do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
1038
       do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
1041
-      do_blocking_move_to_xy(lx, ly);
1039
+      do_blocking_move_to_xy(rx, ry);
1042
     }
1040
     }
1043
 
1041
 
1044
   #endif // NEWPANEL
1042
   #endif // NEWPANEL
1111
     }
1109
     }
1112
 
1110
 
1113
     // If X or Y are not valid, use center of the bed values
1111
     // If X or Y are not valid, use center of the bed values
1114
-    if (!WITHIN(RAW_X_POSITION(g29_x_pos), X_MIN_BED, X_MAX_BED)) g29_x_pos = LOGICAL_X_POSITION(X_CENTER);
1115
-    if (!WITHIN(RAW_Y_POSITION(g29_y_pos), Y_MIN_BED, Y_MAX_BED)) g29_y_pos = LOGICAL_Y_POSITION(Y_CENTER);
1112
+    if (!WITHIN(g29_x_pos, X_MIN_BED, X_MAX_BED)) g29_x_pos = X_CENTER;
1113
+    if (!WITHIN(g29_y_pos, Y_MIN_BED, Y_MAX_BED)) g29_y_pos = Y_CENTER;
1116
 
1114
 
1117
     if (err_flag) return UBL_ERR;
1115
     if (err_flag) return UBL_ERR;
1118
 
1116
 
1365
           const float mx = mesh_index_to_xpos(i),
1363
           const float mx = mesh_index_to_xpos(i),
1366
                       my = mesh_index_to_ypos(j);
1364
                       my = mesh_index_to_ypos(j);
1367
 
1365
 
1368
-          if ( !position_is_reachable_by_probe_raw_xy(mx, my))  // make sure the probe can get to the mesh point
1366
+          if ( !position_is_reachable_by_probe(mx, my))  // make sure the probe can get to the mesh point
1369
             continue;
1367
             continue;
1370
 
1368
 
1371
           found_a_NAN = true;
1369
           found_a_NAN = true;
1413
     return out_mesh;
1411
     return out_mesh;
1414
   }
1412
   }
1415
 
1413
 
1416
-  mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const MeshPointType type, const float &lx, const float &ly, const bool probe_as_reference, uint16_t bits[16]) {
1414
+  mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const MeshPointType type, const float &rx, const float &ry, const bool probe_as_reference, uint16_t bits[16]) {
1417
     mesh_index_pair out_mesh;
1415
     mesh_index_pair out_mesh;
1418
     out_mesh.x_index = out_mesh.y_index = -1;
1416
     out_mesh.x_index = out_mesh.y_index = -1;
1419
     out_mesh.distance = -99999.9;
1417
     out_mesh.distance = -99999.9;
1420
 
1418
 
1421
     // Get our reference position. Either the nozzle or probe location.
1419
     // Get our reference position. Either the nozzle or probe location.
1422
-    const float px = RAW_X_POSITION(lx) - (probe_as_reference == USE_PROBE_AS_REFERENCE ? X_PROBE_OFFSET_FROM_EXTRUDER : 0),
1423
-                py = RAW_Y_POSITION(ly) - (probe_as_reference == USE_PROBE_AS_REFERENCE ? Y_PROBE_OFFSET_FROM_EXTRUDER : 0);
1420
+    const float px = rx - (probe_as_reference == USE_PROBE_AS_REFERENCE ? X_PROBE_OFFSET_FROM_EXTRUDER : 0),
1421
+                py = ry - (probe_as_reference == USE_PROBE_AS_REFERENCE ? Y_PROBE_OFFSET_FROM_EXTRUDER : 0);
1424
 
1422
 
1425
     float best_so_far = 99999.99;
1423
     float best_so_far = 99999.99;
1426
 
1424
 
1433
         ) {
1431
         ) {
1434
           // We only get here if we found a Mesh Point of the specified type
1432
           // We only get here if we found a Mesh Point of the specified type
1435
 
1433
 
1436
-          float raw_x = RAW_CURRENT_POSITION(X), raw_y = RAW_CURRENT_POSITION(Y);
1437
           const float mx = mesh_index_to_xpos(i),
1434
           const float mx = mesh_index_to_xpos(i),
1438
                       my = mesh_index_to_ypos(j);
1435
                       my = mesh_index_to_ypos(j);
1439
 
1436
 
1441
           // Also for round beds, there are grid points outside the bed the nozzle can't reach.
1438
           // Also for round beds, there are grid points outside the bed the nozzle can't reach.
1442
           // Prune them from the list and ignore them till the next Phase (manual nozzle probing).
1439
           // Prune them from the list and ignore them till the next Phase (manual nozzle probing).
1443
 
1440
 
1444
-          if (probe_as_reference ? !position_is_reachable_by_probe_raw_xy(mx, my) : !position_is_reachable_raw_xy(mx, my))
1441
+          if (probe_as_reference ? !position_is_reachable_by_probe(mx, my) : !position_is_reachable(mx, my))
1445
             continue;
1442
             continue;
1446
 
1443
 
1447
           // Reachable. Check if it's the best_so_far location to the nozzle.
1444
           // Reachable. Check if it's the best_so_far location to the nozzle.
1450
 
1447
 
1451
           // factor in the distance from the current location for the normal case
1448
           // factor in the distance from the current location for the normal case
1452
           // so the nozzle isn't running all over the bed.
1449
           // so the nozzle isn't running all over the bed.
1453
-          distance += HYPOT(raw_x - mx, raw_y - my) * 0.1;
1450
+          distance += HYPOT(current_position[X_AXIS] - mx, current_position[Y_AXIS] - my) * 0.1;
1454
           if (distance < best_so_far) {
1451
           if (distance < best_so_far) {
1455
             best_so_far = distance;   // We found a closer location with
1452
             best_so_far = distance;   // We found a closer location with
1456
             out_mesh.x_index = i;     // the specified type of mesh value.
1453
             out_mesh.x_index = i;     // the specified type of mesh value.
1465
 
1462
 
1466
   #if ENABLED(NEWPANEL)
1463
   #if ENABLED(NEWPANEL)
1467
 
1464
 
1468
-    void unified_bed_leveling::fine_tune_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map) {
1465
+    void unified_bed_leveling::fine_tune_mesh(const float &rx, const float &ry, const bool do_ubl_mesh_map) {
1469
       if (!parser.seen('R'))    // fine_tune_mesh() is special. If no repetition count flag is specified
1466
       if (!parser.seen('R'))    // fine_tune_mesh() is special. If no repetition count flag is specified
1470
         g29_repetition_cnt = 1;   // do exactly one mesh location. Otherwise use what the parser decided.
1467
         g29_repetition_cnt = 1;   // do exactly one mesh location. Otherwise use what the parser decided.
1471
 
1468
 
1480
 
1477
 
1481
       mesh_index_pair location;
1478
       mesh_index_pair location;
1482
 
1479
 
1483
-      if (!position_is_reachable_xy(lx, ly)) {
1480
+      if (!position_is_reachable(rx, ry)) {
1484
         SERIAL_PROTOCOLLNPGM("(X,Y) outside printable radius.");
1481
         SERIAL_PROTOCOLLNPGM("(X,Y) outside printable radius.");
1485
         return;
1482
         return;
1486
       }
1483
       }
1490
       LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH);
1487
       LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH);
1491
 
1488
 
1492
       do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
1489
       do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
1493
-      do_blocking_move_to_xy(lx, ly);
1490
+      do_blocking_move_to_xy(rx, ry);
1494
 
1491
 
1495
       uint16_t not_done[16];
1492
       uint16_t not_done[16];
1496
       memset(not_done, 0xFF, sizeof(not_done));
1493
       memset(not_done, 0xFF, sizeof(not_done));
1497
       do {
1494
       do {
1498
-        location = find_closest_mesh_point_of_type(SET_IN_BITMAP, lx, ly, USE_NOZZLE_AS_REFERENCE, not_done);
1495
+        location = find_closest_mesh_point_of_type(SET_IN_BITMAP, rx, ry, USE_NOZZLE_AS_REFERENCE, not_done);
1499
 
1496
 
1500
         if (location.x_index < 0) break; // stop when we can't find any more reachable points.
1497
         if (location.x_index < 0) break; // stop when we can't find any more reachable points.
1501
 
1498
 
1505
         const float rawx = mesh_index_to_xpos(location.x_index),
1502
         const float rawx = mesh_index_to_xpos(location.x_index),
1506
                     rawy = mesh_index_to_ypos(location.y_index);
1503
                     rawy = mesh_index_to_ypos(location.y_index);
1507
 
1504
 
1508
-        if (!position_is_reachable_raw_xy(rawx, rawy)) // SHOULD NOT OCCUR because find_closest_mesh_point_of_type will only return reachable
1505
+        if (!position_is_reachable(rawx, rawy)) // SHOULD NOT OCCUR because find_closest_mesh_point_of_type will only return reachable
1509
           break;
1506
           break;
1510
 
1507
 
1511
         float new_z = z_values[location.x_index][location.y_index];
1508
         float new_z = z_values[location.x_index][location.y_index];
1514
           new_z = 0.0;
1511
           new_z = 0.0;
1515
 
1512
 
1516
         do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);    // Move the nozzle to where we are going to edit
1513
         do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);    // Move the nozzle to where we are going to edit
1517
-        do_blocking_move_to_xy(LOGICAL_X_POSITION(rawx), LOGICAL_Y_POSITION(rawy));
1514
+        do_blocking_move_to_xy(rawx, rawy);
1518
 
1515
 
1519
         new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
1516
         new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
1520
 
1517
 
1576
       restore_ubl_active_state_and_leave();
1573
       restore_ubl_active_state_and_leave();
1577
       do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
1574
       do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
1578
 
1575
 
1579
-      do_blocking_move_to_xy(lx, ly);
1576
+      do_blocking_move_to_xy(rx, ry);
1580
 
1577
 
1581
       LCD_MESSAGEPGM(MSG_UBL_DONE_EDITING_MESH);
1578
       LCD_MESSAGEPGM(MSG_UBL_DONE_EDITING_MESH);
1582
       SERIAL_ECHOLNPGM("Done Editing Mesh");
1579
       SERIAL_ECHOLNPGM("Done Editing Mesh");
1654
 
1651
 
1655
       bool zig_zag = false;
1652
       bool zig_zag = false;
1656
       for (uint8_t ix = 0; ix < g29_grid_size; ix++) {
1653
       for (uint8_t ix = 0; ix < g29_grid_size; ix++) {
1657
-        const float x = float(x_min) + ix * dx;
1654
+        const float rx = float(x_min) + ix * dx;
1658
         for (int8_t iy = 0; iy < g29_grid_size; iy++) {
1655
         for (int8_t iy = 0; iy < g29_grid_size; iy++) {
1659
-          const float y = float(y_min) + dy * (zig_zag ? g29_grid_size - 1 - iy : iy);
1660
-          float measured_z = probe_pt(LOGICAL_X_POSITION(x), LOGICAL_Y_POSITION(y), parser.seen('E'), g29_verbose_level); // TODO: Needs error handling
1656
+          const float ry = float(y_min) + dy * (zig_zag ? g29_grid_size - 1 - iy : iy);
1657
+          float measured_z = probe_pt(rx, ry, parser.seen('E'), g29_verbose_level); // TODO: Needs error handling
1661
           #if ENABLED(DEBUG_LEVELING_FEATURE)
1658
           #if ENABLED(DEBUG_LEVELING_FEATURE)
1662
             if (DEBUGGING(LEVELING)) {
1659
             if (DEBUGGING(LEVELING)) {
1663
               SERIAL_CHAR('(');
1660
               SERIAL_CHAR('(');
1664
-              SERIAL_PROTOCOL_F(x, 7);
1661
+              SERIAL_PROTOCOL_F(rx, 7);
1665
               SERIAL_CHAR(',');
1662
               SERIAL_CHAR(',');
1666
-              SERIAL_PROTOCOL_F(y, 7);
1663
+              SERIAL_PROTOCOL_F(ry, 7);
1667
               SERIAL_ECHOPGM(")   logical: ");
1664
               SERIAL_ECHOPGM(")   logical: ");
1668
               SERIAL_CHAR('(');
1665
               SERIAL_CHAR('(');
1669
-              SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(x), 7);
1666
+              SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(rx), 7);
1670
               SERIAL_CHAR(',');
1667
               SERIAL_CHAR(',');
1671
-              SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(y), 7);
1668
+              SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(ry), 7);
1672
               SERIAL_ECHOPGM(")   measured: ");
1669
               SERIAL_ECHOPGM(")   measured: ");
1673
               SERIAL_PROTOCOL_F(measured_z, 7);
1670
               SERIAL_PROTOCOL_F(measured_z, 7);
1674
               SERIAL_ECHOPGM("   correction: ");
1671
               SERIAL_ECHOPGM("   correction: ");
1675
-              SERIAL_PROTOCOL_F(get_z_correction(LOGICAL_X_POSITION(x), LOGICAL_Y_POSITION(y)), 7);
1672
+              SERIAL_PROTOCOL_F(get_z_correction(rx, ry), 7);
1676
             }
1673
             }
1677
           #endif
1674
           #endif
1678
 
1675
 
1679
-          measured_z -= get_z_correction(LOGICAL_X_POSITION(x), LOGICAL_Y_POSITION(y)) /* + zprobe_zoffset */ ;
1676
+          measured_z -= get_z_correction(rx, ry) /* + zprobe_zoffset */ ;
1680
 
1677
 
1681
           #if ENABLED(DEBUG_LEVELING_FEATURE)
1678
           #if ENABLED(DEBUG_LEVELING_FEATURE)
1682
             if (DEBUGGING(LEVELING)) {
1679
             if (DEBUGGING(LEVELING)) {
1686
             }
1683
             }
1687
           #endif
1684
           #endif
1688
 
1685
 
1689
-          incremental_LSF(&lsf_results, x, y, measured_z);
1686
+          incremental_LSF(&lsf_results, rx, ry, measured_z);
1690
         }
1687
         }
1691
 
1688
 
1692
         zig_zag ^= true;
1689
         zig_zag ^= true;

+ 62
- 71
Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp Wyświetl plik

112
                   destination[E_AXIS]
112
                   destination[E_AXIS]
113
                 };
113
                 };
114
 
114
 
115
-    const int cell_start_xi = get_cell_index_x(RAW_X_POSITION(start[X_AXIS])),
116
-              cell_start_yi = get_cell_index_y(RAW_Y_POSITION(start[Y_AXIS])),
117
-              cell_dest_xi  = get_cell_index_x(RAW_X_POSITION(end[X_AXIS])),
118
-              cell_dest_yi  = get_cell_index_y(RAW_Y_POSITION(end[Y_AXIS]));
115
+    const int cell_start_xi = get_cell_index_x(start[X_AXIS]),
116
+              cell_start_yi = get_cell_index_y(start[Y_AXIS]),
117
+              cell_dest_xi  = get_cell_index_x(end[X_AXIS]),
118
+              cell_dest_yi  = get_cell_index_y(end[Y_AXIS]);
119
 
119
 
120
     if (g26_debug_flag) {
120
     if (g26_debug_flag) {
121
       SERIAL_ECHOPAIR(" ubl.line_to_destination(xe=", end[X_AXIS]);
121
       SERIAL_ECHOPAIR(" ubl.line_to_destination(xe=", end[X_AXIS]);
160
        * to create a 1-over number for us. That will allow us to do a floating point multiply instead of a floating point divide.
160
        * to create a 1-over number for us. That will allow us to do a floating point multiply instead of a floating point divide.
161
        */
161
        */
162
 
162
 
163
-      const float xratio = (RAW_X_POSITION(end[X_AXIS]) - mesh_index_to_xpos(cell_dest_xi)) * (1.0 / (MESH_X_DIST));
163
+      const float xratio = (end[X_AXIS] - mesh_index_to_xpos(cell_dest_xi)) * (1.0 / (MESH_X_DIST));
164
 
164
 
165
       float z1 = z_values[cell_dest_xi    ][cell_dest_yi    ] + xratio *
165
       float z1 = z_values[cell_dest_xi    ][cell_dest_yi    ] + xratio *
166
                 (z_values[cell_dest_xi + 1][cell_dest_yi    ] - z_values[cell_dest_xi][cell_dest_yi    ]),
166
                 (z_values[cell_dest_xi + 1][cell_dest_yi    ] - z_values[cell_dest_xi][cell_dest_yi    ]),
172
       // we are done with the fractional X distance into the cell. Now with the two Z-Heights we have calculated, we
172
       // we are done with the fractional X distance into the cell. Now with the two Z-Heights we have calculated, we
173
       // are going to apply the Y-Distance into the cell to interpolate the final Z correction.
173
       // are going to apply the Y-Distance into the cell to interpolate the final Z correction.
174
 
174
 
175
-      const float yratio = (RAW_Y_POSITION(end[Y_AXIS]) - mesh_index_to_ypos(cell_dest_yi)) * (1.0 / (MESH_Y_DIST));
175
+      const float yratio = (end[Y_AXIS] - mesh_index_to_ypos(cell_dest_yi)) * (1.0 / (MESH_Y_DIST));
176
       float z0 = cell_dest_yi < GRID_MAX_POINTS_Y - 1 ? (z1 + (z2 - z1) * yratio) * planner.fade_scaling_factor_for_z(end[Z_AXIS]) : 0.0;
176
       float z0 = cell_dest_yi < GRID_MAX_POINTS_Y - 1 ? (z1 + (z2 - z1) * yratio) * planner.fade_scaling_factor_for_z(end[Z_AXIS]) : 0.0;
177
 
177
 
178
       /**
178
       /**
248
       current_yi += down_flag;  // Line is heading down, we just want to go to the bottom
248
       current_yi += down_flag;  // Line is heading down, we just want to go to the bottom
249
       while (current_yi != cell_dest_yi + down_flag) {
249
       while (current_yi != cell_dest_yi + down_flag) {
250
         current_yi += dyi;
250
         current_yi += dyi;
251
-        const float next_mesh_line_y = LOGICAL_Y_POSITION(mesh_index_to_ypos(current_yi));
251
+        const float next_mesh_line_y = mesh_index_to_ypos(current_yi);
252
 
252
 
253
         /**
253
         /**
254
          * if the slope of the line is infinite, we won't do the calculations
254
          * if the slope of the line is infinite, we won't do the calculations
255
          * else, we know the next X is the same so we can recover and continue!
255
          * else, we know the next X is the same so we can recover and continue!
256
          * Calculate X at the next Y mesh line
256
          * Calculate X at the next Y mesh line
257
          */
257
          */
258
-        const float x = inf_m_flag ? start[X_AXIS] : (next_mesh_line_y - c) / m;
258
+        const float rx = inf_m_flag ? start[X_AXIS] : (next_mesh_line_y - c) / m;
259
 
259
 
260
-        float z0 = z_correction_for_x_on_horizontal_mesh_line(x, current_xi, current_yi)
260
+        float z0 = z_correction_for_x_on_horizontal_mesh_line(rx, current_xi, current_yi)
261
                    * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
261
                    * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
262
 
262
 
263
         /**
263
         /**
269
          */
269
          */
270
         if (isnan(z0)) z0 = 0.0;
270
         if (isnan(z0)) z0 = 0.0;
271
 
271
 
272
-        const float y = LOGICAL_Y_POSITION(mesh_index_to_ypos(current_yi));
272
+        const float ry = mesh_index_to_ypos(current_yi);
273
 
273
 
274
         /**
274
         /**
275
          * Without this check, it is possible for the algorithm to generate a zero length move in the case
275
          * Without this check, it is possible for the algorithm to generate a zero length move in the case
277
          * happens, it might be best to remove the check and always 'schedule' the move because
277
          * happens, it might be best to remove the check and always 'schedule' the move because
278
          * the planner._buffer_line() routine will filter it if that happens.
278
          * the planner._buffer_line() routine will filter it if that happens.
279
          */
279
          */
280
-        if (y != start[Y_AXIS]) {
280
+        if (ry != start[Y_AXIS]) {
281
           if (!inf_normalized_flag) {
281
           if (!inf_normalized_flag) {
282
-            on_axis_distance = use_x_dist ? x - start[X_AXIS] : y - start[Y_AXIS];
282
+            on_axis_distance = use_x_dist ? rx - start[X_AXIS] : ry - start[Y_AXIS];
283
             e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
283
             e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
284
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
284
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
285
           }
285
           }
288
             z_position = end[Z_AXIS];
288
             z_position = end[Z_AXIS];
289
           }
289
           }
290
 
290
 
291
-          planner._buffer_line(x, y, z_position + z0, e_position, feed_rate, extruder);
291
+          planner._buffer_line(rx, ry, z_position + z0, e_position, feed_rate, extruder);
292
         } //else printf("FIRST MOVE PRUNED  ");
292
         } //else printf("FIRST MOVE PRUNED  ");
293
       }
293
       }
294
 
294
 
318
                                 // edge of this cell for the first move.
318
                                 // edge of this cell for the first move.
319
       while (current_xi != cell_dest_xi + left_flag) {
319
       while (current_xi != cell_dest_xi + left_flag) {
320
         current_xi += dxi;
320
         current_xi += dxi;
321
-        const float next_mesh_line_x = LOGICAL_X_POSITION(mesh_index_to_xpos(current_xi)),
322
-                    y = m * next_mesh_line_x + c;   // Calculate Y at the next X mesh line
321
+        const float next_mesh_line_x = mesh_index_to_xpos(current_xi),
322
+                    ry = m * next_mesh_line_x + c;   // Calculate Y at the next X mesh line
323
 
323
 
324
-        float z0 = z_correction_for_y_on_vertical_mesh_line(y, current_xi, current_yi)
324
+        float z0 = z_correction_for_y_on_vertical_mesh_line(ry, current_xi, current_yi)
325
                    * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
325
                    * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
326
 
326
 
327
         /**
327
         /**
333
          */
333
          */
334
         if (isnan(z0)) z0 = 0.0;
334
         if (isnan(z0)) z0 = 0.0;
335
 
335
 
336
-        const float x = LOGICAL_X_POSITION(mesh_index_to_xpos(current_xi));
336
+        const float rx = mesh_index_to_xpos(current_xi);
337
 
337
 
338
         /**
338
         /**
339
          * Without this check, it is possible for the algorithm to generate a zero length move in the case
339
          * Without this check, it is possible for the algorithm to generate a zero length move in the case
341
          * that happens, it might be best to remove the check and always 'schedule' the move because
341
          * that happens, it might be best to remove the check and always 'schedule' the move because
342
          * the planner._buffer_line() routine will filter it if that happens.
342
          * the planner._buffer_line() routine will filter it if that happens.
343
          */
343
          */
344
-        if (x != start[X_AXIS]) {
344
+        if (rx != start[X_AXIS]) {
345
           if (!inf_normalized_flag) {
345
           if (!inf_normalized_flag) {
346
-            on_axis_distance = use_x_dist ? x - start[X_AXIS] : y - start[Y_AXIS];
346
+            on_axis_distance = use_x_dist ? rx - start[X_AXIS] : ry - start[Y_AXIS];
347
             e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;  // is based on X or Y because this is a horizontal move
347
             e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;  // is based on X or Y because this is a horizontal move
348
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
348
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
349
           }
349
           }
352
             z_position = end[Z_AXIS];
352
             z_position = end[Z_AXIS];
353
           }
353
           }
354
 
354
 
355
-          planner._buffer_line(x, y, z_position + z0, e_position, feed_rate, extruder);
355
+          planner._buffer_line(rx, ry, z_position + z0, e_position, feed_rate, extruder);
356
         } //else printf("FIRST MOVE PRUNED  ");
356
         } //else printf("FIRST MOVE PRUNED  ");
357
       }
357
       }
358
 
358
 
383
 
383
 
384
     while (xi_cnt > 0 || yi_cnt > 0) {
384
     while (xi_cnt > 0 || yi_cnt > 0) {
385
 
385
 
386
-      const float next_mesh_line_x = LOGICAL_X_POSITION(mesh_index_to_xpos(current_xi + dxi)),
387
-                  next_mesh_line_y = LOGICAL_Y_POSITION(mesh_index_to_ypos(current_yi + dyi)),
388
-                  y = m * next_mesh_line_x + c,   // Calculate Y at the next X mesh line
389
-                  x = (next_mesh_line_y - c) / m; // Calculate X at the next Y mesh line
390
-                                                  // (No need to worry about m being zero.
391
-                                                  //  If that was the case, it was already detected
392
-                                                  //  as a vertical line move above.)
386
+      const float next_mesh_line_x = mesh_index_to_xpos(current_xi + dxi),
387
+                  next_mesh_line_y = mesh_index_to_ypos(current_yi + dyi),
388
+                  ry = m * next_mesh_line_x + c,   // Calculate Y at the next X mesh line
389
+                  rx = (next_mesh_line_y - c) / m; // Calculate X at the next Y mesh line
390
+                                                   // (No need to worry about m being zero.
391
+                                                   //  If that was the case, it was already detected
392
+                                                   //  as a vertical line move above.)
393
 
393
 
394
-      if (left_flag == (x > next_mesh_line_x)) { // Check if we hit the Y line first
394
+      if (left_flag == (rx > next_mesh_line_x)) { // Check if we hit the Y line first
395
         // Yes!  Crossing a Y Mesh Line next
395
         // Yes!  Crossing a Y Mesh Line next
396
-        float z0 = z_correction_for_x_on_horizontal_mesh_line(x, current_xi - left_flag, current_yi + dyi)
396
+        float z0 = z_correction_for_x_on_horizontal_mesh_line(rx, current_xi - left_flag, current_yi + dyi)
397
                    * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
397
                    * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
398
 
398
 
399
         /**
399
         /**
406
         if (isnan(z0)) z0 = 0.0;
406
         if (isnan(z0)) z0 = 0.0;
407
 
407
 
408
         if (!inf_normalized_flag) {
408
         if (!inf_normalized_flag) {
409
-          on_axis_distance = use_x_dist ? x - start[X_AXIS] : next_mesh_line_y - start[Y_AXIS];
409
+          on_axis_distance = use_x_dist ? rx - start[X_AXIS] : next_mesh_line_y - start[Y_AXIS];
410
           e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
410
           e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
411
           z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
411
           z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
412
         }
412
         }
414
           e_position = end[E_AXIS];
414
           e_position = end[E_AXIS];
415
           z_position = end[Z_AXIS];
415
           z_position = end[Z_AXIS];
416
         }
416
         }
417
-        planner._buffer_line(x, next_mesh_line_y, z_position + z0, e_position, feed_rate, extruder);
417
+        planner._buffer_line(rx, next_mesh_line_y, z_position + z0, e_position, feed_rate, extruder);
418
         current_yi += dyi;
418
         current_yi += dyi;
419
         yi_cnt--;
419
         yi_cnt--;
420
       }
420
       }
421
       else {
421
       else {
422
         // Yes!  Crossing a X Mesh Line next
422
         // Yes!  Crossing a X Mesh Line next
423
-        float z0 = z_correction_for_y_on_vertical_mesh_line(y, current_xi + dxi, current_yi - down_flag)
423
+        float z0 = z_correction_for_y_on_vertical_mesh_line(ry, current_xi + dxi, current_yi - down_flag)
424
                    * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
424
                    * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
425
 
425
 
426
         /**
426
         /**
433
         if (isnan(z0)) z0 = 0.0;
433
         if (isnan(z0)) z0 = 0.0;
434
 
434
 
435
         if (!inf_normalized_flag) {
435
         if (!inf_normalized_flag) {
436
-          on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : y - start[Y_AXIS];
436
+          on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : ry - start[Y_AXIS];
437
           e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
437
           e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
438
           z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
438
           z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
439
         }
439
         }
442
           z_position = end[Z_AXIS];
442
           z_position = end[Z_AXIS];
443
         }
443
         }
444
 
444
 
445
-        planner._buffer_line(next_mesh_line_x, y, z_position + z0, e_position, feed_rate, extruder);
445
+        planner._buffer_line(next_mesh_line_x, ry, z_position + z0, e_position, feed_rate, extruder);
446
         current_xi += dxi;
446
         current_xi += dxi;
447
         xi_cnt--;
447
         xi_cnt--;
448
       }
448
       }
476
     // We don't want additional apply_leveling() performed by regular buffer_line or buffer_line_kinematic,
476
     // We don't want additional apply_leveling() performed by regular buffer_line or buffer_line_kinematic,
477
     // so we call _buffer_line directly here.  Per-segmented leveling and kinematics performed first.
477
     // so we call _buffer_line directly here.  Per-segmented leveling and kinematics performed first.
478
 
478
 
479
-    inline void _O2 ubl_buffer_segment_raw( float rx, float ry, float rz, float le, float fr ) {
479
+    inline void _O2 ubl_buffer_segment_raw(const float &rx, const float &ry, const float rz, const float &e, const float &fr) {
480
 
480
 
481
       #if ENABLED(DELTA)  // apply delta inverse_kinematics
481
       #if ENABLED(DELTA)  // apply delta inverse_kinematics
482
 
482
 
492
                                          - HYPOT2( delta_tower[C_AXIS][X_AXIS] - rx,
492
                                          - HYPOT2( delta_tower[C_AXIS][X_AXIS] - rx,
493
                                                    delta_tower[C_AXIS][Y_AXIS] - ry ));
493
                                                    delta_tower[C_AXIS][Y_AXIS] - ry ));
494
 
494
 
495
-        planner._buffer_line(delta_A, delta_B, delta_C, le, fr, active_extruder);
495
+        planner._buffer_line(delta_A, delta_B, delta_C, e, fr, active_extruder);
496
 
496
 
497
       #elif IS_SCARA  // apply scara inverse_kinematics (should be changed to save raw->logical->raw)
497
       #elif IS_SCARA  // apply scara inverse_kinematics (should be changed to save raw->logical->raw)
498
 
498
 
499
-        const float lseg[XYZ] = { LOGICAL_X_POSITION(rx),
500
-                                  LOGICAL_Y_POSITION(ry),
501
-                                  LOGICAL_Z_POSITION(rz)
502
-                                };
499
+        const float lseg[XYZ] = { rx, ry, rz };
503
 
500
 
504
         inverse_kinematics(lseg); // this writes delta[ABC] from lseg[XYZ]
501
         inverse_kinematics(lseg); // this writes delta[ABC] from lseg[XYZ]
505
                                   // should move the feedrate scaling to scara inverse_kinematics
502
                                   // should move the feedrate scaling to scara inverse_kinematics
510
         scara_oldB = delta[B_AXIS];
507
         scara_oldB = delta[B_AXIS];
511
         float s_feedrate = max(adiff, bdiff) * scara_feed_factor;
508
         float s_feedrate = max(adiff, bdiff) * scara_feed_factor;
512
 
509
 
513
-        planner._buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], le, s_feedrate, active_extruder);
510
+        planner._buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], e, s_feedrate, active_extruder);
514
 
511
 
515
       #else // CARTESIAN
512
       #else // CARTESIAN
516
 
513
 
517
-        // Cartesian _buffer_line seems to take LOGICAL, not RAW coordinates
518
-
519
-        const float lx = LOGICAL_X_POSITION(rx),
520
-                    ly = LOGICAL_Y_POSITION(ry),
521
-                    lz = LOGICAL_Z_POSITION(rz);
522
-
523
-        planner._buffer_line(lx, ly, lz, le, fr, active_extruder);
514
+        planner._buffer_line(rx, ry, rz, e, fr, active_extruder);
524
 
515
 
525
       #endif
516
       #endif
526
 
517
 
533
      * Returns true if did NOT move, false if moved (requires current_position update).
524
      * Returns true if did NOT move, false if moved (requires current_position update).
534
      */
525
      */
535
 
526
 
536
-    bool _O2 unified_bed_leveling::prepare_segmented_line_to(const float ltarget[XYZE], const float &feedrate) {
527
+    bool _O2 unified_bed_leveling::prepare_segmented_line_to(const float rtarget[XYZE], const float &feedrate) {
537
 
528
 
538
-      if (!position_is_reachable_xy(ltarget[X_AXIS], ltarget[Y_AXIS]))  // fail if moving outside reachable boundary
529
+      if (!position_is_reachable(rtarget[X_AXIS], rtarget[Y_AXIS]))  // fail if moving outside reachable boundary
539
         return true; // did not move, so current_position still accurate
530
         return true; // did not move, so current_position still accurate
540
 
531
 
541
-      const float tot_dx = ltarget[X_AXIS] - current_position[X_AXIS],
542
-                  tot_dy = ltarget[Y_AXIS] - current_position[Y_AXIS],
543
-                  tot_dz = ltarget[Z_AXIS] - current_position[Z_AXIS],
544
-                  tot_de = ltarget[E_AXIS] - current_position[E_AXIS];
532
+      const float tot_dx = rtarget[X_AXIS] - current_position[X_AXIS],
533
+                  tot_dy = rtarget[Y_AXIS] - current_position[Y_AXIS],
534
+                  tot_dz = rtarget[Z_AXIS] - current_position[Z_AXIS],
535
+                  tot_de = rtarget[E_AXIS] - current_position[E_AXIS];
545
 
536
 
546
       const float cartesian_xy_mm = HYPOT(tot_dx, tot_dy);  // total horizontal xy distance
537
       const float cartesian_xy_mm = HYPOT(tot_dx, tot_dy);  // total horizontal xy distance
547
 
538
 
571
       // Note that E segment distance could vary slightly as z mesh height
562
       // Note that E segment distance could vary slightly as z mesh height
572
       // changes for each segment, but small enough to ignore.
563
       // changes for each segment, but small enough to ignore.
573
 
564
 
574
-      float seg_rx = RAW_X_POSITION(current_position[X_AXIS]),
575
-            seg_ry = RAW_Y_POSITION(current_position[Y_AXIS]),
576
-            seg_rz = RAW_Z_POSITION(current_position[Z_AXIS]),
565
+      float seg_rx = current_position[X_AXIS],
566
+            seg_ry = current_position[Y_AXIS],
567
+            seg_rz = current_position[Z_AXIS],
577
             seg_le = current_position[E_AXIS];
568
             seg_le = current_position[E_AXIS];
578
 
569
 
579
       // Only compute leveling per segment if ubl active and target below z_fade_height.
570
       // Only compute leveling per segment if ubl active and target below z_fade_height.
580
 
571
 
581
-      if (!planner.leveling_active || !planner.leveling_active_at_z(ltarget[Z_AXIS])) {   // no mesh leveling
572
+      if (!planner.leveling_active || !planner.leveling_active_at_z(rtarget[Z_AXIS])) {   // no mesh leveling
582
 
573
 
583
         do {
574
         do {
584
 
575
 
588
             seg_rz += seg_dz;
579
             seg_rz += seg_dz;
589
             seg_le += seg_de;
580
             seg_le += seg_de;
590
           } else {              // last segment, use exact destination
581
           } else {              // last segment, use exact destination
591
-            seg_rx = RAW_X_POSITION(ltarget[X_AXIS]);
592
-            seg_ry = RAW_Y_POSITION(ltarget[Y_AXIS]);
593
-            seg_rz = RAW_Z_POSITION(ltarget[Z_AXIS]);
594
-            seg_le = ltarget[E_AXIS];
582
+            seg_rx = rtarget[X_AXIS];
583
+            seg_ry = rtarget[Y_AXIS];
584
+            seg_rz = rtarget[Z_AXIS];
585
+            seg_le = rtarget[E_AXIS];
595
           }
586
           }
596
 
587
 
597
-          ubl_buffer_segment_raw( seg_rx, seg_ry, seg_rz, seg_le, feedrate );
588
+          ubl_buffer_segment_raw(seg_rx, seg_ry, seg_rz, seg_le, feedrate);
598
 
589
 
599
         } while (segments);
590
         } while (segments);
600
 
591
 
604
       // Otherwise perform per-segment leveling
595
       // Otherwise perform per-segment leveling
605
 
596
 
606
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
597
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
607
-        const float fade_scaling_factor = planner.fade_scaling_factor_for_z(ltarget[Z_AXIS]);
598
+        const float fade_scaling_factor = planner.fade_scaling_factor_for_z(rtarget[Z_AXIS]);
608
       #endif
599
       #endif
609
 
600
 
610
       // increment to first segment destination
601
       // increment to first segment destination
671
             z_cxcy *= fade_scaling_factor;          // apply fade factor to interpolated mesh height
662
             z_cxcy *= fade_scaling_factor;          // apply fade factor to interpolated mesh height
672
           #endif
663
           #endif
673
 
664
 
674
-          if (--segments == 0) {                    // if this is last segment, use ltarget for exact
675
-            seg_rx = RAW_X_POSITION(ltarget[X_AXIS]);
676
-            seg_ry = RAW_Y_POSITION(ltarget[Y_AXIS]);
677
-            seg_rz = RAW_Z_POSITION(ltarget[Z_AXIS]);
678
-            seg_le = ltarget[E_AXIS];
665
+          if (--segments == 0) {                    // if this is last segment, use rtarget for exact
666
+            seg_rx = rtarget[X_AXIS];
667
+            seg_ry = rtarget[Y_AXIS];
668
+            seg_rz = rtarget[Z_AXIS];
669
+            seg_le = rtarget[E_AXIS];
679
           }
670
           }
680
 
671
 
681
-          ubl_buffer_segment_raw( seg_rx, seg_ry, seg_rz + z_cxcy, seg_le, feedrate );
672
+          ubl_buffer_segment_raw(seg_rx, seg_ry, seg_rz + z_cxcy, seg_le, feedrate);
682
 
673
 
683
-          if (segments == 0 )                       // done with last segment
674
+          if (segments == 0)                        // done with last segment
684
             return false;                           // did not set_current_from_destination()
675
             return false;                           // did not set_current_from_destination()
685
 
676
 
686
           seg_rx += seg_dx;
677
           seg_rx += seg_dx;

+ 2
- 2
Marlin/src/gcode/bedlevel/G42.cpp Wyświetl plik

56
     #endif
56
     #endif
57
 
57
 
58
     set_destination_from_current();
58
     set_destination_from_current();
59
-    if (hasI) destination[X_AXIS] = LOGICAL_X_POSITION(_GET_MESH_X(ix));
60
-    if (hasJ) destination[Y_AXIS] = LOGICAL_Y_POSITION(_GET_MESH_Y(iy));
59
+    if (hasI) destination[X_AXIS] = _GET_MESH_X(ix);
60
+    if (hasJ) destination[Y_AXIS] = _GET_MESH_Y(iy);
61
     if (parser.boolval('P')) {
61
     if (parser.boolval('P')) {
62
       if (hasI) destination[X_AXIS] -= X_PROBE_OFFSET_FROM_EXTRUDER;
62
       if (hasI) destination[X_AXIS] -= X_PROBE_OFFSET_FROM_EXTRUDER;
63
       if (hasJ) destination[Y_AXIS] -= Y_PROBE_OFFSET_FROM_EXTRUDER;
63
       if (hasJ) destination[Y_AXIS] -= Y_PROBE_OFFSET_FROM_EXTRUDER;

+ 32
- 32
Marlin/src/gcode/bedlevel/abl/G29.cpp Wyświetl plik

258
           return;
258
           return;
259
         }
259
         }
260
 
260
 
261
-        const float z = parser.floatval('Z', RAW_CURRENT_POSITION(Z));
262
-        if (!WITHIN(z, -10, 10)) {
261
+        const float rz = parser.seenval('Z') ? RAW_Z_POSITION(parser.value_linear_units()) : current_position[Z_AXIS];
262
+        if (!WITHIN(rz, -10, 10)) {
263
           SERIAL_ERROR_START();
263
           SERIAL_ERROR_START();
264
           SERIAL_ERRORLNPGM("Bad Z value");
264
           SERIAL_ERRORLNPGM("Bad Z value");
265
           return;
265
           return;
266
         }
266
         }
267
 
267
 
268
-        const float x = parser.floatval('X', NAN),
269
-                    y = parser.floatval('Y', NAN);
268
+        const float rx = RAW_X_POSITION(parser.linearval('X', NAN)),
269
+                    ry = RAW_Y_POSITION(parser.linearval('Y', NAN));
270
         int8_t i = parser.byteval('I', -1),
270
         int8_t i = parser.byteval('I', -1),
271
                j = parser.byteval('J', -1);
271
                j = parser.byteval('J', -1);
272
 
272
 
273
-        if (!isnan(x) && !isnan(y)) {
274
-          // Get nearest i / j from x / y
275
-          i = (x - LOGICAL_X_POSITION(bilinear_start[X_AXIS]) + 0.5 * xGridSpacing) / xGridSpacing;
276
-          j = (y - LOGICAL_Y_POSITION(bilinear_start[Y_AXIS]) + 0.5 * yGridSpacing) / yGridSpacing;
273
+        if (!isnan(rx) && !isnan(ry)) {
274
+          // Get nearest i / j from rx / ry
275
+          i = (rx - bilinear_start[X_AXIS] + 0.5 * xGridSpacing) / xGridSpacing;
276
+          j = (ry - bilinear_start[Y_AXIS] + 0.5 * yGridSpacing) / yGridSpacing;
277
           i = constrain(i, 0, GRID_MAX_POINTS_X - 1);
277
           i = constrain(i, 0, GRID_MAX_POINTS_X - 1);
278
           j = constrain(j, 0, GRID_MAX_POINTS_Y - 1);
278
           j = constrain(j, 0, GRID_MAX_POINTS_Y - 1);
279
         }
279
         }
280
         if (WITHIN(i, 0, GRID_MAX_POINTS_X - 1) && WITHIN(j, 0, GRID_MAX_POINTS_Y)) {
280
         if (WITHIN(i, 0, GRID_MAX_POINTS_X - 1) && WITHIN(j, 0, GRID_MAX_POINTS_Y)) {
281
           set_bed_leveling_enabled(false);
281
           set_bed_leveling_enabled(false);
282
-          z_values[i][j] = z;
282
+          z_values[i][j] = rz;
283
           #if ENABLED(ABL_BILINEAR_SUBDIVISION)
283
           #if ENABLED(ABL_BILINEAR_SUBDIVISION)
284
             bed_level_virt_interpolate();
284
             bed_level_virt_interpolate();
285
           #endif
285
           #endif
340
 
340
 
341
       xy_probe_feedrate_mm_s = MMM_TO_MMS(parser.linearval('S', XY_PROBE_SPEED));
341
       xy_probe_feedrate_mm_s = MMM_TO_MMS(parser.linearval('S', XY_PROBE_SPEED));
342
 
342
 
343
-      left_probe_bed_position = (int)parser.linearval('L', LOGICAL_X_POSITION(LEFT_PROBE_BED_POSITION));
344
-      right_probe_bed_position = (int)parser.linearval('R', LOGICAL_X_POSITION(RIGHT_PROBE_BED_POSITION));
345
-      front_probe_bed_position = (int)parser.linearval('F', LOGICAL_Y_POSITION(FRONT_PROBE_BED_POSITION));
346
-      back_probe_bed_position = (int)parser.linearval('B', LOGICAL_Y_POSITION(BACK_PROBE_BED_POSITION));
347
-
348
-      const bool left_out_l = left_probe_bed_position < LOGICAL_X_POSITION(MIN_PROBE_X),
343
+      left_probe_bed_position  = parser.seenval('L') ? (int)RAW_X_POSITION(parser.value_linear_units()) : LEFT_PROBE_BED_POSITION;
344
+      right_probe_bed_position = parser.seenval('R') ? (int)RAW_X_POSITION(parser.value_linear_units()) : RIGHT_PROBE_BED_POSITION;
345
+      front_probe_bed_position = parser.seenval('F') ? (int)RAW_Y_POSITION(parser.value_linear_units()) : FRONT_PROBE_BED_POSITION;
346
+      back_probe_bed_position  = parser.seenval('B') ? (int)RAW_Y_POSITION(parser.value_linear_units()) : BACK_PROBE_BED_POSITION;
347
+  
348
+      const bool left_out_l = left_probe_bed_position < MIN_PROBE_X,
349
                  left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - (MIN_PROBE_EDGE),
349
                  left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - (MIN_PROBE_EDGE),
350
-                 right_out_r = right_probe_bed_position > LOGICAL_X_POSITION(MAX_PROBE_X),
350
+                 right_out_r = right_probe_bed_position > MAX_PROBE_X,
351
                  right_out = right_out_r || right_probe_bed_position < left_probe_bed_position + MIN_PROBE_EDGE,
351
                  right_out = right_out_r || right_probe_bed_position < left_probe_bed_position + MIN_PROBE_EDGE,
352
-                 front_out_f = front_probe_bed_position < LOGICAL_Y_POSITION(MIN_PROBE_Y),
352
+                 front_out_f = front_probe_bed_position < MIN_PROBE_Y,
353
                  front_out = front_out_f || front_probe_bed_position > back_probe_bed_position - (MIN_PROBE_EDGE),
353
                  front_out = front_out_f || front_probe_bed_position > back_probe_bed_position - (MIN_PROBE_EDGE),
354
-                 back_out_b = back_probe_bed_position > LOGICAL_Y_POSITION(MAX_PROBE_Y),
354
+                 back_out_b = back_probe_bed_position > MAX_PROBE_Y,
355
                  back_out = back_out_b || back_probe_bed_position < front_probe_bed_position + MIN_PROBE_EDGE;
355
                  back_out = back_out_b || back_probe_bed_position < front_probe_bed_position + MIN_PROBE_EDGE;
356
 
356
 
357
       if (left_out || right_out || front_out || back_out) {
357
       if (left_out || right_out || front_out || back_out) {
358
         if (left_out) {
358
         if (left_out) {
359
           out_of_range_error(PSTR("(L)eft"));
359
           out_of_range_error(PSTR("(L)eft"));
360
-          left_probe_bed_position = left_out_l ? LOGICAL_X_POSITION(MIN_PROBE_X) : right_probe_bed_position - (MIN_PROBE_EDGE);
360
+          left_probe_bed_position = left_out_l ? MIN_PROBE_X : right_probe_bed_position - (MIN_PROBE_EDGE);
361
         }
361
         }
362
         if (right_out) {
362
         if (right_out) {
363
           out_of_range_error(PSTR("(R)ight"));
363
           out_of_range_error(PSTR("(R)ight"));
364
-          right_probe_bed_position = right_out_r ? LOGICAL_Y_POSITION(MAX_PROBE_X) : left_probe_bed_position + MIN_PROBE_EDGE;
364
+          right_probe_bed_position = right_out_r ? MAX_PROBE_X : left_probe_bed_position + MIN_PROBE_EDGE;
365
         }
365
         }
366
         if (front_out) {
366
         if (front_out) {
367
           out_of_range_error(PSTR("(F)ront"));
367
           out_of_range_error(PSTR("(F)ront"));
368
-          front_probe_bed_position = front_out_f ? LOGICAL_Y_POSITION(MIN_PROBE_Y) : back_probe_bed_position - (MIN_PROBE_EDGE);
368
+          front_probe_bed_position = front_out_f ? MIN_PROBE_Y : back_probe_bed_position - (MIN_PROBE_EDGE);
369
         }
369
         }
370
         if (back_out) {
370
         if (back_out) {
371
           out_of_range_error(PSTR("(B)ack"));
371
           out_of_range_error(PSTR("(B)ack"));
372
-          back_probe_bed_position = back_out_b ? LOGICAL_Y_POSITION(MAX_PROBE_Y) : front_probe_bed_position + MIN_PROBE_EDGE;
372
+          back_probe_bed_position = back_out_b ? MAX_PROBE_Y : front_probe_bed_position + MIN_PROBE_EDGE;
373
         }
373
         }
374
         return;
374
         return;
375
       }
375
       }
416
       #endif
416
       #endif
417
       if ( xGridSpacing != bilinear_grid_spacing[X_AXIS]
417
       if ( xGridSpacing != bilinear_grid_spacing[X_AXIS]
418
         || yGridSpacing != bilinear_grid_spacing[Y_AXIS]
418
         || yGridSpacing != bilinear_grid_spacing[Y_AXIS]
419
-        || left_probe_bed_position != LOGICAL_X_POSITION(bilinear_start[X_AXIS])
420
-        || front_probe_bed_position != LOGICAL_Y_POSITION(bilinear_start[Y_AXIS])
419
+        || left_probe_bed_position != bilinear_start[X_AXIS]
420
+        || front_probe_bed_position != bilinear_start[Y_AXIS]
421
       ) {
421
       ) {
422
         if (dryrun) {
422
         if (dryrun) {
423
           // Before reset bed level, re-enable to correct the position
423
           // Before reset bed level, re-enable to correct the position
429
         // Initialize a grid with the given dimensions
429
         // Initialize a grid with the given dimensions
430
         bilinear_grid_spacing[X_AXIS] = xGridSpacing;
430
         bilinear_grid_spacing[X_AXIS] = xGridSpacing;
431
         bilinear_grid_spacing[Y_AXIS] = yGridSpacing;
431
         bilinear_grid_spacing[Y_AXIS] = yGridSpacing;
432
-        bilinear_start[X_AXIS] = RAW_X_POSITION(left_probe_bed_position);
433
-        bilinear_start[Y_AXIS] = RAW_Y_POSITION(front_probe_bed_position);
432
+        bilinear_start[X_AXIS] = left_probe_bed_position;
433
+        bilinear_start[Y_AXIS] = front_probe_bed_position;
434
 
434
 
435
         // Can't re-enable (on error) until the new grid is written
435
         // Can't re-enable (on error) until the new grid is written
436
         abl_should_enable = false;
436
         abl_should_enable = false;
555
         #endif
555
         #endif
556
 
556
 
557
         // Keep looping till a reachable point is found
557
         // Keep looping till a reachable point is found
558
-        if (position_is_reachable_xy(xProbe, yProbe)) break;
558
+        if (position_is_reachable(xProbe, yProbe)) break;
559
         ++abl_probe_index;
559
         ++abl_probe_index;
560
       }
560
       }
561
 
561
 
585
 
585
 
586
       // Probe at 3 arbitrary points
586
       // Probe at 3 arbitrary points
587
       if (abl_probe_index < 3) {
587
       if (abl_probe_index < 3) {
588
-        xProbe = LOGICAL_X_POSITION(points[abl_probe_index].x);
589
-        yProbe = LOGICAL_Y_POSITION(points[abl_probe_index].y);
588
+        xProbe = points[abl_probe_index].x;
589
+        yProbe = points[abl_probe_index].y;
590
         #if HAS_SOFTWARE_ENDSTOPS
590
         #if HAS_SOFTWARE_ENDSTOPS
591
           // Disable software endstops to allow manual adjustment
591
           // Disable software endstops to allow manual adjustment
592
           // If G29 is not completed, they will not be re-enabled
592
           // If G29 is not completed, they will not be re-enabled
663
 
663
 
664
           #if IS_KINEMATIC
664
           #if IS_KINEMATIC
665
             // Avoid probing outside the round or hexagonal area
665
             // Avoid probing outside the round or hexagonal area
666
-            if (!position_is_reachable_by_probe_xy(xProbe, yProbe)) continue;
666
+            if (!position_is_reachable_by_probe(xProbe, yProbe)) continue;
667
           #endif
667
           #endif
668
 
668
 
669
           measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
669
           measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
701
 
701
 
702
       for (uint8_t i = 0; i < 3; ++i) {
702
       for (uint8_t i = 0; i < 3; ++i) {
703
         // Retain the last probe position
703
         // Retain the last probe position
704
-        xProbe = LOGICAL_X_POSITION(points[i].x);
705
-        yProbe = LOGICAL_Y_POSITION(points[i].y);
704
+        xProbe = points[i].x;
705
+        yProbe = points[i].y;
706
         measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
706
         measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
707
         if (isnan(measured_z)) {
707
         if (isnan(measured_z)) {
708
           planner.leveling_active = abl_should_enable;
708
           planner.leveling_active = abl_should_enable;

+ 2
- 2
Marlin/src/gcode/bedlevel/mbl/G29.cpp Wyświetl plik

46
   gcode.home_all_axes();
46
   gcode.home_all_axes();
47
   set_bed_leveling_enabled(true);
47
   set_bed_leveling_enabled(true);
48
   #if ENABLED(MESH_G28_REST_ORIGIN)
48
   #if ENABLED(MESH_G28_REST_ORIGIN)
49
-    current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS);
49
+    current_position[Z_AXIS] = Z_MIN_POS;
50
     set_destination_from_current();
50
     set_destination_from_current();
51
     line_to_destination(homing_feedrate(Z_AXIS));
51
     line_to_destination(homing_feedrate(Z_AXIS));
52
     stepper.synchronize();
52
     stepper.synchronize();
139
       }
139
       }
140
       else {
140
       else {
141
         // One last "return to the bed" (as originally coded) at completion
141
         // One last "return to the bed" (as originally coded) at completion
142
-        current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT;
142
+        current_position[Z_AXIS] = Z_MIN_POS + MANUAL_PROBE_HEIGHT;
143
         line_to_current_position();
143
         line_to_current_position();
144
         stepper.synchronize();
144
         stepper.synchronize();
145
 
145
 

+ 5
- 5
Marlin/src/gcode/calibrate/G28.cpp Wyświetl plik

86
     /**
86
     /**
87
      * Move the Z probe (or just the nozzle) to the safe homing point
87
      * Move the Z probe (or just the nozzle) to the safe homing point
88
      */
88
      */
89
-    destination[X_AXIS] = LOGICAL_X_POSITION(Z_SAFE_HOMING_X_POINT);
90
-    destination[Y_AXIS] = LOGICAL_Y_POSITION(Z_SAFE_HOMING_Y_POINT);
89
+    destination[X_AXIS] = Z_SAFE_HOMING_X_POINT;
90
+    destination[Y_AXIS] = Z_SAFE_HOMING_Y_POINT;
91
     destination[Z_AXIS] = current_position[Z_AXIS]; // Z is already at the right height
91
     destination[Z_AXIS] = current_position[Z_AXIS]; // Z is already at the right height
92
 
92
 
93
     #if HOMING_Z_WITH_PROBE
93
     #if HOMING_Z_WITH_PROBE
95
       destination[Y_AXIS] -= Y_PROBE_OFFSET_FROM_EXTRUDER;
95
       destination[Y_AXIS] -= Y_PROBE_OFFSET_FROM_EXTRUDER;
96
     #endif
96
     #endif
97
 
97
 
98
-    if (position_is_reachable_xy(destination[X_AXIS], destination[Y_AXIS])) {
98
+    if (position_is_reachable(destination[X_AXIS], destination[Y_AXIS])) {
99
 
99
 
100
       #if ENABLED(DEBUG_LEVELING_FEATURE)
100
       #if ENABLED(DEBUG_LEVELING_FEATURE)
101
         if (DEBUGGING(LEVELING)) DEBUG_POS("Z_SAFE_HOMING", destination);
101
         if (DEBUGGING(LEVELING)) DEBUG_POS("Z_SAFE_HOMING", destination);
209
 
209
 
210
       if (home_all || homeX || homeY) {
210
       if (home_all || homeX || homeY) {
211
         // Raise Z before homing any other axes and z is not already high enough (never lower z)
211
         // Raise Z before homing any other axes and z is not already high enough (never lower z)
212
-        destination[Z_AXIS] = LOGICAL_Z_POSITION(Z_HOMING_HEIGHT);
212
+        destination[Z_AXIS] = Z_HOMING_HEIGHT;
213
         if (destination[Z_AXIS] > current_position[Z_AXIS]) {
213
         if (destination[Z_AXIS] > current_position[Z_AXIS]) {
214
 
214
 
215
           #if ENABLED(DEBUG_LEVELING_FEATURE)
215
           #if ENABLED(DEBUG_LEVELING_FEATURE)
251
         HOMEAXIS(X);
251
         HOMEAXIS(X);
252
 
252
 
253
         // Remember this extruder's position for later tool change
253
         // Remember this extruder's position for later tool change
254
-        inactive_extruder_x_pos = RAW_X_POSITION(current_position[X_AXIS]);
254
+        inactive_extruder_x_pos = current_position[X_AXIS];
255
 
255
 
256
         // Home the 1st (left) extruder
256
         // Home the 1st (left) extruder
257
         active_extruder = 0;
257
         active_extruder = 0;

+ 1
- 1
Marlin/src/gcode/calibrate/G33.cpp Wyświetl plik

459
     LOOP_CAL_RAD(axis) {
459
     LOOP_CAL_RAD(axis) {
460
       const float a = RADIANS(210 + (360 / NPP) *  (axis - 1)),
460
       const float a = RADIANS(210 + (360 / NPP) *  (axis - 1)),
461
                   r = delta_calibration_radius * (1 + (_7p_9_centre ? 0.1 : 0.0));
461
                   r = delta_calibration_radius * (1 + (_7p_9_centre ? 0.1 : 0.0));
462
-      if (!position_is_reachable_xy(cos(a) * r, sin(a) * r)) {
462
+      if (!position_is_reachable(cos(a) * r, sin(a) * r)) {
463
         SERIAL_PROTOCOLLNPGM("?(M665 B)ed radius is implausible.");
463
         SERIAL_PROTOCOLLNPGM("?(M665 B)ed radius is implausible.");
464
         return;
464
         return;
465
       }
465
       }

+ 4
- 4
Marlin/src/gcode/calibrate/M48.cpp Wyświetl plik

82
               Y_probe_location = parser.linearval('Y', Y_current + Y_PROBE_OFFSET_FROM_EXTRUDER);
82
               Y_probe_location = parser.linearval('Y', Y_current + Y_PROBE_OFFSET_FROM_EXTRUDER);
83
 
83
 
84
   #if DISABLED(DELTA)
84
   #if DISABLED(DELTA)
85
-    if (!WITHIN(X_probe_location, LOGICAL_X_POSITION(MIN_PROBE_X), LOGICAL_X_POSITION(MAX_PROBE_X))) {
85
+    if (!WITHIN(X_probe_location, MIN_PROBE_X, MAX_PROBE_X)) {
86
       out_of_range_error(PSTR("X"));
86
       out_of_range_error(PSTR("X"));
87
       return;
87
       return;
88
     }
88
     }
89
-    if (!WITHIN(Y_probe_location, LOGICAL_Y_POSITION(MIN_PROBE_Y), LOGICAL_Y_POSITION(MAX_PROBE_Y))) {
89
+    if (!WITHIN(Y_probe_location, MIN_PROBE_Y, MAX_PROBE_Y)) {
90
       out_of_range_error(PSTR("Y"));
90
       out_of_range_error(PSTR("Y"));
91
       return;
91
       return;
92
     }
92
     }
93
   #else
93
   #else
94
-    if (!position_is_reachable_by_probe_xy(X_probe_location, Y_probe_location)) {
94
+    if (!position_is_reachable_by_probe(X_probe_location, Y_probe_location)) {
95
       SERIAL_PROTOCOLLNPGM("? (X,Y) location outside of probeable radius.");
95
       SERIAL_PROTOCOLLNPGM("? (X,Y) location outside of probeable radius.");
96
       return;
96
       return;
97
     }
97
     }
184
           #else
184
           #else
185
             // If we have gone out too far, we can do a simple fix and scale the numbers
185
             // If we have gone out too far, we can do a simple fix and scale the numbers
186
             // back in closer to the origin.
186
             // back in closer to the origin.
187
-            while (!position_is_reachable_by_probe_xy(X_current, Y_current)) {
187
+            while (!position_is_reachable_by_probe(X_current, Y_current)) {
188
               X_current *= 0.8;
188
               X_current *= 0.8;
189
               Y_current *= 0.8;
189
               Y_current *= 0.8;
190
               if (verbose_level > 3) {
190
               if (verbose_level > 3) {

+ 1
- 1
Marlin/src/gcode/gcode.cpp Wyświetl plik

89
 void GcodeSuite::get_destination_from_command() {
89
 void GcodeSuite::get_destination_from_command() {
90
   LOOP_XYZE(i) {
90
   LOOP_XYZE(i) {
91
     if (parser.seen(axis_codes[i]))
91
     if (parser.seen(axis_codes[i]))
92
-      destination[i] = parser.value_axis_units((AxisEnum)i) + (axis_relative_modes[i] || relative_mode ? current_position[i] : 0);
92
+      destination[i] = LOGICAL_TO_NATIVE(parser.value_axis_units((AxisEnum)i) + (axis_relative_modes[i] || relative_mode ? current_position[i] : 0), i);
93
     else
93
     else
94
       destination[i] = current_position[i];
94
       destination[i] = current_position[i];
95
   }
95
   }

+ 1
- 1
Marlin/src/gcode/geometry/M206_M428.cpp Wyświetl plik

67
   LOOP_XYZ(i) {
67
   LOOP_XYZ(i) {
68
     if (axis_homed[i]) {
68
     if (axis_homed[i]) {
69
       const float base = (current_position[i] > (soft_endstop_min[i] + soft_endstop_max[i]) * 0.5) ? base_home_pos((AxisEnum)i) : 0,
69
       const float base = (current_position[i] > (soft_endstop_min[i] + soft_endstop_max[i]) * 0.5) ? base_home_pos((AxisEnum)i) : 0,
70
-                  diff = base - RAW_POSITION(current_position[i], i);
70
+                  diff = base - current_position[i];
71
       if (WITHIN(diff, -20, 20)) {
71
       if (WITHIN(diff, -20, 20)) {
72
         set_home_offset((AxisEnum)i, diff);
72
         set_home_offset((AxisEnum)i, diff);
73
       }
73
       }

+ 7
- 3
Marlin/src/gcode/host/M114.cpp Wyświetl plik

46
     stepper.synchronize();
46
     stepper.synchronize();
47
 
47
 
48
     SERIAL_PROTOCOLPGM("\nLogical:");
48
     SERIAL_PROTOCOLPGM("\nLogical:");
49
-    report_xyze(current_position);
49
+    const float logical[XYZ] = {
50
+      LOGICAL_X_POSITION(current_position[X_AXIS]),
51
+      LOGICAL_Y_POSITION(current_position[Y_AXIS]),
52
+      LOGICAL_Z_POSITION(current_position[Z_AXIS])
53
+    };
54
+    report_xyze(logical);
50
 
55
 
51
     SERIAL_PROTOCOLPGM("Raw:    ");
56
     SERIAL_PROTOCOLPGM("Raw:    ");
52
-    const float raw[XYZ] = { RAW_X_POSITION(current_position[X_AXIS]), RAW_Y_POSITION(current_position[Y_AXIS]), RAW_Z_POSITION(current_position[Z_AXIS]) };
53
-    report_xyz(raw);
57
+    report_xyz(current_position);
54
 
58
 
55
     SERIAL_PROTOCOLPGM("Leveled:");
59
     SERIAL_PROTOCOLPGM("Leveled:");
56
     float leveled[XYZ] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };
60
     float leveled[XYZ] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };

+ 7
- 7
Marlin/src/gcode/motion/G2_G3.cpp Wyświetl plik

44
  * options for G2/G3 arc generation. In future these options may be GCode tunable.
44
  * options for G2/G3 arc generation. In future these options may be GCode tunable.
45
  */
45
  */
46
 void plan_arc(
46
 void plan_arc(
47
-  float logical[XYZE], // Destination position
47
+  float rtarget[XYZE], // Destination position
48
   float *offset,       // Center of rotation relative to current_position
48
   float *offset,       // Center of rotation relative to current_position
49
   uint8_t clockwise    // Clockwise?
49
   uint8_t clockwise    // Clockwise?
50
 ) {
50
 ) {
65
   const float radius = HYPOT(r_P, r_Q),
65
   const float radius = HYPOT(r_P, r_Q),
66
               center_P = current_position[p_axis] - r_P,
66
               center_P = current_position[p_axis] - r_P,
67
               center_Q = current_position[q_axis] - r_Q,
67
               center_Q = current_position[q_axis] - r_Q,
68
-              rt_X = logical[p_axis] - center_P,
69
-              rt_Y = logical[q_axis] - center_Q,
70
-              linear_travel = logical[l_axis] - current_position[l_axis],
71
-              extruder_travel = logical[E_AXIS] - current_position[E_AXIS];
68
+              rt_X = rtarget[p_axis] - center_P,
69
+              rt_Y = rtarget[q_axis] - center_Q,
70
+              linear_travel = rtarget[l_axis] - current_position[l_axis],
71
+              extruder_travel = rtarget[E_AXIS] - current_position[E_AXIS];
72
 
72
 
73
   // CCW angle of rotation between position and target from the circle center. Only one atan2() trig computation required.
73
   // CCW angle of rotation between position and target from the circle center. Only one atan2() trig computation required.
74
   float angular_travel = ATAN2(r_P * rt_Y - r_Q * rt_X, r_P * rt_X + r_Q * rt_Y);
74
   float angular_travel = ATAN2(r_P * rt_Y - r_Q * rt_X, r_P * rt_X + r_Q * rt_Y);
76
   if (clockwise) angular_travel -= RADIANS(360);
76
   if (clockwise) angular_travel -= RADIANS(360);
77
 
77
 
78
   // Make a circle if the angular rotation is 0 and the target is current position
78
   // Make a circle if the angular rotation is 0 and the target is current position
79
-  if (angular_travel == 0 && current_position[p_axis] == logical[p_axis] && current_position[q_axis] == logical[q_axis])
79
+  if (angular_travel == 0 && current_position[p_axis] == rtarget[p_axis] && current_position[q_axis] == rtarget[q_axis])
80
     angular_travel = RADIANS(360);
80
     angular_travel = RADIANS(360);
81
 
81
 
82
   const float mm_of_travel = HYPOT(angular_travel * radius, FABS(linear_travel));
82
   const float mm_of_travel = HYPOT(angular_travel * radius, FABS(linear_travel));
176
   }
176
   }
177
 
177
 
178
   // Ensure last segment arrives at target location.
178
   // Ensure last segment arrives at target location.
179
-  planner.buffer_line_kinematic(logical, fr_mm_s, active_extruder);
179
+  planner.buffer_line_kinematic(rtarget, fr_mm_s, active_extruder);
180
 
180
 
181
   // As far as the parser is concerned, the position is now == target. In reality the
181
   // As far as the parser is concerned, the position is now == target. In reality the
182
   // motion control system might still be processing the action and the real tool position
182
   // motion control system might still be processing the action and the real tool position

+ 1
- 1
Marlin/src/gcode/probe/G30.cpp Wyświetl plik

42
   const float xpos = parser.linearval('X', current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER),
42
   const float xpos = parser.linearval('X', current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER),
43
               ypos = parser.linearval('Y', current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER);
43
               ypos = parser.linearval('Y', current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER);
44
 
44
 
45
-  if (!position_is_reachable_by_probe_xy(xpos, ypos)) return;
45
+  if (!position_is_reachable_by_probe(xpos, ypos)) return;
46
 
46
 
47
   // Disable leveling so the planner won't mess with us
47
   // Disable leveling so the planner won't mess with us
48
   #if HAS_LEVELING
48
   #if HAS_LEVELING

+ 2
- 2
Marlin/src/gcode/scara/M360-M364.cpp Wyświetl plik

32
 inline bool SCARA_move_to_cal(const uint8_t delta_a, const uint8_t delta_b) {
32
 inline bool SCARA_move_to_cal(const uint8_t delta_a, const uint8_t delta_b) {
33
   if (IsRunning()) {
33
   if (IsRunning()) {
34
     forward_kinematics_SCARA(delta_a, delta_b);
34
     forward_kinematics_SCARA(delta_a, delta_b);
35
-    destination[X_AXIS] = LOGICAL_X_POSITION(cartes[X_AXIS]);
36
-    destination[Y_AXIS] = LOGICAL_Y_POSITION(cartes[Y_AXIS]);
35
+    destination[X_AXIS] = cartes[X_AXIS];
36
+    destination[Y_AXIS] = cartes[Y_AXIS];
37
     destination[Z_AXIS] = current_position[Z_AXIS];
37
     destination[Z_AXIS] = current_position[Z_AXIS];
38
     prepare_move_to_destination();
38
     prepare_move_to_destination();
39
     return true;
39
     return true;

+ 17
- 20
Marlin/src/lcd/ultralcd.cpp Wyświetl plik

1672
      */
1672
      */
1673
     static int8_t bed_corner;
1673
     static int8_t bed_corner;
1674
     void _lcd_goto_next_corner() {
1674
     void _lcd_goto_next_corner() {
1675
-      line_to_z(LOGICAL_Z_POSITION(4.0));
1675
+      line_to_z(4.0);
1676
       switch (bed_corner) {
1676
       switch (bed_corner) {
1677
         case 0:
1677
         case 0:
1678
           current_position[X_AXIS] = X_MIN_BED + 10;
1678
           current_position[X_AXIS] = X_MIN_BED + 10;
1689
           break;
1689
           break;
1690
       }
1690
       }
1691
       planner.buffer_line_kinematic(current_position, MMM_TO_MMS(manual_feedrate_mm_m[X_AXIS]), active_extruder);
1691
       planner.buffer_line_kinematic(current_position, MMM_TO_MMS(manual_feedrate_mm_m[X_AXIS]), active_extruder);
1692
-      line_to_z(LOGICAL_Z_POSITION(0.0));
1692
+      line_to_z(0.0);
1693
       if (++bed_corner > 3) bed_corner = 0;
1693
       if (++bed_corner > 3) bed_corner = 0;
1694
     }
1694
     }
1695
 
1695
 
1735
     //
1735
     //
1736
     void _lcd_after_probing() {
1736
     void _lcd_after_probing() {
1737
       #if MANUAL_PROBE_HEIGHT > 0
1737
       #if MANUAL_PROBE_HEIGHT > 0
1738
-        line_to_z(LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT);
1738
+        line_to_z(Z_MIN_POS + MANUAL_PROBE_HEIGHT);
1739
       #endif
1739
       #endif
1740
       // Display "Done" screen and wait for moves to complete
1740
       // Display "Done" screen and wait for moves to complete
1741
       #if MANUAL_PROBE_HEIGHT > 0 || ENABLED(MESH_BED_LEVELING)
1741
       #if MANUAL_PROBE_HEIGHT > 0 || ENABLED(MESH_BED_LEVELING)
1750
     #if ENABLED(MESH_BED_LEVELING)
1750
     #if ENABLED(MESH_BED_LEVELING)
1751
 
1751
 
1752
       // Utility to go to the next mesh point
1752
       // Utility to go to the next mesh point
1753
-      inline void _manual_probe_goto_xy(float x, float y) {
1753
+      inline void _manual_probe_goto_xy(const float &rx, const float &ry) {
1754
         #if MANUAL_PROBE_HEIGHT > 0
1754
         #if MANUAL_PROBE_HEIGHT > 0
1755
           const float prev_z = current_position[Z_AXIS];
1755
           const float prev_z = current_position[Z_AXIS];
1756
-          line_to_z(LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT);
1756
+          line_to_z(Z_MIN_POS + MANUAL_PROBE_HEIGHT);
1757
         #endif
1757
         #endif
1758
-        current_position[X_AXIS] = LOGICAL_X_POSITION(x);
1759
-        current_position[Y_AXIS] = LOGICAL_Y_POSITION(y);
1758
+        current_position[X_AXIS] = rx;
1759
+        current_position[Y_AXIS] = ry;
1760
         planner.buffer_line_kinematic(current_position, MMM_TO_MMS(XY_PROBE_SPEED), active_extruder);
1760
         planner.buffer_line_kinematic(current_position, MMM_TO_MMS(XY_PROBE_SPEED), active_extruder);
1761
         #if MANUAL_PROBE_HEIGHT > 0
1761
         #if MANUAL_PROBE_HEIGHT > 0
1762
           line_to_z(prev_z);
1762
           line_to_z(prev_z);
1886
         mbl.zigzag(manual_probe_index, px, py);
1886
         mbl.zigzag(manual_probe_index, px, py);
1887
 
1887
 
1888
         // Controls the loop until the move is done
1888
         // Controls the loop until the move is done
1889
-        _manual_probe_goto_xy(
1890
-          LOGICAL_X_POSITION(mbl.index_to_xpos[px]),
1891
-          LOGICAL_Y_POSITION(mbl.index_to_ypos[py])
1892
-        );
1889
+        _manual_probe_goto_xy(mbl.index_to_xpos[px], mbl.index_to_ypos[py]);
1893
 
1890
 
1894
         // After the blocking function returns, change menus
1891
         // After the blocking function returns, change menus
1895
         lcd_goto_screen(_lcd_level_bed_get_z);
1892
         lcd_goto_screen(_lcd_level_bed_get_z);
2370
      * UBL LCD Map Movement
2367
      * UBL LCD Map Movement
2371
      */
2368
      */
2372
     void ubl_map_move_to_xy() {
2369
     void ubl_map_move_to_xy() {
2373
-      current_position[X_AXIS] = LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]));
2374
-      current_position[Y_AXIS] = LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]));
2370
+      current_position[X_AXIS] = pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]);
2371
+      current_position[Y_AXIS] = pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]);
2375
       planner.buffer_line_kinematic(current_position, MMM_TO_MMS(XY_PROBE_SPEED), active_extruder);
2372
       planner.buffer_line_kinematic(current_position, MMM_TO_MMS(XY_PROBE_SPEED), active_extruder);
2376
     }
2373
     }
2377
 
2374
 
2705
       lcd_goto_screen(_lcd_calibrate_homing);
2702
       lcd_goto_screen(_lcd_calibrate_homing);
2706
     }
2703
     }
2707
 
2704
 
2708
-    void _man_probe_pt(const float &lx, const float &ly) {
2705
+    void _man_probe_pt(const float &rx, const float &ry) {
2709
       #if HAS_LEVELING
2706
       #if HAS_LEVELING
2710
         reset_bed_level(); // After calibration bed-level data is no longer valid
2707
         reset_bed_level(); // After calibration bed-level data is no longer valid
2711
       #endif
2708
       #endif
2712
 
2709
 
2713
-      float z_dest = LOGICAL_Z_POSITION((Z_CLEARANCE_BETWEEN_PROBES) + (DELTA_PRINTABLE_RADIUS) / 5);
2710
+      float z_dest = (Z_CLEARANCE_BETWEEN_PROBES) + (DELTA_PRINTABLE_RADIUS) / 5;
2714
       line_to_z(z_dest);
2711
       line_to_z(z_dest);
2715
-      current_position[X_AXIS] = LOGICAL_X_POSITION(lx);
2716
-      current_position[Y_AXIS] = LOGICAL_Y_POSITION(ly);
2712
+      current_position[X_AXIS] = rx;
2713
+      current_position[Y_AXIS] = ry;
2717
       line_to_current_z();
2714
       line_to_current_z();
2718
-      z_dest = LOGICAL_Z_POSITION(Z_CLEARANCE_BETWEEN_PROBES);
2715
+      z_dest = Z_CLEARANCE_BETWEEN_PROBES;
2719
       line_to_z(z_dest);
2716
       line_to_z(z_dest);
2720
 
2717
 
2721
       lcd_synchronize();
2718
       lcd_synchronize();
2723
       lcd_goto_screen(lcd_move_z);
2720
       lcd_goto_screen(lcd_move_z);
2724
     }
2721
     }
2725
 
2722
 
2726
-    float lcd_probe_pt(const float &lx, const float &ly) {
2727
-      _man_probe_pt(lx, ly);
2723
+    float lcd_probe_pt(const float &rx, const float &ry) {
2724
+      _man_probe_pt(rx, ry);
2728
       KEEPALIVE_STATE(PAUSED_FOR_USER);
2725
       KEEPALIVE_STATE(PAUSED_FOR_USER);
2729
       defer_return_to_status = true;
2726
       defer_return_to_status = true;
2730
       wait_for_user = true;
2727
       wait_for_user = true;

+ 1
- 1
Marlin/src/lcd/ultralcd.h Wyświetl plik

119
     #endif
119
     #endif
120
 
120
 
121
     #if ENABLED(DELTA_CALIBRATION_MENU)
121
     #if ENABLED(DELTA_CALIBRATION_MENU)
122
-      float lcd_probe_pt(const float &lx, const float &ly);
122
+      float lcd_probe_pt(const float &rx, const float &ry);
123
     #endif
123
     #endif
124
 
124
 
125
   #else
125
   #else

+ 3
- 3
Marlin/src/lcd/ultralcd_impl_DOGM.h Wyświetl plik

646
 
646
 
647
   // At the first page, regenerate the XYZ strings
647
   // At the first page, regenerate the XYZ strings
648
   if (page.page == 0) {
648
   if (page.page == 0) {
649
-    strcpy(xstring, ftostr4sign(current_position[X_AXIS]));
650
-    strcpy(ystring, ftostr4sign(current_position[Y_AXIS]));
651
-    strcpy(zstring, ftostr52sp(FIXFLOAT(current_position[Z_AXIS])));
649
+    strcpy(xstring, ftostr4sign(LOGICAL_X_POSITION(current_position[X_AXIS])));
650
+    strcpy(ystring, ftostr4sign(LOGICAL_Y_POSITION(current_position[Y_AXIS])));
651
+    strcpy(zstring, ftostr52sp(FIXFLOAT(LOGICAL_Z_POSITION(current_position[Z_AXIS]))));
652
     #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
652
     #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
653
       strcpy(wstring, ftostr12ns(filament_width_meas));
653
       strcpy(wstring, ftostr12ns(filament_width_meas));
654
       strcpy(mstring, itostr3(100.0 * planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
654
       strcpy(mstring, itostr3(100.0 * planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));

+ 9
- 7
Marlin/src/lcd/ultralcd_impl_HD44780.h Wyświetl plik

621
   lcd.print(itostr3(t1 + 0.5));
621
   lcd.print(itostr3(t1 + 0.5));
622
   lcd.write('/');
622
   lcd.write('/');
623
 
623
 
624
-  #if HEATER_IDLE_HANDLER
624
+  #if !HEATER_IDLE_HANDLER
625
+    UNUSED(blink);
626
+  #else
625
     const bool is_idle = (!isBed ? thermalManager.is_heater_idle(heater) :
627
     const bool is_idle = (!isBed ? thermalManager.is_heater_idle(heater) :
626
       #if HAS_TEMP_BED
628
       #if HAS_TEMP_BED
627
         thermalManager.is_bed_idle()
629
         thermalManager.is_bed_idle()
779
         // When everything is ok you see a constant 'X'.
781
         // When everything is ok you see a constant 'X'.
780
 
782
 
781
         _draw_axis_label(X_AXIS, PSTR(MSG_X), blink);
783
         _draw_axis_label(X_AXIS, PSTR(MSG_X), blink);
782
-        lcd.print(ftostr4sign(current_position[X_AXIS]));
784
+        lcd.print(ftostr4sign(LOGICAL_X_POSITION(current_position[X_AXIS])));
783
 
785
 
784
         lcd.write(' ');
786
         lcd.write(' ');
785
 
787
 
786
         _draw_axis_label(Y_AXIS, PSTR(MSG_Y), blink);
788
         _draw_axis_label(Y_AXIS, PSTR(MSG_Y), blink);
787
-        lcd.print(ftostr4sign(current_position[Y_AXIS]));
789
+        lcd.print(ftostr4sign(LOGICAL_Y_POSITION(current_position[Y_AXIS])));
788
 
790
 
789
       #endif // HOTENDS > 1 || TEMP_SENSOR_BED != 0
791
       #endif // HOTENDS > 1 || TEMP_SENSOR_BED != 0
790
 
792
 
842
 
844
 
843
   #if ENABLED(LCD_PROGRESS_BAR)
845
   #if ENABLED(LCD_PROGRESS_BAR)
844
 
846
 
847
+    // Draw the progress bar if the message has shown long enough
848
+    // or if there is no message set.
845
     #if DISABLED(LCD_SET_PROGRESS_MANUALLY)
849
     #if DISABLED(LCD_SET_PROGRESS_MANUALLY)
846
       const uint8_t progress_bar_percent = card.percentDone();
850
       const uint8_t progress_bar_percent = card.percentDone();
847
     #endif
851
     #endif
848
-    // Draw the progress bar if the message has shown long enough
849
-    // or if there is no message set.
850
     if (progress_bar_percent > 2 && (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !lcd_status_message[0]))
852
     if (progress_bar_percent > 2 && (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !lcd_status_message[0]))
851
       return lcd_draw_progress_bar(progress_bar_percent);
853
       return lcd_draw_progress_bar(progress_bar_percent);
852
 
854
 
1168
       return ret_val;
1170
       return ret_val;
1169
     }
1171
     }
1170
 
1172
 
1171
-    coordinate pixel_location(uint8_t x, uint8_t y) { return pixel_location((int16_t)x, (int16_t)y); }
1173
+    inline coordinate pixel_location(const uint8_t x, const uint8_t y) { return pixel_location((int16_t)x, (int16_t)y); }
1172
 
1174
 
1173
-    void lcd_implementation_ubl_plot(uint8_t x, uint8_t inverted_y) {
1175
+    void lcd_implementation_ubl_plot(const uint8_t x, const uint8_t inverted_y) {
1174
 
1176
 
1175
       #if LCD_WIDTH >= 20
1177
       #if LCD_WIDTH >= 20
1176
         #define _LCD_W_POS 12
1178
         #define _LCD_W_POS 12

+ 5
- 9
Marlin/src/module/delta.cpp Wyświetl plik

72
 /**
72
 /**
73
  * Delta Inverse Kinematics
73
  * Delta Inverse Kinematics
74
  *
74
  *
75
- * Calculate the tower positions for a given logical
75
+ * Calculate the tower positions for a given machine
76
  * position, storing the result in the delta[] array.
76
  * position, storing the result in the delta[] array.
77
  *
77
  *
78
  * This is an expensive calculation, requiring 3 square
78
  * This is an expensive calculation, requiring 3 square
117
     SERIAL_ECHOLNPAIR(" C:", delta[C_AXIS]);      \
117
     SERIAL_ECHOLNPAIR(" C:", delta[C_AXIS]);      \
118
   }while(0)
118
   }while(0)
119
 
119
 
120
-void inverse_kinematics(const float logical[XYZ]) {
121
-  DELTA_LOGICAL_IK();
120
+void inverse_kinematics(const float raw[XYZ]) {
121
+  DELTA_RAW_IK();
122
   // DELTA_DEBUG();
122
   // DELTA_DEBUG();
123
 }
123
 }
124
 
124
 
127
  * effector has the full range of XY motion.
127
  * effector has the full range of XY motion.
128
  */
128
  */
129
 float delta_safe_distance_from_top() {
129
 float delta_safe_distance_from_top() {
130
-  float cartesian[XYZ] = {
131
-    LOGICAL_X_POSITION(0),
132
-    LOGICAL_Y_POSITION(0),
133
-    LOGICAL_Z_POSITION(0)
134
-  };
130
+  float cartesian[XYZ] = { 0, 0, 0 };
135
   inverse_kinematics(cartesian);
131
   inverse_kinematics(cartesian);
136
   float distance = delta[A_AXIS];
132
   float distance = delta[A_AXIS];
137
-  cartesian[Y_AXIS] = LOGICAL_Y_POSITION(DELTA_PRINTABLE_RADIUS);
133
+  cartesian[Y_AXIS] = DELTA_PRINTABLE_RADIUS;
138
   inverse_kinematics(cartesian);
134
   inverse_kinematics(cartesian);
139
   return FABS(distance - delta[A_AXIS]);
135
   return FABS(distance - delta[A_AXIS]);
140
 }
136
 }

+ 2
- 11
Marlin/src/module/delta.h Wyświetl plik

47
 /**
47
 /**
48
  * Delta Inverse Kinematics
48
  * Delta Inverse Kinematics
49
  *
49
  *
50
- * Calculate the tower positions for a given logical
50
+ * Calculate the tower positions for a given machine
51
  * position, storing the result in the delta[] array.
51
  * position, storing the result in the delta[] array.
52
  *
52
  *
53
  * This is an expensive calculation, requiring 3 square
53
  * This is an expensive calculation, requiring 3 square
88
   delta[C_AXIS] = DELTA_Z(C_AXIS); \
88
   delta[C_AXIS] = DELTA_Z(C_AXIS); \
89
 }while(0)
89
 }while(0)
90
 
90
 
91
-#define DELTA_LOGICAL_IK() do {      \
92
-  const float raw[XYZ] = {           \
93
-    RAW_X_POSITION(logical[X_AXIS]), \
94
-    RAW_Y_POSITION(logical[Y_AXIS]), \
95
-    RAW_Z_POSITION(logical[Z_AXIS])  \
96
-  };                                 \
97
-  DELTA_RAW_IK();                    \
98
-}while(0)
99
-
100
-void inverse_kinematics(const float logical[XYZ]);
91
+void inverse_kinematics(const float raw[XYZ]);
101
 
92
 
102
 /**
93
 /**
103
  * Calculate the highest Z position where the
94
  * Calculate the highest Z position where the

+ 68
- 72
Marlin/src/module/motion.cpp Wyświetl plik

73
 
73
 
74
 /**
74
 /**
75
  * Cartesian Current Position
75
  * Cartesian Current Position
76
- *   Used to track the logical position as moves are queued.
76
+ *   Used to track the native machine position as moves are queued.
77
  *   Used by 'line_to_current_position' to do a move after changing it.
77
  *   Used by 'line_to_current_position' to do a move after changing it.
78
  *   Used by 'SYNC_PLAN_POSITION_KINEMATIC' to update 'planner.position'.
78
  *   Used by 'SYNC_PLAN_POSITION_KINEMATIC' to update 'planner.position'.
79
  */
79
  */
197
       stepper.get_axis_position_mm(B_AXIS),
197
       stepper.get_axis_position_mm(B_AXIS),
198
       stepper.get_axis_position_mm(C_AXIS)
198
       stepper.get_axis_position_mm(C_AXIS)
199
     );
199
     );
200
-    cartes[X_AXIS] += LOGICAL_X_POSITION(0);
201
-    cartes[Y_AXIS] += LOGICAL_Y_POSITION(0);
202
-    cartes[Z_AXIS] += LOGICAL_Z_POSITION(0);
203
-  #elif IS_SCARA
204
-    forward_kinematics_SCARA(
205
-      stepper.get_axis_position_degrees(A_AXIS),
206
-      stepper.get_axis_position_degrees(B_AXIS)
207
-    );
208
-    cartes[X_AXIS] += LOGICAL_X_POSITION(0);
209
-    cartes[Y_AXIS] += LOGICAL_Y_POSITION(0);
210
-    cartes[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS);
211
   #else
200
   #else
212
-    cartes[X_AXIS] = stepper.get_axis_position_mm(X_AXIS);
213
-    cartes[Y_AXIS] = stepper.get_axis_position_mm(Y_AXIS);
201
+    #if IS_SCARA
202
+      forward_kinematics_SCARA(
203
+        stepper.get_axis_position_degrees(A_AXIS),
204
+        stepper.get_axis_position_degrees(B_AXIS)
205
+      );
206
+    #else
207
+      cartes[X_AXIS] = stepper.get_axis_position_mm(X_AXIS);
208
+      cartes[Y_AXIS] = stepper.get_axis_position_mm(Y_AXIS);
209
+    #endif
214
     cartes[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS);
210
     cartes[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS);
215
   #endif
211
   #endif
216
 }
212
 }
288
  *  Plan a move to (X, Y, Z) and set the current_position
284
  *  Plan a move to (X, Y, Z) and set the current_position
289
  *  The final current_position may not be the one that was requested
285
  *  The final current_position may not be the one that was requested
290
  */
286
  */
291
-void do_blocking_move_to(const float &lx, const float &ly, const float &lz, const float &fr_mm_s/*=0.0*/) {
287
+void do_blocking_move_to(const float &rx, const float &ry, const float &rz, const float &fr_mm_s/*=0.0*/) {
292
   const float old_feedrate_mm_s = feedrate_mm_s;
288
   const float old_feedrate_mm_s = feedrate_mm_s;
293
 
289
 
294
   #if ENABLED(DEBUG_LEVELING_FEATURE)
290
   #if ENABLED(DEBUG_LEVELING_FEATURE)
295
-    if (DEBUGGING(LEVELING)) print_xyz(PSTR(">>> do_blocking_move_to"), NULL, lx, ly, lz);
291
+    if (DEBUGGING(LEVELING)) print_xyz(PSTR(">>> do_blocking_move_to"), NULL, rx, ry, rz);
296
   #endif
292
   #endif
297
 
293
 
298
   #if ENABLED(DELTA)
294
   #if ENABLED(DELTA)
299
 
295
 
300
-    if (!position_is_reachable_xy(lx, ly)) return;
296
+    if (!position_is_reachable(rx, ry)) return;
301
 
297
 
302
     feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
298
     feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
303
 
299
 
309
 
305
 
310
     // when in the danger zone
306
     // when in the danger zone
311
     if (current_position[Z_AXIS] > delta_clip_start_height) {
307
     if (current_position[Z_AXIS] > delta_clip_start_height) {
312
-      if (lz > delta_clip_start_height) {   // staying in the danger zone
313
-        destination[X_AXIS] = lx;           // move directly (uninterpolated)
314
-        destination[Y_AXIS] = ly;
315
-        destination[Z_AXIS] = lz;
308
+      if (rz > delta_clip_start_height) {   // staying in the danger zone
309
+        destination[X_AXIS] = rx;           // move directly (uninterpolated)
310
+        destination[Y_AXIS] = ry;
311
+        destination[Z_AXIS] = rz;
316
         prepare_uninterpolated_move_to_destination(); // set_current_from_destination()
312
         prepare_uninterpolated_move_to_destination(); // set_current_from_destination()
317
         #if ENABLED(DEBUG_LEVELING_FEATURE)
313
         #if ENABLED(DEBUG_LEVELING_FEATURE)
318
           if (DEBUGGING(LEVELING)) DEBUG_POS("danger zone move", current_position);
314
           if (DEBUGGING(LEVELING)) DEBUG_POS("danger zone move", current_position);
328
       }
324
       }
329
     }
325
     }
330
 
326
 
331
-    if (lz > current_position[Z_AXIS]) {    // raising?
332
-      destination[Z_AXIS] = lz;
327
+    if (rz > current_position[Z_AXIS]) {    // raising?
328
+      destination[Z_AXIS] = rz;
333
       prepare_uninterpolated_move_to_destination();   // set_current_from_destination()
329
       prepare_uninterpolated_move_to_destination();   // set_current_from_destination()
334
       #if ENABLED(DEBUG_LEVELING_FEATURE)
330
       #if ENABLED(DEBUG_LEVELING_FEATURE)
335
         if (DEBUGGING(LEVELING)) DEBUG_POS("z raise move", current_position);
331
         if (DEBUGGING(LEVELING)) DEBUG_POS("z raise move", current_position);
336
       #endif
332
       #endif
337
     }
333
     }
338
 
334
 
339
-    destination[X_AXIS] = lx;
340
-    destination[Y_AXIS] = ly;
335
+    destination[X_AXIS] = rx;
336
+    destination[Y_AXIS] = ry;
341
     prepare_move_to_destination();         // set_current_from_destination()
337
     prepare_move_to_destination();         // set_current_from_destination()
342
     #if ENABLED(DEBUG_LEVELING_FEATURE)
338
     #if ENABLED(DEBUG_LEVELING_FEATURE)
343
       if (DEBUGGING(LEVELING)) DEBUG_POS("xy move", current_position);
339
       if (DEBUGGING(LEVELING)) DEBUG_POS("xy move", current_position);
344
     #endif
340
     #endif
345
 
341
 
346
-    if (lz < current_position[Z_AXIS]) {    // lowering?
347
-      destination[Z_AXIS] = lz;
342
+    if (rz < current_position[Z_AXIS]) {    // lowering?
343
+      destination[Z_AXIS] = rz;
348
       prepare_uninterpolated_move_to_destination();   // set_current_from_destination()
344
       prepare_uninterpolated_move_to_destination();   // set_current_from_destination()
349
       #if ENABLED(DEBUG_LEVELING_FEATURE)
345
       #if ENABLED(DEBUG_LEVELING_FEATURE)
350
         if (DEBUGGING(LEVELING)) DEBUG_POS("z lower move", current_position);
346
         if (DEBUGGING(LEVELING)) DEBUG_POS("z lower move", current_position);
353
 
349
 
354
   #elif IS_SCARA
350
   #elif IS_SCARA
355
 
351
 
356
-    if (!position_is_reachable_xy(lx, ly)) return;
352
+    if (!position_is_reachable(rx, ry)) return;
357
 
353
 
358
     set_destination_from_current();
354
     set_destination_from_current();
359
 
355
 
360
     // If Z needs to raise, do it before moving XY
356
     // If Z needs to raise, do it before moving XY
361
-    if (destination[Z_AXIS] < lz) {
362
-      destination[Z_AXIS] = lz;
357
+    if (destination[Z_AXIS] < rz) {
358
+      destination[Z_AXIS] = rz;
363
       prepare_uninterpolated_move_to_destination(fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS));
359
       prepare_uninterpolated_move_to_destination(fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS));
364
     }
360
     }
365
 
361
 
366
-    destination[X_AXIS] = lx;
367
-    destination[Y_AXIS] = ly;
362
+    destination[X_AXIS] = rx;
363
+    destination[Y_AXIS] = ry;
368
     prepare_uninterpolated_move_to_destination(fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S);
364
     prepare_uninterpolated_move_to_destination(fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S);
369
 
365
 
370
     // If Z needs to lower, do it after moving XY
366
     // If Z needs to lower, do it after moving XY
371
-    if (destination[Z_AXIS] > lz) {
372
-      destination[Z_AXIS] = lz;
367
+    if (destination[Z_AXIS] > rz) {
368
+      destination[Z_AXIS] = rz;
373
       prepare_uninterpolated_move_to_destination(fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS));
369
       prepare_uninterpolated_move_to_destination(fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS));
374
     }
370
     }
375
 
371
 
376
   #else
372
   #else
377
 
373
 
378
     // If Z needs to raise, do it before moving XY
374
     // If Z needs to raise, do it before moving XY
379
-    if (current_position[Z_AXIS] < lz) {
375
+    if (current_position[Z_AXIS] < rz) {
380
       feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
376
       feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
381
-      current_position[Z_AXIS] = lz;
377
+      current_position[Z_AXIS] = rz;
382
       line_to_current_position();
378
       line_to_current_position();
383
     }
379
     }
384
 
380
 
385
     feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
381
     feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
386
-    current_position[X_AXIS] = lx;
387
-    current_position[Y_AXIS] = ly;
382
+    current_position[X_AXIS] = rx;
383
+    current_position[Y_AXIS] = ry;
388
     line_to_current_position();
384
     line_to_current_position();
389
 
385
 
390
     // If Z needs to lower, do it after moving XY
386
     // If Z needs to lower, do it after moving XY
391
-    if (current_position[Z_AXIS] > lz) {
387
+    if (current_position[Z_AXIS] > rz) {
392
       feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
388
       feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
393
-      current_position[Z_AXIS] = lz;
389
+      current_position[Z_AXIS] = rz;
394
       line_to_current_position();
390
       line_to_current_position();
395
     }
391
     }
396
 
392
 
404
     if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< do_blocking_move_to");
400
     if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< do_blocking_move_to");
405
   #endif
401
   #endif
406
 }
402
 }
407
-void do_blocking_move_to_x(const float &lx, const float &fr_mm_s/*=0.0*/) {
408
-  do_blocking_move_to(lx, current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_s);
403
+void do_blocking_move_to_x(const float &rx, const float &fr_mm_s/*=0.0*/) {
404
+  do_blocking_move_to(rx, current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_s);
409
 }
405
 }
410
-void do_blocking_move_to_z(const float &lz, const float &fr_mm_s/*=0.0*/) {
411
-  do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], lz, fr_mm_s);
406
+void do_blocking_move_to_z(const float &rz, const float &fr_mm_s/*=0.0*/) {
407
+  do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], rz, fr_mm_s);
412
 }
408
 }
413
-void do_blocking_move_to_xy(const float &lx, const float &ly, const float &fr_mm_s/*=0.0*/) {
414
-  do_blocking_move_to(lx, ly, current_position[Z_AXIS], fr_mm_s);
409
+void do_blocking_move_to_xy(const float &rx, const float &ry, const float &fr_mm_s/*=0.0*/) {
410
+  do_blocking_move_to(rx, ry, current_position[Z_AXIS], fr_mm_s);
415
 }
411
 }
416
 
412
 
417
 //
413
 //
521
    * This calls planner.buffer_line several times, adding
517
    * This calls planner.buffer_line several times, adding
522
    * small incremental moves for DELTA or SCARA.
518
    * small incremental moves for DELTA or SCARA.
523
    */
519
    */
524
-  inline bool prepare_kinematic_move_to(float ltarget[XYZE]) {
520
+  inline bool prepare_kinematic_move_to(float rtarget[XYZE]) {
525
 
521
 
526
     // Get the top feedrate of the move in the XY plane
522
     // Get the top feedrate of the move in the XY plane
527
     const float _feedrate_mm_s = MMS_SCALED(feedrate_mm_s);
523
     const float _feedrate_mm_s = MMS_SCALED(feedrate_mm_s);
528
 
524
 
529
     // If the move is only in Z/E don't split up the move
525
     // If the move is only in Z/E don't split up the move
530
-    if (ltarget[X_AXIS] == current_position[X_AXIS] && ltarget[Y_AXIS] == current_position[Y_AXIS]) {
531
-      planner.buffer_line_kinematic(ltarget, _feedrate_mm_s, active_extruder);
526
+    if (rtarget[X_AXIS] == current_position[X_AXIS] && rtarget[Y_AXIS] == current_position[Y_AXIS]) {
527
+      planner.buffer_line_kinematic(rtarget, _feedrate_mm_s, active_extruder);
532
       return false;
528
       return false;
533
     }
529
     }
534
 
530
 
535
     // Fail if attempting move outside printable radius
531
     // Fail if attempting move outside printable radius
536
-    if (!position_is_reachable_xy(ltarget[X_AXIS], ltarget[Y_AXIS])) return true;
532
+    if (!position_is_reachable(rtarget[X_AXIS], rtarget[Y_AXIS])) return true;
537
 
533
 
538
     // Get the cartesian distances moved in XYZE
534
     // Get the cartesian distances moved in XYZE
539
     const float difference[XYZE] = {
535
     const float difference[XYZE] = {
540
-      ltarget[X_AXIS] - current_position[X_AXIS],
541
-      ltarget[Y_AXIS] - current_position[Y_AXIS],
542
-      ltarget[Z_AXIS] - current_position[Z_AXIS],
543
-      ltarget[E_AXIS] - current_position[E_AXIS]
536
+      rtarget[X_AXIS] - current_position[X_AXIS],
537
+      rtarget[Y_AXIS] - current_position[Y_AXIS],
538
+      rtarget[Z_AXIS] - current_position[Z_AXIS],
539
+      rtarget[E_AXIS] - current_position[E_AXIS]
544
     };
540
     };
545
 
541
 
546
     // Get the linear distance in XYZ
542
     // Get the linear distance in XYZ
588
             oldB = stepper.get_axis_position_degrees(B_AXIS);
584
             oldB = stepper.get_axis_position_degrees(B_AXIS);
589
     #endif
585
     #endif
590
 
586
 
591
-    // Get the logical current position as starting point
592
-    float logical[XYZE];
593
-    COPY(logical, current_position);
587
+    // Get the current position as starting point
588
+    float raw[XYZE];
589
+    COPY(raw, current_position);
594
 
590
 
595
     // Drop one segment so the last move is to the exact target.
591
     // Drop one segment so the last move is to the exact target.
596
     // If there's only 1 segment, loops will be skipped entirely.
592
     // If there's only 1 segment, loops will be skipped entirely.
598
 
594
 
599
     // Calculate and execute the segments
595
     // Calculate and execute the segments
600
     for (uint16_t s = segments + 1; --s;) {
596
     for (uint16_t s = segments + 1; --s;) {
601
-      LOOP_XYZE(i) logical[i] += segment_distance[i];
597
+      LOOP_XYZE(i) raw[i] += segment_distance[i];
602
       #if ENABLED(DELTA)
598
       #if ENABLED(DELTA)
603
-        DELTA_LOGICAL_IK(); // Delta can inline its kinematics
599
+        DELTA_RAW_IK(); // Delta can inline its kinematics
604
       #else
600
       #else
605
-        inverse_kinematics(logical);
601
+        inverse_kinematics(raw);
606
       #endif
602
       #endif
607
 
603
 
608
-      ADJUST_DELTA(logical); // Adjust Z if bed leveling is enabled
604
+      ADJUST_DELTA(raw); // Adjust Z if bed leveling is enabled
609
 
605
 
610
       #if IS_SCARA && ENABLED(SCARA_FEEDRATE_SCALING)
606
       #if IS_SCARA && ENABLED(SCARA_FEEDRATE_SCALING)
611
         // For SCARA scale the feed rate from mm/s to degrees/s
607
         // For SCARA scale the feed rate from mm/s to degrees/s
612
         // Use ratio between the length of the move and the larger angle change
608
         // Use ratio between the length of the move and the larger angle change
613
         const float adiff = abs(delta[A_AXIS] - oldA),
609
         const float adiff = abs(delta[A_AXIS] - oldA),
614
                     bdiff = abs(delta[B_AXIS] - oldB);
610
                     bdiff = abs(delta[B_AXIS] - oldB);
615
-        planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], logical[E_AXIS], max(adiff, bdiff) * feed_factor, active_extruder);
611
+        planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS], max(adiff, bdiff) * feed_factor, active_extruder);
616
         oldA = delta[A_AXIS];
612
         oldA = delta[A_AXIS];
617
         oldB = delta[B_AXIS];
613
         oldB = delta[B_AXIS];
618
       #else
614
       #else
619
-        planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], logical[E_AXIS], _feedrate_mm_s, active_extruder);
615
+        planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS], _feedrate_mm_s, active_extruder);
620
       #endif
616
       #endif
621
     }
617
     }
622
 
618
 
626
     #if IS_SCARA && ENABLED(SCARA_FEEDRATE_SCALING)
622
     #if IS_SCARA && ENABLED(SCARA_FEEDRATE_SCALING)
627
       // For SCARA scale the feed rate from mm/s to degrees/s
623
       // For SCARA scale the feed rate from mm/s to degrees/s
628
       // With segments > 1 length is 1 segment, otherwise total length
624
       // With segments > 1 length is 1 segment, otherwise total length
629
-      inverse_kinematics(ltarget);
630
-      ADJUST_DELTA(ltarget);
625
+      inverse_kinematics(rtarget);
626
+      ADJUST_DELTA(rtarget);
631
       const float adiff = abs(delta[A_AXIS] - oldA),
627
       const float adiff = abs(delta[A_AXIS] - oldA),
632
                   bdiff = abs(delta[B_AXIS] - oldB);
628
                   bdiff = abs(delta[B_AXIS] - oldB);
633
-      planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], logical[E_AXIS], max(adiff, bdiff) * feed_factor, active_extruder);
629
+      planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS], max(adiff, bdiff) * feed_factor, active_extruder);
634
     #else
630
     #else
635
-      planner.buffer_line_kinematic(ltarget, _feedrate_mm_s, active_extruder);
631
+      planner.buffer_line_kinematic(rtarget, _feedrate_mm_s, active_extruder);
636
     #endif
632
     #endif
637
 
633
 
638
     return false;
634
     return false;
687
 
683
 
688
   float x_home_pos(const int extruder) {
684
   float x_home_pos(const int extruder) {
689
     if (extruder == 0)
685
     if (extruder == 0)
690
-      return LOGICAL_X_POSITION(base_home_pos(X_AXIS));
686
+      return base_home_pos(X_AXIS);
691
     else
687
     else
692
       /**
688
       /**
693
        * In dual carriage mode the extruder offset provides an override of the
689
        * In dual carriage mode the extruder offset provides an override of the
695
        * This allows soft recalibration of the second extruder home position
691
        * This allows soft recalibration of the second extruder home position
696
        * without firmware reflash (through the M218 command).
692
        * without firmware reflash (through the M218 command).
697
        */
693
        */
698
-      return LOGICAL_X_POSITION(hotend_offset[X_AXIS][1] > 0 ? hotend_offset[X_AXIS][1] : X2_HOME_POS);
694
+      return hotend_offset[X_AXIS][1] > 0 ? hotend_offset[X_AXIS][1] : X2_HOME_POS;
699
   }
695
   }
700
 
696
 
701
   /**
697
   /**
740
           if (active_extruder == 0) {
736
           if (active_extruder == 0) {
741
             #if ENABLED(DEBUG_LEVELING_FEATURE)
737
             #if ENABLED(DEBUG_LEVELING_FEATURE)
742
               if (DEBUGGING(LEVELING)) {
738
               if (DEBUGGING(LEVELING)) {
743
-                SERIAL_ECHOPAIR("Set planner X", LOGICAL_X_POSITION(inactive_extruder_x_pos));
739
+                SERIAL_ECHOPAIR("Set planner X", inactive_extruder_x_pos);
744
                 SERIAL_ECHOLNPAIR(" ... Line to X", current_position[X_AXIS] + duplicate_extruder_x_offset);
740
                 SERIAL_ECHOLNPAIR(" ... Line to X", current_position[X_AXIS] + duplicate_extruder_x_offset);
745
               }
741
               }
746
             #endif
742
             #endif
747
             // move duplicate extruder into correct duplication position.
743
             // move duplicate extruder into correct duplication position.
748
             planner.set_position_mm(
744
             planner.set_position_mm(
749
-              LOGICAL_X_POSITION(inactive_extruder_x_pos),
745
+              inactive_extruder_x_pos,
750
               current_position[Y_AXIS],
746
               current_position[Y_AXIS],
751
               current_position[Z_AXIS],
747
               current_position[Z_AXIS],
752
               current_position[E_AXIS]
748
               current_position[E_AXIS]
970
   #if ENABLED(MORGAN_SCARA)
966
   #if ENABLED(MORGAN_SCARA)
971
     scara_set_axis_is_at_home(axis);
967
     scara_set_axis_is_at_home(axis);
972
   #else
968
   #else
973
-    current_position[axis] = LOGICAL_POSITION(base_home_pos(axis), axis);
969
+    current_position[axis] = base_home_pos(axis);
974
   #endif
970
   #endif
975
 
971
 
976
   /**
972
   /**

+ 14
- 23
Marlin/src/module/motion.h Wyświetl plik

217
   #define WORKSPACE_OFFSET(AXIS) 0
217
   #define WORKSPACE_OFFSET(AXIS) 0
218
 #endif
218
 #endif
219
 
219
 
220
-#define LOGICAL_POSITION(POS, AXIS) ((POS) + WORKSPACE_OFFSET(AXIS))
221
-#define RAW_POSITION(POS, AXIS)     ((POS) - WORKSPACE_OFFSET(AXIS))
220
+#define NATIVE_TO_LOGICAL(POS, AXIS) ((POS) + WORKSPACE_OFFSET(AXIS))
221
+#define LOGICAL_TO_NATIVE(POS, AXIS) ((POS) - WORKSPACE_OFFSET(AXIS))
222
 
222
 
223
 #if HAS_POSITION_SHIFT || DISABLED(DELTA)
223
 #if HAS_POSITION_SHIFT || DISABLED(DELTA)
224
-  #define LOGICAL_X_POSITION(POS)   LOGICAL_POSITION(POS, X_AXIS)
225
-  #define LOGICAL_Y_POSITION(POS)   LOGICAL_POSITION(POS, Y_AXIS)
226
-  #define RAW_X_POSITION(POS)       RAW_POSITION(POS, X_AXIS)
227
-  #define RAW_Y_POSITION(POS)       RAW_POSITION(POS, Y_AXIS)
224
+  #define LOGICAL_X_POSITION(POS)   NATIVE_TO_LOGICAL(POS, X_AXIS)
225
+  #define LOGICAL_Y_POSITION(POS)   NATIVE_TO_LOGICAL(POS, Y_AXIS)
226
+  #define RAW_X_POSITION(POS)       LOGICAL_TO_NATIVE(POS, X_AXIS)
227
+  #define RAW_Y_POSITION(POS)       LOGICAL_TO_NATIVE(POS, Y_AXIS)
228
 #else
228
 #else
229
   #define LOGICAL_X_POSITION(POS)   (POS)
229
   #define LOGICAL_X_POSITION(POS)   (POS)
230
   #define LOGICAL_Y_POSITION(POS)   (POS)
230
   #define LOGICAL_Y_POSITION(POS)   (POS)
232
   #define RAW_Y_POSITION(POS)       (POS)
232
   #define RAW_Y_POSITION(POS)       (POS)
233
 #endif
233
 #endif
234
 
234
 
235
-#define LOGICAL_Z_POSITION(POS)     LOGICAL_POSITION(POS, Z_AXIS)
236
-#define RAW_Z_POSITION(POS)         RAW_POSITION(POS, Z_AXIS)
237
-#define RAW_CURRENT_POSITION(A)     RAW_##A##_POSITION(current_position[A##_AXIS])
235
+#define LOGICAL_Z_POSITION(POS)     NATIVE_TO_LOGICAL(POS, Z_AXIS)
236
+#define RAW_Z_POSITION(POS)         LOGICAL_TO_NATIVE(POS, Z_AXIS)
238
 
237
 
239
 /**
238
 /**
240
  * position_is_reachable family of functions
239
  * position_is_reachable family of functions
242
 
241
 
243
 #if IS_KINEMATIC // (DELTA or SCARA)
242
 #if IS_KINEMATIC // (DELTA or SCARA)
244
 
243
 
245
-  inline bool position_is_reachable_raw_xy(const float &rx, const float &ry) {
244
+  inline bool position_is_reachable(const float &rx, const float &ry) {
246
     #if ENABLED(DELTA)
245
     #if ENABLED(DELTA)
247
       return HYPOT2(rx, ry) <= sq(DELTA_PRINTABLE_RADIUS);
246
       return HYPOT2(rx, ry) <= sq(DELTA_PRINTABLE_RADIUS);
248
     #elif IS_SCARA
247
     #elif IS_SCARA
257
     #endif
256
     #endif
258
   }
257
   }
259
 
258
 
260
-  inline bool position_is_reachable_by_probe_raw_xy(const float &rx, const float &ry) {
259
+  inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
261
 
260
 
262
     // Both the nozzle and the probe must be able to reach the point.
261
     // Both the nozzle and the probe must be able to reach the point.
263
     // This won't work on SCARA since the probe offset rotates with the arm.
262
     // This won't work on SCARA since the probe offset rotates with the arm.
264
 
263
 
265
-    return position_is_reachable_raw_xy(rx, ry)
266
-        && position_is_reachable_raw_xy(rx - X_PROBE_OFFSET_FROM_EXTRUDER, ry - Y_PROBE_OFFSET_FROM_EXTRUDER);
264
+    return position_is_reachable(rx, ry)
265
+        && position_is_reachable(rx - X_PROBE_OFFSET_FROM_EXTRUDER, ry - Y_PROBE_OFFSET_FROM_EXTRUDER);
267
   }
266
   }
268
 
267
 
269
 #else // CARTESIAN
268
 #else // CARTESIAN
270
 
269
 
271
-  inline bool position_is_reachable_raw_xy(const float &rx, const float &ry) {
270
+  inline bool position_is_reachable(const float &rx, const float &ry) {
272
       // Add 0.001 margin to deal with float imprecision
271
       // Add 0.001 margin to deal with float imprecision
273
       return WITHIN(rx, X_MIN_POS - 0.001, X_MAX_POS + 0.001)
272
       return WITHIN(rx, X_MIN_POS - 0.001, X_MAX_POS + 0.001)
274
           && WITHIN(ry, Y_MIN_POS - 0.001, Y_MAX_POS + 0.001);
273
           && WITHIN(ry, Y_MIN_POS - 0.001, Y_MAX_POS + 0.001);
275
   }
274
   }
276
 
275
 
277
-  inline bool position_is_reachable_by_probe_raw_xy(const float &rx, const float &ry) {
276
+  inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
278
       // Add 0.001 margin to deal with float imprecision
277
       // Add 0.001 margin to deal with float imprecision
279
       return WITHIN(rx, MIN_PROBE_X - 0.001, MAX_PROBE_X + 0.001)
278
       return WITHIN(rx, MIN_PROBE_X - 0.001, MAX_PROBE_X + 0.001)
280
           && WITHIN(ry, MIN_PROBE_Y - 0.001, MAX_PROBE_Y + 0.001);
279
           && WITHIN(ry, MIN_PROBE_Y - 0.001, MAX_PROBE_Y + 0.001);
282
 
281
 
283
 #endif // CARTESIAN
282
 #endif // CARTESIAN
284
 
283
 
285
-FORCE_INLINE bool position_is_reachable_by_probe_xy(const float &lx, const float &ly) {
286
-  return position_is_reachable_by_probe_raw_xy(RAW_X_POSITION(lx), RAW_Y_POSITION(ly));
287
-}
288
-
289
-FORCE_INLINE bool position_is_reachable_xy(const float &lx, const float &ly) {
290
-  return position_is_reachable_raw_xy(RAW_X_POSITION(lx), RAW_Y_POSITION(ly));
291
-}
292
-
293
 /**
284
 /**
294
  * Dual X Carriage / Dual Nozzle
285
  * Dual X Carriage / Dual Nozzle
295
  */
286
  */

+ 34
- 38
Marlin/src/module/planner.cpp Wyświetl plik

132
 #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
132
 #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
133
   float Planner::z_fade_height, // Initialized by settings.load()
133
   float Planner::z_fade_height, // Initialized by settings.load()
134
         Planner::inverse_z_fade_height,
134
         Planner::inverse_z_fade_height,
135
-        Planner::last_raw_lz;
135
+        Planner::last_fade_z;
136
 #endif
136
 #endif
137
 
137
 
138
 #if ENABLED(AUTOTEMP)
138
 #if ENABLED(AUTOTEMP)
552
 
552
 
553
 #if PLANNER_LEVELING
553
 #if PLANNER_LEVELING
554
   /**
554
   /**
555
-   * lx, ly, lz - logical (cartesian, not delta) positions in mm
555
+   * rx, ry, rz - Cartesian positions in mm
556
    */
556
    */
557
-  void Planner::apply_leveling(float &lx, float &ly, float &lz) {
557
+  void Planner::apply_leveling(float &rx, float &ry, float &rz) {
558
 
558
 
559
     if (!planner.leveling_active) return;
559
     if (!planner.leveling_active) return;
560
 
560
 
561
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
561
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
562
-      const float fade_scaling_factor = fade_scaling_factor_for_z(lz);
562
+      const float fade_scaling_factor = fade_scaling_factor_for_z(rz);
563
       if (!fade_scaling_factor) return;
563
       if (!fade_scaling_factor) return;
564
     #else
564
     #else
565
       constexpr float fade_scaling_factor = 1.0;
565
       constexpr float fade_scaling_factor = 1.0;
567
 
567
 
568
     #if ENABLED(AUTO_BED_LEVELING_UBL)
568
     #if ENABLED(AUTO_BED_LEVELING_UBL)
569
 
569
 
570
-      lz += ubl.get_z_correction(lx, ly) * fade_scaling_factor;
570
+      rz += ubl.get_z_correction(rx, ry) * fade_scaling_factor;
571
 
571
 
572
     #elif ENABLED(MESH_BED_LEVELING)
572
     #elif ENABLED(MESH_BED_LEVELING)
573
 
573
 
574
-      lz += mbl.get_z(RAW_X_POSITION(lx), RAW_Y_POSITION(ly)
574
+      rz += mbl.get_z(rx, ry
575
         #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
575
         #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
576
           , fade_scaling_factor
576
           , fade_scaling_factor
577
         #endif
577
         #endif
581
 
581
 
582
       UNUSED(fade_scaling_factor);
582
       UNUSED(fade_scaling_factor);
583
 
583
 
584
-      float dx = RAW_X_POSITION(lx) - (X_TILT_FULCRUM),
585
-            dy = RAW_Y_POSITION(ly) - (Y_TILT_FULCRUM),
586
-            dz = RAW_Z_POSITION(lz);
584
+      float dx = rx - (X_TILT_FULCRUM),
585
+            dy = ry - (Y_TILT_FULCRUM);
587
 
586
 
588
-      apply_rotation_xyz(bed_level_matrix, dx, dy, dz);
587
+      apply_rotation_xyz(bed_level_matrix, dx, dy, rz);
589
 
588
 
590
-      lx = LOGICAL_X_POSITION(dx + X_TILT_FULCRUM);
591
-      ly = LOGICAL_Y_POSITION(dy + Y_TILT_FULCRUM);
592
-      lz = LOGICAL_Z_POSITION(dz);
589
+      rx = dx + X_TILT_FULCRUM;
590
+      ry = dy + Y_TILT_FULCRUM;
593
 
591
 
594
     #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
592
     #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
595
 
593
 
596
-      float tmp[XYZ] = { lx, ly, 0 };
597
-      lz += bilinear_z_offset(tmp) * fade_scaling_factor;
594
+      float tmp[XYZ] = { rx, ry, 0 };
595
+      rz += bilinear_z_offset(tmp) * fade_scaling_factor;
598
 
596
 
599
     #endif
597
     #endif
600
   }
598
   }
601
 
599
 
602
-  void Planner::unapply_leveling(float logical[XYZ]) {
600
+  void Planner::unapply_leveling(float raw[XYZ]) {
603
 
601
 
604
     if (!planner.leveling_active) return;
602
     if (!planner.leveling_active) return;
605
 
603
 
606
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
604
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
607
-      if (z_fade_height && RAW_Z_POSITION(logical[Z_AXIS]) >= z_fade_height) return;
605
+      if (z_fade_height && raw[Z_AXIS] >= z_fade_height) return;
608
     #endif
606
     #endif
609
 
607
 
610
     #if ENABLED(AUTO_BED_LEVELING_UBL)
608
     #if ENABLED(AUTO_BED_LEVELING_UBL)
611
 
609
 
612
-      const float z_physical = RAW_Z_POSITION(logical[Z_AXIS]),
613
-                  z_correct = ubl.get_z_correction(logical[X_AXIS], logical[Y_AXIS]),
614
-                  z_virtual = z_physical - z_correct;
615
-            float z_logical = LOGICAL_Z_POSITION(z_virtual);
610
+      const float z_correct = ubl.get_z_correction(raw[X_AXIS], raw[Y_AXIS]);
611
+            float z_raw = raw[Z_AXIS] - z_correct;
616
 
612
 
617
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
613
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
618
 
614
 
619
-        // for P=physical_z, L=logical_z, M=mesh_z, H=fade_height,
615
+        // for P=physical_z, L=raw_z, M=mesh_z, H=fade_height,
620
         // Given P=L+M(1-L/H) (faded mesh correction formula for L<H)
616
         // Given P=L+M(1-L/H) (faded mesh correction formula for L<H)
621
         //  then L=P-M(1-L/H)
617
         //  then L=P-M(1-L/H)
622
         //    so L=P-M+ML/H
618
         //    so L=P-M+ML/H
625
         //    so L=(P-M)/(1-M/H) for L<H
621
         //    so L=(P-M)/(1-M/H) for L<H
626
 
622
 
627
         if (planner.z_fade_height) {
623
         if (planner.z_fade_height) {
628
-          if (z_logical >= planner.z_fade_height)
629
-            z_logical = LOGICAL_Z_POSITION(z_physical);
624
+          if (z_raw >= planner.z_fade_height)
625
+            z_raw = raw[Z_AXIS];
630
           else
626
           else
631
-            z_logical /= 1.0 - z_correct * planner.inverse_z_fade_height;
627
+            z_raw /= 1.0 - z_correct * planner.inverse_z_fade_height;
632
         }
628
         }
633
 
629
 
634
       #endif // ENABLE_LEVELING_FADE_HEIGHT
630
       #endif // ENABLE_LEVELING_FADE_HEIGHT
635
 
631
 
636
-      logical[Z_AXIS] = z_logical;
632
+      raw[Z_AXIS] = z_raw;
637
 
633
 
638
     #elif ENABLED(MESH_BED_LEVELING)
634
     #elif ENABLED(MESH_BED_LEVELING)
639
 
635
 
640
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
636
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
641
-        const float c = mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS]), 1.0);
642
-        logical[Z_AXIS] = (z_fade_height * (RAW_Z_POSITION(logical[Z_AXIS]) - c)) / (z_fade_height - c);
637
+        const float c = mbl.get_z(raw[X_AXIS], raw[Y_AXIS], 1.0);
638
+        raw[Z_AXIS] = (z_fade_height * (raw[Z_AXIS] - c)) / (z_fade_height - c);
643
       #else
639
       #else
644
-        logical[Z_AXIS] -= mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS]));
640
+        raw[Z_AXIS] -= mbl.get_z(raw[X_AXIS], raw[Y_AXIS]);
645
       #endif
641
       #endif
646
 
642
 
647
     #elif ABL_PLANAR
643
     #elif ABL_PLANAR
648
 
644
 
649
       matrix_3x3 inverse = matrix_3x3::transpose(bed_level_matrix);
645
       matrix_3x3 inverse = matrix_3x3::transpose(bed_level_matrix);
650
 
646
 
651
-      float dx = RAW_X_POSITION(logical[X_AXIS]) - (X_TILT_FULCRUM),
652
-            dy = RAW_Y_POSITION(logical[Y_AXIS]) - (Y_TILT_FULCRUM),
653
-            dz = RAW_Z_POSITION(logical[Z_AXIS]);
647
+      float dx = raw[X_AXIS] - (X_TILT_FULCRUM),
648
+            dy = raw[Y_AXIS] - (Y_TILT_FULCRUM),
649
+            dz = raw[Z_AXIS];
654
 
650
 
655
       apply_rotation_xyz(inverse, dx, dy, dz);
651
       apply_rotation_xyz(inverse, dx, dy, dz);
656
 
652
 
657
-      logical[X_AXIS] = LOGICAL_X_POSITION(dx + X_TILT_FULCRUM);
658
-      logical[Y_AXIS] = LOGICAL_Y_POSITION(dy + Y_TILT_FULCRUM);
659
-      logical[Z_AXIS] = LOGICAL_Z_POSITION(dz);
653
+      raw[X_AXIS] = dx + X_TILT_FULCRUM;
654
+      raw[Y_AXIS] = dy + Y_TILT_FULCRUM;
655
+      raw[Z_AXIS] = dz;
660
 
656
 
661
     #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
657
     #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
662
 
658
 
663
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
659
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
664
-        const float c = bilinear_z_offset(logical);
665
-        logical[Z_AXIS] = (z_fade_height * (RAW_Z_POSITION(logical[Z_AXIS]) - c)) / (z_fade_height - c);
660
+        const float c = bilinear_z_offset(raw);
661
+        raw[Z_AXIS] = (z_fade_height * (raw[Z_AXIS]) - c) / (z_fade_height - c);
666
       #else
662
       #else
667
-        logical[Z_AXIS] -= bilinear_z_offset(logical);
663
+        raw[Z_AXIS] -= bilinear_z_offset(raw);
668
       #endif
664
       #endif
669
 
665
 
670
     #endif
666
     #endif

+ 32
- 33
Marlin/src/module/planner.h Wyświetl plik

202
     static uint32_t cutoff_long;
202
     static uint32_t cutoff_long;
203
 
203
 
204
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
204
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
205
-      static float last_raw_lz;
205
+      static float last_fade_z;
206
     #endif
206
     #endif
207
 
207
 
208
     #if ENABLED(DISABLE_INACTIVE_EXTRUDER)
208
     #if ENABLED(DISABLE_INACTIVE_EXTRUDER)
275
        *  Returns 1.0 if planner.z_fade_height is 0.0.
275
        *  Returns 1.0 if planner.z_fade_height is 0.0.
276
        *  Returns 0.0 if Z is past the specified 'Fade Height'.
276
        *  Returns 0.0 if Z is past the specified 'Fade Height'.
277
        */
277
        */
278
-      inline static float fade_scaling_factor_for_z(const float &lz) {
278
+      inline static float fade_scaling_factor_for_z(const float &rz) {
279
         static float z_fade_factor = 1.0;
279
         static float z_fade_factor = 1.0;
280
         if (z_fade_height) {
280
         if (z_fade_height) {
281
-          const float raw_lz = RAW_Z_POSITION(lz);
282
-          if (raw_lz >= z_fade_height) return 0.0;
283
-          if (last_raw_lz != raw_lz) {
284
-            last_raw_lz = raw_lz;
285
-            z_fade_factor = 1.0 - raw_lz * inverse_z_fade_height;
281
+          if (rz >= z_fade_height) return 0.0;
282
+          if (last_fade_z != rz) {
283
+            last_fade_z = rz;
284
+            z_fade_factor = 1.0 - rz * inverse_z_fade_height;
286
           }
285
           }
287
           return z_fade_factor;
286
           return z_fade_factor;
288
         }
287
         }
289
         return 1.0;
288
         return 1.0;
290
       }
289
       }
291
 
290
 
292
-      FORCE_INLINE static void force_fade_recalc() { last_raw_lz = -999.999; }
291
+      FORCE_INLINE static void force_fade_recalc() { last_fade_z = -999.999; }
293
 
292
 
294
       FORCE_INLINE static void set_z_fade_height(const float &zfh) {
293
       FORCE_INLINE static void set_z_fade_height(const float &zfh) {
295
         z_fade_height = zfh > 0 ? zfh : 0;
294
         z_fade_height = zfh > 0 ? zfh : 0;
297
         force_fade_recalc();
296
         force_fade_recalc();
298
       }
297
       }
299
 
298
 
300
-      FORCE_INLINE static bool leveling_active_at_z(const float &lz) {
301
-        return !z_fade_height || RAW_Z_POSITION(lz) < z_fade_height;
299
+      FORCE_INLINE static bool leveling_active_at_z(const float &rz) {
300
+        return !z_fade_height || rz < z_fade_height;
302
       }
301
       }
303
 
302
 
304
     #else
303
     #else
305
 
304
 
306
-      FORCE_INLINE static float fade_scaling_factor_for_z(const float &lz) {
307
-        UNUSED(lz);
305
+      FORCE_INLINE static float fade_scaling_factor_for_z(const float &rz) {
306
+        UNUSED(rz);
308
         return 1.0;
307
         return 1.0;
309
       }
308
       }
310
 
309
 
311
-      FORCE_INLINE static bool leveling_active_at_z(const float &lz) { UNUSED(lz); return true; }
310
+      FORCE_INLINE static bool leveling_active_at_z(const float &rz) { UNUSED(rz); return true; }
312
 
311
 
313
     #endif
312
     #endif
314
 
313
 
315
     #if PLANNER_LEVELING
314
     #if PLANNER_LEVELING
316
 
315
 
317
-      #define ARG_X float lx
318
-      #define ARG_Y float ly
319
-      #define ARG_Z float lz
316
+      #define ARG_X float rx
317
+      #define ARG_Y float ry
318
+      #define ARG_Z float rz
320
 
319
 
321
       /**
320
       /**
322
        * Apply leveling to transform a cartesian position
321
        * Apply leveling to transform a cartesian position
323
        * as it will be given to the planner and steppers.
322
        * as it will be given to the planner and steppers.
324
        */
323
        */
325
-      static void apply_leveling(float &lx, float &ly, float &lz);
326
-      static void apply_leveling(float logical[XYZ]) { apply_leveling(logical[X_AXIS], logical[Y_AXIS], logical[Z_AXIS]); }
327
-      static void unapply_leveling(float logical[XYZ]);
324
+      static void apply_leveling(float &rx, float &ry, float &rz);
325
+      static void apply_leveling(float raw[XYZ]) { apply_leveling(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS]); }
326
+      static void unapply_leveling(float raw[XYZ]);
328
 
327
 
329
     #else
328
     #else
330
 
329
 
331
-      #define ARG_X const float &lx
332
-      #define ARG_Y const float &ly
333
-      #define ARG_Z const float &lz
330
+      #define ARG_X const float &rx
331
+      #define ARG_Y const float &ry
332
+      #define ARG_Z const float &rz
334
 
333
 
335
     #endif
334
     #endif
336
 
335
 
357
      * Kinematic machines should call buffer_line_kinematic (for leveled moves).
356
      * Kinematic machines should call buffer_line_kinematic (for leveled moves).
358
      * (Cartesians may also call buffer_line_kinematic.)
357
      * (Cartesians may also call buffer_line_kinematic.)
359
      *
358
      *
360
-     *  lx,ly,lz,e   - target position in mm or degrees
359
+     *  rx,ry,rz,e   - target position in mm or degrees
361
      *  fr_mm_s      - (target) speed of the move (mm/s)
360
      *  fr_mm_s      - (target) speed of the move (mm/s)
362
      *  extruder     - target extruder
361
      *  extruder     - target extruder
363
      */
362
      */
364
     static FORCE_INLINE void buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, const float &fr_mm_s, const uint8_t extruder) {
363
     static FORCE_INLINE void buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, const float &fr_mm_s, const uint8_t extruder) {
365
       #if PLANNER_LEVELING && IS_CARTESIAN
364
       #if PLANNER_LEVELING && IS_CARTESIAN
366
-        apply_leveling(lx, ly, lz);
365
+        apply_leveling(rx, ry, rz);
367
       #endif
366
       #endif
368
-      _buffer_line(lx, ly, lz, e, fr_mm_s, extruder);
367
+      _buffer_line(rx, ry, rz, e, fr_mm_s, extruder);
369
     }
368
     }
370
 
369
 
371
     /**
370
     /**
373
      * The target is cartesian, it's translated to delta/scara if
372
      * The target is cartesian, it's translated to delta/scara if
374
      * needed.
373
      * needed.
375
      *
374
      *
376
-     *  ltarget  - x,y,z,e CARTESIAN target in mm
375
+     *  rtarget  - x,y,z,e CARTESIAN target in mm
377
      *  fr_mm_s  - (target) speed of the move (mm/s)
376
      *  fr_mm_s  - (target) speed of the move (mm/s)
378
      *  extruder - target extruder
377
      *  extruder - target extruder
379
      */
378
      */
380
-    static FORCE_INLINE void buffer_line_kinematic(const float ltarget[XYZE], const float &fr_mm_s, const uint8_t extruder) {
379
+    static FORCE_INLINE void buffer_line_kinematic(const float rtarget[XYZE], const float &fr_mm_s, const uint8_t extruder) {
381
       #if PLANNER_LEVELING
380
       #if PLANNER_LEVELING
382
-        float lpos[XYZ] = { ltarget[X_AXIS], ltarget[Y_AXIS], ltarget[Z_AXIS] };
381
+        float lpos[XYZ] = { rtarget[X_AXIS], rtarget[Y_AXIS], rtarget[Z_AXIS] };
383
         apply_leveling(lpos);
382
         apply_leveling(lpos);
384
       #else
383
       #else
385
-        const float * const lpos = ltarget;
384
+        const float * const lpos = rtarget;
386
       #endif
385
       #endif
387
       #if IS_KINEMATIC
386
       #if IS_KINEMATIC
388
         inverse_kinematics(lpos);
387
         inverse_kinematics(lpos);
389
-        _buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], ltarget[E_AXIS], fr_mm_s, extruder);
388
+        _buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], rtarget[E_AXIS], fr_mm_s, extruder);
390
       #else
389
       #else
391
-        _buffer_line(lpos[X_AXIS], lpos[Y_AXIS], lpos[Z_AXIS], ltarget[E_AXIS], fr_mm_s, extruder);
390
+        _buffer_line(lpos[X_AXIS], lpos[Y_AXIS], lpos[Z_AXIS], rtarget[E_AXIS], fr_mm_s, extruder);
392
       #endif
391
       #endif
393
     }
392
     }
394
 
393
 
403
      */
402
      */
404
     static FORCE_INLINE void set_position_mm(ARG_X, ARG_Y, ARG_Z, const float &e) {
403
     static FORCE_INLINE void set_position_mm(ARG_X, ARG_Y, ARG_Z, const float &e) {
405
       #if PLANNER_LEVELING && IS_CARTESIAN
404
       #if PLANNER_LEVELING && IS_CARTESIAN
406
-        apply_leveling(lx, ly, lz);
405
+        apply_leveling(rx, ry, rz);
407
       #endif
406
       #endif
408
-      _set_position_mm(lx, ly, lz, e);
407
+      _set_position_mm(rx, ry, rz, e);
409
     }
408
     }
410
     static void set_position_mm_kinematic(const float position[NUM_AXIS]);
409
     static void set_position_mm_kinematic(const float position[NUM_AXIS]);
411
     static void set_position_mm(const AxisEnum axis, const float &v);
410
     static void set_position_mm(const AxisEnum axis, const float &v);

+ 11
- 11
Marlin/src/module/probe.cpp Wyświetl plik

106
 
106
 
107
 #elif ENABLED(Z_PROBE_ALLEN_KEY)
107
 #elif ENABLED(Z_PROBE_ALLEN_KEY)
108
 
108
 
109
-  FORCE_INLINE void do_blocking_move_to(const float logical[XYZ], const float &fr_mm_s) {
110
-    do_blocking_move_to(logical[X_AXIS], logical[Y_AXIS], logical[Z_AXIS], fr_mm_s);
109
+  FORCE_INLINE void do_blocking_move_to(const float raw[XYZ], const float &fr_mm_s) {
110
+    do_blocking_move_to(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS], fr_mm_s);
111
   }
111
   }
112
 
112
 
113
   void run_deploy_moves_script() {
113
   void run_deploy_moves_script() {
564
     }
564
     }
565
   #endif
565
   #endif
566
 
566
 
567
-  return RAW_CURRENT_POSITION(Z) + zprobe_zoffset
567
+  return current_position[Z_AXIS] + zprobe_zoffset
568
     #if ENABLED(DELTA)
568
     #if ENABLED(DELTA)
569
       + home_offset[Z_AXIS] // Account for delta height adjustment
569
       + home_offset[Z_AXIS] // Account for delta height adjustment
570
     #endif
570
     #endif
580
  *   - Raise to the BETWEEN height
580
  *   - Raise to the BETWEEN height
581
  * - Return the probed Z position
581
  * - Return the probed Z position
582
  */
582
  */
583
-float probe_pt(const float &lx, const float &ly, const bool stow, const uint8_t verbose_level, const bool printable/*=true*/) {
583
+float probe_pt(const float &rx, const float &ry, const bool stow, const uint8_t verbose_level, const bool printable/*=true*/) {
584
   #if ENABLED(DEBUG_LEVELING_FEATURE)
584
   #if ENABLED(DEBUG_LEVELING_FEATURE)
585
     if (DEBUGGING(LEVELING)) {
585
     if (DEBUGGING(LEVELING)) {
586
-      SERIAL_ECHOPAIR(">>> probe_pt(", lx);
587
-      SERIAL_ECHOPAIR(", ", ly);
586
+      SERIAL_ECHOPAIR(">>> probe_pt(", LOGICAL_X_POSITION(rx));
587
+      SERIAL_ECHOPAIR(", ", LOGICAL_Y_POSITION(ry));
588
       SERIAL_ECHOPAIR(", ", stow ? "" : "no ");
588
       SERIAL_ECHOPAIR(", ", stow ? "" : "no ");
589
       SERIAL_ECHOLNPGM("stow)");
589
       SERIAL_ECHOLNPGM("stow)");
590
       DEBUG_POS("", current_position);
590
       DEBUG_POS("", current_position);
591
     }
591
     }
592
   #endif
592
   #endif
593
 
593
 
594
-  const float nx = lx - (X_PROBE_OFFSET_FROM_EXTRUDER), ny = ly - (Y_PROBE_OFFSET_FROM_EXTRUDER);
594
+  const float nx = rx - (X_PROBE_OFFSET_FROM_EXTRUDER), ny = ry - (Y_PROBE_OFFSET_FROM_EXTRUDER);
595
 
595
 
596
   if (printable
596
   if (printable
597
-    ? !position_is_reachable_xy(nx, ny)
598
-    : !position_is_reachable_by_probe_xy(lx, ly)
597
+    ? !position_is_reachable(nx, ny)
598
+    : !position_is_reachable_by_probe(rx, ry)
599
   ) return NAN;
599
   ) return NAN;
600
 
600
 
601
 
601
 
634
 
634
 
635
   if (verbose_level > 2) {
635
   if (verbose_level > 2) {
636
     SERIAL_PROTOCOLPGM("Bed X: ");
636
     SERIAL_PROTOCOLPGM("Bed X: ");
637
-    SERIAL_PROTOCOL_F(lx, 3);
637
+    SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(rx), 3);
638
     SERIAL_PROTOCOLPGM(" Y: ");
638
     SERIAL_PROTOCOLPGM(" Y: ");
639
-    SERIAL_PROTOCOL_F(ly, 3);
639
+    SERIAL_PROTOCOL_F(LOGICAL_Y_POSITION(ry), 3);
640
     SERIAL_PROTOCOLPGM(" Z: ");
640
     SERIAL_PROTOCOLPGM(" Z: ");
641
     SERIAL_PROTOCOL_F(measured_z, 3);
641
     SERIAL_PROTOCOL_F(measured_z, 3);
642
     SERIAL_EOL();
642
     SERIAL_EOL();

+ 1
- 1
Marlin/src/module/probe.h Wyświetl plik

30
 #include "../inc/MarlinConfig.h"
30
 #include "../inc/MarlinConfig.h"
31
 
31
 
32
 bool set_probe_deployed(const bool deploy);
32
 bool set_probe_deployed(const bool deploy);
33
-float probe_pt(const float &lx, const float &ly, const bool, const uint8_t, const bool printable=true);
33
+float probe_pt(const float &rx, const float &ry, const bool, const uint8_t, const bool printable=true);
34
 
34
 
35
 #if HAS_BED_PROBE
35
 #if HAS_BED_PROBE
36
   extern float zprobe_zoffset;
36
   extern float zprobe_zoffset;

+ 8
- 8
Marlin/src/module/scara.cpp Wyświetl plik

36
 
36
 
37
 void scara_set_axis_is_at_home(const AxisEnum axis) {
37
 void scara_set_axis_is_at_home(const AxisEnum axis) {
38
   if (axis == Z_AXIS)
38
   if (axis == Z_AXIS)
39
-    current_position[Z_AXIS] = LOGICAL_POSITION(Z_HOME_POS, Z_AXIS);
39
+    current_position[Z_AXIS] = Z_HOME_POS;
40
   else {
40
   else {
41
 
41
 
42
     /**
42
     /**
43
      * SCARA homes XY at the same time
43
      * SCARA homes XY at the same time
44
      */
44
      */
45
     float homeposition[XYZ];
45
     float homeposition[XYZ];
46
-    LOOP_XYZ(i) homeposition[i] = LOGICAL_POSITION(base_home_pos((AxisEnum)i), i);
46
+    LOOP_XYZ(i) homeposition[i] = base_home_pos((AxisEnum)i);
47
 
47
 
48
     // SERIAL_ECHOPAIR("homeposition X:", homeposition[X_AXIS]);
48
     // SERIAL_ECHOPAIR("homeposition X:", homeposition[X_AXIS]);
49
     // SERIAL_ECHOLNPAIR(" Y:", homeposition[Y_AXIS]);
49
     // SERIAL_ECHOLNPAIR(" Y:", homeposition[Y_AXIS]);
58
     // SERIAL_ECHOPAIR("Cartesian X:", cartes[X_AXIS]);
58
     // SERIAL_ECHOPAIR("Cartesian X:", cartes[X_AXIS]);
59
     // SERIAL_ECHOLNPAIR(" Y:", cartes[Y_AXIS]);
59
     // SERIAL_ECHOLNPAIR(" Y:", cartes[Y_AXIS]);
60
 
60
 
61
-    current_position[axis] = LOGICAL_POSITION(cartes[axis], axis);
61
+    current_position[axis] = cartes[axis];
62
 
62
 
63
     /**
63
     /**
64
      * SCARA home positions are based on configuration since the actual
64
      * SCARA home positions are based on configuration since the actual
104
  * Maths and first version by QHARLEY.
104
  * Maths and first version by QHARLEY.
105
  * Integrated into Marlin and slightly restructured by Joachim Cerny.
105
  * Integrated into Marlin and slightly restructured by Joachim Cerny.
106
  */
106
  */
107
-void inverse_kinematics(const float logical[XYZ]) {
107
+void inverse_kinematics(const float raw[XYZ]) {
108
 
108
 
109
   static float C2, S2, SK1, SK2, THETA, PSI;
109
   static float C2, S2, SK1, SK2, THETA, PSI;
110
 
110
 
111
-  float sx = RAW_X_POSITION(logical[X_AXIS]) - SCARA_OFFSET_X,  // Translate SCARA to standard X Y
112
-        sy = RAW_Y_POSITION(logical[Y_AXIS]) - SCARA_OFFSET_Y;  // With scaling factor.
111
+  float sx = raw[X_AXIS] - SCARA_OFFSET_X,  // Translate SCARA to standard X Y
112
+        sy = raw[Y_AXIS] - SCARA_OFFSET_Y;  // With scaling factor.
113
 
113
 
114
   if (L1 == L2)
114
   if (L1 == L2)
115
     C2 = HYPOT2(sx, sy) / L1_2_2 - 1;
115
     C2 = HYPOT2(sx, sy) / L1_2_2 - 1;
132
 
132
 
133
   delta[A_AXIS] = DEGREES(THETA);        // theta is support arm angle
133
   delta[A_AXIS] = DEGREES(THETA);        // theta is support arm angle
134
   delta[B_AXIS] = DEGREES(THETA + PSI);  // equal to sub arm angle (inverted motor)
134
   delta[B_AXIS] = DEGREES(THETA + PSI);  // equal to sub arm angle (inverted motor)
135
-  delta[C_AXIS] = logical[Z_AXIS];
135
+  delta[C_AXIS] = raw[Z_AXIS];
136
 
136
 
137
   /*
137
   /*
138
-    DEBUG_POS("SCARA IK", logical);
138
+    DEBUG_POS("SCARA IK", raw);
139
     DEBUG_POS("SCARA IK", delta);
139
     DEBUG_POS("SCARA IK", delta);
140
     SERIAL_ECHOPAIR("  SCARA (x,y) ", sx);
140
     SERIAL_ECHOPAIR("  SCARA (x,y) ", sx);
141
     SERIAL_ECHOPAIR(",", sy);
141
     SERIAL_ECHOPAIR(",", sy);

+ 1
- 1
Marlin/src/module/scara.h Wyświetl plik

38
 
38
 
39
 void scara_set_axis_is_at_home(const AxisEnum axis);
39
 void scara_set_axis_is_at_home(const AxisEnum axis);
40
 
40
 
41
-void inverse_kinematics(const float logical[XYZ]);
41
+void inverse_kinematics(const float raw[XYZ]);
42
 void forward_kinematics_SCARA(const float &a, const float &b);
42
 void forward_kinematics_SCARA(const float &a, const float &b);
43
 
43
 
44
 void scara_report_positions();
44
 void scara_report_positions();

+ 4
- 4
Marlin/src/module/tool_change.cpp Wyświetl plik

240
           switch (dual_x_carriage_mode) {
240
           switch (dual_x_carriage_mode) {
241
             case DXC_FULL_CONTROL_MODE:
241
             case DXC_FULL_CONTROL_MODE:
242
               // New current position is the position of the activated extruder
242
               // New current position is the position of the activated extruder
243
-              current_position[X_AXIS] = LOGICAL_X_POSITION(inactive_extruder_x_pos);
243
+              current_position[X_AXIS] = inactive_extruder_x_pos;
244
               // Save the inactive extruder's position (from the old current_position)
244
               // Save the inactive extruder's position (from the old current_position)
245
-              inactive_extruder_x_pos = RAW_X_POSITION(destination[X_AXIS]);
245
+              inactive_extruder_x_pos = destination[X_AXIS];
246
               break;
246
               break;
247
             case DXC_AUTO_PARK_MODE:
247
             case DXC_AUTO_PARK_MODE:
248
               // record raised toolhead position for use by unpark
248
               // record raised toolhead position for use by unpark
260
               active_extruder_parked = (active_extruder == 0);
260
               active_extruder_parked = (active_extruder == 0);
261
 
261
 
262
               if (active_extruder_parked)
262
               if (active_extruder_parked)
263
-                current_position[X_AXIS] = LOGICAL_X_POSITION(inactive_extruder_x_pos);
263
+                current_position[X_AXIS] = inactive_extruder_x_pos;
264
               else
264
               else
265
                 current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset;
265
                 current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset;
266
-              inactive_extruder_x_pos = RAW_X_POSITION(destination[X_AXIS]);
266
+              inactive_extruder_x_pos = destination[X_AXIS];
267
               extruder_duplication_enabled = false;
267
               extruder_duplication_enabled = false;
268
               #if ENABLED(DEBUG_LEVELING_FEATURE)
268
               #if ENABLED(DEBUG_LEVELING_FEATURE)
269
                 if (DEBUGGING(LEVELING)) {
269
                 if (DEBUGGING(LEVELING)) {

Ładowanie…
Anuluj
Zapisz