Bläddra i källkod

Add a feedRate_t data type (#15349)

Scott Lahteine 5 år sedan
förälder
incheckning
455dabb183
Inget konto är kopplat till bidragsgivarens mejladress
42 ändrade filer med 382 tillägg och 375 borttagningar
  1. 3
    0
      Marlin/src/core/macros.h
  2. 7
    9
      Marlin/src/feature/I2CPositionEncoder.cpp
  3. 5
    5
      Marlin/src/feature/bedlevel/abl/abl.cpp
  4. 1
    1
      Marlin/src/feature/bedlevel/abl/abl.h
  5. 5
    5
      Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp
  6. 1
    1
      Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h
  7. 2
    2
      Marlin/src/feature/bedlevel/ubl/ubl.h
  8. 25
    28
      Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp
  9. 18
    21
      Marlin/src/feature/fwretract.cpp
  10. 8
    8
      Marlin/src/feature/fwretract.h
  11. 5
    5
      Marlin/src/feature/pause.cpp
  12. 1
    1
      Marlin/src/feature/pause.h
  13. 8
    9
      Marlin/src/feature/prusa_MMU2/mmu2.cpp
  14. 12
    19
      Marlin/src/gcode/bedlevel/G26.cpp
  15. 6
    4
      Marlin/src/gcode/bedlevel/G42.cpp
  16. 1
    2
      Marlin/src/gcode/bedlevel/mbl/G29.cpp
  17. 4
    5
      Marlin/src/gcode/calibrate/G425.cpp
  18. 18
    20
      Marlin/src/gcode/feature/L6470/M916-918.cpp
  19. 6
    6
      Marlin/src/gcode/feature/camera/M240.cpp
  20. 4
    4
      Marlin/src/gcode/feature/pause/M701_M702.cpp
  21. 1
    1
      Marlin/src/gcode/gcode.cpp
  22. 1
    1
      Marlin/src/gcode/gcode.h
  23. 10
    10
      Marlin/src/gcode/motion/G0_G1.cpp
  24. 4
    4
      Marlin/src/gcode/motion/G2_G3.cpp
  25. 1
    1
      Marlin/src/gcode/parser.h
  26. 2
    2
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_status_screen.cpp
  27. 16
    22
      Marlin/src/lcd/extensible_ui/ui_api.cpp
  28. 9
    9
      Marlin/src/lcd/extensible_ui/ui_api.h
  29. 4
    4
      Marlin/src/lcd/menu/menu_ubl.cpp
  30. 3
    6
      Marlin/src/lcd/ultralcd.cpp
  31. 1
    1
      Marlin/src/lcd/ultralcd.h
  32. 1
    1
      Marlin/src/libs/nozzle.cpp
  33. 18
    17
      Marlin/src/module/configuration_store.cpp
  34. 3
    3
      Marlin/src/module/delta.cpp
  35. 89
    69
      Marlin/src/module/motion.cpp
  36. 29
    22
      Marlin/src/module/motion.h
  37. 10
    11
      Marlin/src/module/planner.cpp
  38. 18
    19
      Marlin/src/module/planner.h
  39. 9
    4
      Marlin/src/module/planner_bezier.cpp
  40. 6
    6
      Marlin/src/module/planner_bezier.h
  41. 1
    1
      Marlin/src/module/probe.cpp
  42. 6
    6
      Marlin/src/module/tool_change.h

+ 3
- 0
Marlin/src/core/macros.h Visa fil

244
 #define DECREMENT_(n) DEC_##n
244
 #define DECREMENT_(n) DEC_##n
245
 #define DECREMENT(n) DECREMENT_(n)
245
 #define DECREMENT(n) DECREMENT_(n)
246
 
246
 
247
+// Feedrate
248
+typedef float feedRate_t;
247
 #define MMM_TO_MMS(MM_M) ((MM_M)/60.0f)
249
 #define MMM_TO_MMS(MM_M) ((MM_M)/60.0f)
248
 #define MMS_TO_MMM(MM_S) ((MM_S)*60.0f)
250
 #define MMS_TO_MMM(MM_S) ((MM_S)*60.0f)
251
+#define MMS_SCALED(V)    ((V) * 0.01f * feedrate_percentage)
249
 
252
 
250
 #define NOOP (void(0))
253
 #define NOOP (void(0))
251
 
254
 

+ 7
- 9
Marlin/src/feature/I2CPositionEncoder.cpp Visa fil

329
   float startCoord[NUM_AXIS] = { 0 }, endCoord[NUM_AXIS] = { 0 };
329
   float startCoord[NUM_AXIS] = { 0 }, endCoord[NUM_AXIS] = { 0 };
330
 
330
 
331
   const float startPosition = soft_endstop[encoderAxis].min + 10,
331
   const float startPosition = soft_endstop[encoderAxis].min + 10,
332
-              endPosition = soft_endstop[encoderAxis].max - 10,
333
-              feedrate = FLOOR(MMM_TO_MMS((encoderAxis == Z_AXIS) ? HOMING_FEEDRATE_Z : HOMING_FEEDRATE_XY));
332
+              endPosition = soft_endstop[encoderAxis].max - 10;
333
+  const feedRate_t fr_mm_s = FLOOR(MMM_TO_MMS((encoderAxis == Z_AXIS) ? HOMING_FEEDRATE_Z : HOMING_FEEDRATE_XY));
334
 
334
 
335
   ec = false;
335
   ec = false;
336
 
336
 
344
   planner.synchronize();
344
   planner.synchronize();
345
 
345
 
346
   planner.buffer_line(startCoord[X_AXIS], startCoord[Y_AXIS], startCoord[Z_AXIS],
346
   planner.buffer_line(startCoord[X_AXIS], startCoord[Y_AXIS], startCoord[Z_AXIS],
347
-                      planner.get_axis_position_mm(E_AXIS), feedrate, 0);
347
+                      planner.get_axis_position_mm(E_AXIS), fr_mm_s, 0);
348
   planner.synchronize();
348
   planner.synchronize();
349
 
349
 
350
   // if the module isn't currently trusted, wait until it is (or until it should be if things are working)
350
   // if the module isn't currently trusted, wait until it is (or until it should be if things are working)
356
 
356
 
357
   if (trusted) { // if trusted, commence test
357
   if (trusted) { // if trusted, commence test
358
     planner.buffer_line(endCoord[X_AXIS], endCoord[Y_AXIS], endCoord[Z_AXIS],
358
     planner.buffer_line(endCoord[X_AXIS], endCoord[Y_AXIS], endCoord[Z_AXIS],
359
-                        planner.get_axis_position_mm(E_AXIS), feedrate, 0);
359
+                        planner.get_axis_position_mm(E_AXIS), fr_mm_s, 0);
360
     planner.synchronize();
360
     planner.synchronize();
361
   }
361
   }
362
 
362
 
379
         travelDistance, travelledDistance, total = 0,
379
         travelDistance, travelledDistance, total = 0,
380
         startCoord[NUM_AXIS] = { 0 }, endCoord[NUM_AXIS] = { 0 };
380
         startCoord[NUM_AXIS] = { 0 }, endCoord[NUM_AXIS] = { 0 };
381
 
381
 
382
-  float feedrate;
383
-
384
   int32_t startCount, stopCount;
382
   int32_t startCount, stopCount;
385
 
383
 
386
-  feedrate = MMM_TO_MMS((encoderAxis == Z_AXIS) ? HOMING_FEEDRATE_Z : HOMING_FEEDRATE_XY);
384
+  const feedRate_t fr_mm_s = MMM_TO_MMS((encoderAxis == Z_AXIS) ? HOMING_FEEDRATE_Z : HOMING_FEEDRATE_XY);
387
 
385
 
388
   bool oldec = ec;
386
   bool oldec = ec;
389
   ec = false;
387
   ec = false;
404
 
402
 
405
   LOOP_L_N(i, iter) {
403
   LOOP_L_N(i, iter) {
406
     planner.buffer_line(startCoord[X_AXIS], startCoord[Y_AXIS], startCoord[Z_AXIS],
404
     planner.buffer_line(startCoord[X_AXIS], startCoord[Y_AXIS], startCoord[Z_AXIS],
407
-                        planner.get_axis_position_mm(E_AXIS), feedrate, 0);
405
+                        planner.get_axis_position_mm(E_AXIS), fr_mm_s, 0);
408
     planner.synchronize();
406
     planner.synchronize();
409
 
407
 
410
     delay(250);
408
     delay(250);
413
     //do_blocking_move_to(endCoord[X_AXIS],endCoord[Y_AXIS],endCoord[Z_AXIS]);
411
     //do_blocking_move_to(endCoord[X_AXIS],endCoord[Y_AXIS],endCoord[Z_AXIS]);
414
 
412
 
415
     planner.buffer_line(endCoord[X_AXIS], endCoord[Y_AXIS], endCoord[Z_AXIS],
413
     planner.buffer_line(endCoord[X_AXIS], endCoord[Y_AXIS], endCoord[Z_AXIS],
416
-                        planner.get_axis_position_mm(E_AXIS), feedrate, 0);
414
+                        planner.get_axis_position_mm(E_AXIS), fr_mm_s, 0);
417
     planner.synchronize();
415
     planner.synchronize();
418
 
416
 
419
     //Read encoder distance
417
     //Read encoder distance

+ 5
- 5
Marlin/src/feature/bedlevel/abl/abl.cpp Visa fil

360
    * Prepare a bilinear-leveled linear move on Cartesian,
360
    * Prepare a bilinear-leveled linear move on Cartesian,
361
    * splitting the move where it crosses grid borders.
361
    * splitting the move where it crosses grid borders.
362
    */
362
    */
363
-  void bilinear_line_to_destination(const float fr_mm_s, uint16_t x_splits, uint16_t y_splits) {
363
+  void bilinear_line_to_destination(const feedRate_t scaled_fr_mm_s, uint16_t x_splits, uint16_t y_splits) {
364
     // Get current and destination cells for this line
364
     // Get current and destination cells for this line
365
     int cx1 = CELL_INDEX(X, current_position[X_AXIS]),
365
     int cx1 = CELL_INDEX(X, current_position[X_AXIS]),
366
         cy1 = CELL_INDEX(Y, current_position[Y_AXIS]),
366
         cy1 = CELL_INDEX(Y, current_position[Y_AXIS]),
373
 
373
 
374
     // Start and end in the same cell? No split needed.
374
     // Start and end in the same cell? No split needed.
375
     if (cx1 == cx2 && cy1 == cy2) {
375
     if (cx1 == cx2 && cy1 == cy2) {
376
-      buffer_line_to_destination(fr_mm_s);
377
       set_current_from_destination();
376
       set_current_from_destination();
377
+      line_to_current_position(scaled_fr_mm_s);
378
       return;
378
       return;
379
     }
379
     }
380
 
380
 
405
     else {
405
     else {
406
       // Must already have been split on these border(s)
406
       // Must already have been split on these border(s)
407
       // This should be a rare case.
407
       // This should be a rare case.
408
-      buffer_line_to_destination(fr_mm_s);
409
       set_current_from_destination();
408
       set_current_from_destination();
409
+      line_to_current_position(scaled_fr_mm_s);
410
       return;
410
       return;
411
     }
411
     }
412
 
412
 
414
     destination[E_AXIS] = LINE_SEGMENT_END(E);
414
     destination[E_AXIS] = LINE_SEGMENT_END(E);
415
 
415
 
416
     // Do the split and look for more borders
416
     // Do the split and look for more borders
417
-    bilinear_line_to_destination(fr_mm_s, x_splits, y_splits);
417
+    bilinear_line_to_destination(scaled_fr_mm_s, x_splits, y_splits);
418
 
418
 
419
     // Restore destination from stack
419
     // Restore destination from stack
420
     COPY(destination, end);
420
     COPY(destination, end);
421
-    bilinear_line_to_destination(fr_mm_s, x_splits, y_splits);
421
+    bilinear_line_to_destination(scaled_fr_mm_s, x_splits, y_splits);
422
   }
422
   }
423
 
423
 
424
 #endif // IS_CARTESIAN && !SEGMENT_LEVELED_MOVES
424
 #endif // IS_CARTESIAN && !SEGMENT_LEVELED_MOVES

+ 1
- 1
Marlin/src/feature/bedlevel/abl/abl.h Visa fil

37
 #endif
37
 #endif
38
 
38
 
39
 #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES)
39
 #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES)
40
-  void bilinear_line_to_destination(const float fr_mm_s, uint16_t x_splits=0xFFFF, uint16_t y_splits=0xFFFF);
40
+  void bilinear_line_to_destination(const feedRate_t &scaled_fr_mm_s, uint16_t x_splits=0xFFFF, uint16_t y_splits=0xFFFF);
41
 #endif
41
 #endif
42
 
42
 
43
 #define _GET_MESH_X(I) (bilinear_start[X_AXIS] + (I) * bilinear_grid_spacing[X_AXIS])
43
 #define _GET_MESH_X(I) (bilinear_start[X_AXIS] + (I) * bilinear_grid_spacing[X_AXIS])

+ 5
- 5
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp Visa fil

64
      * Prepare a mesh-leveled linear move in a Cartesian setup,
64
      * Prepare a mesh-leveled linear move in a Cartesian setup,
65
      * splitting the move where it crosses mesh borders.
65
      * splitting the move where it crosses mesh borders.
66
      */
66
      */
67
-    void mesh_bed_leveling::line_to_destination(const float fr_mm_s, uint8_t x_splits, uint8_t y_splits) {
67
+    void mesh_bed_leveling::line_to_destination(const feedRate_t &scaled_fr_mm_s, uint8_t x_splits, uint8_t y_splits) {
68
       // Get current and destination cells for this line
68
       // Get current and destination cells for this line
69
       int cx1 = cell_index_x(current_position[X_AXIS]),
69
       int cx1 = cell_index_x(current_position[X_AXIS]),
70
           cy1 = cell_index_y(current_position[Y_AXIS]),
70
           cy1 = cell_index_y(current_position[Y_AXIS]),
77
 
77
 
78
       // Start and end in the same cell? No split needed.
78
       // Start and end in the same cell? No split needed.
79
       if (cx1 == cx2 && cy1 == cy2) {
79
       if (cx1 == cx2 && cy1 == cy2) {
80
-        line_to_destination(fr_mm_s);
80
+        line_to_destination(scaled_fr_mm_s);
81
         set_current_from_destination();
81
         set_current_from_destination();
82
         return;
82
         return;
83
       }
83
       }
109
       else {
109
       else {
110
         // Must already have been split on these border(s)
110
         // Must already have been split on these border(s)
111
         // This should be a rare case.
111
         // This should be a rare case.
112
-        line_to_destination(fr_mm_s);
112
+        line_to_destination(scaled_fr_mm_s);
113
         set_current_from_destination();
113
         set_current_from_destination();
114
         return;
114
         return;
115
       }
115
       }
118
       destination[E_AXIS] = MBL_SEGMENT_END(E);
118
       destination[E_AXIS] = MBL_SEGMENT_END(E);
119
 
119
 
120
       // Do the split and look for more borders
120
       // Do the split and look for more borders
121
-      line_to_destination(fr_mm_s, x_splits, y_splits);
121
+      line_to_destination(scaled_fr_mm_s, x_splits, y_splits);
122
 
122
 
123
       // Restore destination from stack
123
       // Restore destination from stack
124
       COPY(destination, end);
124
       COPY(destination, end);
125
-      line_to_destination(fr_mm_s, x_splits, y_splits);
125
+      line_to_destination(scaled_fr_mm_s, x_splits, y_splits);
126
     }
126
     }
127
 
127
 
128
   #endif // IS_CARTESIAN && !SEGMENT_LEVELED_MOVES
128
   #endif // IS_CARTESIAN && !SEGMENT_LEVELED_MOVES

+ 1
- 1
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h Visa fil

116
   }
116
   }
117
 
117
 
118
   #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES)
118
   #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES)
119
-    static void line_to_destination(const float fr_mm_s, uint8_t x_splits=0xFF, uint8_t y_splits=0xFF);
119
+    static void line_to_destination(const feedRate_t &scaled_fr_mm_s, uint8_t x_splits=0xFF, uint8_t y_splits=0xFF);
120
   #endif
120
   #endif
121
 };
121
 };
122
 
122
 

+ 2
- 2
Marlin/src/feature/bedlevel/ubl/ubl.h Visa fil

285
     }
285
     }
286
 
286
 
287
     #if UBL_SEGMENTED
287
     #if UBL_SEGMENTED
288
-      static bool prepare_segmented_line_to(const float (&rtarget)[XYZE], const float &feedrate);
288
+      static bool line_to_destination_segmented(const feedRate_t &scaled_fr_mm_s);
289
     #else
289
     #else
290
-      static void line_to_destination_cartesian(const float &fr, const uint8_t e);
290
+      static void line_to_destination_cartesian(const feedRate_t &scaled_fr_mm_s, const uint8_t e);
291
     #endif
291
     #endif
292
 
292
 
293
     static inline bool mesh_is_valid() {
293
     static inline bool mesh_is_valid() {

+ 25
- 28
Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp Visa fil

43
 
43
 
44
 #if !UBL_SEGMENTED
44
 #if !UBL_SEGMENTED
45
 
45
 
46
-  void unified_bed_leveling::line_to_destination_cartesian(const float &feed_rate, const uint8_t extruder) {
46
+  void unified_bed_leveling::line_to_destination_cartesian(const feedRate_t &scaled_fr_mm_s, const uint8_t extruder) {
47
     /**
47
     /**
48
      * Much of the nozzle movement will be within the same cell. So we will do as little computation
48
      * Much of the nozzle movement will be within the same cell. So we will do as little computation
49
      * as possible to determine if this is the case. If this move is within the same cell, we will
49
      * as possible to determine if this is the case. If this move is within the same cell, we will
79
             + UBL_Z_RAISE_WHEN_OFF_MESH
79
             + UBL_Z_RAISE_WHEN_OFF_MESH
80
           #endif
80
           #endif
81
         ;
81
         ;
82
-        planner.buffer_segment(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + z_raise, end[E_AXIS], feed_rate, extruder);
82
+        planner.buffer_segment(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + z_raise, end[E_AXIS], scaled_fr_mm_s, extruder);
83
         set_current_from_destination();
83
         set_current_from_destination();
84
-
85
         return;
84
         return;
86
       }
85
       }
87
 
86
 
103
 
102
 
104
       // Undefined parts of the Mesh in z_values[][] are NAN.
103
       // Undefined parts of the Mesh in z_values[][] are NAN.
105
       // Replace NAN corrections with 0.0 to prevent NAN propagation.
104
       // Replace NAN corrections with 0.0 to prevent NAN propagation.
106
-      planner.buffer_segment(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + (isnan(z0) ? 0.0 : z0), end[E_AXIS], feed_rate, extruder);
107
-
105
+      planner.buffer_segment(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + (isnan(z0) ? 0.0 : z0), end[E_AXIS], scaled_fr_mm_s, extruder);
108
       set_current_from_destination();
106
       set_current_from_destination();
109
       return;
107
       return;
110
     }
108
     }
194
             z_position = end[Z_AXIS];
192
             z_position = end[Z_AXIS];
195
           }
193
           }
196
 
194
 
197
-          planner.buffer_segment(rx, ry, z_position + z0, e_position, feed_rate, extruder);
195
+          planner.buffer_segment(rx, ry, z_position + z0, e_position, scaled_fr_mm_s, extruder);
198
         } //else printf("FIRST MOVE PRUNED  ");
196
         } //else printf("FIRST MOVE PRUNED  ");
199
       }
197
       }
200
 
198
 
242
             z_position = end[Z_AXIS];
240
             z_position = end[Z_AXIS];
243
           }
241
           }
244
 
242
 
245
-          if (!planner.buffer_segment(rx, ry, z_position + z0, e_position, feed_rate, extruder))
243
+          if (!planner.buffer_segment(rx, ry, z_position + z0, e_position, scaled_fr_mm_s, extruder))
246
             break;
244
             break;
247
         } //else printf("FIRST MOVE PRUNED  ");
245
         } //else printf("FIRST MOVE PRUNED  ");
248
       }
246
       }
297
           e_position = end[E_AXIS];
295
           e_position = end[E_AXIS];
298
           z_position = end[Z_AXIS];
296
           z_position = end[Z_AXIS];
299
         }
297
         }
300
-        if (!planner.buffer_segment(rx, next_mesh_line_y, z_position + z0, e_position, feed_rate, extruder))
298
+        if (!planner.buffer_segment(rx, next_mesh_line_y, z_position + z0, e_position, scaled_fr_mm_s, extruder))
301
           break;
299
           break;
302
         current_yi += dyi;
300
         current_yi += dyi;
303
         yi_cnt--;
301
         yi_cnt--;
321
           z_position = end[Z_AXIS];
319
           z_position = end[Z_AXIS];
322
         }
320
         }
323
 
321
 
324
-        if (!planner.buffer_segment(next_mesh_line_x, ry, z_position + z0, e_position, feed_rate, extruder))
322
+        if (!planner.buffer_segment(next_mesh_line_x, ry, z_position + z0, e_position, scaled_fr_mm_s, extruder))
325
           break;
323
           break;
326
         current_xi += dxi;
324
         current_xi += dxi;
327
         xi_cnt--;
325
         xi_cnt--;
356
    * Returns true if did NOT move, false if moved (requires current_position update).
354
    * Returns true if did NOT move, false if moved (requires current_position update).
357
    */
355
    */
358
 
356
 
359
-  bool _O2 unified_bed_leveling::prepare_segmented_line_to(const float (&rtarget)[XYZE], const float &feedrate) {
357
+  bool _O2 unified_bed_leveling::line_to_destination_segmented(const feedRate_t &scaled_fr_mm_s) {
360
 
358
 
361
-    if (!position_is_reachable(rtarget[X_AXIS], rtarget[Y_AXIS]))  // fail if moving outside reachable boundary
359
+    if (!position_is_reachable(destination[X_AXIS], destination[Y_AXIS]))  // fail if moving outside reachable boundary
362
       return true; // did not move, so current_position still accurate
360
       return true; // did not move, so current_position still accurate
363
 
361
 
364
     const float total[XYZE] = {
362
     const float total[XYZE] = {
365
-      rtarget[X_AXIS] - current_position[X_AXIS],
366
-      rtarget[Y_AXIS] - current_position[Y_AXIS],
367
-      rtarget[Z_AXIS] - current_position[Z_AXIS],
368
-      rtarget[E_AXIS] - current_position[E_AXIS]
363
+      destination[X_AXIS] - current_position[X_AXIS],
364
+      destination[Y_AXIS] - current_position[Y_AXIS],
365
+      destination[Z_AXIS] - current_position[Z_AXIS],
366
+      destination[E_AXIS] - current_position[E_AXIS]
369
     };
367
     };
370
 
368
 
371
     const float cartesian_xy_mm = HYPOT(total[X_AXIS], total[Y_AXIS]);  // total horizontal xy distance
369
     const float cartesian_xy_mm = HYPOT(total[X_AXIS], total[Y_AXIS]);  // total horizontal xy distance
372
 
370
 
373
     #if IS_KINEMATIC
371
     #if IS_KINEMATIC
374
-      const float seconds = cartesian_xy_mm / feedrate;                                  // seconds to move xy distance at requested rate
375
-      uint16_t segments = LROUND(delta_segments_per_second * seconds),                  // preferred number of segments for distance @ feedrate
376
-               seglimit = LROUND(cartesian_xy_mm * RECIPROCAL(DELTA_SEGMENT_MIN_LENGTH)); // number of segments at minimum segment length
377
-      NOMORE(segments, seglimit);                                                        // limit to minimum segment length (fewer segments)
372
+      const float seconds = cartesian_xy_mm / scaled_fr_mm_s;                             // Duration of XY move at requested rate
373
+      uint16_t segments = LROUND(delta_segments_per_second * seconds),                    // Preferred number of segments for distance @ feedrate
374
+               seglimit = LROUND(cartesian_xy_mm * RECIPROCAL(DELTA_SEGMENT_MIN_LENGTH)); // Number of segments at minimum segment length
375
+      NOMORE(segments, seglimit);                                                         // Limit to minimum segment length (fewer segments)
378
     #else
376
     #else
379
       uint16_t segments = LROUND(cartesian_xy_mm * RECIPROCAL(DELTA_SEGMENT_MIN_LENGTH)); // cartesian fixed segment length
377
       uint16_t segments = LROUND(cartesian_xy_mm * RECIPROCAL(DELTA_SEGMENT_MIN_LENGTH)); // cartesian fixed segment length
380
     #endif
378
     #endif
384
 
382
 
385
     const float segment_xyz_mm = HYPOT(cartesian_xy_mm, total[Z_AXIS]) * inv_segments;   // length of each segment
383
     const float segment_xyz_mm = HYPOT(cartesian_xy_mm, total[Z_AXIS]) * inv_segments;   // length of each segment
386
     #if ENABLED(SCARA_FEEDRATE_SCALING)
384
     #if ENABLED(SCARA_FEEDRATE_SCALING)
387
-      const float inv_duration = feedrate / segment_xyz_mm;
385
+      const float inv_duration = scaled_fr_mm_s / segment_xyz_mm;
388
     #endif
386
     #endif
389
 
387
 
390
     const float diff[XYZE] = {
388
     const float diff[XYZE] = {
404
       current_position[E_AXIS]
402
       current_position[E_AXIS]
405
     };
403
     };
406
 
404
 
407
-    // Only compute leveling per segment if ubl active and target below z_fade_height.
408
-    if (!planner.leveling_active || !planner.leveling_active_at_z(rtarget[Z_AXIS])) {   // no mesh leveling
405
+    // Just do plain segmentation if UBL is inactive or the target is above the fade height
406
+    if (!planner.leveling_active || !planner.leveling_active_at_z(destination[Z_AXIS])) {
409
       while (--segments) {
407
       while (--segments) {
410
         LOOP_XYZE(i) raw[i] += diff[i];
408
         LOOP_XYZE(i) raw[i] += diff[i];
411
-        planner.buffer_line(raw, feedrate, active_extruder, segment_xyz_mm
409
+        planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, segment_xyz_mm
412
           #if ENABLED(SCARA_FEEDRATE_SCALING)
410
           #if ENABLED(SCARA_FEEDRATE_SCALING)
413
             , inv_duration
411
             , inv_duration
414
           #endif
412
           #endif
415
         );
413
         );
416
       }
414
       }
417
-      planner.buffer_line(rtarget, feedrate, active_extruder, segment_xyz_mm
415
+      planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, segment_xyz_mm
418
         #if ENABLED(SCARA_FEEDRATE_SCALING)
416
         #if ENABLED(SCARA_FEEDRATE_SCALING)
419
           , inv_duration
417
           , inv_duration
420
         #endif
418
         #endif
425
     // Otherwise perform per-segment leveling
423
     // Otherwise perform per-segment leveling
426
 
424
 
427
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
425
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
428
-      const float fade_scaling_factor = planner.fade_scaling_factor_for_z(rtarget[Z_AXIS]);
426
+      const float fade_scaling_factor = planner.fade_scaling_factor_for_z(destination[Z_AXIS]);
429
     #endif
427
     #endif
430
 
428
 
431
     // increment to first segment destination
429
     // increment to first segment destination
483
 
481
 
484
       for (;;) {  // for all segments within this mesh cell
482
       for (;;) {  // for all segments within this mesh cell
485
 
483
 
486
-        if (--segments == 0)                      // if this is last segment, use rtarget for exact
487
-          COPY(raw, rtarget);
484
+        if (--segments == 0) COPY(raw, destination); // if this is last segment, use destination for exact
488
 
485
 
489
         const float z_cxcy = (z_cxy0 + z_cxym * cy) // interpolated mesh z height along cx at cy
486
         const float z_cxcy = (z_cxy0 + z_cxym * cy) // interpolated mesh z height along cx at cy
490
           #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
487
           #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
494
 
491
 
495
         const float z = raw[Z_AXIS];
492
         const float z = raw[Z_AXIS];
496
         raw[Z_AXIS] += z_cxcy;
493
         raw[Z_AXIS] += z_cxcy;
497
-        planner.buffer_line(raw, feedrate, active_extruder, segment_xyz_mm
494
+        planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, segment_xyz_mm
498
           #if ENABLED(SCARA_FEEDRATE_SCALING)
495
           #if ENABLED(SCARA_FEEDRATE_SCALING)
499
             , inv_duration
496
             , inv_duration
500
           #endif
497
           #endif

+ 18
- 21
Marlin/src/feature/fwretract.cpp Visa fil

128
     SERIAL_ECHOLNPAIR("current_hop ", current_hop);
128
     SERIAL_ECHOLNPAIR("current_hop ", current_hop);
129
   //*/
129
   //*/
130
 
130
 
131
-  const float old_feedrate_mm_s = feedrate_mm_s,
132
-              unscale_e = RECIPROCAL(planner.e_factor[active_extruder]),
133
-              unscale_fr = 100.0 / feedrate_percentage, // Disable feedrate scaling for retract moves
134
-              base_retract = (
131
+  const float base_retract = (
135
                 (swapping ? settings.swap_retract_length : settings.retract_length)
132
                 (swapping ? settings.swap_retract_length : settings.retract_length)
136
                 #if ENABLED(RETRACT_SYNC_MIXING)
133
                 #if ENABLED(RETRACT_SYNC_MIXING)
137
                   * (MIXING_STEPPERS)
134
                   * (MIXING_STEPPERS)
146
     mixer.T(MIXER_AUTORETRACT_TOOL);
143
     mixer.T(MIXER_AUTORETRACT_TOOL);
147
   #endif
144
   #endif
148
 
145
 
146
+  const feedRate_t fr_max_z = planner.settings.max_feedrate_mm_s[Z_AXIS];
149
   if (retracting) {
147
   if (retracting) {
150
     // Retract by moving from a faux E position back to the current E position
148
     // Retract by moving from a faux E position back to the current E position
151
-    feedrate_mm_s = (
152
-      settings.retract_feedrate_mm_s * unscale_fr
149
+    current_retract[active_extruder] = base_retract;
150
+    prepare_internal_move_to_destination(  // set_current_to_destination
151
+      settings.retract_feedrate_mm_s
153
       #if ENABLED(RETRACT_SYNC_MIXING)
152
       #if ENABLED(RETRACT_SYNC_MIXING)
154
         * (MIXING_STEPPERS)
153
         * (MIXING_STEPPERS)
155
       #endif
154
       #endif
156
     );
155
     );
157
-    current_retract[active_extruder] = base_retract * unscale_e;
158
-    prepare_move_to_destination();                        // set_current_to_destination
159
 
156
 
160
     // Is a Z hop set, and has the hop not yet been done?
157
     // Is a Z hop set, and has the hop not yet been done?
161
-    if (settings.retract_zraise > 0.01 && !current_hop) {           // Apply hop only once
162
-      current_hop += settings.retract_zraise;                       // Add to the hop total (again, only once)
163
-      feedrate_mm_s = planner.settings.max_feedrate_mm_s[Z_AXIS] * unscale_fr;  // Maximum Z feedrate
164
-      prepare_move_to_destination();                      // Raise up, set_current_to_destination
158
+    if (!current_hop && settings.retract_zraise > 0.01f) {  // Apply hop only once
159
+      current_hop += settings.retract_zraise;               // Add to the hop total (again, only once)
160
+      // Raise up, set_current_to_destination. Maximum Z feedrate
161
+      prepare_internal_move_to_destination(fr_max_z);
165
     }
162
     }
166
   }
163
   }
167
   else {
164
   else {
168
     // If a hop was done and Z hasn't changed, undo the Z hop
165
     // If a hop was done and Z hasn't changed, undo the Z hop
169
     if (current_hop) {
166
     if (current_hop) {
170
-      current_hop = 0.0;
171
-      feedrate_mm_s = planner.settings.max_feedrate_mm_s[Z_AXIS] * unscale_fr;  // Z feedrate to max
172
-      prepare_move_to_destination();                      // Lower Z, set_current_to_destination
167
+      current_hop = 0;
168
+      // Lower Z, set_current_to_destination. Maximum Z feedrate
169
+      prepare_internal_move_to_destination(fr_max_z);
173
     }
170
     }
174
 
171
 
175
     const float extra_recover = swapping ? settings.swap_retract_recover_extra : settings.retract_recover_extra;
172
     const float extra_recover = swapping ? settings.swap_retract_recover_extra : settings.retract_recover_extra;
176
-    if (extra_recover != 0.0) {
173
+    if (extra_recover) {
177
       current_position[E_AXIS] -= extra_recover;          // Adjust the current E position by the extra amount to recover
174
       current_position[E_AXIS] -= extra_recover;          // Adjust the current E position by the extra amount to recover
178
       sync_plan_position_e();                             // Sync the planner position so the extra amount is recovered
175
       sync_plan_position_e();                             // Sync the planner position so the extra amount is recovered
179
     }
176
     }
180
 
177
 
181
-    current_retract[active_extruder] = 0.0;
182
-    feedrate_mm_s = (
183
-      (swapping ? settings.swap_retract_recover_feedrate_mm_s : settings.retract_recover_feedrate_mm_s) * unscale_fr
178
+    current_retract[active_extruder] = 0;
179
+
180
+    const feedRate_t fr_mm_s = (
181
+      (swapping ? settings.swap_retract_recover_feedrate_mm_s : settings.retract_recover_feedrate_mm_s)
184
       #if ENABLED(RETRACT_SYNC_MIXING)
182
       #if ENABLED(RETRACT_SYNC_MIXING)
185
         * (MIXING_STEPPERS)
183
         * (MIXING_STEPPERS)
186
       #endif
184
       #endif
187
     );
185
     );
188
-    prepare_move_to_destination();                        // Recover E, set_current_to_destination
186
+    prepare_internal_move_to_destination(fr_mm_s);        // Recover E, set_current_to_destination
189
   }
187
   }
190
 
188
 
191
   #if ENABLED(RETRACT_SYNC_MIXING)
189
   #if ENABLED(RETRACT_SYNC_MIXING)
192
     mixer.T(old_mixing_tool);                             // Restore original mixing tool
190
     mixer.T(old_mixing_tool);                             // Restore original mixing tool
193
   #endif
191
   #endif
194
 
192
 
195
-  feedrate_mm_s = old_feedrate_mm_s;                      // Restore original feedrate
196
   retracted[active_extruder] = retracting;                // Active extruder now retracted / recovered
193
   retracted[active_extruder] = retracting;                // Active extruder now retracted / recovered
197
 
194
 
198
   // If swap retract/recover update the retracted_swap flag too
195
   // If swap retract/recover update the retracted_swap flag too

+ 8
- 8
Marlin/src/feature/fwretract.h Visa fil

28
 #include "../inc/MarlinConfigPre.h"
28
 #include "../inc/MarlinConfigPre.h"
29
 
29
 
30
 typedef struct {
30
 typedef struct {
31
-  float retract_length,                     // M207 S - G10 Retract length
32
-        retract_feedrate_mm_s,              // M207 F - G10 Retract feedrate
33
-        retract_zraise,                     // M207 Z - G10 Retract hop size
34
-        retract_recover_extra,              // M208 S - G11 Recover length
35
-        retract_recover_feedrate_mm_s,      // M208 F - G11 Recover feedrate
36
-        swap_retract_length,                // M207 W - G10 Swap Retract length
37
-        swap_retract_recover_extra,         // M208 W - G11 Swap Recover length
38
-        swap_retract_recover_feedrate_mm_s; // M208 R - G11 Swap Recover feedrate
31
+       float retract_length;                      // M207 S - G10 Retract length
32
+  feedRate_t retract_feedrate_mm_s;               // M207 F - G10 Retract feedrate
33
+       float retract_zraise,                      // M207 Z - G10 Retract hop size
34
+             retract_recover_extra;               // M208 S - G11 Recover length
35
+  feedRate_t retract_recover_feedrate_mm_s;       // M208 F - G11 Recover feedrate
36
+       float swap_retract_length,                 // M207 W - G10 Swap Retract length
37
+             swap_retract_recover_extra;          // M208 W - G11 Swap Recover length
38
+  feedRate_t swap_retract_recover_feedrate_mm_s;  // M208 R - G11 Swap Recover feedrate
39
 } fwretract_settings_t;
39
 } fwretract_settings_t;
40
 
40
 
41
 #if ENABLED(FWRETRACT)
41
 #if ENABLED(FWRETRACT)

+ 5
- 5
Marlin/src/feature/pause.cpp Visa fil

122
   return thermalManager.wait_for_hotend(active_extruder);
122
   return thermalManager.wait_for_hotend(active_extruder);
123
 }
123
 }
124
 
124
 
125
-void do_pause_e_move(const float &length, const float &fr_mm_s) {
125
+void do_pause_e_move(const float &length, const feedRate_t &fr_mm_s) {
126
   #if HAS_FILAMENT_SENSOR
126
   #if HAS_FILAMENT_SENSOR
127
     runout.reset();
127
     runout.reset();
128
   #endif
128
   #endif
648
   #endif
648
   #endif
649
 
649
 
650
   // If resume_position is negative
650
   // If resume_position is negative
651
-  if (resume_position[E_AXIS] < 0) do_pause_e_move(resume_position[E_AXIS], PAUSE_PARK_RETRACT_FEEDRATE);
651
+  if (resume_position[E_AXIS] < 0) do_pause_e_move(resume_position[E_AXIS], feedRate_t(PAUSE_PARK_RETRACT_FEEDRATE));
652
 
652
 
653
   // Move XY to starting position, then Z
653
   // Move XY to starting position, then Z
654
-  do_blocking_move_to_xy(resume_position[X_AXIS], resume_position[Y_AXIS], NOZZLE_PARK_XY_FEEDRATE);
654
+  do_blocking_move_to_xy(resume_position[X_AXIS], resume_position[Y_AXIS], feedRate_t(NOZZLE_PARK_XY_FEEDRATE));
655
 
655
 
656
   // Move Z_AXIS to saved position
656
   // Move Z_AXIS to saved position
657
-  do_blocking_move_to_z(resume_position[Z_AXIS], NOZZLE_PARK_Z_FEEDRATE);
657
+  do_blocking_move_to_z(resume_position[Z_AXIS], feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
658
 
658
 
659
   #if ADVANCED_PAUSE_RESUME_PRIME != 0
659
   #if ADVANCED_PAUSE_RESUME_PRIME != 0
660
-    do_pause_e_move(ADVANCED_PAUSE_RESUME_PRIME, ADVANCED_PAUSE_PURGE_FEEDRATE);
660
+    do_pause_e_move(ADVANCED_PAUSE_RESUME_PRIME, feedRate_t(ADVANCED_PAUSE_PURGE_FEEDRATE));
661
   #endif
661
   #endif
662
 
662
 
663
   // Now all extrusion positions are resumed and ready to be confirmed
663
   // Now all extrusion positions are resumed and ready to be confirmed

+ 1
- 1
Marlin/src/feature/pause.h Visa fil

81
   #define DXC_PASS
81
   #define DXC_PASS
82
 #endif
82
 #endif
83
 
83
 
84
-void do_pause_e_move(const float &length, const float &fr_mm_s);
84
+void do_pause_e_move(const float &length, const feedRate_t &fr_mm_s);
85
 
85
 
86
 bool pause_print(const float &retract, const point_t &park_point, const float &unload_length=0, const bool show_lcd=false DXC_PARAMS);
86
 bool pause_print(const float &retract, const point_t &park_point, const float &unload_length=0, const bool show_lcd=false DXC_PARAMS);
87
 
87
 

+ 8
- 9
Marlin/src/feature/prusa_MMU2/mmu2.cpp Visa fil

102
 #if HAS_LCD_MENU && ENABLED(MMU2_MENUS)
102
 #if HAS_LCD_MENU && ENABLED(MMU2_MENUS)
103
 
103
 
104
   struct E_Step {
104
   struct E_Step {
105
-    float extrude;    //!< extrude distance in mm
106
-    float feedRate;   //!< feed rate in mm/s
105
+    float extrude;        //!< extrude distance in mm
106
+    feedRate_t feedRate;  //!< feed rate in mm/s
107
   };
107
   };
108
 
108
 
109
   static constexpr E_Step ramming_sequence[] PROGMEM = { MMU2_RAMMING_SEQUENCE };
109
   static constexpr E_Step ramming_sequence[] PROGMEM = { MMU2_RAMMING_SEQUENCE };
606
         BUZZ(200, 404);
606
         BUZZ(200, 404);
607
 
607
 
608
         // Move XY to starting position, then Z
608
         // Move XY to starting position, then Z
609
-        do_blocking_move_to_xy(resume_position[X_AXIS], resume_position[Y_AXIS], NOZZLE_PARK_XY_FEEDRATE);
609
+        do_blocking_move_to_xy(resume_position[X_AXIS], resume_position[Y_AXIS], feedRate_t(NOZZLE_PARK_XY_FEEDRATE));
610
 
610
 
611
         // Move Z_AXIS to saved position
611
         // Move Z_AXIS to saved position
612
-        do_blocking_move_to_z(resume_position[Z_AXIS], NOZZLE_PARK_Z_FEEDRATE);
612
+        do_blocking_move_to_z(resume_position[Z_AXIS], feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
613
       }
613
       }
614
       else {
614
       else {
615
         BUZZ(200, 404);
615
         BUZZ(200, 404);
783
     const E_Step* step = sequence;
783
     const E_Step* step = sequence;
784
 
784
 
785
     for (uint8_t i = 0; i < steps; i++) {
785
     for (uint8_t i = 0; i < steps; i++) {
786
-      const float es = pgm_read_float(&(step->extrude)),
787
-                  fr = pgm_read_float(&(step->feedRate));
786
+      const float es = pgm_read_float(&(step->extrude));
787
+      const feedRate_t fr_mm_m = pgm_read_float(&(step->feedRate));
788
 
788
 
789
       DEBUG_ECHO_START();
789
       DEBUG_ECHO_START();
790
-      DEBUG_ECHOLNPAIR("E step ", es, "/", fr);
790
+      DEBUG_ECHOLNPAIR("E step ", es, "/", fr_mm_m);
791
 
791
 
792
       current_position[E_AXIS] += es;
792
       current_position[E_AXIS] += es;
793
-      planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
794
-                          current_position[E_AXIS], MMM_TO_MMS(fr), active_extruder);
793
+      line_to_current_position(MMM_TO_MMS(fr_mm_m));
795
       planner.synchronize();
794
       planner.synchronize();
796
 
795
 
797
       step++;
796
       step++;

+ 12
- 19
Marlin/src/gcode/bedlevel/G26.cpp Visa fil

216
   return return_val;
216
   return return_val;
217
 }
217
 }
218
 
218
 
219
-void G26_line_to_destination(const float &feed_rate) {
220
-  const float save_feedrate = feedrate_mm_s;
221
-  feedrate_mm_s = feed_rate;
222
-  prepare_move_to_destination();  // will ultimately call ubl.line_to_destination_cartesian or ubl.prepare_linear_move_to for UBL_SEGMENTED
223
-  feedrate_mm_s = save_feedrate;
224
-}
225
-
226
 void move_to(const float &rx, const float &ry, const float &z, const float &e_delta) {
219
 void move_to(const float &rx, const float &ry, const float &z, const float &e_delta) {
227
-  float feed_value;
228
   static float last_z = -999.99;
220
   static float last_z = -999.99;
229
 
221
 
230
   bool has_xy_component = (rx != current_position[X_AXIS] || ry != current_position[Y_AXIS]); // Check if X or Y is involved in the movement.
222
   bool has_xy_component = (rx != current_position[X_AXIS] || ry != current_position[Y_AXIS]); // Check if X or Y is involved in the movement.
231
 
223
 
232
   if (z != last_z) {
224
   if (z != last_z) {
233
     last_z = z;
225
     last_z = z;
234
-    feed_value = planner.settings.max_feedrate_mm_s[Z_AXIS]/(2.0);  // Base the feed rate off of the configured Z_AXIS feed rate
226
+    const feedRate_t feed_value = planner.settings.max_feedrate_mm_s[Z_AXIS] * 0.5f; // Use half of the Z_AXIS max feed rate
235
 
227
 
236
     destination[X_AXIS] = current_position[X_AXIS];
228
     destination[X_AXIS] = current_position[X_AXIS];
237
     destination[Y_AXIS] = current_position[Y_AXIS];
229
     destination[Y_AXIS] = current_position[Y_AXIS];
238
     destination[Z_AXIS] = z;                          // We know the last_z!=z or we wouldn't be in this block of code.
230
     destination[Z_AXIS] = z;                          // We know the last_z!=z or we wouldn't be in this block of code.
239
     destination[E_AXIS] = current_position[E_AXIS];
231
     destination[E_AXIS] = current_position[E_AXIS];
240
 
232
 
241
-    G26_line_to_destination(feed_value);
233
+    prepare_internal_move_to_destination(feed_value);
242
     set_destination_from_current();
234
     set_destination_from_current();
243
   }
235
   }
244
 
236
 
245
-  // Check if X or Y is involved in the movement.
246
-  // Yes: a 'normal' movement. No: a retract() or recover()
247
-  feed_value = has_xy_component ? G26_XY_FEEDRATE : planner.settings.max_feedrate_mm_s[E_AXIS] / 1.5;
237
+  // If X or Y is involved do a 'normal' move. Otherwise retract/recover/hop.
238
+  const feedRate_t feed_value = has_xy_component ? feedRate_t(G26_XY_FEEDRATE) : planner.settings.max_feedrate_mm_s[E_AXIS] * 0.666f;
248
 
239
 
249
   destination[X_AXIS] = rx;
240
   destination[X_AXIS] = rx;
250
   destination[Y_AXIS] = ry;
241
   destination[Y_AXIS] = ry;
251
   destination[E_AXIS] += e_delta;
242
   destination[E_AXIS] += e_delta;
252
 
243
 
253
-  G26_line_to_destination(feed_value);
244
+  prepare_internal_move_to_destination(feed_value);
254
   set_destination_from_current();
245
   set_destination_from_current();
255
 }
246
 }
256
 
247
 
433
  */
424
  */
434
 inline bool prime_nozzle() {
425
 inline bool prime_nozzle() {
435
 
426
 
427
+  const feedRate_t fr_slow_e = planner.settings.max_feedrate_mm_s[E_AXIS] / 15.0f;
436
   #if HAS_LCD_MENU
428
   #if HAS_LCD_MENU
437
     #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
429
     #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
438
       float Total_Prime = 0.0;
430
       float Total_Prime = 0.0;
455
           Total_Prime += 0.25;
447
           Total_Prime += 0.25;
456
           if (Total_Prime >= EXTRUDE_MAXLENGTH) return G26_ERR;
448
           if (Total_Prime >= EXTRUDE_MAXLENGTH) return G26_ERR;
457
         #endif
449
         #endif
458
-        G26_line_to_destination(planner.settings.max_feedrate_mm_s[E_AXIS] / 15.0);
450
+        prepare_internal_move_to_destination(fr_slow_e);
459
         set_destination_from_current();
451
         set_destination_from_current();
460
         planner.synchronize();    // Without this synchronize, the purge is more consistent,
452
         planner.synchronize();    // Without this synchronize, the purge is more consistent,
461
                                   // but because the planner has a buffer, we won't be able
453
                                   // but because the planner has a buffer, we won't be able
478
     #endif
470
     #endif
479
     set_destination_from_current();
471
     set_destination_from_current();
480
     destination[E_AXIS] += g26_prime_length;
472
     destination[E_AXIS] += g26_prime_length;
481
-    G26_line_to_destination(planner.settings.max_feedrate_mm_s[E_AXIS] / 15.0);
473
+    prepare_internal_move_to_destination(fr_slow_e);
482
     set_destination_from_current();
474
     set_destination_from_current();
483
     retract_filament(destination);
475
     retract_filament(destination);
484
   }
476
   }
781
         move_to(sx, sy, g26_layer_height, 0.0); // Get to the starting point with no extrusion / un-Z bump
773
         move_to(sx, sy, g26_layer_height, 0.0); // Get to the starting point with no extrusion / un-Z bump
782
 
774
 
783
         recover_filament(destination);
775
         recover_filament(destination);
784
-        const float save_feedrate = feedrate_mm_s;
785
-        feedrate_mm_s = PLANNER_XY_FEEDRATE() / 10.0;
786
 
776
 
777
+        const feedRate_t old_feedrate = feedrate_mm_s;
778
+        feedrate_mm_s = PLANNER_XY_FEEDRATE() * 0.1f;
787
         plan_arc(endpoint, arc_offset, false);  // Draw a counter-clockwise arc
779
         plan_arc(endpoint, arc_offset, false);  // Draw a counter-clockwise arc
788
-        feedrate_mm_s = save_feedrate;
780
+        feedrate_mm_s = old_feedrate;
789
         set_destination_from_current();
781
         set_destination_from_current();
782
+
790
         #if HAS_LCD_MENU
783
         #if HAS_LCD_MENU
791
           if (user_canceled()) goto LEAVE; // Check if the user wants to stop the Mesh Validation
784
           if (user_canceled()) goto LEAVE; // Check if the user wants to stop the Mesh Validation
792
         #endif
785
         #endif

+ 6
- 4
Marlin/src/gcode/bedlevel/G42.cpp Visa fil

45
     }
45
     }
46
 
46
 
47
     set_destination_from_current();
47
     set_destination_from_current();
48
+
48
     if (hasI) destination[X_AXIS] = _GET_MESH_X(ix);
49
     if (hasI) destination[X_AXIS] = _GET_MESH_X(ix);
49
     if (hasJ) destination[Y_AXIS] = _GET_MESH_Y(iy);
50
     if (hasJ) destination[Y_AXIS] = _GET_MESH_Y(iy);
51
+
50
     #if HAS_BED_PROBE
52
     #if HAS_BED_PROBE
51
       if (parser.boolval('P')) {
53
       if (parser.boolval('P')) {
52
         if (hasI) destination[X_AXIS] -= probe_offset[X_AXIS];
54
         if (hasI) destination[X_AXIS] -= probe_offset[X_AXIS];
54
       }
56
       }
55
     #endif
57
     #endif
56
 
58
 
57
-    const float fval = parser.linearval('F');
58
-    if (fval > 0.0) feedrate_mm_s = MMM_TO_MMS(fval);
59
+    const feedRate_t fval = parser.linearval('F'),
60
+                     fr_mm_s = fval > 0 ? MMM_TO_MMS(fval) : 0.0f;
59
 
61
 
60
     // SCARA kinematic has "safe" XY raw moves
62
     // SCARA kinematic has "safe" XY raw moves
61
     #if IS_SCARA
63
     #if IS_SCARA
62
-      prepare_uninterpolated_move_to_destination();
64
+      prepare_internal_fast_move_to_destination(fr_mm_s);
63
     #else
65
     #else
64
-      prepare_move_to_destination();
66
+      prepare_internal_move_to_destination(fr_mm_s);
65
     #endif
67
     #endif
66
   }
68
   }
67
 }
69
 }

+ 1
- 2
Marlin/src/gcode/bedlevel/mbl/G29.cpp Visa fil

143
 
143
 
144
         #if ENABLED(MESH_G28_REST_ORIGIN)
144
         #if ENABLED(MESH_G28_REST_ORIGIN)
145
           current_position[Z_AXIS] = 0;
145
           current_position[Z_AXIS] = 0;
146
-          set_destination_from_current();
147
-          buffer_line_to_destination(homing_feedrate(Z_AXIS));
146
+          line_to_current_position(homing_feedrate(Z_AXIS));
148
           planner.synchronize();
147
           planner.synchronize();
149
         #endif
148
         #endif
150
 
149
 

+ 4
- 5
Marlin/src/gcode/calibrate/G425.cpp Visa fil

171
  *   fast         in - Fast vs. precise measurement
171
  *   fast         in - Fast vs. precise measurement
172
  */
172
  */
173
 float measuring_movement(const AxisEnum axis, const int dir, const bool stop_state, const bool fast) {
173
 float measuring_movement(const AxisEnum axis, const int dir, const bool stop_state, const bool fast) {
174
-  const float step  =            fast ? 0.25                      : CALIBRATION_MEASUREMENT_RESOLUTION;
175
-  const float mms   = MMM_TO_MMS(fast ? CALIBRATION_FEEDRATE_FAST : CALIBRATION_FEEDRATE_SLOW);
176
-  const float limit =            fast ? 50                        : 5;
174
+  const float step     = fast ? 0.25 : CALIBRATION_MEASUREMENT_RESOLUTION;
175
+  const feedRate_t mms = fast ? MMM_TO_MMS(CALIBRATION_FEEDRATE_FAST) : MMM_TO_MMS(CALIBRATION_FEEDRATE_SLOW);
176
+  const float limit    = fast ? 50 : 5;
177
 
177
 
178
   set_destination_from_current();
178
   set_destination_from_current();
179
   for (float travel = 0; travel < limit; travel += step) {
179
   for (float travel = 0; travel < limit; travel += step) {
180
     destination[axis] += dir * step;
180
     destination[axis] += dir * step;
181
     do_blocking_move_to(destination, mms);
181
     do_blocking_move_to(destination, mms);
182
     planner.synchronize();
182
     planner.synchronize();
183
-    if (read_calibration_pin() == stop_state)
184
-      break;
183
+    if (read_calibration_pin() == stop_state) break;
185
   }
184
   }
186
   return destination[axis];
185
   return destination[axis];
187
 }
186
 }

+ 18
- 20
Marlin/src/gcode/feature/L6470/M916-918.cpp Visa fil

32
 #define DEBUG_OUT ENABLED(L6470_CHITCHAT)
32
 #define DEBUG_OUT ENABLED(L6470_CHITCHAT)
33
 #include "../../../core/debug_out.h"
33
 #include "../../../core/debug_out.h"
34
 
34
 
35
-static void jiggle_axis(const char axis_char, const float &min, const float &max, const float &rate) {
35
+static void jiggle_axis(const char axis_char, const float &min, const float &max, const feedRate_t &fr_mm_m) {
36
   char gcode_string[30], str1[11], str2[11];
36
   char gcode_string[30], str1[11], str2[11];
37
 
37
 
38
   // Turn the motor(s) both directions
38
   // Turn the motor(s) both directions
84
   uint8_t driver_count = 1;
84
   uint8_t driver_count = 1;
85
   float position_max;
85
   float position_max;
86
   float position_min;
86
   float position_min;
87
-  float final_feedrate;
87
+  feedRate_t final_fr_mm_m;
88
   uint8_t kval_hold;
88
   uint8_t kval_hold;
89
   uint8_t ocd_th_val = 0;
89
   uint8_t ocd_th_val = 0;
90
   uint8_t stall_th_val = 0;
90
   uint8_t stall_th_val = 0;
93
 
93
 
94
   uint8_t j;   // general purpose counter
94
   uint8_t j;   // general purpose counter
95
 
95
 
96
-  if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold))
96
+  if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_fr_mm_m, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold))
97
     return;  // quit if invalid user input
97
     return;  // quit if invalid user input
98
 
98
 
99
-  DEBUG_ECHOLNPAIR("feedrate = ", final_feedrate);
99
+  DEBUG_ECHOLNPAIR("feedrate = ", final_fr_mm_m);
100
 
100
 
101
   planner.synchronize();                  // Wait for moves to finish
101
   planner.synchronize();                  // Wait for moves to finish
102
 
102
 
115
       L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
115
       L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
116
 
116
 
117
     // Turn the motor(s) both directions
117
     // Turn the motor(s) both directions
118
-    jiggle_axis(axis_mon[0][0], position_min, position_max, final_feedrate);
118
+    jiggle_axis(axis_mon[0][0], position_min, position_max, final_fr_mm_m);
119
 
119
 
120
     status_composite = 0;    // clear out the old bits
120
     status_composite = 0;    // clear out the old bits
121
 
121
 
190
   uint8_t driver_count = 1;
190
   uint8_t driver_count = 1;
191
   float position_max;
191
   float position_max;
192
   float position_min;
192
   float position_min;
193
-  float final_feedrate;
193
+  feedRate_t final_fr_mm_m;
194
   uint8_t kval_hold;
194
   uint8_t kval_hold;
195
   uint8_t ocd_th_val = 0;
195
   uint8_t ocd_th_val = 0;
196
   uint8_t stall_th_val = 0;
196
   uint8_t stall_th_val = 0;
199
 
199
 
200
   uint8_t j;   // general purpose counter
200
   uint8_t j;   // general purpose counter
201
 
201
 
202
-  if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold))
202
+  if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_fr_mm_m, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold))
203
     return;  // quit if invalid user input
203
     return;  // quit if invalid user input
204
 
204
 
205
-  DEBUG_ECHOLNPAIR("feedrate = ", final_feedrate);
205
+  DEBUG_ECHOLNPAIR("feedrate = ", final_fr_mm_m);
206
 
206
 
207
   planner.synchronize();                // Wait for moves to finish
207
   planner.synchronize();                // Wait for moves to finish
208
   for (j = 0; j < driver_count; j++)
208
   for (j = 0; j < driver_count; j++)
225
     DEBUG_ECHOPAIR("STALL threshold : ", (stall_th_val + 1) * 31.25);
225
     DEBUG_ECHOPAIR("STALL threshold : ", (stall_th_val + 1) * 31.25);
226
     DEBUG_ECHOLNPAIR("   OCD threshold : ", (ocd_th_val + 1) * 375);
226
     DEBUG_ECHOLNPAIR("   OCD threshold : ", (ocd_th_val + 1) * 375);
227
 
227
 
228
-    jiggle_axis(axis_mon[0][0], position_min, position_max, final_feedrate);
228
+    jiggle_axis(axis_mon[0][0], position_min, position_max, final_fr_mm_m);
229
 
229
 
230
     status_composite = 0;    // clear out the old bits
230
     status_composite = 0;    // clear out the old bits
231
 
231
 
452
   uint16_t axis_status[3];
452
   uint16_t axis_status[3];
453
   uint8_t driver_count = 1;
453
   uint8_t driver_count = 1;
454
   float position_max, position_min;
454
   float position_max, position_min;
455
-  float final_feedrate;
455
+  feedRate_t final_fr_mm_m;
456
   uint8_t kval_hold;
456
   uint8_t kval_hold;
457
   uint8_t ocd_th_val = 0;
457
   uint8_t ocd_th_val = 0;
458
   uint8_t stall_th_val = 0;
458
   uint8_t stall_th_val = 0;
461
 
461
 
462
   uint8_t j;   // general purpose counter
462
   uint8_t j;   // general purpose counter
463
 
463
 
464
-  if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold))
464
+  if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_fr_mm_m, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold))
465
     return;  // quit if invalid user input
465
     return;  // quit if invalid user input
466
 
466
 
467
   uint8_t m_steps = parser.byteval('M');
467
   uint8_t m_steps = parser.byteval('M');
489
   for (j = 0; j < driver_count; j++)
489
   for (j = 0; j < driver_count; j++)
490
     L6470.set_param(axis_index[j], L6470_STEP_MODE, m_bits);   // set microsteps
490
     L6470.set_param(axis_index[j], L6470_STEP_MODE, m_bits);   // set microsteps
491
 
491
 
492
-  DEBUG_ECHOLNPAIR("target (maximum) feedrate = ",final_feedrate);
493
-
494
-  float feedrate_inc = final_feedrate / 10, // start at 1/10 of max & go up by 1/10 per step)
495
-        current_feedrate = 0;
492
+  DEBUG_ECHOLNPAIR("target (maximum) feedrate = ", final_fr_mm_m);
496
 
493
 
497
   planner.synchronize();                  // Wait for moves to finish
494
   planner.synchronize();                  // Wait for moves to finish
498
 
495
 
502
   uint16_t status_composite = 0;
499
   uint16_t status_composite = 0;
503
   DEBUG_ECHOLNPGM(".\n.\n.");             // Make the feedrate prints easier to see
500
   DEBUG_ECHOLNPGM(".\n.\n.");             // Make the feedrate prints easier to see
504
 
501
 
505
-  do {
506
-    current_feedrate += feedrate_inc;
507
-    DEBUG_ECHOLNPAIR("...feedrate = ", current_feedrate);
502
+  constexpr uint8_t iterations = 10;
503
+  for (uint8_t i = 1; i <= iterations; i++) {
504
+    const feedRate_t fr_mm_m = i * final_fr_mm_m / iterations;
505
+    DEBUG_ECHOLNPAIR("...feedrate = ", fr_mm_m);
508
 
506
 
509
-    jiggle_axis(axis_mon[0][0], position_min, position_max, current_feedrate);
507
+    jiggle_axis(axis_mon[0][0], position_min, position_max, fr_mm_m);
510
 
508
 
511
     for (j = 0; j < driver_count; j++) {
509
     for (j = 0; j < driver_count; j++) {
512
       axis_status[j] = (~L6470.get_status(axis_index[j])) & 0x0800;    // bits of interest are all active low
510
       axis_status[j] = (~L6470.get_status(axis_index[j])) & 0x0800;    // bits of interest are all active low
513
       status_composite |= axis_status[j];
511
       status_composite |= axis_status[j];
514
     }
512
     }
515
     if (status_composite) break;       // quit if any errors flags are raised
513
     if (status_composite) break;       // quit if any errors flags are raised
516
-  } while (current_feedrate < final_feedrate * 0.99);
514
+  }
517
 
515
 
518
   DEBUG_ECHOPGM("Completed with errors");
516
   DEBUG_ECHOPGM("Completed with errors");
519
   if (status_composite) {
517
   if (status_composite) {

+ 6
- 6
Marlin/src/gcode/feature/camera/M240.cpp Visa fil

43
   #endif
43
   #endif
44
 
44
 
45
   #ifdef PHOTO_RETRACT_MM
45
   #ifdef PHOTO_RETRACT_MM
46
-    inline void e_move_m240(const float length, const float fr_mm_s) {
46
+    inline void e_move_m240(const float length, const feedRate_t &fr_mm_s) {
47
       if (length && thermalManager.hotEnoughToExtrude(active_extruder)) {
47
       if (length && thermalManager.hotEnoughToExtrude(active_extruder)) {
48
         #if ENABLED(ADVANCED_PAUSE_FEATURE)
48
         #if ENABLED(ADVANCED_PAUSE_FEATURE)
49
           do_pause_e_move(length, fr_mm_s);
49
           do_pause_e_move(length, fr_mm_s);
104
     };
104
     };
105
 
105
 
106
     #ifdef PHOTO_RETRACT_MM
106
     #ifdef PHOTO_RETRACT_MM
107
-      constexpr float rfr = (MMS_TO_MMM(
107
+      const float rval = parser.seenval('R') ? parser.value_linear_units() : _PHOTO_RETRACT_MM;
108
+      feedRate_t sval = (
108
         #if ENABLED(ADVANCED_PAUSE_FEATURE)
109
         #if ENABLED(ADVANCED_PAUSE_FEATURE)
109
           PAUSE_PARK_RETRACT_FEEDRATE
110
           PAUSE_PARK_RETRACT_FEEDRATE
110
         #elif ENABLED(FWRETRACT)
111
         #elif ENABLED(FWRETRACT)
112
         #else
113
         #else
113
           45
114
           45
114
         #endif
115
         #endif
115
-      ));
116
-      const float rval = parser.seenval('R') ? parser.value_linear_units() : _PHOTO_RETRACT_MM,
117
-                  sval = parser.seenval('S') ? MMM_TO_MMS(parser.value_feedrate()) : rfr;
116
+      );
117
+      if (parser.seenval('S')) sval = parser.value_feedrate();
118
       e_move_m240(-rval, sval);
118
       e_move_m240(-rval, sval);
119
     #endif
119
     #endif
120
 
120
 
121
-    float fr_mm_s = MMM_TO_MMS(parser.linearval('F'));
121
+    feedRate_t fr_mm_s = MMM_TO_MMS(parser.linearval('F'));
122
     if (fr_mm_s) NOLESS(fr_mm_s, 10.0f);
122
     if (fr_mm_s) NOLESS(fr_mm_s, 10.0f);
123
 
123
 
124
     constexpr float photo_position[XYZ] = PHOTO_POSITION;
124
     constexpr float photo_position[XYZ] = PHOTO_POSITION;

+ 4
- 4
Marlin/src/gcode/feature/pause/M701_M702.cpp Visa fil

97
 
97
 
98
   // Lift Z axis
98
   // Lift Z axis
99
   if (park_point.z > 0)
99
   if (park_point.z > 0)
100
-    do_blocking_move_to_z(_MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
100
+    do_blocking_move_to_z(_MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
101
 
101
 
102
   // Load filament
102
   // Load filament
103
   #if ENABLED(PRUSA_MMU2)
103
   #if ENABLED(PRUSA_MMU2)
116
 
116
 
117
   // Restore Z axis
117
   // Restore Z axis
118
   if (park_point.z > 0)
118
   if (park_point.z > 0)
119
-    do_blocking_move_to_z(_MAX(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
119
+    do_blocking_move_to_z(_MAX(current_position[Z_AXIS] - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
120
 
120
 
121
   #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
121
   #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
122
     // Restore toolhead if it was changed
122
     // Restore toolhead if it was changed
196
 
196
 
197
   // Lift Z axis
197
   // Lift Z axis
198
   if (park_point.z > 0)
198
   if (park_point.z > 0)
199
-    do_blocking_move_to_z(_MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
199
+    do_blocking_move_to_z(_MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
200
 
200
 
201
   // Unload filament
201
   // Unload filament
202
   #if ENABLED(PRUSA_MMU2)
202
   #if ENABLED(PRUSA_MMU2)
226
 
226
 
227
   // Restore Z axis
227
   // Restore Z axis
228
   if (park_point.z > 0)
228
   if (park_point.z > 0)
229
-    do_blocking_move_to_z(_MAX(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
229
+    do_blocking_move_to_z(_MAX(current_position[Z_AXIS] - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
230
 
230
 
231
   #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
231
   #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
232
     // Restore toolhead if it was changed
232
     // Restore toolhead if it was changed

+ 1
- 1
Marlin/src/gcode/gcode.cpp Visa fil

129
   #endif
129
   #endif
130
 
130
 
131
   if (parser.linearval('F') > 0)
131
   if (parser.linearval('F') > 0)
132
-    feedrate_mm_s = MMM_TO_MMS(parser.value_feedrate());
132
+    feedrate_mm_s = parser.value_feedrate();
133
 
133
 
134
   #if ENABLED(PRINTCOUNTER)
134
   #if ENABLED(PRINTCOUNTER)
135
     if (!DEBUGGING(DRYRUN))
135
     if (!DEBUGGING(DRYRUN))

+ 1
- 1
Marlin/src/gcode/gcode.h Visa fil

370
 
370
 
371
   static void G0_G1(
371
   static void G0_G1(
372
     #if IS_SCARA || defined(G0_FEEDRATE)
372
     #if IS_SCARA || defined(G0_FEEDRATE)
373
-      bool fast_move=false
373
+      const bool fast_move=false
374
     #endif
374
     #endif
375
   );
375
   );
376
 
376
 

+ 10
- 10
Marlin/src/gcode/motion/G0_G1.cpp Visa fil

38
 extern float destination[XYZE];
38
 extern float destination[XYZE];
39
 
39
 
40
 #if ENABLED(VARIABLE_G0_FEEDRATE)
40
 #if ENABLED(VARIABLE_G0_FEEDRATE)
41
-  float saved_g0_feedrate_mm_s = MMM_TO_MMS(G0_FEEDRATE);
41
+  feedRate_t fast_move_feedrate = MMM_TO_MMS(G0_FEEDRATE);
42
 #endif
42
 #endif
43
 
43
 
44
 /**
44
 /**
46
  */
46
  */
47
 void GcodeSuite::G0_G1(
47
 void GcodeSuite::G0_G1(
48
   #if IS_SCARA || defined(G0_FEEDRATE)
48
   #if IS_SCARA || defined(G0_FEEDRATE)
49
-    bool fast_move/*=false*/
49
+    const bool fast_move/*=false*/
50
   #endif
50
   #endif
51
 ) {
51
 ) {
52
 
52
 
60
   ) {
60
   ) {
61
 
61
 
62
     #ifdef G0_FEEDRATE
62
     #ifdef G0_FEEDRATE
63
-      float saved_feedrate_mm_s;
63
+      feedRate_t old_feedrate;
64
       #if ENABLED(VARIABLE_G0_FEEDRATE)
64
       #if ENABLED(VARIABLE_G0_FEEDRATE)
65
         if (fast_move) {
65
         if (fast_move) {
66
-          saved_feedrate_mm_s = feedrate_mm_s;      // Back up the (old) motion mode feedrate
67
-          feedrate_mm_s = saved_g0_feedrate_mm_s;   // Get G0 feedrate from last usage
66
+          old_feedrate = feedrate_mm_s;             // Back up the (old) motion mode feedrate
67
+          feedrate_mm_s = fast_move_feedrate;       // Get G0 feedrate from last usage
68
         }
68
         }
69
       #endif
69
       #endif
70
     #endif
70
     #endif
71
 
71
 
72
-    get_destination_from_command(); // For X Y Z E F
72
+    get_destination_from_command();                 // Process X Y Z E F parameters
73
 
73
 
74
     #ifdef G0_FEEDRATE
74
     #ifdef G0_FEEDRATE
75
       if (fast_move) {
75
       if (fast_move) {
76
         #if ENABLED(VARIABLE_G0_FEEDRATE)
76
         #if ENABLED(VARIABLE_G0_FEEDRATE)
77
-          saved_g0_feedrate_mm_s = feedrate_mm_s;   // Save feedrate for the next G0
77
+          fast_move_feedrate = feedrate_mm_s;       // Save feedrate for the next G0
78
         #else
78
         #else
79
-          saved_feedrate_mm_s = feedrate_mm_s;      // Back up the (new) motion mode feedrate
79
+          old_feedrate = feedrate_mm_s;             // Back up the (new) motion mode feedrate
80
           feedrate_mm_s = MMM_TO_MMS(G0_FEEDRATE);  // Get the fixed G0 feedrate
80
           feedrate_mm_s = MMM_TO_MMS(G0_FEEDRATE);  // Get the fixed G0 feedrate
81
         #endif
81
         #endif
82
       }
82
       }
100
     #endif // FWRETRACT
100
     #endif // FWRETRACT
101
 
101
 
102
     #if IS_SCARA
102
     #if IS_SCARA
103
-      fast_move ? prepare_uninterpolated_move_to_destination() : prepare_move_to_destination();
103
+      fast_move ? prepare_fast_move_to_destination() : prepare_move_to_destination();
104
     #else
104
     #else
105
       prepare_move_to_destination();
105
       prepare_move_to_destination();
106
     #endif
106
     #endif
107
 
107
 
108
     #ifdef G0_FEEDRATE
108
     #ifdef G0_FEEDRATE
109
       // Restore the motion mode feedrate
109
       // Restore the motion mode feedrate
110
-      if (fast_move) feedrate_mm_s = saved_feedrate_mm_s;
110
+      if (fast_move) feedrate_mm_s = old_feedrate;
111
     #endif
111
     #endif
112
 
112
 
113
     #if ENABLED(NANODLP_Z_SYNC)
113
     #if ENABLED(NANODLP_Z_SYNC)

+ 4
- 4
Marlin/src/gcode/motion/G2_G3.cpp Visa fil

146
   // Initialize the extruder axis
146
   // Initialize the extruder axis
147
   raw[E_AXIS] = current_position[E_AXIS];
147
   raw[E_AXIS] = current_position[E_AXIS];
148
 
148
 
149
-  const float fr_mm_s = MMS_SCALED(feedrate_mm_s);
149
+  const feedRate_t scaled_fr_mm_s = MMS_SCALED(feedrate_mm_s);
150
 
150
 
151
   #if ENABLED(SCARA_FEEDRATE_SCALING)
151
   #if ENABLED(SCARA_FEEDRATE_SCALING)
152
-    const float inv_duration = fr_mm_s / MM_PER_ARC_SEGMENT;
152
+    const float inv_duration = scaled_fr_mm_s / MM_PER_ARC_SEGMENT;
153
   #endif
153
   #endif
154
 
154
 
155
   millis_t next_idle_ms = millis() + 200UL;
155
   millis_t next_idle_ms = millis() + 200UL;
206
       planner.apply_leveling(raw);
206
       planner.apply_leveling(raw);
207
     #endif
207
     #endif
208
 
208
 
209
-    if (!planner.buffer_line(raw, fr_mm_s, active_extruder, MM_PER_ARC_SEGMENT
209
+    if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, MM_PER_ARC_SEGMENT
210
       #if ENABLED(SCARA_FEEDRATE_SCALING)
210
       #if ENABLED(SCARA_FEEDRATE_SCALING)
211
         , inv_duration
211
         , inv_duration
212
       #endif
212
       #endif
226
     planner.apply_leveling(raw);
226
     planner.apply_leveling(raw);
227
   #endif
227
   #endif
228
 
228
 
229
-  planner.buffer_line(raw, fr_mm_s, active_extruder, MM_PER_ARC_SEGMENT
229
+  planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, MM_PER_ARC_SEGMENT
230
     #if ENABLED(SCARA_FEEDRATE_SCALING)
230
     #if ENABLED(SCARA_FEEDRATE_SCALING)
231
       , inv_duration
231
       , inv_duration
232
     #endif
232
     #endif

+ 1
- 1
Marlin/src/gcode/parser.h Visa fil

364
 
364
 
365
   #endif // !TEMPERATURE_UNITS_SUPPORT
365
   #endif // !TEMPERATURE_UNITS_SUPPORT
366
 
366
 
367
-  static inline float value_feedrate() { return value_linear_units(); }
367
+  static inline feedRate_t value_feedrate() { return MMM_TO_MMS(value_linear_units()); }
368
 
368
 
369
   void unknown_command_error();
369
   void unknown_command_error();
370
 
370
 

+ 2
- 2
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_status_screen.cpp Visa fil

289
 
289
 
290
 bool StatusScreen::onTouchHeld(uint8_t tag) {
290
 bool StatusScreen::onTouchHeld(uint8_t tag) {
291
   if (tag >= 1 && tag <= 4 && !jog_xy) return false;
291
   if (tag >= 1 && tag <= 4 && !jog_xy) return false;
292
-  const float s  = min_speed  + (fine_motion ? 0 : (max_speed  - min_speed)  * sq(increment));
292
+  const float s = min_speed + (fine_motion ? 0 : (max_speed - min_speed) * sq(increment));
293
   switch (tag) {
293
   switch (tag) {
294
     case 1: jog(-s,  0,  0); break;
294
     case 1: jog(-s,  0,  0); break;
295
     case 2: jog( s,  0,  0); break;
295
     case 2: jog( s,  0,  0); break;
301
     case 8:
301
     case 8:
302
     {
302
     {
303
       if (ExtUI::isMoving()) return false;
303
       if (ExtUI::isMoving()) return false;
304
-      const float feedrate  =  emin_speed + (fine_motion ? 0 : (emax_speed - emin_speed) * sq(increment));
304
+      const feedRate_t feedrate = emin_speed + (fine_motion ? 0 : (emax_speed - emin_speed) * sq(increment));
305
       const float increment = 0.25 * feedrate * (tag == 7 ? -1 : 1);
305
       const float increment = 0.25 * feedrate * (tag == 7 ? -1 : 1);
306
       MoveAxisScreen::setManualFeedrate(E0, feedrate);
306
       MoveAxisScreen::setManualFeedrate(E0, feedrate);
307
       UI_INCREMENT(AxisPosition_mm, E0);
307
       UI_INCREMENT(AxisPosition_mm, E0);

+ 16
- 22
Marlin/src/lcd/extensible_ui/ui_api.cpp Visa fil

338
     return pos;
338
     return pos;
339
   }
339
   }
340
 
340
 
341
+  constexpr feedRate_t manual_feedrate_mm_m[XYZE] = MANUAL_FEEDRATE;
342
+
341
   void setAxisPosition_mm(const float position, const axis_t axis) {
343
   void setAxisPosition_mm(const float position, const axis_t axis) {
342
     // Start with no limits to movement
344
     // Start with no limits to movement
343
     float min = current_position[axis] - 1000,
345
     float min = current_position[axis] - 1000,
382
       }
384
       }
383
     #endif
385
     #endif
384
 
386
 
385
-    constexpr float manual_feedrate[XYZE] = MANUAL_FEEDRATE;
386
-    setFeedrate_mm_s(MMM_TO_MMS(manual_feedrate[axis]));
387
-
388
-    set_destination_from_current();
389
-    destination[axis] = constrain(position, min, max);
390
-    prepare_move_to_destination();
387
+    current_position[axis] = constrain(position, min, max);
388
+    line_to_current_position(MMM_TO_MMS(manual_feedrate_mm_m[axis]));
391
   }
389
   }
392
 
390
 
393
   void setAxisPosition_mm(const float position, const extruder_t extruder) {
391
   void setAxisPosition_mm(const float position, const extruder_t extruder) {
394
     setActiveTool(extruder, true);
392
     setActiveTool(extruder, true);
395
 
393
 
396
-    constexpr float manual_feedrate[XYZE] = MANUAL_FEEDRATE;
397
-    setFeedrate_mm_s(MMM_TO_MMS(manual_feedrate[E_AXIS]));
398
-
399
-    set_destination_from_current();
400
-    destination[E_AXIS] = position;
401
-    prepare_move_to_destination();
394
+    current_position[E_AXIS] = position;
395
+    line_to_current_position(MMM_TO_MMS(manual_feedrate_mm_m[E_AXIS]));
402
   }
396
   }
403
 
397
 
404
   void setActiveTool(const extruder_t extruder, bool no_move) {
398
   void setActiveTool(const extruder_t extruder, bool no_move) {
581
     planner.settings.axis_steps_per_mm[E_AXIS_N(axis - E0)] = value;
575
     planner.settings.axis_steps_per_mm[E_AXIS_N(axis - E0)] = value;
582
   }
576
   }
583
 
577
 
584
-  float getAxisMaxFeedrate_mm_s(const axis_t axis) {
578
+  feedRate_t getAxisMaxFeedrate_mm_s(const axis_t axis) {
585
     return planner.settings.max_feedrate_mm_s[axis];
579
     return planner.settings.max_feedrate_mm_s[axis];
586
   }
580
   }
587
 
581
 
588
-  float getAxisMaxFeedrate_mm_s(const extruder_t extruder) {
582
+  feedRate_t getAxisMaxFeedrate_mm_s(const extruder_t extruder) {
589
     UNUSED_E(extruder);
583
     UNUSED_E(extruder);
590
     return planner.settings.max_feedrate_mm_s[E_AXIS_N(axis - E0)];
584
     return planner.settings.max_feedrate_mm_s[E_AXIS_N(axis - E0)];
591
   }
585
   }
592
 
586
 
593
-  void setAxisMaxFeedrate_mm_s(const float value, const axis_t axis) {
587
+  void setAxisMaxFeedrate_mm_s(const feedRate_t value, const axis_t axis) {
594
     planner.settings.max_feedrate_mm_s[axis] = value;
588
     planner.settings.max_feedrate_mm_s[axis] = value;
595
   }
589
   }
596
 
590
 
597
-  void setAxisMaxFeedrate_mm_s(const float value, const extruder_t extruder) {
591
+  void setAxisMaxFeedrate_mm_s(const feedRate_t value, const extruder_t extruder) {
598
     UNUSED_E(extruder);
592
     UNUSED_E(extruder);
599
     planner.settings.max_feedrate_mm_s[E_AXIS_N(axis - E0)] = value;
593
     planner.settings.max_feedrate_mm_s[E_AXIS_N(axis - E0)] = value;
600
   }
594
   }
670
     }
664
     }
671
   #endif
665
   #endif
672
 
666
 
673
-  float getFeedrate_mm_s()                            { return feedrate_mm_s; }
674
-  float getMinFeedrate_mm_s()                         { return planner.settings.min_feedrate_mm_s; }
675
-  float getMinTravelFeedrate_mm_s()                   { return planner.settings.min_travel_feedrate_mm_s; }
667
+  feedRate_t getFeedrate_mm_s()                       { return feedrate_mm_s; }
668
+  feedRate_t getMinFeedrate_mm_s()                    { return planner.settings.min_feedrate_mm_s; }
669
+  feedRate_t getMinTravelFeedrate_mm_s()              { return planner.settings.min_travel_feedrate_mm_s; }
676
   float getPrintingAcceleration_mm_s2()               { return planner.settings.acceleration; }
670
   float getPrintingAcceleration_mm_s2()               { return planner.settings.acceleration; }
677
   float getRetractAcceleration_mm_s2()                { return planner.settings.retract_acceleration; }
671
   float getRetractAcceleration_mm_s2()                { return planner.settings.retract_acceleration; }
678
   float getTravelAcceleration_mm_s2()                 { return planner.settings.travel_acceleration; }
672
   float getTravelAcceleration_mm_s2()                 { return planner.settings.travel_acceleration; }
679
-  void setFeedrate_mm_s(const float fr)               { feedrate_mm_s = fr; }
680
-  void setMinFeedrate_mm_s(const float fr)            { planner.settings.min_feedrate_mm_s = fr; }
681
-  void setMinTravelFeedrate_mm_s(const float fr)      { planner.settings.min_travel_feedrate_mm_s = fr; }
673
+  void setFeedrate_mm_s(const feedRate_t fr)          { feedrate_mm_s = fr; }
674
+  void setMinFeedrate_mm_s(const feedRate_t fr)       { planner.settings.min_feedrate_mm_s = fr; }
675
+  void setMinTravelFeedrate_mm_s(const feedRate_t fr) { planner.settings.min_travel_feedrate_mm_s = fr; }
682
   void setPrintingAcceleration_mm_s2(const float acc) { planner.settings.acceleration = acc; }
676
   void setPrintingAcceleration_mm_s2(const float acc) { planner.settings.acceleration = acc; }
683
   void setRetractAcceleration_mm_s2(const float acc)  { planner.settings.retract_acceleration = acc; }
677
   void setRetractAcceleration_mm_s2(const float acc)  { planner.settings.retract_acceleration = acc; }
684
   void setTravelAcceleration_mm_s2(const float acc)   { planner.settings.travel_acceleration = acc; }
678
   void setTravelAcceleration_mm_s2(const float acc)   { planner.settings.travel_acceleration = acc; }

+ 9
- 9
Marlin/src/lcd/extensible_ui/ui_api.h Visa fil

116
   float getAxisPosition_mm(const extruder_t);
116
   float getAxisPosition_mm(const extruder_t);
117
   float getAxisSteps_per_mm(const axis_t);
117
   float getAxisSteps_per_mm(const axis_t);
118
   float getAxisSteps_per_mm(const extruder_t);
118
   float getAxisSteps_per_mm(const extruder_t);
119
-  float getAxisMaxFeedrate_mm_s(const axis_t);
120
-  float getAxisMaxFeedrate_mm_s(const extruder_t);
119
+  feedRate_t getAxisMaxFeedrate_mm_s(const axis_t);
120
+  feedRate_t getAxisMaxFeedrate_mm_s(const extruder_t);
121
   float getAxisMaxAcceleration_mm_s2(const axis_t);
121
   float getAxisMaxAcceleration_mm_s2(const axis_t);
122
   float getAxisMaxAcceleration_mm_s2(const extruder_t);
122
   float getAxisMaxAcceleration_mm_s2(const extruder_t);
123
-  float getMinFeedrate_mm_s();
124
-  float getMinTravelFeedrate_mm_s();
123
+  feedRate_t getMinFeedrate_mm_s();
124
+  feedRate_t getMinTravelFeedrate_mm_s();
125
   float getPrintingAcceleration_mm_s2();
125
   float getPrintingAcceleration_mm_s2();
126
   float getRetractAcceleration_mm_s2();
126
   float getRetractAcceleration_mm_s2();
127
   float getTravelAcceleration_mm_s2();
127
   float getTravelAcceleration_mm_s2();
160
   void setAxisPosition_mm(const float, const extruder_t);
160
   void setAxisPosition_mm(const float, const extruder_t);
161
   void setAxisSteps_per_mm(const float, const axis_t);
161
   void setAxisSteps_per_mm(const float, const axis_t);
162
   void setAxisSteps_per_mm(const float, const extruder_t);
162
   void setAxisSteps_per_mm(const float, const extruder_t);
163
-  void setAxisMaxFeedrate_mm_s(const float, const axis_t);
164
-  void setAxisMaxFeedrate_mm_s(const float, const extruder_t);
163
+  void setAxisMaxFeedrate_mm_s(const feedRate_t, const axis_t);
164
+  void setAxisMaxFeedrate_mm_s(const feedRate_t, const extruder_t);
165
   void setAxisMaxAcceleration_mm_s2(const float, const axis_t);
165
   void setAxisMaxAcceleration_mm_s2(const float, const axis_t);
166
   void setAxisMaxAcceleration_mm_s2(const float, const extruder_t);
166
   void setAxisMaxAcceleration_mm_s2(const float, const extruder_t);
167
-  void setFeedrate_mm_s(const float);
168
-  void setMinFeedrate_mm_s(const float);
169
-  void setMinTravelFeedrate_mm_s(const float);
167
+  void setFeedrate_mm_s(const feedRate_t);
168
+  void setMinFeedrate_mm_s(const feedRate_t);
169
+  void setMinTravelFeedrate_mm_s(const feedRate_t);
170
   void setPrintingAcceleration_mm_s2(const float);
170
   void setPrintingAcceleration_mm_s2(const float);
171
   void setRetractAcceleration_mm_s2(const float);
171
   void setRetractAcceleration_mm_s2(const float);
172
   void setTravelAcceleration_mm_s2(const float);
172
   void setTravelAcceleration_mm_s2(const float);

+ 4
- 4
Marlin/src/lcd/menu/menu_ubl.cpp Visa fil

430
  * UBL LCD Map Movement
430
  * UBL LCD Map Movement
431
  */
431
  */
432
 void ubl_map_move_to_xy() {
432
 void ubl_map_move_to_xy() {
433
-  REMEMBER(fr, feedrate_mm_s, MMM_TO_MMS(XY_PROBE_SPEED));
433
+  const feedRate_t fr_mm_s = MMM_TO_MMS(XY_PROBE_SPEED);
434
 
434
 
435
-  set_destination_from_current();          // sync destination at the start
435
+  set_destination_from_current(); // sync destination at the start
436
 
436
 
437
   #if ENABLED(DELTA)
437
   #if ENABLED(DELTA)
438
     if (current_position[Z_AXIS] > delta_clip_start_height) {
438
     if (current_position[Z_AXIS] > delta_clip_start_height) {
439
       destination[Z_AXIS] = delta_clip_start_height;
439
       destination[Z_AXIS] = delta_clip_start_height;
440
-      prepare_move_to_destination();
440
+      prepare_internal_move_to_destination(fr_mm_s);
441
     }
441
     }
442
   #endif
442
   #endif
443
 
443
 
444
   destination[X_AXIS] = pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]);
444
   destination[X_AXIS] = pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]);
445
   destination[Y_AXIS] = pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]);
445
   destination[Y_AXIS] = pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]);
446
 
446
 
447
-  prepare_move_to_destination();
447
+  prepare_internal_move_to_destination(fr_mm_s);
448
 }
448
 }
449
 
449
 
450
 /**
450
 /**

+ 3
- 6
Marlin/src/lcd/ultralcd.cpp Visa fil

662
 
662
 
663
     if (manual_move_axis != (int8_t)NO_AXIS && ELAPSED(millis(), manual_move_start_time) && !planner.is_full()) {
663
     if (manual_move_axis != (int8_t)NO_AXIS && ELAPSED(millis(), manual_move_start_time) && !planner.is_full()) {
664
 
664
 
665
+      const feedRate_t fr_mm_s = MMM_TO_MMS(manual_feedrate_mm_m[manual_move_axis]);
665
       #if IS_KINEMATIC
666
       #if IS_KINEMATIC
666
 
667
 
667
-        const float old_feedrate = feedrate_mm_s;
668
-        feedrate_mm_s = MMM_TO_MMS(manual_feedrate_mm_m[manual_move_axis]);
669
-
670
         #if EXTRUDERS > 1
668
         #if EXTRUDERS > 1
671
           const int8_t old_extruder = active_extruder;
669
           const int8_t old_extruder = active_extruder;
672
           if (manual_move_axis == E_AXIS) active_extruder = manual_move_e_index;
670
           if (manual_move_axis == E_AXIS) active_extruder = manual_move_e_index;
685
         // previous invocation is being blocked. Modifications to manual_move_offset shouldn't be made while
683
         // previous invocation is being blocked. Modifications to manual_move_offset shouldn't be made while
686
         // processing_manual_move is true or the planner will get out of sync.
684
         // processing_manual_move is true or the planner will get out of sync.
687
         processing_manual_move = true;
685
         processing_manual_move = true;
688
-        prepare_move_to_destination(); // will set current_position from destination
686
+        prepare_internal_move_to_destination(fr_mm_s);  // will set current_position from destination
689
         processing_manual_move = false;
687
         processing_manual_move = false;
690
 
688
 
691
-        feedrate_mm_s = old_feedrate;
692
         #if EXTRUDERS > 1
689
         #if EXTRUDERS > 1
693
           active_extruder = old_extruder;
690
           active_extruder = old_extruder;
694
         #endif
691
         #endif
695
 
692
 
696
       #else
693
       #else
697
 
694
 
698
-        planner.buffer_line(current_position, MMM_TO_MMS(manual_feedrate_mm_m[manual_move_axis]), manual_move_axis == E_AXIS ? manual_move_e_index : active_extruder);
695
+        planner.buffer_line(current_position, fr_mm_s, manual_move_axis == E_AXIS ? manual_move_e_index : active_extruder);
699
         manual_move_axis = (int8_t)NO_AXIS;
696
         manual_move_axis = (int8_t)NO_AXIS;
700
 
697
 
701
       #endif
698
       #endif

+ 1
- 1
Marlin/src/lcd/ultralcd.h Visa fil

90
     typedef void (*menuAction_t)();
90
     typedef void (*menuAction_t)();
91
 
91
 
92
     // Manual Movement
92
     // Manual Movement
93
-    constexpr float manual_feedrate_mm_m[XYZE] = MANUAL_FEEDRATE;
93
+    constexpr feedRate_t manual_feedrate_mm_m[XYZE] = MANUAL_FEEDRATE;
94
     extern float move_menu_scale;
94
     extern float move_menu_scale;
95
 
95
 
96
     #if ENABLED(ADVANCED_PAUSE_FEATURE)
96
     #if ENABLED(ADVANCED_PAUSE_FEATURE)

+ 1
- 1
Marlin/src/libs/nozzle.cpp Visa fil

186
 #if ENABLED(NOZZLE_PARK_FEATURE)
186
 #if ENABLED(NOZZLE_PARK_FEATURE)
187
 
187
 
188
   void Nozzle::park(const uint8_t z_action, const point_t &park/*=NOZZLE_PARK_POINT*/) {
188
   void Nozzle::park(const uint8_t z_action, const point_t &park/*=NOZZLE_PARK_POINT*/) {
189
-    constexpr float fr_xy = NOZZLE_PARK_XY_FEEDRATE, fr_z = NOZZLE_PARK_Z_FEEDRATE;
189
+    constexpr feedRate_t fr_xy = NOZZLE_PARK_XY_FEEDRATE, fr_z = NOZZLE_PARK_Z_FEEDRATE;
190
 
190
 
191
     switch (z_action) {
191
     switch (z_action) {
192
       case 1: // Go to Z-park height
192
       case 1: // Go to Z-park height

+ 18
- 17
Marlin/src/module/configuration_store.cpp Visa fil

124
 // Limit an index to an array size
124
 // Limit an index to an array size
125
 #define ALIM(I,ARR) _MIN(I, COUNT(ARR) - 1)
125
 #define ALIM(I,ARR) _MIN(I, COUNT(ARR) - 1)
126
 
126
 
127
+// Defaults for reset / fill in on load
128
+static const uint32_t   _DMA[] PROGMEM = DEFAULT_MAX_ACCELERATION;
129
+static const float     _DASU[] PROGMEM = DEFAULT_AXIS_STEPS_PER_UNIT;
130
+static const feedRate_t _DMF[] PROGMEM = DEFAULT_MAX_FEEDRATE;
131
+
127
 /**
132
 /**
128
  * Current EEPROM Layout
133
  * Current EEPROM Layout
129
  *
134
  *
1289
       {
1294
       {
1290
         // Get only the number of E stepper parameters previously stored
1295
         // Get only the number of E stepper parameters previously stored
1291
         // Any steppers added later are set to their defaults
1296
         // Any steppers added later are set to their defaults
1292
-        const uint32_t def1[] = DEFAULT_MAX_ACCELERATION;
1293
-        const float def2[] = DEFAULT_AXIS_STEPS_PER_UNIT, def3[] = DEFAULT_MAX_FEEDRATE;
1294
-
1295
         uint32_t tmp1[XYZ + esteppers];
1297
         uint32_t tmp1[XYZ + esteppers];
1298
+        float tmp2[XYZ + esteppers];
1299
+        feedRate_t tmp3[XYZ + esteppers];
1296
         EEPROM_READ(tmp1);                         // max_acceleration_mm_per_s2
1300
         EEPROM_READ(tmp1);                         // max_acceleration_mm_per_s2
1297
         EEPROM_READ(planner.settings.min_segment_time_us);
1301
         EEPROM_READ(planner.settings.min_segment_time_us);
1298
-
1299
-        float tmp2[XYZ + esteppers], tmp3[XYZ + esteppers];
1300
         EEPROM_READ(tmp2);                         // axis_steps_per_mm
1302
         EEPROM_READ(tmp2);                         // axis_steps_per_mm
1301
         EEPROM_READ(tmp3);                         // max_feedrate_mm_s
1303
         EEPROM_READ(tmp3);                         // max_feedrate_mm_s
1304
+
1302
         if (!validating) LOOP_XYZE_N(i) {
1305
         if (!validating) LOOP_XYZE_N(i) {
1303
           const bool in = (i < esteppers + XYZ);
1306
           const bool in = (i < esteppers + XYZ);
1304
-          planner.settings.max_acceleration_mm_per_s2[i] = in ? tmp1[i] : def1[ALIM(i, def1)];
1305
-          planner.settings.axis_steps_per_mm[i]          = in ? tmp2[i] : def2[ALIM(i, def2)];
1306
-          planner.settings.max_feedrate_mm_s[i]          = in ? tmp3[i] : def3[ALIM(i, def3)];
1307
+          planner.settings.max_acceleration_mm_per_s2[i] = in ? tmp1[i] : pgm_read_dword(&_DMA[ALIM(i, _DMA)]);
1308
+          planner.settings.axis_steps_per_mm[i]          = in ? tmp2[i] : pgm_read_float(&_DASU[ALIM(i, _DASU)]);
1309
+          planner.settings.max_feedrate_mm_s[i]          = in ? tmp3[i] : pgm_read_float(&_DMF[ALIM(i, _DMF)]);
1307
         }
1310
         }
1308
 
1311
 
1309
         EEPROM_READ(planner.settings.acceleration);
1312
         EEPROM_READ(planner.settings.acceleration);
2205
  * M502 - Reset Configuration
2208
  * M502 - Reset Configuration
2206
  */
2209
  */
2207
 void MarlinSettings::reset() {
2210
 void MarlinSettings::reset() {
2208
-  static const float tmp1[] PROGMEM = DEFAULT_AXIS_STEPS_PER_UNIT, tmp2[] PROGMEM = DEFAULT_MAX_FEEDRATE;
2209
-  static const uint32_t tmp3[] PROGMEM = DEFAULT_MAX_ACCELERATION;
2210
   LOOP_XYZE_N(i) {
2211
   LOOP_XYZE_N(i) {
2211
-    planner.settings.axis_steps_per_mm[i]          = pgm_read_float(&tmp1[ALIM(i, tmp1)]);
2212
-    planner.settings.max_feedrate_mm_s[i]          = pgm_read_float(&tmp2[ALIM(i, tmp2)]);
2213
-    planner.settings.max_acceleration_mm_per_s2[i] = pgm_read_dword(&tmp3[ALIM(i, tmp3)]);
2212
+    planner.settings.max_acceleration_mm_per_s2[i] = pgm_read_dword(&_DMA[ALIM(i, _DMA)]);
2213
+    planner.settings.axis_steps_per_mm[i]          = pgm_read_float(&_DASU[ALIM(i, _DASU)]);
2214
+    planner.settings.max_feedrate_mm_s[i]          = pgm_read_float(&_DMF[ALIM(i, _DMF)]);
2214
   }
2215
   }
2215
 
2216
 
2216
   planner.settings.min_segment_time_us = DEFAULT_MINSEGMENTTIME;
2217
   planner.settings.min_segment_time_us = DEFAULT_MINSEGMENTTIME;
2217
   planner.settings.acceleration = DEFAULT_ACCELERATION;
2218
   planner.settings.acceleration = DEFAULT_ACCELERATION;
2218
   planner.settings.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
2219
   planner.settings.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
2219
   planner.settings.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
2220
   planner.settings.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
2220
-  planner.settings.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE;
2221
-  planner.settings.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
2221
+  planner.settings.min_feedrate_mm_s = feedRate_t(DEFAULT_MINIMUMFEEDRATE);
2222
+  planner.settings.min_travel_feedrate_mm_s = feedRate_t(DEFAULT_MINTRAVELFEEDRATE);
2222
 
2223
 
2223
   #if HAS_CLASSIC_JERK
2224
   #if HAS_CLASSIC_JERK
2224
     #ifndef DEFAULT_XJERK
2225
     #ifndef DEFAULT_XJERK
3039
       SERIAL_ECHOLNPAIR(
3040
       SERIAL_ECHOLNPAIR(
3040
           "  M207 S", LINEAR_UNIT(fwretract.settings.retract_length)
3041
           "  M207 S", LINEAR_UNIT(fwretract.settings.retract_length)
3041
         , " W", LINEAR_UNIT(fwretract.settings.swap_retract_length)
3042
         , " W", LINEAR_UNIT(fwretract.settings.swap_retract_length)
3042
-        , " F", MMS_TO_MMM(LINEAR_UNIT(fwretract.settings.retract_feedrate_mm_s))
3043
+        , " F", LINEAR_UNIT(MMS_TO_MMM(fwretract.settings.retract_feedrate_mm_s))
3043
         , " Z", LINEAR_UNIT(fwretract.settings.retract_zraise)
3044
         , " Z", LINEAR_UNIT(fwretract.settings.retract_zraise)
3044
       );
3045
       );
3045
 
3046
 
3048
       SERIAL_ECHOLNPAIR(
3049
       SERIAL_ECHOLNPAIR(
3049
           "  M208 S", LINEAR_UNIT(fwretract.settings.retract_recover_extra)
3050
           "  M208 S", LINEAR_UNIT(fwretract.settings.retract_recover_extra)
3050
         , " W", LINEAR_UNIT(fwretract.settings.swap_retract_recover_extra)
3051
         , " W", LINEAR_UNIT(fwretract.settings.swap_retract_recover_extra)
3051
-        , " F", MMS_TO_MMM(LINEAR_UNIT(fwretract.settings.retract_recover_feedrate_mm_s))
3052
+        , " F", LINEAR_UNIT(MMS_TO_MMM(fwretract.settings.retract_recover_feedrate_mm_s))
3052
       );
3053
       );
3053
 
3054
 
3054
       #if ENABLED(FWRETRACT_AUTORETRACT)
3055
       #if ENABLED(FWRETRACT_AUTORETRACT)

+ 3
- 3
Marlin/src/module/delta.cpp Visa fil

231
   #endif
231
   #endif
232
 
232
 
233
   // Move all carriages together linearly until an endstop is hit.
233
   // Move all carriages together linearly until an endstop is hit.
234
-  destination[Z_AXIS] = (delta_height
234
+  current_position[Z_AXIS] = (delta_height + 10
235
     #if HAS_BED_PROBE
235
     #if HAS_BED_PROBE
236
       - probe_offset[Z_AXIS]
236
       - probe_offset[Z_AXIS]
237
     #endif
237
     #endif
238
-    + 10);
239
-  buffer_line_to_destination(homing_feedrate(X_AXIS));
238
+  );
239
+  line_to_current_position(homing_feedrate(X_AXIS));
240
   planner.synchronize();
240
   planner.synchronize();
241
 
241
 
242
   // Re-enable stealthChop if used. Disable diag1 pin on driver.
242
   // Re-enable stealthChop if used. Disable diag1 pin on driver.

+ 89
- 69
Marlin/src/module/motion.cpp Visa fil

134
 // no other feedrate is specified. Overridden for special moves.
134
 // no other feedrate is specified. Overridden for special moves.
135
 // Set by the last G0 through G5 command's "F" parameter.
135
 // Set by the last G0 through G5 command's "F" parameter.
136
 // Functions that override this for custom moves *must always* restore it!
136
 // Functions that override this for custom moves *must always* restore it!
137
-float feedrate_mm_s = MMM_TO_MMS(1500.0f);
138
-
137
+feedRate_t feedrate_mm_s = MMM_TO_MMS(1500);
139
 int16_t feedrate_percentage = 100;
138
 int16_t feedrate_percentage = 100;
140
 
139
 
141
 // Homing feedrate is const progmem - compare to constexpr in the header
140
 // Homing feedrate is const progmem - compare to constexpr in the header
142
-const float homing_feedrate_mm_s[XYZ] PROGMEM = {
141
+const feedRate_t homing_feedrate_mm_s[XYZ] PROGMEM = {
143
   #if ENABLED(DELTA)
142
   #if ENABLED(DELTA)
144
     MMM_TO_MMS(HOMING_FEEDRATE_Z), MMM_TO_MMS(HOMING_FEEDRATE_Z),
143
     MMM_TO_MMS(HOMING_FEEDRATE_Z), MMM_TO_MMS(HOMING_FEEDRATE_Z),
145
   #else
144
   #else
285
  * Move the planner to the current position from wherever it last moved
284
  * Move the planner to the current position from wherever it last moved
286
  * (or from wherever it has been told it is located).
285
  * (or from wherever it has been told it is located).
287
  */
286
  */
288
-void line_to_current_position(const float &fr_mm_s/*=feedrate_mm_s*/) {
289
-  planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], fr_mm_s, active_extruder);
290
-}
291
-
292
-/**
293
- * Move the planner to the position stored in the destination array, which is
294
- * used by G0/G1/G2/G3/G5 and many other functions to set a destination.
295
- */
296
-void buffer_line_to_destination(const float fr_mm_s) {
297
-  planner.buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], fr_mm_s, active_extruder);
287
+void line_to_current_position(const feedRate_t &fr_mm_s/*=feedrate_mm_s*/) {
288
+  planner.buffer_line(current_position, fr_mm_s, active_extruder);
298
 }
289
 }
299
 
290
 
300
 #if IS_KINEMATIC
291
 #if IS_KINEMATIC
301
 
292
 
302
   /**
293
   /**
303
-   * Calculate delta, start a line, and set current_position to destination
294
+   * Buffer a fast move without interpolation. Set current_position to destination
304
    */
295
    */
305
-  void prepare_uninterpolated_move_to_destination(const float &fr_mm_s/*=0.0*/) {
306
-    if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_uninterpolated_move_to_destination", destination);
296
+  void prepare_fast_move_to_destination(const feedRate_t &scaled_fr_mm_s/*=MMS_SCALED(feedrate_mm_s)*/) {
297
+    if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_fast_move_to_destination", destination);
307
 
298
 
308
     #if UBL_SEGMENTED
299
     #if UBL_SEGMENTED
309
-      // ubl segmented line will do z-only moves in single segment
310
-      ubl.prepare_segmented_line_to(destination, MMS_SCALED(fr_mm_s ? fr_mm_s : feedrate_mm_s));
300
+      // UBL segmented line will do Z-only moves in single segment
301
+      ubl.line_to_destination_segmented(scaled_fr_mm_s);
311
     #else
302
     #else
312
       if ( current_position[X_AXIS] == destination[X_AXIS]
303
       if ( current_position[X_AXIS] == destination[X_AXIS]
313
         && current_position[Y_AXIS] == destination[Y_AXIS]
304
         && current_position[Y_AXIS] == destination[Y_AXIS]
315
         && current_position[E_AXIS] == destination[E_AXIS]
306
         && current_position[E_AXIS] == destination[E_AXIS]
316
       ) return;
307
       ) return;
317
 
308
 
318
-      planner.buffer_line(destination, MMS_SCALED(fr_mm_s ? fr_mm_s : feedrate_mm_s), active_extruder);
309
+      planner.buffer_line(destination, scaled_fr_mm_s, active_extruder);
319
     #endif
310
     #endif
320
 
311
 
321
     set_current_from_destination();
312
     set_current_from_destination();
323
 
314
 
324
 #endif // IS_KINEMATIC
315
 #endif // IS_KINEMATIC
325
 
316
 
317
+void _internal_move_to_destination(const feedRate_t &fr_mm_s/*=0.0f*/
318
+  #if IS_KINEMATIC
319
+    , const bool is_fast/*=false*/
320
+  #endif
321
+) {
322
+  const feedRate_t old_feedrate = feedrate_mm_s;
323
+  if (fr_mm_s) feedrate_mm_s = fr_mm_s;
324
+
325
+  const uint16_t old_pct = feedrate_percentage;
326
+  feedrate_percentage = 100;
327
+
328
+  const float old_fac = planner.e_factor[active_extruder];
329
+  planner.e_factor[active_extruder] = 1.0f;
330
+
331
+  #if IS_KINEMATIC
332
+    if (is_fast)
333
+      prepare_fast_move_to_destination();
334
+    else
335
+  #endif
336
+      prepare_move_to_destination();
337
+
338
+  feedrate_mm_s = old_feedrate;
339
+  feedrate_percentage = old_pct;
340
+  planner.e_factor[active_extruder] = old_fac;
341
+}
342
+
326
 /**
343
 /**
327
  * Plan a move to (X, Y, Z) and set the current_position
344
  * Plan a move to (X, Y, Z) and set the current_position
328
  */
345
  */
329
-void do_blocking_move_to(const float rx, const float ry, const float rz, const float &fr_mm_s/*=0.0*/) {
346
+void do_blocking_move_to(const float rx, const float ry, const float rz, const feedRate_t &fr_mm_s/*=0.0*/) {
330
   if (DEBUGGING(LEVELING)) DEBUG_XYZ(">>> do_blocking_move_to", rx, ry, rz);
347
   if (DEBUGGING(LEVELING)) DEBUG_XYZ(">>> do_blocking_move_to", rx, ry, rz);
331
 
348
 
332
-  const float z_feedrate  = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS),
333
-              xy_feedrate = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
349
+  const feedRate_t z_feedrate = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS),
350
+                  xy_feedrate = fr_mm_s ? fr_mm_s : feedRate_t(XY_PROBE_FEEDRATE_MM_S);
334
 
351
 
335
   #if ENABLED(DELTA)
352
   #if ENABLED(DELTA)
336
 
353
 
344
 
361
 
345
     // when in the danger zone
362
     // when in the danger zone
346
     if (current_position[Z_AXIS] > delta_clip_start_height) {
363
     if (current_position[Z_AXIS] > delta_clip_start_height) {
347
-      if (rz > delta_clip_start_height) {   // staying in the danger zone
348
-        destination[X_AXIS] = rx;           // move directly (uninterpolated)
364
+      if (rz > delta_clip_start_height) {                     // staying in the danger zone
365
+        destination[X_AXIS] = rx;                             // move directly (uninterpolated)
349
         destination[Y_AXIS] = ry;
366
         destination[Y_AXIS] = ry;
350
         destination[Z_AXIS] = rz;
367
         destination[Z_AXIS] = rz;
351
-        prepare_uninterpolated_move_to_destination(); // set_current_from_destination()
368
+        prepare_internal_fast_move_to_destination();          // set_current_from_destination()
352
         if (DEBUGGING(LEVELING)) DEBUG_POS("danger zone move", current_position);
369
         if (DEBUGGING(LEVELING)) DEBUG_POS("danger zone move", current_position);
353
         return;
370
         return;
354
       }
371
       }
355
       destination[Z_AXIS] = delta_clip_start_height;
372
       destination[Z_AXIS] = delta_clip_start_height;
356
-      prepare_uninterpolated_move_to_destination(); // set_current_from_destination()
373
+      prepare_internal_fast_move_to_destination();            // set_current_from_destination()
357
       if (DEBUGGING(LEVELING)) DEBUG_POS("zone border move", current_position);
374
       if (DEBUGGING(LEVELING)) DEBUG_POS("zone border move", current_position);
358
     }
375
     }
359
 
376
 
360
-    if (rz > current_position[Z_AXIS]) {    // raising?
377
+    if (rz > current_position[Z_AXIS]) {                      // raising?
361
       destination[Z_AXIS] = rz;
378
       destination[Z_AXIS] = rz;
362
-      prepare_uninterpolated_move_to_destination(z_feedrate);   // set_current_from_destination()
379
+      prepare_internal_fast_move_to_destination(z_feedrate);  // set_current_from_destination()
363
       if (DEBUGGING(LEVELING)) DEBUG_POS("z raise move", current_position);
380
       if (DEBUGGING(LEVELING)) DEBUG_POS("z raise move", current_position);
364
     }
381
     }
365
 
382
 
366
     destination[X_AXIS] = rx;
383
     destination[X_AXIS] = rx;
367
     destination[Y_AXIS] = ry;
384
     destination[Y_AXIS] = ry;
368
-    prepare_move_to_destination();         // set_current_from_destination()
385
+    prepare_internal_move_to_destination();                   // set_current_from_destination()
369
     if (DEBUGGING(LEVELING)) DEBUG_POS("xy move", current_position);
386
     if (DEBUGGING(LEVELING)) DEBUG_POS("xy move", current_position);
370
 
387
 
371
-    if (rz < current_position[Z_AXIS]) {    // lowering?
388
+    if (rz < current_position[Z_AXIS]) {                      // lowering?
372
       destination[Z_AXIS] = rz;
389
       destination[Z_AXIS] = rz;
373
-      prepare_uninterpolated_move_to_destination(z_feedrate);   // set_current_from_destination()
390
+      prepare_fast_move_to_destination(z_feedrate);           // set_current_from_destination()
374
       if (DEBUGGING(LEVELING)) DEBUG_POS("z lower move", current_position);
391
       if (DEBUGGING(LEVELING)) DEBUG_POS("z lower move", current_position);
375
     }
392
     }
376
 
393
 
383
     // If Z needs to raise, do it before moving XY
400
     // If Z needs to raise, do it before moving XY
384
     if (destination[Z_AXIS] < rz) {
401
     if (destination[Z_AXIS] < rz) {
385
       destination[Z_AXIS] = rz;
402
       destination[Z_AXIS] = rz;
386
-      prepare_uninterpolated_move_to_destination(z_feedrate);
403
+      prepare_internal_fast_move_to_destination(z_feedrate);
387
     }
404
     }
388
 
405
 
389
     destination[X_AXIS] = rx;
406
     destination[X_AXIS] = rx;
390
     destination[Y_AXIS] = ry;
407
     destination[Y_AXIS] = ry;
391
-    prepare_uninterpolated_move_to_destination(xy_feedrate);
408
+    prepare_internal_fast_move_to_destination(xy_feedrate);
392
 
409
 
393
     // If Z needs to lower, do it after moving XY
410
     // If Z needs to lower, do it after moving XY
394
     if (destination[Z_AXIS] > rz) {
411
     if (destination[Z_AXIS] > rz) {
395
       destination[Z_AXIS] = rz;
412
       destination[Z_AXIS] = rz;
396
-      prepare_uninterpolated_move_to_destination(z_feedrate);
413
+      prepare_internal_fast_move_to_destination(z_feedrate);
397
     }
414
     }
398
 
415
 
399
   #else
416
   #else
420
 
437
 
421
   planner.synchronize();
438
   planner.synchronize();
422
 }
439
 }
423
-void do_blocking_move_to_x(const float &rx, const float &fr_mm_s/*=0.0*/) {
440
+void do_blocking_move_to_x(const float &rx, const feedRate_t &fr_mm_s/*=0.0*/) {
424
   do_blocking_move_to(rx, current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_s);
441
   do_blocking_move_to(rx, current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_s);
425
 }
442
 }
426
-void do_blocking_move_to_y(const float &ry, const float &fr_mm_s/*=0.0*/) {
443
+void do_blocking_move_to_y(const float &ry, const feedRate_t &fr_mm_s/*=0.0*/) {
427
   do_blocking_move_to(current_position[X_AXIS], ry, current_position[Z_AXIS], fr_mm_s);
444
   do_blocking_move_to(current_position[X_AXIS], ry, current_position[Z_AXIS], fr_mm_s);
428
 }
445
 }
429
-void do_blocking_move_to_z(const float &rz, const float &fr_mm_s/*=0.0*/) {
446
+void do_blocking_move_to_z(const float &rz, const feedRate_t &fr_mm_s/*=0.0*/) {
430
   do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], rz, fr_mm_s);
447
   do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], rz, fr_mm_s);
431
 }
448
 }
432
-void do_blocking_move_to_xy(const float &rx, const float &ry, const float &fr_mm_s/*=0.0*/) {
449
+void do_blocking_move_to_xy(const float &rx, const float &ry, const feedRate_t &fr_mm_s/*=0.0*/) {
433
   do_blocking_move_to(rx, ry, current_position[Z_AXIS], fr_mm_s);
450
   do_blocking_move_to(rx, ry, current_position[Z_AXIS], fr_mm_s);
434
 }
451
 }
435
 
452
 
629
    * small incremental moves for DELTA or SCARA.
646
    * small incremental moves for DELTA or SCARA.
630
    *
647
    *
631
    * For Unified Bed Leveling (Delta or Segmented Cartesian)
648
    * For Unified Bed Leveling (Delta or Segmented Cartesian)
632
-   * the ubl.prepare_segmented_line_to method replaces this.
649
+   * the ubl.line_to_destination_segmented method replaces this.
633
    *
650
    *
634
    * For Auto Bed Leveling (Bilinear) with SEGMENT_LEVELED_MOVES
651
    * For Auto Bed Leveling (Bilinear) with SEGMENT_LEVELED_MOVES
635
    * this is replaced by segmented_line_to_destination below.
652
    * this is replaced by segmented_line_to_destination below.
636
    */
653
    */
637
-  inline bool prepare_kinematic_move_to(const float (&rtarget)[XYZE]) {
654
+  inline bool line_to_destination_kinematic() {
638
 
655
 
639
     // Get the top feedrate of the move in the XY plane
656
     // Get the top feedrate of the move in the XY plane
640
-    const float _feedrate_mm_s = MMS_SCALED(feedrate_mm_s);
657
+    const float scaled_fr_mm_s = MMS_SCALED(feedrate_mm_s);
641
 
658
 
642
-    const float xdiff = rtarget[X_AXIS] - current_position[X_AXIS],
643
-                ydiff = rtarget[Y_AXIS] - current_position[Y_AXIS];
659
+    const float xdiff = destination[X_AXIS] - current_position[X_AXIS],
660
+                ydiff = destination[Y_AXIS] - current_position[Y_AXIS];
644
 
661
 
645
     // If the move is only in Z/E don't split up the move
662
     // If the move is only in Z/E don't split up the move
646
     if (!xdiff && !ydiff) {
663
     if (!xdiff && !ydiff) {
647
-      planner.buffer_line(rtarget, _feedrate_mm_s, active_extruder);
664
+      planner.buffer_line(destination, scaled_fr_mm_s, active_extruder);
648
       return false; // caller will update current_position
665
       return false; // caller will update current_position
649
     }
666
     }
650
 
667
 
651
     // Fail if attempting move outside printable radius
668
     // Fail if attempting move outside printable radius
652
-    if (!position_is_reachable(rtarget[X_AXIS], rtarget[Y_AXIS])) return true;
669
+    if (!position_is_reachable(destination[X_AXIS], destination[Y_AXIS])) return true;
653
 
670
 
654
     // Remaining cartesian distances
671
     // Remaining cartesian distances
655
-    const float zdiff = rtarget[Z_AXIS] - current_position[Z_AXIS],
656
-                ediff = rtarget[E_AXIS] - current_position[E_AXIS];
672
+    const float zdiff = destination[Z_AXIS] - current_position[Z_AXIS],
673
+                ediff = destination[E_AXIS] - current_position[E_AXIS];
657
 
674
 
658
     // Get the linear distance in XYZ
675
     // Get the linear distance in XYZ
659
     float cartesian_mm = SQRT(sq(xdiff) + sq(ydiff) + sq(zdiff));
676
     float cartesian_mm = SQRT(sq(xdiff) + sq(ydiff) + sq(zdiff));
665
     if (UNEAR_ZERO(cartesian_mm)) return true;
682
     if (UNEAR_ZERO(cartesian_mm)) return true;
666
 
683
 
667
     // Minimum number of seconds to move the given distance
684
     // Minimum number of seconds to move the given distance
668
-    const float seconds = cartesian_mm / _feedrate_mm_s;
685
+    const float seconds = cartesian_mm / scaled_fr_mm_s;
669
 
686
 
670
     // The number of segments-per-second times the duration
687
     // The number of segments-per-second times the duration
671
     // gives the number of segments
688
     // gives the number of segments
690
                 cartesian_segment_mm = cartesian_mm * inv_segments;
707
                 cartesian_segment_mm = cartesian_mm * inv_segments;
691
 
708
 
692
     #if ENABLED(SCARA_FEEDRATE_SCALING)
709
     #if ENABLED(SCARA_FEEDRATE_SCALING)
693
-      const float inv_duration = _feedrate_mm_s / cartesian_segment_mm;
710
+      const float inv_duration = scaled_fr_mm_s / cartesian_segment_mm;
694
     #endif
711
     #endif
695
 
712
 
696
     /*
713
     /*
717
 
734
 
718
       LOOP_XYZE(i) raw[i] += segment_distance[i];
735
       LOOP_XYZE(i) raw[i] += segment_distance[i];
719
 
736
 
720
-      if (!planner.buffer_line(raw, _feedrate_mm_s, active_extruder, cartesian_segment_mm
737
+      if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, cartesian_segment_mm
721
         #if ENABLED(SCARA_FEEDRATE_SCALING)
738
         #if ENABLED(SCARA_FEEDRATE_SCALING)
722
           , inv_duration
739
           , inv_duration
723
         #endif
740
         #endif
726
     }
743
     }
727
 
744
 
728
     // Ensure last segment arrives at target location.
745
     // Ensure last segment arrives at target location.
729
-    planner.buffer_line(rtarget, _feedrate_mm_s, active_extruder, cartesian_segment_mm
746
+    planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, cartesian_segment_mm
730
       #if ENABLED(SCARA_FEEDRATE_SCALING)
747
       #if ENABLED(SCARA_FEEDRATE_SCALING)
731
         , inv_duration
748
         , inv_duration
732
       #endif
749
       #endif
746
      * small incremental moves. This allows the planner to
763
      * small incremental moves. This allows the planner to
747
      * apply more detailed bed leveling to the full move.
764
      * apply more detailed bed leveling to the full move.
748
      */
765
      */
749
-    inline void segmented_line_to_destination(const float &fr_mm_s, const float segment_size=LEVELED_SEGMENT_LENGTH) {
766
+    inline void segmented_line_to_destination(const feedRate_t &fr_mm_s, const float segment_size=LEVELED_SEGMENT_LENGTH) {
750
 
767
 
751
       const float xdiff = destination[X_AXIS] - current_position[X_AXIS],
768
       const float xdiff = destination[X_AXIS] - current_position[X_AXIS],
752
                   ydiff = destination[Y_AXIS] - current_position[Y_AXIS];
769
                   ydiff = destination[Y_AXIS] - current_position[Y_AXIS];
784
                   };
801
                   };
785
 
802
 
786
       #if ENABLED(SCARA_FEEDRATE_SCALING)
803
       #if ENABLED(SCARA_FEEDRATE_SCALING)
787
-        const float inv_duration = _feedrate_mm_s / cartesian_segment_mm;
804
+        const float inv_duration = scaled_fr_mm_s / cartesian_segment_mm;
788
       #endif
805
       #endif
789
 
806
 
790
       // SERIAL_ECHOPAIR("mm=", cartesian_mm);
807
       // SERIAL_ECHOPAIR("mm=", cartesian_mm);
832
    * Returns true if current_position[] was set to destination[]
849
    * Returns true if current_position[] was set to destination[]
833
    */
850
    */
834
   inline bool prepare_move_to_destination_cartesian() {
851
   inline bool prepare_move_to_destination_cartesian() {
852
+    const float scaled_fr_mm_s = MMS_SCALED(feedrate_mm_s);
835
     #if HAS_MESH
853
     #if HAS_MESH
836
       if (planner.leveling_active && planner.leveling_active_at_z(destination[Z_AXIS])) {
854
       if (planner.leveling_active && planner.leveling_active_at_z(destination[Z_AXIS])) {
837
         #if ENABLED(AUTO_BED_LEVELING_UBL)
855
         #if ENABLED(AUTO_BED_LEVELING_UBL)
838
-          ubl.line_to_destination_cartesian(MMS_SCALED(feedrate_mm_s), active_extruder);  // UBL's motion routine needs to know about
839
-          return true;                                                                    // all moves, including Z-only moves.
856
+          ubl.line_to_destination_cartesian(scaled_fr_mm_s, active_extruder); // UBL's motion routine needs to know about
857
+          return true;                                                        // all moves, including Z-only moves.
840
         #elif ENABLED(SEGMENT_LEVELED_MOVES)
858
         #elif ENABLED(SEGMENT_LEVELED_MOVES)
841
-          segmented_line_to_destination(MMS_SCALED(feedrate_mm_s));
859
+          segmented_line_to_destination(scaled_fr_mm_s);
842
           return false; // caller will update current_position
860
           return false; // caller will update current_position
843
         #else
861
         #else
844
           /**
862
           /**
847
            */
865
            */
848
           if (current_position[X_AXIS] != destination[X_AXIS] || current_position[Y_AXIS] != destination[Y_AXIS]) {
866
           if (current_position[X_AXIS] != destination[X_AXIS] || current_position[Y_AXIS] != destination[Y_AXIS]) {
849
             #if ENABLED(MESH_BED_LEVELING)
867
             #if ENABLED(MESH_BED_LEVELING)
850
-              mbl.line_to_destination(MMS_SCALED(feedrate_mm_s));
868
+              mbl.line_to_destination(scaled_fr_mm_s);
851
             #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
869
             #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
852
-              bilinear_line_to_destination(MMS_SCALED(feedrate_mm_s));
870
+              bilinear_line_to_destination(scaled_fr_mm_s);
853
             #endif
871
             #endif
854
             return true;
872
             return true;
855
           }
873
           }
857
       }
875
       }
858
     #endif // HAS_MESH
876
     #endif // HAS_MESH
859
 
877
 
860
-    buffer_line_to_destination(MMS_SCALED(feedrate_mm_s));
878
+    planner.buffer_line(destination, scaled_fr_mm_s, active_extruder);
861
     return false; // caller will update current_position
879
     return false; // caller will update current_position
862
   }
880
   }
863
 
881
 
971
  *
989
  *
972
  * Make sure current_position[E] and destination[E] are good
990
  * Make sure current_position[E] and destination[E] are good
973
  * before calling or cold/lengthy extrusion may get missed.
991
  * before calling or cold/lengthy extrusion may get missed.
992
+ *
993
+ * Before exit, current_position is set to destination.
974
  */
994
  */
975
 void prepare_move_to_destination() {
995
 void prepare_move_to_destination() {
976
   apply_motion_limits(destination);
996
   apply_motion_limits(destination);
1014
 
1034
 
1015
   if (
1035
   if (
1016
     #if UBL_SEGMENTED
1036
     #if UBL_SEGMENTED
1017
-      //ubl.prepare_segmented_line_to(destination, MMS_SCALED(feedrate_mm_s))   // This doesn't seem to work correctly on UBL.
1018
-      #if IS_KINEMATIC                                                          // Use Kinematic / Cartesian cases as a workaround for now.
1019
-        ubl.prepare_segmented_line_to(destination, MMS_SCALED(feedrate_mm_s))
1037
+      #if IS_KINEMATIC // UBL using Kinematic / Cartesian cases as a workaround for now.
1038
+        ubl.line_to_destination_segmented(MMS_SCALED(feedrate_mm_s))
1020
       #else
1039
       #else
1021
         prepare_move_to_destination_cartesian()
1040
         prepare_move_to_destination_cartesian()
1022
       #endif
1041
       #endif
1023
     #elif IS_KINEMATIC
1042
     #elif IS_KINEMATIC
1024
-      prepare_kinematic_move_to(destination)
1043
+      line_to_destination_kinematic()
1025
     #else
1044
     #else
1026
       prepare_move_to_destination_cartesian()
1045
       prepare_move_to_destination_cartesian()
1027
     #endif
1046
     #endif
1065
 /**
1084
 /**
1066
  * Homing bump feedrate (mm/s)
1085
  * Homing bump feedrate (mm/s)
1067
  */
1086
  */
1068
-float get_homing_bump_feedrate(const AxisEnum axis) {
1087
+feedRate_t get_homing_bump_feedrate(const AxisEnum axis) {
1069
   #if HOMING_Z_WITH_PROBE
1088
   #if HOMING_Z_WITH_PROBE
1070
     if (axis == Z_AXIS) return MMM_TO_MMS(Z_PROBE_SPEED_SLOW);
1089
     if (axis == Z_AXIS) return MMM_TO_MMS(Z_PROBE_SPEED_SLOW);
1071
   #endif
1090
   #endif
1075
     hbd = 10;
1094
     hbd = 10;
1076
     SERIAL_ECHO_MSG("Warning: Homing Bump Divisor < 1");
1095
     SERIAL_ECHO_MSG("Warning: Homing Bump Divisor < 1");
1077
   }
1096
   }
1078
-  return homing_feedrate(axis) / hbd;
1097
+  return homing_feedrate(axis) / float(hbd);
1079
 }
1098
 }
1080
 
1099
 
1081
 #if ENABLED(SENSORLESS_HOMING)
1100
 #if ENABLED(SENSORLESS_HOMING)
1221
 /**
1240
 /**
1222
  * Home an individual linear axis
1241
  * Home an individual linear axis
1223
  */
1242
  */
1224
-void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm_s=0.0) {
1243
+void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t fr_mm_s=0.0) {
1225
 
1244
 
1226
   if (DEBUGGING(LEVELING)) {
1245
   if (DEBUGGING(LEVELING)) {
1227
     DEBUG_ECHOPAIR(">>> do_homing_move(", axis_codes[axis], ", ", distance, ", ");
1246
     DEBUG_ECHOPAIR(">>> do_homing_move(", axis_codes[axis], ", ", distance, ", ");
1266
     #endif
1285
     #endif
1267
   }
1286
   }
1268
 
1287
 
1288
+  const feedRate_t real_fr_mm_s = fr_mm_s ? fr_mm_s : homing_feedrate(axis);
1269
   #if IS_SCARA
1289
   #if IS_SCARA
1270
     // Tell the planner the axis is at 0
1290
     // Tell the planner the axis is at 0
1271
     current_position[axis] = 0;
1291
     current_position[axis] = 0;
1272
     sync_plan_position();
1292
     sync_plan_position();
1273
     current_position[axis] = distance;
1293
     current_position[axis] = distance;
1274
-    planner.buffer_line(current_position, fr_mm_s ? fr_mm_s : homing_feedrate(axis), active_extruder);
1294
+    line_to_current_position(real_fr_mm_s);
1275
   #else
1295
   #else
1276
     float target[ABCE] = { planner.get_axis_position_mm(A_AXIS), planner.get_axis_position_mm(B_AXIS), planner.get_axis_position_mm(C_AXIS), planner.get_axis_position_mm(E_AXIS) };
1296
     float target[ABCE] = { planner.get_axis_position_mm(A_AXIS), planner.get_axis_position_mm(B_AXIS), planner.get_axis_position_mm(C_AXIS), planner.get_axis_position_mm(E_AXIS) };
1277
     target[axis] = 0;
1297
     target[axis] = 0;
1287
       #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
1307
       #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
1288
         , delta_mm_cart
1308
         , delta_mm_cart
1289
       #endif
1309
       #endif
1290
-      , fr_mm_s ? fr_mm_s : homing_feedrate(axis), active_extruder
1310
+      , real_fr_mm_s, active_extruder
1291
     );
1311
     );
1292
   #endif
1312
   #endif
1293
 
1313
 
1507
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Move Away:");
1527
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Move Away:");
1508
     do_homing_move(axis, -bump
1528
     do_homing_move(axis, -bump
1509
       #if HOMING_Z_WITH_PROBE
1529
       #if HOMING_Z_WITH_PROBE
1510
-        , axis == Z_AXIS ? MMM_TO_MMS(Z_PROBE_SPEED_FAST) : 0.0
1530
+        , MMM_TO_MMS(axis == Z_AXIS ? Z_PROBE_SPEED_FAST : 0)
1511
       #endif
1531
       #endif
1512
     );
1532
     );
1513
 
1533
 

+ 29
- 22
Marlin/src/module/motion.h Visa fil

85
  * Feed rates are often configured with mm/m
85
  * Feed rates are often configured with mm/m
86
  * but the planner and stepper like mm/s units.
86
  * but the planner and stepper like mm/s units.
87
  */
87
  */
88
-extern const float homing_feedrate_mm_s[XYZ];
89
-FORCE_INLINE float homing_feedrate(const AxisEnum a) { return pgm_read_float(&homing_feedrate_mm_s[a]); }
90
-float get_homing_bump_feedrate(const AxisEnum axis);
88
+extern const feedRate_t homing_feedrate_mm_s[XYZ];
89
+FORCE_INLINE feedRate_t homing_feedrate(const AxisEnum a) { return pgm_read_float(&homing_feedrate_mm_s[a]); }
90
+feedRate_t get_homing_bump_feedrate(const AxisEnum axis);
91
 
91
 
92
-extern float feedrate_mm_s;
92
+extern feedRate_t feedrate_mm_s;
93
 
93
 
94
 /**
94
 /**
95
- * Feedrate scaling and conversion
95
+ * Feedrate scaling
96
  */
96
  */
97
 extern int16_t feedrate_percentage;
97
 extern int16_t feedrate_percentage;
98
-#define MMS_SCALED(MM_S) ((MM_S)*feedrate_percentage*0.01f)
99
 
98
 
100
 // The active extruder (tool). Set with T<extruder> command.
99
 // The active extruder (tool). Set with T<extruder> command.
101
 #if EXTRUDERS > 1
100
 #if EXTRUDERS > 1
172
  * Move the planner to the current position from wherever it last moved
171
  * Move the planner to the current position from wherever it last moved
173
  * (or from wherever it has been told it is located).
172
  * (or from wherever it has been told it is located).
174
  */
173
  */
175
-void line_to_current_position(const float &fr_mm_s=feedrate_mm_s);
174
+void line_to_current_position(const feedRate_t &fr_mm_s=feedrate_mm_s);
176
 
175
 
177
-/**
178
- * Move the planner to the position stored in the destination array, which is
179
- * used by G0/G1/G2/G3/G5 and many other functions to set a destination.
180
- */
181
-void buffer_line_to_destination(const float fr_mm_s);
176
+void prepare_move_to_destination();
177
+
178
+void _internal_move_to_destination(const feedRate_t &fr_mm_s=0.0f
179
+  #if IS_KINEMATIC
180
+    , const bool is_fast=false
181
+  #endif
182
+);
183
+
184
+inline void prepare_internal_move_to_destination(const feedRate_t &fr_mm_s=0.0f) {
185
+  _internal_move_to_destination(fr_mm_s);
186
+}
182
 
187
 
183
 #if IS_KINEMATIC
188
 #if IS_KINEMATIC
184
-  void prepare_uninterpolated_move_to_destination(const float &fr_mm_s=0);
185
-#endif
189
+  void prepare_fast_move_to_destination(const feedRate_t &scaled_fr_mm_s=MMS_SCALED(feedrate_mm_s));
186
 
190
 
187
-void prepare_move_to_destination();
191
+  inline void prepare_internal_fast_move_to_destination(const feedRate_t &fr_mm_s=0.0f) {
192
+    _internal_move_to_destination(fr_mm_s, true);
193
+  }
194
+#endif
188
 
195
 
189
 /**
196
 /**
190
  * Blocking movement and shorthand functions
197
  * Blocking movement and shorthand functions
191
  */
198
  */
192
-void do_blocking_move_to(const float rx, const float ry, const float rz, const float &fr_mm_s=0);
193
-void do_blocking_move_to_x(const float &rx, const float &fr_mm_s=0);
194
-void do_blocking_move_to_y(const float &ry, const float &fr_mm_s=0);
195
-void do_blocking_move_to_z(const float &rz, const float &fr_mm_s=0);
196
-void do_blocking_move_to_xy(const float &rx, const float &ry, const float &fr_mm_s=0);
199
+void do_blocking_move_to(const float rx, const float ry, const float rz, const feedRate_t &fr_mm_s=0.0f);
200
+void do_blocking_move_to_x(const float &rx, const feedRate_t &fr_mm_s=0.0f);
201
+void do_blocking_move_to_y(const float &ry, const feedRate_t &fr_mm_s=0.0f);
202
+void do_blocking_move_to_z(const float &rz, const feedRate_t &fr_mm_s=0.0f);
203
+void do_blocking_move_to_xy(const float &rx, const float &ry, const feedRate_t &fr_mm_s=0.0f);
197
 
204
 
198
-FORCE_INLINE void do_blocking_move_to(const float (&raw)[XYZ], const float &fr_mm_s=0) {
205
+FORCE_INLINE void do_blocking_move_to(const float (&raw)[XYZ], const feedRate_t &fr_mm_s=0) {
199
   do_blocking_move_to(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS], fr_mm_s);
206
   do_blocking_move_to(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS], fr_mm_s);
200
 }
207
 }
201
 
208
 
202
-FORCE_INLINE void do_blocking_move_to(const float (&raw)[XYZE], const float &fr_mm_s=0) {
209
+FORCE_INLINE void do_blocking_move_to(const float (&raw)[XYZE], const feedRate_t &fr_mm_s=0) {
203
   do_blocking_move_to(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS], fr_mm_s);
210
   do_blocking_move_to(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS], fr_mm_s);
204
 }
211
 }
205
 
212
 

+ 10
- 11
Marlin/src/module/planner.cpp Visa fil

1570
   #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
1570
   #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
1571
     , const float (&delta_mm_cart)[XYZE]
1571
     , const float (&delta_mm_cart)[XYZE]
1572
   #endif
1572
   #endif
1573
-  , float fr_mm_s, const uint8_t extruder, const float &millimeters
1573
+  , feedRate_t fr_mm_s, const uint8_t extruder, const float &millimeters
1574
 ) {
1574
 ) {
1575
 
1575
 
1576
   // If we are cleaning, do not accept queuing of movements
1576
   // If we are cleaning, do not accept queuing of movements
1634
   #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
1634
   #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
1635
     , const float (&delta_mm_cart)[XYZE]
1635
     , const float (&delta_mm_cart)[XYZE]
1636
   #endif
1636
   #endif
1637
-  , float fr_mm_s, const uint8_t extruder, const float &millimeters/*=0.0*/
1637
+  , feedRate_t fr_mm_s, const uint8_t extruder, const float &millimeters/*=0.0*/
1638
 ) {
1638
 ) {
1639
 
1639
 
1640
   const int32_t da = target[A_AXIS] - position[A_AXIS],
1640
   const int32_t da = target[A_AXIS] - position[A_AXIS],
2091
     #else
2091
     #else
2092
       const float delta_mm_i = delta_mm[i];
2092
       const float delta_mm_i = delta_mm[i];
2093
     #endif
2093
     #endif
2094
-    const float cs = ABS(current_speed[i] = delta_mm_i * inverse_secs);
2094
+    const feedRate_t cs = ABS(current_speed[i] = delta_mm_i * inverse_secs);
2095
     #if ENABLED(DISTINCT_E_FACTORS)
2095
     #if ENABLED(DISTINCT_E_FACTORS)
2096
       if (i == E_AXIS) i += extruder;
2096
       if (i == E_AXIS) i += extruder;
2097
     #endif
2097
     #endif
2569
   #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
2569
   #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
2570
     , const float (&delta_mm_cart)[XYZE]
2570
     , const float (&delta_mm_cart)[XYZE]
2571
   #endif
2571
   #endif
2572
-  , const float &fr_mm_s, const uint8_t extruder, const float &millimeters/*=0.0*/
2572
+  , const feedRate_t &fr_mm_s, const uint8_t extruder, const float &millimeters/*=0.0*/
2573
 ) {
2573
 ) {
2574
 
2574
 
2575
   // If we are cleaning, do not accept queuing of movements
2575
   // If we are cleaning, do not accept queuing of movements
2651
 
2651
 
2652
 /**
2652
 /**
2653
  * Add a new linear movement to the buffer.
2653
  * Add a new linear movement to the buffer.
2654
- * The target is cartesian, it's translated to delta/scara if
2655
- * needed.
2656
- *
2654
+ * The target is cartesian. It's translated to
2655
+ * delta/scara if needed.
2657
  *
2656
  *
2658
  *  rx,ry,rz,e   - target position in mm or degrees
2657
  *  rx,ry,rz,e   - target position in mm or degrees
2659
  *  fr_mm_s      - (target) speed of the move (mm/s)
2658
  *  fr_mm_s      - (target) speed of the move (mm/s)
2661
  *  millimeters  - the length of the movement, if known
2660
  *  millimeters  - the length of the movement, if known
2662
  *  inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled)
2661
  *  inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled)
2663
  */
2662
  */
2664
-bool Planner::buffer_line(const float &rx, const float &ry, const float &rz, const float &e, const float &fr_mm_s, const uint8_t extruder, const float millimeters
2663
+bool Planner::buffer_line(const float &rx, const float &ry, const float &rz, const float &e, const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters
2665
   #if ENABLED(SCARA_FEEDRATE_SCALING)
2664
   #if ENABLED(SCARA_FEEDRATE_SCALING)
2666
     , const float &inv_duration
2665
     , const float &inv_duration
2667
   #endif
2666
   #endif
2690
     #if ENABLED(SCARA_FEEDRATE_SCALING)
2689
     #if ENABLED(SCARA_FEEDRATE_SCALING)
2691
       // For SCARA scale the feed rate from mm/s to degrees/s
2690
       // For SCARA scale the feed rate from mm/s to degrees/s
2692
       // i.e., Complete the angular vector in the given time.
2691
       // i.e., Complete the angular vector in the given time.
2693
-      const float duration_recip = inv_duration ? inv_duration : fr_mm_s / mm,
2694
-                  feedrate = HYPOT(delta[A_AXIS] - position_float[A_AXIS], delta[B_AXIS] - position_float[B_AXIS]) * duration_recip;
2692
+      const float duration_recip = inv_duration ? inv_duration : fr_mm_s / mm;
2693
+      const feedRate_t feedrate = HYPOT(delta[A_AXIS] - position_float[A_AXIS], delta[B_AXIS] - position_float[B_AXIS]) * duration_recip;
2695
     #else
2694
     #else
2696
-      const float feedrate = fr_mm_s;
2695
+      const feedRate_t feedrate = fr_mm_s;
2697
     #endif
2696
     #endif
2698
     if (buffer_segment(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS]
2697
     if (buffer_segment(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS]
2699
       #if ENABLED(JUNCTION_DEVIATION)
2698
       #if ENABLED(JUNCTION_DEVIATION)

+ 18
- 19
Marlin/src/module/planner.h Visa fil

170
 #define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1))
170
 #define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1))
171
 
171
 
172
 typedef struct {
172
 typedef struct {
173
-  uint32_t max_acceleration_mm_per_s2[XYZE_N],  // (mm/s^2) M201 XYZE
174
-           min_segment_time_us;                 // (µs) M205 B
175
-  float axis_steps_per_mm[XYZE_N],              // (steps) M92 XYZE - Steps per millimeter
176
-        max_feedrate_mm_s[XYZE_N],              // (mm/s) M203 XYZE - Max speeds
177
-        acceleration,                           // (mm/s^2) M204 S - Normal acceleration. DEFAULT ACCELERATION for all printing moves.
178
-        retract_acceleration,                   // (mm/s^2) M204 R - Retract acceleration. Filament pull-back and push-forward while standing still in the other axes
179
-        travel_acceleration,                    // (mm/s^2) M204 T - Travel acceleration. DEFAULT ACCELERATION for all NON printing moves.
180
-        min_feedrate_mm_s,                      // (mm/s) M205 S - Minimum linear feedrate
181
-        min_travel_feedrate_mm_s;               // (mm/s) M205 T - Minimum travel feedrate
173
+   uint32_t max_acceleration_mm_per_s2[XYZE_N], // (mm/s^2) M201 XYZE
174
+            min_segment_time_us;                // (µs) M205 B
175
+      float axis_steps_per_mm[XYZE_N];          // (steps) M92 XYZE - Steps per millimeter
176
+ feedRate_t max_feedrate_mm_s[XYZE_N];          // (mm/s) M203 XYZE - Max speeds
177
+      float acceleration,                       // (mm/s^2) M204 S - Normal acceleration. DEFAULT ACCELERATION for all printing moves.
178
+            retract_acceleration,               // (mm/s^2) M204 R - Retract acceleration. Filament pull-back and push-forward while standing still in the other axes
179
+            travel_acceleration;                // (mm/s^2) M204 T - Travel acceleration. DEFAULT ACCELERATION for all NON printing moves.
180
+ feedRate_t min_feedrate_mm_s,                  // (mm/s) M205 S - Minimum linear feedrate
181
+            min_travel_feedrate_mm_s;           // (mm/s) M205 T - Minimum travel feedrate
182
 } planner_settings_t;
182
 } planner_settings_t;
183
 
183
 
184
 #if DISABLED(SKEW_CORRECTION)
184
 #if DISABLED(SKEW_CORRECTION)
585
       #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
585
       #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
586
         , const float (&delta_mm_cart)[XYZE]
586
         , const float (&delta_mm_cart)[XYZE]
587
       #endif
587
       #endif
588
-      , float fr_mm_s, const uint8_t extruder, const float &millimeters=0.0
588
+      , feedRate_t fr_mm_s, const uint8_t extruder, const float &millimeters=0.0
589
     );
589
     );
590
 
590
 
591
     /**
591
     /**
608
       #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
608
       #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
609
         , const float (&delta_mm_cart)[XYZE]
609
         , const float (&delta_mm_cart)[XYZE]
610
       #endif
610
       #endif
611
-      , float fr_mm_s, const uint8_t extruder, const float &millimeters=0.0
611
+      , feedRate_t fr_mm_s, const uint8_t extruder, const float &millimeters=0.0
612
     );
612
     );
613
 
613
 
614
     /**
614
     /**
621
     private:
621
     private:
622
 
622
 
623
       // Allow do_homing_move to access internal functions, such as buffer_segment.
623
       // Allow do_homing_move to access internal functions, such as buffer_segment.
624
-      friend void do_homing_move(const AxisEnum, const float, const float);
624
+      friend void do_homing_move(const AxisEnum, const float, const feedRate_t);
625
   #endif
625
   #endif
626
 
626
 
627
     /**
627
     /**
640
       #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
640
       #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
641
         , const float (&delta_mm_cart)[XYZE]
641
         , const float (&delta_mm_cart)[XYZE]
642
       #endif
642
       #endif
643
-      , const float &fr_mm_s, const uint8_t extruder, const float &millimeters=0.0
643
+      , const feedRate_t &fr_mm_s, const uint8_t extruder, const float &millimeters=0.0
644
     );
644
     );
645
 
645
 
646
     FORCE_INLINE static bool buffer_segment(const float (&abce)[ABCE]
646
     FORCE_INLINE static bool buffer_segment(const float (&abce)[ABCE]
647
       #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
647
       #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
648
         , const float (&delta_mm_cart)[XYZE]
648
         , const float (&delta_mm_cart)[XYZE]
649
       #endif
649
       #endif
650
-      , const float &fr_mm_s, const uint8_t extruder, const float &millimeters=0.0
650
+      , const feedRate_t &fr_mm_s, const uint8_t extruder, const float &millimeters=0.0
651
     ) {
651
     ) {
652
       return buffer_segment(abce[A_AXIS], abce[B_AXIS], abce[C_AXIS], abce[E_AXIS]
652
       return buffer_segment(abce[A_AXIS], abce[B_AXIS], abce[C_AXIS], abce[E_AXIS]
653
         #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
653
         #if IS_KINEMATIC && ENABLED(JUNCTION_DEVIATION)
660
 
660
 
661
     /**
661
     /**
662
      * Add a new linear movement to the buffer.
662
      * Add a new linear movement to the buffer.
663
-     * The target is cartesian, it's translated to delta/scara if
664
-     * needed.
665
-     *
663
+     * The target is cartesian. It's translated to
664
+     * delta/scara if needed.
666
      *
665
      *
667
      *  rx,ry,rz,e   - target position in mm or degrees
666
      *  rx,ry,rz,e   - target position in mm or degrees
668
      *  fr_mm_s      - (target) speed of the move (mm/s)
667
      *  fr_mm_s      - (target) speed of the move (mm/s)
670
      *  millimeters  - the length of the movement, if known
669
      *  millimeters  - the length of the movement, if known
671
      *  inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled)
670
      *  inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled)
672
      */
671
      */
673
-    static bool buffer_line(const float &rx, const float &ry, const float &rz, const float &e, const float &fr_mm_s, const uint8_t extruder, const float millimeters=0.0
672
+    static bool buffer_line(const float &rx, const float &ry, const float &rz, const float &e, const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters=0.0
674
       #if ENABLED(SCARA_FEEDRATE_SCALING)
673
       #if ENABLED(SCARA_FEEDRATE_SCALING)
675
         , const float &inv_duration=0.0
674
         , const float &inv_duration=0.0
676
       #endif
675
       #endif
677
     );
676
     );
678
 
677
 
679
-    FORCE_INLINE static bool buffer_line(const float (&cart)[XYZE], const float &fr_mm_s, const uint8_t extruder, const float millimeters=0.0
678
+    FORCE_INLINE static bool buffer_line(const float (&cart)[XYZE], const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters=0.0
680
       #if ENABLED(SCARA_FEEDRATE_SCALING)
679
       #if ENABLED(SCARA_FEEDRATE_SCALING)
681
         , const float &inv_duration=0.0
680
         , const float &inv_duration=0.0
682
       #endif
681
       #endif

+ 9
- 4
Marlin/src/module/planner_bezier.cpp Visa fil

107
  * the mitigation offered by MIN_STEP and the small computational
107
  * the mitigation offered by MIN_STEP and the small computational
108
  * power available on Arduino, I think it is not wise to implement it.
108
  * power available on Arduino, I think it is not wise to implement it.
109
  */
109
  */
110
-void cubic_b_spline(const float position[NUM_AXIS], const float target[NUM_AXIS], const float offset[4], float fr_mm_s, uint8_t extruder) {
110
+void cubic_b_spline(
111
+  const float position[NUM_AXIS],   // current position
112
+  const float target[NUM_AXIS],     // target position
113
+  const float (&offset)[4],         // a pair of offsets
114
+  const feedRate_t &scaled_fr_mm_s, // mm/s scaled by feedrate %
115
+  const uint8_t extruder
116
+) {
111
   // Absolute first and second control points are recovered.
117
   // Absolute first and second control points are recovered.
112
   const float first0 = position[X_AXIS] + offset[0],
118
   const float first0 = position[X_AXIS] + offset[0],
113
               first1 = position[Y_AXIS] + offset[1],
119
               first1 = position[Y_AXIS] + offset[1],
114
               second0 = target[X_AXIS] + offset[2],
120
               second0 = target[X_AXIS] + offset[2],
115
               second1 = target[Y_AXIS] + offset[3];
121
               second1 = target[Y_AXIS] + offset[3];
116
-  float t = 0;
117
 
122
 
118
   float bez_target[4];
123
   float bez_target[4];
119
   bez_target[X_AXIS] = position[X_AXIS];
124
   bez_target[X_AXIS] = position[X_AXIS];
122
 
127
 
123
   millis_t next_idle_ms = millis() + 200UL;
128
   millis_t next_idle_ms = millis() + 200UL;
124
 
129
 
125
-  while (t < 1) {
130
+  for (float t = 0; t < 1;) {
126
 
131
 
127
     thermalManager.manage_heater();
132
     thermalManager.manage_heater();
128
     millis_t now = millis();
133
     millis_t now = millis();
197
       const float (&pos)[XYZE] = bez_target;
202
       const float (&pos)[XYZE] = bez_target;
198
     #endif
203
     #endif
199
 
204
 
200
-    if (!planner.buffer_line(pos, fr_mm_s, active_extruder, step))
205
+    if (!planner.buffer_line(pos, scaled_fr_mm_s, active_extruder, step))
201
       break;
206
       break;
202
   }
207
   }
203
 }
208
 }

+ 6
- 6
Marlin/src/module/planner_bezier.h Visa fil

32
 #include "../core/macros.h"
32
 #include "../core/macros.h"
33
 
33
 
34
 void cubic_b_spline(
34
 void cubic_b_spline(
35
-              const float position[NUM_AXIS], // current position
36
-              const float target[NUM_AXIS],   // target position
37
-              const float offset[4],          // a pair of offsets
38
-              float fr_mm_s,
39
-              uint8_t extruder
40
-            );
35
+  const float position[NUM_AXIS],   // current position
36
+  const float target[NUM_AXIS],     // target position
37
+  const float (&offset)[4],         // a pair of offsets
38
+  const feedRate_t &scaled_fr_mm_s, // mm/s scaled by feedrate %
39
+  const uint8_t extruder
40
+);

+ 1
- 1
Marlin/src/module/probe.cpp Visa fil

446
   const char msg_wait_for_bed_heating[25] PROGMEM = "Wait for bed heating...\n";
446
   const char msg_wait_for_bed_heating[25] PROGMEM = "Wait for bed heating...\n";
447
 #endif
447
 #endif
448
 
448
 
449
-static bool do_probe_move(const float z, const float fr_mm_s) {
449
+static bool do_probe_move(const float z, const feedRate_t fr_mm_s) {
450
   if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position);
450
   if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position);
451
 
451
 
452
   #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
452
   #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)

+ 6
- 6
Marlin/src/module/tool_change.h Visa fil

71
 #elif ENABLED(MAGNETIC_PARKING_EXTRUDER)
71
 #elif ENABLED(MAGNETIC_PARKING_EXTRUDER)
72
 
72
 
73
   typedef struct MPESettings {
73
   typedef struct MPESettings {
74
-    float parking_xpos[2],      // M951 L R
75
-          grab_distance,        // M951 I
76
-          slow_feedrate,        // M951 J
77
-          fast_feedrate,        // M951 H
78
-          travel_distance,      // M951 D
79
-          compensation_factor;  // M951 C
74
+      float parking_xpos[2],      // M951 L R
75
+            grab_distance;        // M951 I
76
+ feedRate_t slow_feedrate,        // M951 J
77
+            fast_feedrate;        // M951 H
78
+      float travel_distance,      // M951 D
79
+            compensation_factor;  // M951 C
80
   } mpe_settings_t;
80
   } mpe_settings_t;
81
 
81
 
82
   extern mpe_settings_t mpe_settings;
82
   extern mpe_settings_t mpe_settings;

Laddar…
Avbryt
Spara