Ver código fonte

Merge pull request #8234 from thinkyhead/bf2_native_operation

[2.0.x] Operate in Native Machine Space
Scott Lahteine 7 anos atrás
pai
commit
4df024d7b9
Nenhuma conta vinculada ao e-mail do autor do commit
36 arquivos alterados com 449 adições e 489 exclusões
  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 Ver arquivo

@@ -365,10 +365,10 @@ void safe_delay(millis_t ms) {
365 365
 
366 366
       SERIAL_ECHOPGM("Mesh Bed Leveling");
367 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 370
         SERIAL_ECHOLNPGM(" (enabled)");
371
-        SERIAL_ECHOPAIR("MBL Adjustment Z", lz);
371
+        SERIAL_ECHOPAIR("MBL Adjustment Z", rz);
372 372
       }
373 373
       else
374 374
         SERIAL_ECHOPGM(" (disabled)");

+ 15
- 15
Marlin/src/feature/bedlevel/abl/abl.cpp Ver arquivo

@@ -259,7 +259,7 @@ void refresh_bed_level() {
259 259
 #endif
260 260
 
261 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 264
   static float z1, d2, z3, d4, L, D, ratio_x, ratio_y,
265 265
                last_x = -999.999, last_y = -999.999;
@@ -269,8 +269,8 @@ float bilinear_z_offset(const float logical[XYZ]) {
269 269
                 last_gridx = -99, last_gridy = -99;
270 270
 
271 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 275
   #if ENABLED(EXTRAPOLATE_BEYOND_GRID)
276 276
     // Keep using the last grid box
@@ -280,9 +280,9 @@ float bilinear_z_offset(const float logical[XYZ]) {
280 280
     #define FAR_EDGE_OR_BOX 1
281 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 286
     const float gx = constrain(FLOOR(ratio_x), 0, ABL_BG_POINTS_X - FAR_EDGE_OR_BOX);
287 287
     ratio_x -= gx;      // Subtract whole to get the ratio within the grid box
288 288
 
@@ -295,11 +295,11 @@ float bilinear_z_offset(const float logical[XYZ]) {
295 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 303
       const float gy = constrain(FLOOR(ratio_y), 0, ABL_BG_POINTS_Y - FAR_EDGE_OR_BOX);
304 304
       ratio_y -= gy;
305 305
 
@@ -322,7 +322,7 @@ float bilinear_z_offset(const float logical[XYZ]) {
322 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 326
                 L = z1 + d2 * ratio_y;   // Linear interp. LF -> LB
327 327
     const float R = z3 + d4 * ratio_y;   // Linear interp. RF -> RB
328 328
 
@@ -335,10 +335,10 @@ float bilinear_z_offset(const float logical[XYZ]) {
335 335
   static float last_offset = 0;
336 336
   if (FABS(last_offset - offset) > 0.2) {
337 337
     SERIAL_ECHOPGM("Sudden Shift at ");
338
-    SERIAL_ECHOPAIR("x=", x);
338
+    SERIAL_ECHOPAIR("x=", rx);
339 339
     SERIAL_ECHOPAIR(" / ", bilinear_grid_spacing[X_AXIS]);
340 340
     SERIAL_ECHOLNPAIR(" -> gridx=", gridx);
341
-    SERIAL_ECHOPAIR(" y=", y);
341
+    SERIAL_ECHOPAIR(" y=", ry);
342 342
     SERIAL_ECHOPAIR(" / ", bilinear_grid_spacing[Y_AXIS]);
343 343
     SERIAL_ECHOLNPAIR(" -> gridy=", gridy);
344 344
     SERIAL_ECHOPAIR(" ratio_x=", ratio_x);
@@ -390,14 +390,14 @@ float bilinear_z_offset(const float logical[XYZ]) {
390 390
     const int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
391 391
     if (cx2 != cx1 && TEST(x_splits, gcx)) {
392 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 394
       normalized_dist = (destination[X_AXIS] - current_position[X_AXIS]) / (end[X_AXIS] - current_position[X_AXIS]);
395 395
       destination[Y_AXIS] = LINE_SEGMENT_END(Y);
396 396
       CBI(x_splits, gcx);
397 397
     }
398 398
     else if (cy2 != cy1 && TEST(y_splits, gcy)) {
399 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 401
       normalized_dist = (destination[Y_AXIS] - current_position[Y_AXIS]) / (end[Y_AXIS] - current_position[Y_AXIS]);
402 402
       destination[X_AXIS] = LINE_SEGMENT_END(X);
403 403
       CBI(y_splits, gcy);

+ 1
- 1
Marlin/src/feature/bedlevel/abl/abl.h Ver arquivo

@@ -32,7 +32,7 @@
32 32
   extern int bilinear_grid_spacing[2], bilinear_start[2];
33 33
   extern float bilinear_grid_factor[2],
34 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 37
   void extrapolate_unprobed_bed_level();
38 38
   void print_bilinear_leveling_grid();

+ 4
- 4
Marlin/src/feature/bedlevel/bedlevel.cpp Ver arquivo

@@ -256,18 +256,18 @@ void reset_bed_level() {
256 256
 
257 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 260
     const float old_feedrate_mm_s = feedrate_mm_s;
261 261
     #if MANUAL_PROBE_HEIGHT > 0
262 262
       const float prev_z = current_position[Z_AXIS];
263 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 265
       line_to_current_position();
266 266
     #endif
267 267
 
268 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 271
     line_to_current_position();
272 272
 
273 273
     #if MANUAL_PROBE_HEIGHT > 0

+ 6
- 6
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp Ver arquivo

@@ -57,10 +57,10 @@
57 57
    * splitting the move where it crosses mesh borders.
58 58
    */
59 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 64
     NOMORE(cx1, GRID_MAX_POINTS_X - 2);
65 65
     NOMORE(cy1, GRID_MAX_POINTS_Y - 2);
66 66
     NOMORE(cx2, GRID_MAX_POINTS_X - 2);
@@ -81,14 +81,14 @@
81 81
     const int8_t gcx = max(cx1, cx2), gcy = max(cy1, cy2);
82 82
     if (cx2 != cx1 && TEST(x_splits, gcx)) {
83 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 85
       normalized_dist = (destination[X_AXIS] - current_position[X_AXIS]) / (end[X_AXIS] - current_position[X_AXIS]);
86 86
       destination[Y_AXIS] = MBL_SEGMENT_END(Y);
87 87
       CBI(x_splits, gcx);
88 88
     }
89 89
     else if (cy2 != cy1 && TEST(y_splits, gcy)) {
90 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 92
       normalized_dist = (destination[Y_AXIS] - current_position[Y_AXIS]) / (end[Y_AXIS] - current_position[Y_AXIS]);
93 93
       destination[X_AXIS] = MBL_SEGMENT_END(X);
94 94
       CBI(y_splits, gcy);

+ 18
- 18
Marlin/src/feature/bedlevel/ubl/G26_Mesh_Validation_Tool.cpp Ver arquivo

@@ -276,7 +276,7 @@ void unified_bed_leveling::G26() {
276 276
 
277 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 281
       xi = location.x_index;  // Just to shrink the next few lines and make them easier to understand
282 282
       yi = location.y_index;
@@ -325,16 +325,16 @@ void unified_bed_leveling::G26() {
325 325
         if (tmp_div_30 < 0) tmp_div_30 += 360 / 30;
326 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 330
               xe = circle_x + cos_table[tmp_div_30 + 1],
331 331
               ye = circle_y + sin_table[tmp_div_30 + 1];
332 332
         #if IS_KINEMATIC
333 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 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 338
           xe = constrain(xe, X_MIN_POS + 1, X_MAX_POS - 1);
339 339
           ye = constrain(ye, Y_MIN_POS + 1, Y_MAX_POS - 1);
340 340
         #endif
@@ -350,7 +350,7 @@ void unified_bed_leveling::G26() {
350 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 356
       if (look_for_lines_to_connect())
@@ -456,7 +456,7 @@ bool unified_bed_leveling::look_for_lines_to_connect() {
456 456
             sy = ey = constrain(mesh_index_to_ypos(j), Y_MIN_POS + 1, Y_MAX_POS - 1);
457 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 461
               if (g26_debug_flag) {
462 462
                 SERIAL_ECHOPAIR(" Connecting with horizontal line (sx=", sx);
@@ -468,7 +468,7 @@ bool unified_bed_leveling::look_for_lines_to_connect() {
468 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 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,7 +490,7 @@ bool unified_bed_leveling::look_for_lines_to_connect() {
490 490
               sy = constrain(sy, Y_MIN_POS + 1, Y_MAX_POS - 1);
491 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 495
                 if (g26_debug_flag) {
496 496
                   SERIAL_ECHOPAIR(" Connecting with vertical line (sx=", sx);
@@ -501,7 +501,7 @@ bool unified_bed_leveling::look_for_lines_to_connect() {
501 501
                   SERIAL_EOL();
502 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 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,11 +513,11 @@ bool unified_bed_leveling::look_for_lines_to_connect() {
513 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 517
   float feed_value;
518 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 522
   if (z != last_z) {
523 523
     last_z = z;
@@ -540,8 +540,8 @@ void unified_bed_leveling::move_to(const float &x, const float &y, const float &
540 540
 
541 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 545
   destination[E_AXIS] += e_delta;
546 546
 
547 547
   G26_line_to_destination(feed_value);
@@ -734,9 +734,9 @@ bool unified_bed_leveling::parse_G26_parameters() {
734 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 740
     SERIAL_PROTOCOLLNPGM("?Specified X,Y coordinate out of bounds.");
741 741
     return UBL_ERR;
742 742
   }

+ 21
- 21
Marlin/src/feature/bedlevel/ubl/ubl.h Ver arquivo

@@ -108,14 +108,14 @@ class unified_bed_leveling {
108 108
     static bool g29_parameter_parsing();
109 109
     static void find_mean_mesh_height();
110 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 112
     static void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
113 113
     static void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3);
114 114
     static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map);
115 115
     static void g29_what_command();
116 116
     static void g29_eeprom_dump();
117 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 119
     static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
120 120
     static void smart_fill_mesh();
121 121
 
@@ -243,12 +243,12 @@ class unified_bed_leveling {
243 243
      * z_correction_for_x_on_horizontal_mesh_line is an optimization for
244 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 247
       if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 2) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
248 248
         #if ENABLED(DEBUG_LEVELING_FEATURE)
249 249
           if (DEBUGGING(LEVELING)) {
250 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 252
             SERIAL_ECHOPAIR(",x1_i=", x1_i);
253 253
             SERIAL_ECHOPAIR(",yi=", yi);
254 254
             SERIAL_CHAR(')');
@@ -258,7 +258,7 @@ class unified_bed_leveling {
258 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 262
                   z1 = z_values[x1_i][yi];
263 263
 
264 264
       return z1 + xratio * (z_values[x1_i + 1][yi] - z1);
@@ -267,12 +267,12 @@ class unified_bed_leveling {
267 267
     //
268 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 271
       if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 2)) {
272 272
         #if ENABLED(DEBUG_LEVELING_FEATURE)
273 273
           if (DEBUGGING(LEVELING)) {
274 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 276
             SERIAL_ECHOPAIR(", xi=", xi);
277 277
             SERIAL_ECHOPAIR(", y1_i=", y1_i);
278 278
             SERIAL_CHAR(')');
@@ -282,7 +282,7 @@ class unified_bed_leveling {
282 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 286
                   z1 = z_values[xi][y1_i];
287 287
 
288 288
       return z1 + yratio * (z_values[xi][y1_i + 1] - z1);
@@ -294,14 +294,14 @@ class unified_bed_leveling {
294 294
      * Z-Height at both ends. Then it does a linear interpolation of these heights based
295 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 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 305
         SERIAL_CHAR(')');
306 306
         SERIAL_EOL();
307 307
 
@@ -312,23 +312,23 @@ class unified_bed_leveling {
312 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 316
                                mesh_index_to_xpos(cx), z_values[cx][cy],
317 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 320
                                mesh_index_to_xpos(cx), z_values[cx][cy + 1],
321 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 324
                          mesh_index_to_ypos(cy), z1,
325 325
                          mesh_index_to_ypos(cy + 1), z2);
326 326
 
327 327
       #if ENABLED(DEBUG_LEVELING_FEATURE)
328 328
         if (DEBUGGING(MESH_ADJUST)) {
329
-          SERIAL_ECHOPAIR(" raw get_z_correction(", lx0);
329
+          SERIAL_ECHOPAIR(" raw get_z_correction(", rx0);
330 330
           SERIAL_CHAR(',');
331
-          SERIAL_ECHO(ly0);
331
+          SERIAL_ECHO(ry0);
332 332
           SERIAL_ECHOPGM(") = ");
333 333
           SERIAL_ECHO_F(z0, 6);
334 334
         }
@@ -350,9 +350,9 @@ class unified_bed_leveling {
350 350
 
351 351
         #if ENABLED(DEBUG_LEVELING_FEATURE)
352 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 354
             SERIAL_CHAR(',');
355
-            SERIAL_ECHO(ly0);
355
+            SERIAL_ECHO(ry0);
356 356
             SERIAL_CHAR(')');
357 357
             SERIAL_EOL();
358 358
           }
@@ -369,7 +369,7 @@ class unified_bed_leveling {
369 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 373
     static void line_to_destination_cartesian(const float &fr, uint8_t e);
374 374
 
375 375
     #define _CMPZ(a,b) (z_values[a][b] == z_values[a][b+1])

+ 44
- 47
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Ver arquivo

@@ -393,11 +393,11 @@
393 393
           restore_ubl_active_state_and_leave();
394 394
         }
395 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 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 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 403
           if (isnan(z1) || isnan(z2) || isnan(z3)) { // probe_pt will return NAN if unreachable
@@ -411,9 +411,9 @@
411 411
           // its height is.)
412 412
 
413 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 418
           do_blocking_move_to_xy(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)));
419 419
           tilt_mesh_based_on_3pts(z1, z2, z3);
@@ -497,7 +497,7 @@
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 501
               SERIAL_PROTOCOLLNPGM("XY outside printable radius.");
502 502
               return;
503 503
             }
@@ -734,7 +734,7 @@
734 734
      * Probe all invalidated locations of the mesh that can be reached by the probe.
735 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 738
       mesh_index_pair location;
739 739
 
740 740
       has_control_of_lcd_panel = true;
@@ -762,13 +762,13 @@
762 762
         if (close_or_far)
763 763
           location = find_furthest_invalid_mesh_point();
764 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 767
         if (location.x_index >= 0) {    // mesh point found and is reachable by probe
768 768
           const float rawx = mesh_index_to_xpos(location.x_index),
769 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 772
           z_values[location.x_index][location.y_index] = measured_z;
773 773
         }
774 774
 
@@ -778,8 +778,8 @@
778 778
       restore_ubl_active_state_and_leave();
779 779
 
780 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,28 +953,26 @@
953 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 958
       has_control_of_lcd_panel = true;
959 959
 
960 960
       save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
961 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 964
       lcd_return_to_status();
965 965
 
966 966
       mesh_index_pair location;
967 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 969
         // It doesn't matter if the probe can't reach the NAN location. This is a manual probe.
970 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 977
         do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
980 978
 
@@ -1038,7 +1036,7 @@
1038 1036
       restore_ubl_active_state_and_leave();
1039 1037
       KEEPALIVE_STATE(IN_HANDLER);
1040 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 1042
   #endif // NEWPANEL
@@ -1111,8 +1109,8 @@
1111 1109
     }
1112 1110
 
1113 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 1115
     if (err_flag) return UBL_ERR;
1118 1116
 
@@ -1365,7 +1363,7 @@
1365 1363
           const float mx = mesh_index_to_xpos(i),
1366 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 1367
             continue;
1370 1368
 
1371 1369
           found_a_NAN = true;
@@ -1413,14 +1411,14 @@
1413 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 1415
     mesh_index_pair out_mesh;
1418 1416
     out_mesh.x_index = out_mesh.y_index = -1;
1419 1417
     out_mesh.distance = -99999.9;
1420 1418
 
1421 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 1423
     float best_so_far = 99999.99;
1426 1424
 
@@ -1433,7 +1431,6 @@
1433 1431
         ) {
1434 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 1434
           const float mx = mesh_index_to_xpos(i),
1438 1435
                       my = mesh_index_to_ypos(j);
1439 1436
 
@@ -1441,7 +1438,7 @@
1441 1438
           // Also for round beds, there are grid points outside the bed the nozzle can't reach.
1442 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 1442
             continue;
1446 1443
 
1447 1444
           // Reachable. Check if it's the best_so_far location to the nozzle.
@@ -1450,7 +1447,7 @@
1450 1447
 
1451 1448
           // factor in the distance from the current location for the normal case
1452 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 1451
           if (distance < best_so_far) {
1455 1452
             best_so_far = distance;   // We found a closer location with
1456 1453
             out_mesh.x_index = i;     // the specified type of mesh value.
@@ -1465,7 +1462,7 @@
1465 1462
 
1466 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 1466
       if (!parser.seen('R'))    // fine_tune_mesh() is special. If no repetition count flag is specified
1470 1467
         g29_repetition_cnt = 1;   // do exactly one mesh location. Otherwise use what the parser decided.
1471 1468
 
@@ -1480,7 +1477,7 @@
1480 1477
 
1481 1478
       mesh_index_pair location;
1482 1479
 
1483
-      if (!position_is_reachable_xy(lx, ly)) {
1480
+      if (!position_is_reachable(rx, ry)) {
1484 1481
         SERIAL_PROTOCOLLNPGM("(X,Y) outside printable radius.");
1485 1482
         return;
1486 1483
       }
@@ -1490,12 +1487,12 @@
1490 1487
       LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH);
1491 1488
 
1492 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 1492
       uint16_t not_done[16];
1496 1493
       memset(not_done, 0xFF, sizeof(not_done));
1497 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 1497
         if (location.x_index < 0) break; // stop when we can't find any more reachable points.
1501 1498
 
@@ -1505,7 +1502,7 @@
1505 1502
         const float rawx = mesh_index_to_xpos(location.x_index),
1506 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 1506
           break;
1510 1507
 
1511 1508
         float new_z = z_values[location.x_index][location.y_index];
@@ -1514,7 +1511,7 @@
1514 1511
           new_z = 0.0;
1515 1512
 
1516 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 1516
         new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
1520 1517
 
@@ -1576,7 +1573,7 @@
1576 1573
       restore_ubl_active_state_and_leave();
1577 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 1578
       LCD_MESSAGEPGM(MSG_UBL_DONE_EDITING_MESH);
1582 1579
       SERIAL_ECHOLNPGM("Done Editing Mesh");
@@ -1654,29 +1651,29 @@
1654 1651
 
1655 1652
       bool zig_zag = false;
1656 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 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 1658
           #if ENABLED(DEBUG_LEVELING_FEATURE)
1662 1659
             if (DEBUGGING(LEVELING)) {
1663 1660
               SERIAL_CHAR('(');
1664
-              SERIAL_PROTOCOL_F(x, 7);
1661
+              SERIAL_PROTOCOL_F(rx, 7);
1665 1662
               SERIAL_CHAR(',');
1666
-              SERIAL_PROTOCOL_F(y, 7);
1663
+              SERIAL_PROTOCOL_F(ry, 7);
1667 1664
               SERIAL_ECHOPGM(")   logical: ");
1668 1665
               SERIAL_CHAR('(');
1669
-              SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(x), 7);
1666
+              SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(rx), 7);
1670 1667
               SERIAL_CHAR(',');
1671
-              SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(y), 7);
1668
+              SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(ry), 7);
1672 1669
               SERIAL_ECHOPGM(")   measured: ");
1673 1670
               SERIAL_PROTOCOL_F(measured_z, 7);
1674 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 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 1678
           #if ENABLED(DEBUG_LEVELING_FEATURE)
1682 1679
             if (DEBUGGING(LEVELING)) {
@@ -1686,7 +1683,7 @@
1686 1683
             }
1687 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 1689
         zig_zag ^= true;

+ 62
- 71
Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp Ver arquivo

@@ -112,10 +112,10 @@
112 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 120
     if (g26_debug_flag) {
121 121
       SERIAL_ECHOPAIR(" ubl.line_to_destination(xe=", end[X_AXIS]);
@@ -160,7 +160,7 @@
160 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 165
       float z1 = z_values[cell_dest_xi    ][cell_dest_yi    ] + xratio *
166 166
                 (z_values[cell_dest_xi + 1][cell_dest_yi    ] - z_values[cell_dest_xi][cell_dest_yi    ]),
@@ -172,7 +172,7 @@
172 172
       // we are done with the fractional X distance into the cell. Now with the two Z-Heights we have calculated, we
173 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 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,16 +248,16 @@
248 248
       current_yi += down_flag;  // Line is heading down, we just want to go to the bottom
249 249
       while (current_yi != cell_dest_yi + down_flag) {
250 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 254
          * if the slope of the line is infinite, we won't do the calculations
255 255
          * else, we know the next X is the same so we can recover and continue!
256 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 261
                    * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
262 262
 
263 263
         /**
@@ -269,7 +269,7 @@
269 269
          */
270 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 275
          * Without this check, it is possible for the algorithm to generate a zero length move in the case
@@ -277,9 +277,9 @@
277 277
          * happens, it might be best to remove the check and always 'schedule' the move because
278 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 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 283
             e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
284 284
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
285 285
           }
@@ -288,7 +288,7 @@
288 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 292
         } //else printf("FIRST MOVE PRUNED  ");
293 293
       }
294 294
 
@@ -318,10 +318,10 @@
318 318
                                 // edge of this cell for the first move.
319 319
       while (current_xi != cell_dest_xi + left_flag) {
320 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 325
                    * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
326 326
 
327 327
         /**
@@ -333,7 +333,7 @@
333 333
          */
334 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 339
          * Without this check, it is possible for the algorithm to generate a zero length move in the case
@@ -341,9 +341,9 @@
341 341
          * that happens, it might be best to remove the check and always 'schedule' the move because
342 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 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 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 348
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
349 349
           }
@@ -352,7 +352,7 @@
352 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 356
         } //else printf("FIRST MOVE PRUNED  ");
357 357
       }
358 358
 
@@ -383,17 +383,17 @@
383 383
 
384 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 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 397
                    * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
398 398
 
399 399
         /**
@@ -406,7 +406,7 @@
406 406
         if (isnan(z0)) z0 = 0.0;
407 407
 
408 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 410
           e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
411 411
           z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
412 412
         }
@@ -414,13 +414,13 @@
414 414
           e_position = end[E_AXIS];
415 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 418
         current_yi += dyi;
419 419
         yi_cnt--;
420 420
       }
421 421
       else {
422 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 424
                    * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
425 425
 
426 426
         /**
@@ -433,7 +433,7 @@
433 433
         if (isnan(z0)) z0 = 0.0;
434 434
 
435 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 437
           e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
438 438
           z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
439 439
         }
@@ -442,7 +442,7 @@
442 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 446
         current_xi += dxi;
447 447
         xi_cnt--;
448 448
       }
@@ -476,7 +476,7 @@
476 476
     // We don't want additional apply_leveling() performed by regular buffer_line or buffer_line_kinematic,
477 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 481
       #if ENABLED(DELTA)  // apply delta inverse_kinematics
482 482
 
@@ -492,14 +492,11 @@
492 492
                                          - HYPOT2( delta_tower[C_AXIS][X_AXIS] - rx,
493 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 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 501
         inverse_kinematics(lseg); // this writes delta[ABC] from lseg[XYZ]
505 502
                                   // should move the feedrate scaling to scara inverse_kinematics
@@ -510,17 +507,11 @@
510 507
         scara_oldB = delta[B_AXIS];
511 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 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 516
       #endif
526 517
 
@@ -533,15 +524,15 @@
533 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 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 537
       const float cartesian_xy_mm = HYPOT(tot_dx, tot_dy);  // total horizontal xy distance
547 538
 
@@ -571,14 +562,14 @@
571 562
       // Note that E segment distance could vary slightly as z mesh height
572 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 568
             seg_le = current_position[E_AXIS];
578 569
 
579 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 574
         do {
584 575
 
@@ -588,13 +579,13 @@
588 579
             seg_rz += seg_dz;
589 580
             seg_le += seg_de;
590 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 590
         } while (segments);
600 591
 
@@ -604,7 +595,7 @@
604 595
       // Otherwise perform per-segment leveling
605 596
 
606 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 599
       #endif
609 600
 
610 601
       // increment to first segment destination
@@ -671,16 +662,16 @@
671 662
             z_cxcy *= fade_scaling_factor;          // apply fade factor to interpolated mesh height
672 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 675
             return false;                           // did not set_current_from_destination()
685 676
 
686 677
           seg_rx += seg_dx;

+ 2
- 2
Marlin/src/gcode/bedlevel/G42.cpp Ver arquivo

@@ -56,8 +56,8 @@ void GcodeSuite::G42() {
56 56
     #endif
57 57
 
58 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 61
     if (parser.boolval('P')) {
62 62
       if (hasI) destination[X_AXIS] -= X_PROBE_OFFSET_FROM_EXTRUDER;
63 63
       if (hasJ) destination[Y_AXIS] -= Y_PROBE_OFFSET_FROM_EXTRUDER;

+ 32
- 32
Marlin/src/gcode/bedlevel/abl/G29.cpp Ver arquivo

@@ -258,28 +258,28 @@ void GcodeSuite::G29() {
258 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 263
           SERIAL_ERROR_START();
264 264
           SERIAL_ERRORLNPGM("Bad Z value");
265 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 270
         int8_t i = parser.byteval('I', -1),
271 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 277
           i = constrain(i, 0, GRID_MAX_POINTS_X - 1);
278 278
           j = constrain(j, 0, GRID_MAX_POINTS_Y - 1);
279 279
         }
280 280
         if (WITHIN(i, 0, GRID_MAX_POINTS_X - 1) && WITHIN(j, 0, GRID_MAX_POINTS_Y)) {
281 281
           set_bed_leveling_enabled(false);
282
-          z_values[i][j] = z;
282
+          z_values[i][j] = rz;
283 283
           #if ENABLED(ABL_BILINEAR_SUBDIVISION)
284 284
             bed_level_virt_interpolate();
285 285
           #endif
@@ -340,36 +340,36 @@ void GcodeSuite::G29() {
340 340
 
341 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 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 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 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 355
                  back_out = back_out_b || back_probe_bed_position < front_probe_bed_position + MIN_PROBE_EDGE;
356 356
 
357 357
       if (left_out || right_out || front_out || back_out) {
358 358
         if (left_out) {
359 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 362
         if (right_out) {
363 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 366
         if (front_out) {
367 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 370
         if (back_out) {
371 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 374
         return;
375 375
       }
@@ -416,8 +416,8 @@ void GcodeSuite::G29() {
416 416
       #endif
417 417
       if ( xGridSpacing != bilinear_grid_spacing[X_AXIS]
418 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 422
         if (dryrun) {
423 423
           // Before reset bed level, re-enable to correct the position
@@ -429,8 +429,8 @@ void GcodeSuite::G29() {
429 429
         // Initialize a grid with the given dimensions
430 430
         bilinear_grid_spacing[X_AXIS] = xGridSpacing;
431 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 435
         // Can't re-enable (on error) until the new grid is written
436 436
         abl_should_enable = false;
@@ -555,7 +555,7 @@ void GcodeSuite::G29() {
555 555
         #endif
556 556
 
557 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 559
         ++abl_probe_index;
560 560
       }
561 561
 
@@ -585,8 +585,8 @@ void GcodeSuite::G29() {
585 585
 
586 586
       // Probe at 3 arbitrary points
587 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 590
         #if HAS_SOFTWARE_ENDSTOPS
591 591
           // Disable software endstops to allow manual adjustment
592 592
           // If G29 is not completed, they will not be re-enabled
@@ -663,7 +663,7 @@ void GcodeSuite::G29() {
663 663
 
664 664
           #if IS_KINEMATIC
665 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 667
           #endif
668 668
 
669 669
           measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
@@ -701,8 +701,8 @@ void GcodeSuite::G29() {
701 701
 
702 702
       for (uint8_t i = 0; i < 3; ++i) {
703 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 706
         measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
707 707
         if (isnan(measured_z)) {
708 708
           planner.leveling_active = abl_should_enable;

+ 2
- 2
Marlin/src/gcode/bedlevel/mbl/G29.cpp Ver arquivo

@@ -46,7 +46,7 @@ void mesh_probing_done() {
46 46
   gcode.home_all_axes();
47 47
   set_bed_leveling_enabled(true);
48 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 50
     set_destination_from_current();
51 51
     line_to_destination(homing_feedrate(Z_AXIS));
52 52
     stepper.synchronize();
@@ -139,7 +139,7 @@ void GcodeSuite::G29() {
139 139
       }
140 140
       else {
141 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 143
         line_to_current_position();
144 144
         stepper.synchronize();
145 145
 

+ 5
- 5
Marlin/src/gcode/calibrate/G28.cpp Ver arquivo

@@ -86,8 +86,8 @@
86 86
     /**
87 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 91
     destination[Z_AXIS] = current_position[Z_AXIS]; // Z is already at the right height
92 92
 
93 93
     #if HOMING_Z_WITH_PROBE
@@ -95,7 +95,7 @@
95 95
       destination[Y_AXIS] -= Y_PROBE_OFFSET_FROM_EXTRUDER;
96 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 100
       #if ENABLED(DEBUG_LEVELING_FEATURE)
101 101
         if (DEBUGGING(LEVELING)) DEBUG_POS("Z_SAFE_HOMING", destination);
@@ -209,7 +209,7 @@ void GcodeSuite::G28(const bool always_home_all) {
209 209
 
210 210
       if (home_all || homeX || homeY) {
211 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 213
         if (destination[Z_AXIS] > current_position[Z_AXIS]) {
214 214
 
215 215
           #if ENABLED(DEBUG_LEVELING_FEATURE)
@@ -251,7 +251,7 @@ void GcodeSuite::G28(const bool always_home_all) {
251 251
         HOMEAXIS(X);
252 252
 
253 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 256
         // Home the 1st (left) extruder
257 257
         active_extruder = 0;

+ 1
- 1
Marlin/src/gcode/calibrate/G33.cpp Ver arquivo

@@ -459,7 +459,7 @@ void GcodeSuite::G33() {
459 459
     LOOP_CAL_RAD(axis) {
460 460
       const float a = RADIANS(210 + (360 / NPP) *  (axis - 1)),
461 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 463
         SERIAL_PROTOCOLLNPGM("?(M665 B)ed radius is implausible.");
464 464
         return;
465 465
       }

+ 4
- 4
Marlin/src/gcode/calibrate/M48.cpp Ver arquivo

@@ -82,16 +82,16 @@ void GcodeSuite::M48() {
82 82
               Y_probe_location = parser.linearval('Y', Y_current + Y_PROBE_OFFSET_FROM_EXTRUDER);
83 83
 
84 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 86
       out_of_range_error(PSTR("X"));
87 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 90
       out_of_range_error(PSTR("Y"));
91 91
       return;
92 92
     }
93 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 95
       SERIAL_PROTOCOLLNPGM("? (X,Y) location outside of probeable radius.");
96 96
       return;
97 97
     }
@@ -184,7 +184,7 @@ void GcodeSuite::M48() {
184 184
           #else
185 185
             // If we have gone out too far, we can do a simple fix and scale the numbers
186 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 188
               X_current *= 0.8;
189 189
               Y_current *= 0.8;
190 190
               if (verbose_level > 3) {

+ 1
- 1
Marlin/src/gcode/gcode.cpp Ver arquivo

@@ -89,7 +89,7 @@ bool GcodeSuite::get_target_extruder_from_command() {
89 89
 void GcodeSuite::get_destination_from_command() {
90 90
   LOOP_XYZE(i) {
91 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 93
     else
94 94
       destination[i] = current_position[i];
95 95
   }

+ 1
- 1
Marlin/src/gcode/geometry/M206_M428.cpp Ver arquivo

@@ -67,7 +67,7 @@ void GcodeSuite::M428() {
67 67
   LOOP_XYZ(i) {
68 68
     if (axis_homed[i]) {
69 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 71
       if (WITHIN(diff, -20, 20)) {
72 72
         set_home_offset((AxisEnum)i, diff);
73 73
       }

+ 7
- 3
Marlin/src/gcode/host/M114.cpp Ver arquivo

@@ -46,11 +46,15 @@
46 46
     stepper.synchronize();
47 47
 
48 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 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 59
     SERIAL_PROTOCOLPGM("Leveled:");
56 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 Ver arquivo

@@ -44,7 +44,7 @@
44 44
  * options for G2/G3 arc generation. In future these options may be GCode tunable.
45 45
  */
46 46
 void plan_arc(
47
-  float logical[XYZE], // Destination position
47
+  float rtarget[XYZE], // Destination position
48 48
   float *offset,       // Center of rotation relative to current_position
49 49
   uint8_t clockwise    // Clockwise?
50 50
 ) {
@@ -65,10 +65,10 @@ void plan_arc(
65 65
   const float radius = HYPOT(r_P, r_Q),
66 66
               center_P = current_position[p_axis] - r_P,
67 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 73
   // CCW angle of rotation between position and target from the circle center. Only one atan2() trig computation required.
74 74
   float angular_travel = ATAN2(r_P * rt_Y - r_Q * rt_X, r_P * rt_X + r_Q * rt_Y);
@@ -76,7 +76,7 @@ void plan_arc(
76 76
   if (clockwise) angular_travel -= RADIANS(360);
77 77
 
78 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 80
     angular_travel = RADIANS(360);
81 81
 
82 82
   const float mm_of_travel = HYPOT(angular_travel * radius, FABS(linear_travel));
@@ -176,7 +176,7 @@ void plan_arc(
176 176
   }
177 177
 
178 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 181
   // As far as the parser is concerned, the position is now == target. In reality the
182 182
   // motion control system might still be processing the action and the real tool position

+ 1
- 1
Marlin/src/gcode/probe/G30.cpp Ver arquivo

@@ -42,7 +42,7 @@ void GcodeSuite::G30() {
42 42
   const float xpos = parser.linearval('X', current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER),
43 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 47
   // Disable leveling so the planner won't mess with us
48 48
   #if HAS_LEVELING

+ 2
- 2
Marlin/src/gcode/scara/M360-M364.cpp Ver arquivo

@@ -32,8 +32,8 @@
32 32
 inline bool SCARA_move_to_cal(const uint8_t delta_a, const uint8_t delta_b) {
33 33
   if (IsRunning()) {
34 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 37
     destination[Z_AXIS] = current_position[Z_AXIS];
38 38
     prepare_move_to_destination();
39 39
     return true;

+ 17
- 20
Marlin/src/lcd/ultralcd.cpp Ver arquivo

@@ -1672,7 +1672,7 @@ void kill_screen(const char* lcd_msg) {
1672 1672
      */
1673 1673
     static int8_t bed_corner;
1674 1674
     void _lcd_goto_next_corner() {
1675
-      line_to_z(LOGICAL_Z_POSITION(4.0));
1675
+      line_to_z(4.0);
1676 1676
       switch (bed_corner) {
1677 1677
         case 0:
1678 1678
           current_position[X_AXIS] = X_MIN_BED + 10;
@@ -1689,7 +1689,7 @@ void kill_screen(const char* lcd_msg) {
1689 1689
           break;
1690 1690
       }
1691 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 1693
       if (++bed_corner > 3) bed_corner = 0;
1694 1694
     }
1695 1695
 
@@ -1735,7 +1735,7 @@ void kill_screen(const char* lcd_msg) {
1735 1735
     //
1736 1736
     void _lcd_after_probing() {
1737 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 1739
       #endif
1740 1740
       // Display "Done" screen and wait for moves to complete
1741 1741
       #if MANUAL_PROBE_HEIGHT > 0 || ENABLED(MESH_BED_LEVELING)
@@ -1750,13 +1750,13 @@ void kill_screen(const char* lcd_msg) {
1750 1750
     #if ENABLED(MESH_BED_LEVELING)
1751 1751
 
1752 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 1754
         #if MANUAL_PROBE_HEIGHT > 0
1755 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 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 1760
         planner.buffer_line_kinematic(current_position, MMM_TO_MMS(XY_PROBE_SPEED), active_extruder);
1761 1761
         #if MANUAL_PROBE_HEIGHT > 0
1762 1762
           line_to_z(prev_z);
@@ -1886,10 +1886,7 @@ void kill_screen(const char* lcd_msg) {
1886 1886
         mbl.zigzag(manual_probe_index, px, py);
1887 1887
 
1888 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 1891
         // After the blocking function returns, change menus
1895 1892
         lcd_goto_screen(_lcd_level_bed_get_z);
@@ -2370,8 +2367,8 @@ void kill_screen(const char* lcd_msg) {
2370 2367
      * UBL LCD Map Movement
2371 2368
      */
2372 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 2372
       planner.buffer_line_kinematic(current_position, MMM_TO_MMS(XY_PROBE_SPEED), active_extruder);
2376 2373
     }
2377 2374
 
@@ -2705,17 +2702,17 @@ void kill_screen(const char* lcd_msg) {
2705 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 2706
       #if HAS_LEVELING
2710 2707
         reset_bed_level(); // After calibration bed-level data is no longer valid
2711 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 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 2714
       line_to_current_z();
2718
-      z_dest = LOGICAL_Z_POSITION(Z_CLEARANCE_BETWEEN_PROBES);
2715
+      z_dest = Z_CLEARANCE_BETWEEN_PROBES;
2719 2716
       line_to_z(z_dest);
2720 2717
 
2721 2718
       lcd_synchronize();
@@ -2723,8 +2720,8 @@ void kill_screen(const char* lcd_msg) {
2723 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 2725
       KEEPALIVE_STATE(PAUSED_FOR_USER);
2729 2726
       defer_return_to_status = true;
2730 2727
       wait_for_user = true;

+ 1
- 1
Marlin/src/lcd/ultralcd.h Ver arquivo

@@ -119,7 +119,7 @@
119 119
     #endif
120 120
 
121 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 123
     #endif
124 124
 
125 125
   #else

+ 3
- 3
Marlin/src/lcd/ultralcd_impl_DOGM.h Ver arquivo

@@ -646,9 +646,9 @@ static void lcd_implementation_status_screen() {
646 646
 
647 647
   // At the first page, regenerate the XYZ strings
648 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 652
     #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
653 653
       strcpy(wstring, ftostr12ns(filament_width_meas));
654 654
       strcpy(mstring, itostr3(100.0 * planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));

+ 9
- 7
Marlin/src/lcd/ultralcd_impl_HD44780.h Ver arquivo

@@ -621,7 +621,9 @@ FORCE_INLINE void _draw_heater_status(const int8_t heater, const char prefix, co
621 621
   lcd.print(itostr3(t1 + 0.5));
622 622
   lcd.write('/');
623 623
 
624
-  #if HEATER_IDLE_HANDLER
624
+  #if !HEATER_IDLE_HANDLER
625
+    UNUSED(blink);
626
+  #else
625 627
     const bool is_idle = (!isBed ? thermalManager.is_heater_idle(heater) :
626 628
       #if HAS_TEMP_BED
627 629
         thermalManager.is_bed_idle()
@@ -779,12 +781,12 @@ static void lcd_implementation_status_screen() {
779 781
         // When everything is ok you see a constant 'X'.
780 782
 
781 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 786
         lcd.write(' ');
785 787
 
786 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 791
       #endif // HOTENDS > 1 || TEMP_SENSOR_BED != 0
790 792
 
@@ -842,11 +844,11 @@ static void lcd_implementation_status_screen() {
842 844
 
843 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 849
     #if DISABLED(LCD_SET_PROGRESS_MANUALLY)
846 850
       const uint8_t progress_bar_percent = card.percentDone();
847 851
     #endif
848
-    // Draw the progress bar if the message has shown long enough
849
-    // or if there is no message set.
850 852
     if (progress_bar_percent > 2 && (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !lcd_status_message[0]))
851 853
       return lcd_draw_progress_bar(progress_bar_percent);
852 854
 
@@ -1168,9 +1170,9 @@ static void lcd_implementation_status_screen() {
1168 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 1177
       #if LCD_WIDTH >= 20
1176 1178
         #define _LCD_W_POS 12

+ 5
- 9
Marlin/src/module/delta.cpp Ver arquivo

@@ -72,7 +72,7 @@ void recalc_delta_settings(const float radius, const float diagonal_rod, const f
72 72
 /**
73 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 76
  * position, storing the result in the delta[] array.
77 77
  *
78 78
  * This is an expensive calculation, requiring 3 square
@@ -117,8 +117,8 @@ void recalc_delta_settings(const float radius, const float diagonal_rod, const f
117 117
     SERIAL_ECHOLNPAIR(" C:", delta[C_AXIS]);      \
118 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 122
   // DELTA_DEBUG();
123 123
 }
124 124
 
@@ -127,14 +127,10 @@ void inverse_kinematics(const float logical[XYZ]) {
127 127
  * effector has the full range of XY motion.
128 128
  */
129 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 131
   inverse_kinematics(cartesian);
136 132
   float distance = delta[A_AXIS];
137
-  cartesian[Y_AXIS] = LOGICAL_Y_POSITION(DELTA_PRINTABLE_RADIUS);
133
+  cartesian[Y_AXIS] = DELTA_PRINTABLE_RADIUS;
138 134
   inverse_kinematics(cartesian);
139 135
   return FABS(distance - delta[A_AXIS]);
140 136
 }

+ 2
- 11
Marlin/src/module/delta.h Ver arquivo

@@ -47,7 +47,7 @@ void recalc_delta_settings(const float radius, const float diagonal_rod, const f
47 47
 /**
48 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 51
  * position, storing the result in the delta[] array.
52 52
  *
53 53
  * This is an expensive calculation, requiring 3 square
@@ -88,16 +88,7 @@ void recalc_delta_settings(const float radius, const float diagonal_rod, const f
88 88
   delta[C_AXIS] = DELTA_Z(C_AXIS); \
89 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 94
  * Calculate the highest Z position where the

+ 68
- 72
Marlin/src/module/motion.cpp Ver arquivo

@@ -73,7 +73,7 @@ bool relative_mode = false;
73 73
 
74 74
 /**
75 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 77
  *   Used by 'line_to_current_position' to do a move after changing it.
78 78
  *   Used by 'SYNC_PLAN_POSITION_KINEMATIC' to update 'planner.position'.
79 79
  */
@@ -197,20 +197,16 @@ void get_cartesian_from_steppers() {
197 197
       stepper.get_axis_position_mm(B_AXIS),
198 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 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 210
     cartes[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS);
215 211
   #endif
216 212
 }
@@ -288,16 +284,16 @@ void line_to_destination(const float fr_mm_s) {
288 284
  *  Plan a move to (X, Y, Z) and set the current_position
289 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 288
   const float old_feedrate_mm_s = feedrate_mm_s;
293 289
 
294 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 292
   #endif
297 293
 
298 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 298
     feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
303 299
 
@@ -309,10 +305,10 @@ void do_blocking_move_to(const float &lx, const float &ly, const float &lz, cons
309 305
 
310 306
     // when in the danger zone
311 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 312
         prepare_uninterpolated_move_to_destination(); // set_current_from_destination()
317 313
         #if ENABLED(DEBUG_LEVELING_FEATURE)
318 314
           if (DEBUGGING(LEVELING)) DEBUG_POS("danger zone move", current_position);
@@ -328,23 +324,23 @@ void do_blocking_move_to(const float &lx, const float &ly, const float &lz, cons
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 329
       prepare_uninterpolated_move_to_destination();   // set_current_from_destination()
334 330
       #if ENABLED(DEBUG_LEVELING_FEATURE)
335 331
         if (DEBUGGING(LEVELING)) DEBUG_POS("z raise move", current_position);
336 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 337
     prepare_move_to_destination();         // set_current_from_destination()
342 338
     #if ENABLED(DEBUG_LEVELING_FEATURE)
343 339
       if (DEBUGGING(LEVELING)) DEBUG_POS("xy move", current_position);
344 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 344
       prepare_uninterpolated_move_to_destination();   // set_current_from_destination()
349 345
       #if ENABLED(DEBUG_LEVELING_FEATURE)
350 346
         if (DEBUGGING(LEVELING)) DEBUG_POS("z lower move", current_position);
@@ -353,44 +349,44 @@ void do_blocking_move_to(const float &lx, const float &ly, const float &lz, cons
353 349
 
354 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 354
     set_destination_from_current();
359 355
 
360 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 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 364
     prepare_uninterpolated_move_to_destination(fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S);
369 365
 
370 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 369
       prepare_uninterpolated_move_to_destination(fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS));
374 370
     }
375 371
 
376 372
   #else
377 373
 
378 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 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 378
       line_to_current_position();
383 379
     }
384 380
 
385 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 384
     line_to_current_position();
389 385
 
390 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 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 390
       line_to_current_position();
395 391
     }
396 392
 
@@ -404,14 +400,14 @@ void do_blocking_move_to(const float &lx, const float &ly, const float &lz, cons
404 400
     if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< do_blocking_move_to");
405 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,26 +517,26 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
521 517
    * This calls planner.buffer_line several times, adding
522 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 522
     // Get the top feedrate of the move in the XY plane
527 523
     const float _feedrate_mm_s = MMS_SCALED(feedrate_mm_s);
528 524
 
529 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 528
       return false;
533 529
     }
534 530
 
535 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 534
     // Get the cartesian distances moved in XYZE
539 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 542
     // Get the linear distance in XYZ
@@ -588,9 +584,9 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
588 584
             oldB = stepper.get_axis_position_degrees(B_AXIS);
589 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 591
     // Drop one segment so the last move is to the exact target.
596 592
     // If there's only 1 segment, loops will be skipped entirely.
@@ -598,25 +594,25 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
598 594
 
599 595
     // Calculate and execute the segments
600 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 598
       #if ENABLED(DELTA)
603
-        DELTA_LOGICAL_IK(); // Delta can inline its kinematics
599
+        DELTA_RAW_IK(); // Delta can inline its kinematics
604 600
       #else
605
-        inverse_kinematics(logical);
601
+        inverse_kinematics(raw);
606 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 606
       #if IS_SCARA && ENABLED(SCARA_FEEDRATE_SCALING)
611 607
         // For SCARA scale the feed rate from mm/s to degrees/s
612 608
         // Use ratio between the length of the move and the larger angle change
613 609
         const float adiff = abs(delta[A_AXIS] - oldA),
614 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 612
         oldA = delta[A_AXIS];
617 613
         oldB = delta[B_AXIS];
618 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 616
       #endif
621 617
     }
622 618
 
@@ -626,13 +622,13 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
626 622
     #if IS_SCARA && ENABLED(SCARA_FEEDRATE_SCALING)
627 623
       // For SCARA scale the feed rate from mm/s to degrees/s
628 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 627
       const float adiff = abs(delta[A_AXIS] - oldA),
632 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 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 632
     #endif
637 633
 
638 634
     return false;
@@ -687,7 +683,7 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
687 683
 
688 684
   float x_home_pos(const int extruder) {
689 685
     if (extruder == 0)
690
-      return LOGICAL_X_POSITION(base_home_pos(X_AXIS));
686
+      return base_home_pos(X_AXIS);
691 687
     else
692 688
       /**
693 689
        * In dual carriage mode the extruder offset provides an override of the
@@ -695,7 +691,7 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
695 691
        * This allows soft recalibration of the second extruder home position
696 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,13 +736,13 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
740 736
           if (active_extruder == 0) {
741 737
             #if ENABLED(DEBUG_LEVELING_FEATURE)
742 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 740
                 SERIAL_ECHOLNPAIR(" ... Line to X", current_position[X_AXIS] + duplicate_extruder_x_offset);
745 741
               }
746 742
             #endif
747 743
             // move duplicate extruder into correct duplication position.
748 744
             planner.set_position_mm(
749
-              LOGICAL_X_POSITION(inactive_extruder_x_pos),
745
+              inactive_extruder_x_pos,
750 746
               current_position[Y_AXIS],
751 747
               current_position[Z_AXIS],
752 748
               current_position[E_AXIS]
@@ -970,7 +966,7 @@ void set_axis_is_at_home(const AxisEnum axis) {
970 966
   #if ENABLED(MORGAN_SCARA)
971 967
     scara_set_axis_is_at_home(axis);
972 968
   #else
973
-    current_position[axis] = LOGICAL_POSITION(base_home_pos(axis), axis);
969
+    current_position[axis] = base_home_pos(axis);
974 970
   #endif
975 971
 
976 972
   /**

+ 14
- 23
Marlin/src/module/motion.h Ver arquivo

@@ -217,14 +217,14 @@ void homeaxis(const AxisEnum axis);
217 217
   #define WORKSPACE_OFFSET(AXIS) 0
218 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 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 228
 #else
229 229
   #define LOGICAL_X_POSITION(POS)   (POS)
230 230
   #define LOGICAL_Y_POSITION(POS)   (POS)
@@ -232,9 +232,8 @@ void homeaxis(const AxisEnum axis);
232 232
   #define RAW_Y_POSITION(POS)       (POS)
233 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 239
  * position_is_reachable family of functions
@@ -242,7 +241,7 @@ void homeaxis(const AxisEnum axis);
242 241
 
243 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 245
     #if ENABLED(DELTA)
247 246
       return HYPOT2(rx, ry) <= sq(DELTA_PRINTABLE_RADIUS);
248 247
     #elif IS_SCARA
@@ -257,24 +256,24 @@ void homeaxis(const AxisEnum axis);
257 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 261
     // Both the nozzle and the probe must be able to reach the point.
263 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 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 271
       // Add 0.001 margin to deal with float imprecision
273 272
       return WITHIN(rx, X_MIN_POS - 0.001, X_MAX_POS + 0.001)
274 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 277
       // Add 0.001 margin to deal with float imprecision
279 278
       return WITHIN(rx, MIN_PROBE_X - 0.001, MAX_PROBE_X + 0.001)
280 279
           && WITHIN(ry, MIN_PROBE_Y - 0.001, MAX_PROBE_Y + 0.001);
@@ -282,14 +281,6 @@ void homeaxis(const AxisEnum axis);
282 281
 
283 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 285
  * Dual X Carriage / Dual Nozzle
295 286
  */

+ 34
- 38
Marlin/src/module/planner.cpp Ver arquivo

@@ -132,7 +132,7 @@ float Planner::min_feedrate_mm_s,
132 132
 #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
133 133
   float Planner::z_fade_height, // Initialized by settings.load()
134 134
         Planner::inverse_z_fade_height,
135
-        Planner::last_raw_lz;
135
+        Planner::last_fade_z;
136 136
 #endif
137 137
 
138 138
 #if ENABLED(AUTOTEMP)
@@ -552,14 +552,14 @@ void Planner::calculate_volumetric_multipliers() {
552 552
 
553 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 559
     if (!planner.leveling_active) return;
560 560
 
561 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 563
       if (!fade_scaling_factor) return;
564 564
     #else
565 565
       constexpr float fade_scaling_factor = 1.0;
@@ -567,11 +567,11 @@ void Planner::calculate_volumetric_multipliers() {
567 567
 
568 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 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 575
         #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
576 576
           , fade_scaling_factor
577 577
         #endif
@@ -581,42 +581,38 @@ void Planner::calculate_volumetric_multipliers() {
581 581
 
582 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 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 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 602
     if (!planner.leveling_active) return;
605 603
 
606 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 606
     #endif
609 607
 
610 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 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 616
         // Given P=L+M(1-L/H) (faded mesh correction formula for L<H)
621 617
         //  then L=P-M(1-L/H)
622 618
         //    so L=P-M+ML/H
@@ -625,46 +621,46 @@ void Planner::calculate_volumetric_multipliers() {
625 621
         //    so L=(P-M)/(1-M/H) for L<H
626 622
 
627 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 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 630
       #endif // ENABLE_LEVELING_FADE_HEIGHT
635 631
 
636
-      logical[Z_AXIS] = z_logical;
632
+      raw[Z_AXIS] = z_raw;
637 633
 
638 634
     #elif ENABLED(MESH_BED_LEVELING)
639 635
 
640 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 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 641
       #endif
646 642
 
647 643
     #elif ABL_PLANAR
648 644
 
649 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 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 657
     #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
662 658
 
663 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 662
       #else
667
-        logical[Z_AXIS] -= bilinear_z_offset(logical);
663
+        raw[Z_AXIS] -= bilinear_z_offset(raw);
668 664
       #endif
669 665
 
670 666
     #endif

+ 32
- 33
Marlin/src/module/planner.h Ver arquivo

@@ -202,7 +202,7 @@ class Planner {
202 202
     static uint32_t cutoff_long;
203 203
 
204 204
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
205
-      static float last_raw_lz;
205
+      static float last_fade_z;
206 206
     #endif
207 207
 
208 208
     #if ENABLED(DISABLE_INACTIVE_EXTRUDER)
@@ -275,21 +275,20 @@ class Planner {
275 275
        *  Returns 1.0 if planner.z_fade_height is 0.0.
276 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 279
         static float z_fade_factor = 1.0;
280 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 286
           return z_fade_factor;
288 287
         }
289 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 293
       FORCE_INLINE static void set_z_fade_height(const float &zfh) {
295 294
         z_fade_height = zfh > 0 ? zfh : 0;
@@ -297,40 +296,40 @@ class Planner {
297 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 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 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 312
     #endif
314 313
 
315 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 321
        * Apply leveling to transform a cartesian position
323 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 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 334
     #endif
336 335
 
@@ -357,15 +356,15 @@ class Planner {
357 356
      * Kinematic machines should call buffer_line_kinematic (for leveled moves).
358 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 360
      *  fr_mm_s      - (target) speed of the move (mm/s)
362 361
      *  extruder     - target extruder
363 362
      */
364 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 364
       #if PLANNER_LEVELING && IS_CARTESIAN
366
-        apply_leveling(lx, ly, lz);
365
+        apply_leveling(rx, ry, rz);
367 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,22 +372,22 @@ class Planner {
373 372
      * The target is cartesian, it's translated to delta/scara if
374 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 376
      *  fr_mm_s  - (target) speed of the move (mm/s)
378 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 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 382
         apply_leveling(lpos);
384 383
       #else
385
-        const float * const lpos = ltarget;
384
+        const float * const lpos = rtarget;
386 385
       #endif
387 386
       #if IS_KINEMATIC
388 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 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 391
       #endif
393 392
     }
394 393
 
@@ -403,9 +402,9 @@ class Planner {
403 402
      */
404 403
     static FORCE_INLINE void set_position_mm(ARG_X, ARG_Y, ARG_Z, const float &e) {
405 404
       #if PLANNER_LEVELING && IS_CARTESIAN
406
-        apply_leveling(lx, ly, lz);
405
+        apply_leveling(rx, ry, rz);
407 406
       #endif
408
-      _set_position_mm(lx, ly, lz, e);
407
+      _set_position_mm(rx, ry, rz, e);
409 408
     }
410 409
     static void set_position_mm_kinematic(const float position[NUM_AXIS]);
411 410
     static void set_position_mm(const AxisEnum axis, const float &v);

+ 11
- 11
Marlin/src/module/probe.cpp Ver arquivo

@@ -106,8 +106,8 @@ inline void do_probe_raise(const float z_raise) {
106 106
 
107 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 113
   void run_deploy_moves_script() {
@@ -564,7 +564,7 @@ static float run_z_probe(const bool short_move=true) {
564 564
     }
565 565
   #endif
566 566
 
567
-  return RAW_CURRENT_POSITION(Z) + zprobe_zoffset
567
+  return current_position[Z_AXIS] + zprobe_zoffset
568 568
     #if ENABLED(DELTA)
569 569
       + home_offset[Z_AXIS] // Account for delta height adjustment
570 570
     #endif
@@ -580,22 +580,22 @@ static float run_z_probe(const bool short_move=true) {
580 580
  *   - Raise to the BETWEEN height
581 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 584
   #if ENABLED(DEBUG_LEVELING_FEATURE)
585 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 588
       SERIAL_ECHOPAIR(", ", stow ? "" : "no ");
589 589
       SERIAL_ECHOLNPGM("stow)");
590 590
       DEBUG_POS("", current_position);
591 591
     }
592 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 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 599
   ) return NAN;
600 600
 
601 601
 
@@ -634,9 +634,9 @@ float probe_pt(const float &lx, const float &ly, const bool stow, const uint8_t
634 634
 
635 635
   if (verbose_level > 2) {
636 636
     SERIAL_PROTOCOLPGM("Bed X: ");
637
-    SERIAL_PROTOCOL_F(lx, 3);
637
+    SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(rx), 3);
638 638
     SERIAL_PROTOCOLPGM(" Y: ");
639
-    SERIAL_PROTOCOL_F(ly, 3);
639
+    SERIAL_PROTOCOL_F(LOGICAL_Y_POSITION(ry), 3);
640 640
     SERIAL_PROTOCOLPGM(" Z: ");
641 641
     SERIAL_PROTOCOL_F(measured_z, 3);
642 642
     SERIAL_EOL();

+ 1
- 1
Marlin/src/module/probe.h Ver arquivo

@@ -30,7 +30,7 @@
30 30
 #include "../inc/MarlinConfig.h"
31 31
 
32 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 35
 #if HAS_BED_PROBE
36 36
   extern float zprobe_zoffset;

+ 8
- 8
Marlin/src/module/scara.cpp Ver arquivo

@@ -36,14 +36,14 @@ float delta_segments_per_second = SCARA_SEGMENTS_PER_SECOND;
36 36
 
37 37
 void scara_set_axis_is_at_home(const AxisEnum axis) {
38 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 40
   else {
41 41
 
42 42
     /**
43 43
      * SCARA homes XY at the same time
44 44
      */
45 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 48
     // SERIAL_ECHOPAIR("homeposition X:", homeposition[X_AXIS]);
49 49
     // SERIAL_ECHOLNPAIR(" Y:", homeposition[Y_AXIS]);
@@ -58,7 +58,7 @@ void scara_set_axis_is_at_home(const AxisEnum axis) {
58 58
     // SERIAL_ECHOPAIR("Cartesian X:", cartes[X_AXIS]);
59 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 64
      * SCARA home positions are based on configuration since the actual
@@ -104,12 +104,12 @@ void forward_kinematics_SCARA(const float &a, const float &b) {
104 104
  * Maths and first version by QHARLEY.
105 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 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 114
   if (L1 == L2)
115 115
     C2 = HYPOT2(sx, sy) / L1_2_2 - 1;
@@ -132,10 +132,10 @@ void inverse_kinematics(const float logical[XYZ]) {
132 132
 
133 133
   delta[A_AXIS] = DEGREES(THETA);        // theta is support arm angle
134 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 139
     DEBUG_POS("SCARA IK", delta);
140 140
     SERIAL_ECHOPAIR("  SCARA (x,y) ", sx);
141 141
     SERIAL_ECHOPAIR(",", sy);

+ 1
- 1
Marlin/src/module/scara.h Ver arquivo

@@ -38,7 +38,7 @@ float constexpr L1 = SCARA_LINKAGE_1, L2 = SCARA_LINKAGE_2,
38 38
 
39 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 42
 void forward_kinematics_SCARA(const float &a, const float &b);
43 43
 
44 44
 void scara_report_positions();

+ 4
- 4
Marlin/src/module/tool_change.cpp Ver arquivo

@@ -240,9 +240,9 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
240 240
           switch (dual_x_carriage_mode) {
241 241
             case DXC_FULL_CONTROL_MODE:
242 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 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 246
               break;
247 247
             case DXC_AUTO_PARK_MODE:
248 248
               // record raised toolhead position for use by unpark
@@ -260,10 +260,10 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
260 260
               active_extruder_parked = (active_extruder == 0);
261 261
 
262 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 264
               else
265 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 267
               extruder_duplication_enabled = false;
268 268
               #if ENABLED(DEBUG_LEVELING_FEATURE)
269 269
                 if (DEBUGGING(LEVELING)) {

Carregando…
Cancelar
Salvar