Bläddra i källkod

Clarify some motion code

Scott Lahteine 7 år sedan
förälder
incheckning
ad879a1f90
3 ändrade filer med 28 tillägg och 33 borttagningar
  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 Visa fil

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

+ 1
- 1
Marlin/SanityCheck.h Visa fil

797
    */
797
    */
798
 
798
 
799
   #if ENABLED(DELTA)
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
   #elif GRID_MAX_POINTS_X > 9 || GRID_MAX_POINTS_Y > 9
801
   #elif GRID_MAX_POINTS_X > 9 || GRID_MAX_POINTS_Y > 9
802
     #error "GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y must be less than 10 for MBL."
802
     #error "GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y must be less than 10 for MBL."
803
   #endif
803
   #endif

+ 7
- 7
Marlin/planner.h Visa fil

356
      *  fr_mm_s  - (target) speed of the move (mm/s)
356
      *  fr_mm_s  - (target) speed of the move (mm/s)
357
      *  extruder - target extruder
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
       #if PLANNER_LEVELING
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
       #else
363
       #else
364
-        const float * const lpos = rtarget;
364
+        const float * const raw = cart;
365
       #endif
365
       #endif
366
       #if IS_KINEMATIC
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
       #else
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
       #endif
371
       #endif
372
     }
372
     }
373
 
373
 

Laddar…
Avbryt
Spara