Browse Source

Clarify some motion code

Scott Lahteine 6 years ago
parent
commit
ad879a1f90
3 changed files with 28 additions and 33 deletions
  1. 20
    25
      Marlin/Marlin_main.cpp
  2. 1
    1
      Marlin/SanityCheck.h
  3. 7
    7
      Marlin/planner.h

+ 20
- 25
Marlin/Marlin_main.cpp View File

@@ -376,16 +376,16 @@ uint8_t marlin_debug_flags = DEBUG_NONE;
376 376
 /**
377 377
  * Cartesian Current Position
378 378
  *   Used to track the native machine position as moves are queued.
379
- *   Used by 'line_to_current_position' to do a move after changing it.
379
+ *   Used by 'buffer_line_to_current_position' to do a move after changing it.
380 380
  *   Used by 'SYNC_PLAN_POSITION_KINEMATIC' to update 'planner.position'.
381 381
  */
382 382
 float current_position[XYZE] = { 0.0 };
383 383
 
384 384
 /**
385 385
  * Cartesian Destination
386
- *   A temporary position, usually applied to 'current_position'.
386
+ *   The destination for a move, filled in by G-code movement commands,
387
+ *   and expected by functions like 'prepare_move_to_destination'.
387 388
  *   Set with 'gcode_get_destination' or 'set_destination_from_current'.
388
- *   'line_to_destination' sets 'current_position' to 'destination'.
389 389
  */
390 390
 float destination[XYZE] = { 0.0 };
391 391
 
@@ -1633,7 +1633,7 @@ inline float get_homing_bump_feedrate(const AxisEnum axis) {
1633 1633
  * Move the planner to the current position from wherever it last moved
1634 1634
  * (or from wherever it has been told it is located).
1635 1635
  */
1636
-inline void line_to_current_position() {
1636
+inline void buffer_line_to_current_position() {
1637 1637
   planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate_mm_s, active_extruder);
1638 1638
 }
1639 1639
 
@@ -1641,10 +1641,9 @@ inline void line_to_current_position() {
1641 1641
  * Move the planner to the position stored in the destination array, which is
1642 1642
  * used by G0/G1/G2/G3/G5 and many other functions to set a destination.
1643 1643
  */
1644
-inline void line_to_destination(const float fr_mm_s) {
1644
+inline void buffer_line_to_destination(const float fr_mm_s) {
1645 1645
   planner.buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], fr_mm_s, active_extruder);
1646 1646
 }
1647
-inline void line_to_destination() { line_to_destination(feedrate_mm_s); }
1648 1647
 
1649 1648
 inline void set_current_from_destination() { COPY(current_position, destination); }
1650 1649
 inline void set_destination_from_current() { COPY(destination, current_position); }
@@ -1772,19 +1771,19 @@ void do_blocking_move_to(const float &rx, const float &ry, const float &rz, cons
1772 1771
     if (current_position[Z_AXIS] < rz) {
1773 1772
       feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
1774 1773
       current_position[Z_AXIS] = rz;
1775
-      line_to_current_position();
1774
+      buffer_line_to_current_position();
1776 1775
     }
1777 1776
 
1778 1777
     feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
1779 1778
     current_position[X_AXIS] = rx;
1780 1779
     current_position[Y_AXIS] = ry;
1781
-    line_to_current_position();
1780
+    buffer_line_to_current_position();
1782 1781
 
1783 1782
     // If Z needs to lower, do it after moving XY
1784 1783
     if (current_position[Z_AXIS] > rz) {
1785 1784
       feedrate_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
1786 1785
       current_position[Z_AXIS] = rz;
1787
-      line_to_current_position();
1786
+      buffer_line_to_current_position();
1788 1787
     }
1789 1788
 
1790 1789
   #endif
@@ -3933,7 +3932,7 @@ inline void gcode_G4() {
3933 3932
     // Move all carriages together linearly until an endstop is hit.
3934 3933
     current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (DELTA_HEIGHT + home_offset[Z_AXIS] + 10);
3935 3934
     feedrate_mm_s = homing_feedrate(X_AXIS);
3936
-    line_to_current_position();
3935
+    buffer_line_to_current_position();
3937 3936
     stepper.synchronize();
3938 3937
 
3939 3938
     // If an endstop was not hit, then damage can occur if homing is continued.
@@ -4314,7 +4313,7 @@ void home_all_axes() { gcode_G28(true); }
4314 4313
     #if ENABLED(MESH_G28_REST_ORIGIN)
4315 4314
       current_position[Z_AXIS] = Z_MIN_POS;
4316 4315
       set_destination_from_current();
4317
-      line_to_destination(homing_feedrate(Z_AXIS));
4316
+      buffer_line_to_destination(homing_feedrate(Z_AXIS));
4318 4317
       stepper.synchronize();
4319 4318
     #endif
4320 4319
   }
@@ -4406,7 +4405,7 @@ void home_all_axes() { gcode_G28(true); }
4406 4405
         else {
4407 4406
           // One last "return to the bed" (as originally coded) at completion
4408 4407
           current_position[Z_AXIS] = Z_MIN_POS + MANUAL_PROBE_HEIGHT;
4409
-          line_to_current_position();
4408
+          buffer_line_to_current_position();
4410 4409
           stepper.synchronize();
4411 4410
 
4412 4411
           // After recording the last point, activate home and activate
@@ -6563,17 +6562,13 @@ inline void gcode_M17() {
6563 6562
   #if IS_KINEMATIC
6564 6563
     #define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder)
6565 6564
   #else
6566
-    #define RUNPLAN(RATE_MM_S) line_to_destination(RATE_MM_S)
6565
+    #define RUNPLAN(RATE_MM_S) buffer_line_to_destination(RATE_MM_S)
6567 6566
   #endif
6568 6567
 
6569 6568
   void do_pause_e_move(const float &length, const float fr) {
6570 6569
     current_position[E_AXIS] += length;
6571 6570
     set_destination_from_current();
6572
-    #if IS_KINEMATIC
6573
-      planner.buffer_line_kinematic(destination, fr, active_extruder);
6574
-    #else
6575
-      line_to_destination(fr);
6576
-    #endif
6571
+    RUNPLAN(fr);
6577 6572
     stepper.synchronize();
6578 6573
   }
6579 6574
 
@@ -12596,7 +12591,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12596 12591
    * Prepare a mesh-leveled linear move in a Cartesian setup,
12597 12592
    * splitting the move where it crosses mesh borders.
12598 12593
    */
12599
-  void mesh_line_to_destination(float fr_mm_s, uint8_t x_splits = 0xFF, uint8_t y_splits = 0xFF) {
12594
+  void mesh_line_to_destination(const float fr_mm_s, uint8_t x_splits = 0xFF, uint8_t y_splits = 0xFF) {
12600 12595
     int cx1 = mbl.cell_index_x(current_position[X_AXIS]),
12601 12596
         cy1 = mbl.cell_index_y(current_position[Y_AXIS]),
12602 12597
         cx2 = mbl.cell_index_x(destination[X_AXIS]),
@@ -12608,7 +12603,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12608 12603
 
12609 12604
     if (cx1 == cx2 && cy1 == cy2) {
12610 12605
       // Start and end on same mesh square
12611
-      line_to_destination(fr_mm_s);
12606
+      buffer_line_to_destination(fr_mm_s);
12612 12607
       set_current_from_destination();
12613 12608
       return;
12614 12609
     }
@@ -12635,7 +12630,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12635 12630
     }
12636 12631
     else {
12637 12632
       // Already split on a border
12638
-      line_to_destination(fr_mm_s);
12633
+      buffer_line_to_destination(fr_mm_s);
12639 12634
       set_current_from_destination();
12640 12635
       return;
12641 12636
     }
@@ -12659,7 +12654,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12659 12654
    * Prepare a bilinear-leveled linear move on Cartesian,
12660 12655
    * splitting the move where it crosses grid borders.
12661 12656
    */
12662
-  void bilinear_line_to_destination(float fr_mm_s, uint16_t x_splits = 0xFFFF, uint16_t y_splits = 0xFFFF) {
12657
+  void bilinear_line_to_destination(const float fr_mm_s, uint16_t x_splits = 0xFFFF, uint16_t y_splits = 0xFFFF) {
12663 12658
     int cx1 = CELL_INDEX(X, current_position[X_AXIS]),
12664 12659
         cy1 = CELL_INDEX(Y, current_position[Y_AXIS]),
12665 12660
         cx2 = CELL_INDEX(X, destination[X_AXIS]),
@@ -12671,7 +12666,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12671 12666
 
12672 12667
     if (cx1 == cx2 && cy1 == cy2) {
12673 12668
       // Start and end on same mesh square
12674
-      line_to_destination(fr_mm_s);
12669
+      buffer_line_to_destination(fr_mm_s);
12675 12670
       set_current_from_destination();
12676 12671
       return;
12677 12672
     }
@@ -12698,7 +12693,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12698 12693
     }
12699 12694
     else {
12700 12695
       // Already split on a border
12701
-      line_to_destination(fr_mm_s);
12696
+      buffer_line_to_destination(fr_mm_s);
12702 12697
       set_current_from_destination();
12703 12698
       return;
12704 12699
     }
@@ -12878,7 +12873,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12878 12873
       }
12879 12874
     #endif // HAS_MESH
12880 12875
 
12881
-    line_to_destination(MMS_SCALED(feedrate_mm_s));
12876
+    buffer_line_to_destination(MMS_SCALED(feedrate_mm_s));
12882 12877
     return false;
12883 12878
   }
12884 12879
 

+ 1
- 1
Marlin/SanityCheck.h View File

@@ -797,7 +797,7 @@ static_assert(1 >= 0
797 797
    */
798 798
 
799 799
   #if ENABLED(DELTA)
800
-    #error "MESH_BED_LEVELING does not yet support DELTA printers."
800
+    #error "MESH_BED_LEVELING is not compatible with DELTA printers."
801 801
   #elif GRID_MAX_POINTS_X > 9 || GRID_MAX_POINTS_Y > 9
802 802
     #error "GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y must be less than 10 for MBL."
803 803
   #endif

+ 7
- 7
Marlin/planner.h View File

@@ -356,18 +356,18 @@ class Planner {
356 356
      *  fr_mm_s  - (target) speed of the move (mm/s)
357 357
      *  extruder - target extruder
358 358
      */
359
-    static FORCE_INLINE void buffer_line_kinematic(const float rtarget[XYZE], const float &fr_mm_s, const uint8_t extruder) {
359
+    static FORCE_INLINE void buffer_line_kinematic(const float cart[XYZE], const float &fr_mm_s, const uint8_t extruder) {
360 360
       #if PLANNER_LEVELING
361
-        float lpos[XYZ] = { rtarget[X_AXIS], rtarget[Y_AXIS], rtarget[Z_AXIS] };
362
-        apply_leveling(lpos);
361
+        float raw[XYZ] = { cart[X_AXIS], cart[Y_AXIS], cart[Z_AXIS] };
362
+        apply_leveling(raw);
363 363
       #else
364
-        const float * const lpos = rtarget;
364
+        const float * const raw = cart;
365 365
       #endif
366 366
       #if IS_KINEMATIC
367
-        inverse_kinematics(lpos);
368
-        _buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], rtarget[E_AXIS], fr_mm_s, extruder);
367
+        inverse_kinematics(raw);
368
+        _buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], cart[E_AXIS], fr_mm_s, extruder);
369 369
       #else
370
-        _buffer_line(lpos[X_AXIS], lpos[Y_AXIS], lpos[Z_AXIS], rtarget[E_AXIS], fr_mm_s, extruder);
370
+        _buffer_line(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS], cart[E_AXIS], fr_mm_s, extruder);
371 371
       #endif
372 372
     }
373 373
 

Loading…
Cancel
Save