Browse Source

Clean up some motion code

Scott Lahteine 6 years ago
parent
commit
5d28575d4d

+ 1
- 1
Marlin/src/feature/fwretract.cpp View File

@@ -142,7 +142,7 @@ void FWRetract::retract(const bool retracting
142 142
   set_destination_from_current();
143 143
 
144 144
   #if ENABLED(RETRACT_SYNC_MIXING)
145
-    uint8_t old_mixing_tool = mixer.get_current_vtool();
145
+    const uint8_t old_mixing_tool = mixer.get_current_vtool();
146 146
     mixer.T(MIXER_AUTORETRACT_TOOL);
147 147
   #endif
148 148
 

+ 1
- 3
Marlin/src/gcode/calibrate/G28.cpp View File

@@ -263,9 +263,7 @@ void GcodeSuite::G28(const bool always_home_all) {
263 263
   #endif
264 264
 
265 265
   setup_for_endstop_or_probe_move();
266
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
267
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(true)");
268
-  #endif
266
+
269 267
   endstops.enable(true); // Enable endstops for next homing move
270 268
 
271 269
   #if ENABLED(DELTA)

+ 22
- 39
Marlin/src/module/motion.cpp View File

@@ -253,8 +253,8 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
253 253
  * Move the planner to the current position from wherever it last moved
254 254
  * (or from wherever it has been told it is located).
255 255
  */
256
-void line_to_current_position() {
257
-  planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate_mm_s, active_extruder);
256
+void line_to_current_position(const float &fr_mm_s/*=feedrate_mm_s*/) {
257
+  planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], fr_mm_s, active_extruder);
258 258
 }
259 259
 
260 260
 /**
@@ -270,7 +270,7 @@ void buffer_line_to_destination(const float fr_mm_s) {
270 270
   /**
271 271
    * Calculate delta, start a line, and set current_position to destination
272 272
    */
273
-  void prepare_uninterpolated_move_to_destination(const float fr_mm_s/*=0.0*/) {
273
+  void prepare_uninterpolated_move_to_destination(const float &fr_mm_s/*=0.0*/) {
274 274
     #if ENABLED(DEBUG_LEVELING_FEATURE)
275 275
       if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_uninterpolated_move_to_destination", destination);
276 276
     #endif
@@ -297,19 +297,18 @@ void buffer_line_to_destination(const float fr_mm_s) {
297 297
  * Plan a move to (X, Y, Z) and set the current_position
298 298
  */
299 299
 void do_blocking_move_to(const float rx, const float ry, const float rz, const float &fr_mm_s/*=0.0*/) {
300
-  const float old_feedrate_mm_s = feedrate_mm_s;
301
-
302 300
   #if ENABLED(DEBUG_LEVELING_FEATURE)
303 301
     if (DEBUGGING(LEVELING)) print_xyz(PSTR(">>> do_blocking_move_to"), NULL, rx, ry, rz);
304 302
   #endif
305 303
 
306
-  const float z_feedrate = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
304
+  const float z_feedrate  = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS),
305
+              xy_feedrate = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
307 306
 
308 307
   #if ENABLED(DELTA)
309 308
 
310 309
     if (!position_is_reachable(rx, ry)) return;
311 310
 
312
-    feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
311
+    REMEMBER(fr, feedrate_mm_s, xy_feedrate);
313 312
 
314 313
     set_destination_from_current();          // sync destination at the start
315 314
 
@@ -373,7 +372,7 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f
373 372
 
374 373
     destination[X_AXIS] = rx;
375 374
     destination[Y_AXIS] = ry;
376
-    prepare_uninterpolated_move_to_destination(fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S);
375
+    prepare_uninterpolated_move_to_destination(xy_feedrate);
377 376
 
378 377
     // If Z needs to lower, do it after moving XY
379 378
     if (destination[Z_AXIS] > rz) {
@@ -385,27 +384,22 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f
385 384
 
386 385
     // If Z needs to raise, do it before moving XY
387 386
     if (current_position[Z_AXIS] < rz) {
388
-      feedrate_mm_s = z_feedrate;
389 387
       current_position[Z_AXIS] = rz;
390
-      line_to_current_position();
388
+      line_to_current_position(z_feedrate);
391 389
     }
392 390
 
393
-    feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
394 391
     current_position[X_AXIS] = rx;
395 392
     current_position[Y_AXIS] = ry;
396
-    line_to_current_position();
393
+    line_to_current_position(xy_feedrate);
397 394
 
398 395
     // If Z needs to lower, do it after moving XY
399 396
     if (current_position[Z_AXIS] > rz) {
400
-      feedrate_mm_s = z_feedrate;
401 397
       current_position[Z_AXIS] = rz;
402
-      line_to_current_position();
398
+      line_to_current_position(z_feedrate);
403 399
     }
404 400
 
405 401
   #endif
406 402
 
407
-  feedrate_mm_s = old_feedrate_mm_s;
408
-
409 403
   #if ENABLED(DEBUG_LEVELING_FEATURE)
410 404
     if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< do_blocking_move_to");
411 405
   #endif
@@ -423,31 +417,20 @@ void do_blocking_move_to_xy(const float &rx, const float &ry, const float &fr_mm
423 417
 }
424 418
 
425 419
 //
426
-// Prepare to do endstop or probe moves
427
-// with custom feedrates.
428
-//
429
-//  - Save current feedrates
430
-//  - Reset the rate multiplier
420
+// Prepare to do endstop or probe moves with custom feedrates.
421
+//  - Save / restore current feedrate and multiplier
431 422
 //
432
-void bracket_probe_move(const bool before) {
433
-  static float saved_feedrate_mm_s;
434
-  static int16_t saved_feedrate_percentage;
435
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
436
-    if (DEBUGGING(LEVELING)) DEBUG_POS("bracket_probe_move", current_position);
437
-  #endif
438
-  if (before) {
439
-    saved_feedrate_mm_s = feedrate_mm_s;
440
-    saved_feedrate_percentage = feedrate_percentage;
441
-    feedrate_percentage = 100;
442
-  }
443
-  else {
444
-    feedrate_mm_s = saved_feedrate_mm_s;
445
-    feedrate_percentage = saved_feedrate_percentage;
446
-  }
423
+static float saved_feedrate_mm_s;
424
+static int16_t saved_feedrate_percentage;
425
+void setup_for_endstop_or_probe_move() {
426
+  saved_feedrate_mm_s = feedrate_mm_s;
427
+  saved_feedrate_percentage = feedrate_percentage;
428
+  feedrate_percentage = 100;
429
+}
430
+void clean_up_after_endstop_or_probe_move() {
431
+  feedrate_mm_s = saved_feedrate_mm_s;
432
+  feedrate_percentage = saved_feedrate_percentage;
447 433
 }
448
-
449
-void setup_for_endstop_or_probe_move() { bracket_probe_move(true); }
450
-void clean_up_after_endstop_or_probe_move() { bracket_probe_move(false); }
451 434
 
452 435
 #if HAS_SOFTWARE_ENDSTOPS
453 436
 

+ 2
- 6
Marlin/src/module/motion.h View File

@@ -149,7 +149,7 @@ void sync_plan_position_e();
149 149
  * Move the planner to the current position from wherever it last moved
150 150
  * (or from wherever it has been told it is located).
151 151
  */
152
-void line_to_current_position();
152
+void line_to_current_position(const float &fr_mm_s=feedrate_mm_s);
153 153
 
154 154
 /**
155 155
  * Move the planner to the position stored in the destination array, which is
@@ -158,7 +158,7 @@ void line_to_current_position();
158 158
 void buffer_line_to_destination(const float fr_mm_s);
159 159
 
160 160
 #if IS_KINEMATIC
161
-  void prepare_uninterpolated_move_to_destination(const float fr_mm_s=0);
161
+  void prepare_uninterpolated_move_to_destination(const float &fr_mm_s=0);
162 162
 #endif
163 163
 
164 164
 void prepare_move_to_destination();
@@ -182,10 +182,6 @@ FORCE_INLINE void do_blocking_move_to(const float (&raw)[XYZE], const float &fr_
182 182
 void setup_for_endstop_or_probe_move();
183 183
 void clean_up_after_endstop_or_probe_move();
184 184
 
185
-void bracket_probe_move(const bool before);
186
-void setup_for_endstop_or_probe_move();
187
-void clean_up_after_endstop_or_probe_move();
188
-
189 185
 //
190 186
 // Homing
191 187
 //

Loading…
Cancel
Save