Pārlūkot izejas kodu

Clean up some motion code

Scott Lahteine 6 gadus atpakaļ
vecāks
revīzija
5d28575d4d

+ 1
- 1
Marlin/src/feature/fwretract.cpp Parādīt failu

142
   set_destination_from_current();
142
   set_destination_from_current();
143
 
143
 
144
   #if ENABLED(RETRACT_SYNC_MIXING)
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
     mixer.T(MIXER_AUTORETRACT_TOOL);
146
     mixer.T(MIXER_AUTORETRACT_TOOL);
147
   #endif
147
   #endif
148
 
148
 

+ 1
- 3
Marlin/src/gcode/calibrate/G28.cpp Parādīt failu

263
   #endif
263
   #endif
264
 
264
 
265
   setup_for_endstop_or_probe_move();
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
   endstops.enable(true); // Enable endstops for next homing move
267
   endstops.enable(true); // Enable endstops for next homing move
270
 
268
 
271
   #if ENABLED(DELTA)
269
   #if ENABLED(DELTA)

+ 22
- 39
Marlin/src/module/motion.cpp Parādīt failu

253
  * Move the planner to the current position from wherever it last moved
253
  * Move the planner to the current position from wherever it last moved
254
  * (or from wherever it has been told it is located).
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
   /**
270
   /**
271
    * Calculate delta, start a line, and set current_position to destination
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
     #if ENABLED(DEBUG_LEVELING_FEATURE)
274
     #if ENABLED(DEBUG_LEVELING_FEATURE)
275
       if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_uninterpolated_move_to_destination", destination);
275
       if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_uninterpolated_move_to_destination", destination);
276
     #endif
276
     #endif
297
  * Plan a move to (X, Y, Z) and set the current_position
297
  * Plan a move to (X, Y, Z) and set the current_position
298
  */
298
  */
299
 void do_blocking_move_to(const float rx, const float ry, const float rz, const float &fr_mm_s/*=0.0*/) {
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
   #if ENABLED(DEBUG_LEVELING_FEATURE)
300
   #if ENABLED(DEBUG_LEVELING_FEATURE)
303
     if (DEBUGGING(LEVELING)) print_xyz(PSTR(">>> do_blocking_move_to"), NULL, rx, ry, rz);
301
     if (DEBUGGING(LEVELING)) print_xyz(PSTR(">>> do_blocking_move_to"), NULL, rx, ry, rz);
304
   #endif
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
   #if ENABLED(DELTA)
307
   #if ENABLED(DELTA)
309
 
308
 
310
     if (!position_is_reachable(rx, ry)) return;
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
     set_destination_from_current();          // sync destination at the start
313
     set_destination_from_current();          // sync destination at the start
315
 
314
 
373
 
372
 
374
     destination[X_AXIS] = rx;
373
     destination[X_AXIS] = rx;
375
     destination[Y_AXIS] = ry;
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
     // If Z needs to lower, do it after moving XY
377
     // If Z needs to lower, do it after moving XY
379
     if (destination[Z_AXIS] > rz) {
378
     if (destination[Z_AXIS] > rz) {
385
 
384
 
386
     // If Z needs to raise, do it before moving XY
385
     // If Z needs to raise, do it before moving XY
387
     if (current_position[Z_AXIS] < rz) {
386
     if (current_position[Z_AXIS] < rz) {
388
-      feedrate_mm_s = z_feedrate;
389
       current_position[Z_AXIS] = rz;
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
     current_position[X_AXIS] = rx;
391
     current_position[X_AXIS] = rx;
395
     current_position[Y_AXIS] = ry;
392
     current_position[Y_AXIS] = ry;
396
-    line_to_current_position();
393
+    line_to_current_position(xy_feedrate);
397
 
394
 
398
     // If Z needs to lower, do it after moving XY
395
     // If Z needs to lower, do it after moving XY
399
     if (current_position[Z_AXIS] > rz) {
396
     if (current_position[Z_AXIS] > rz) {
400
-      feedrate_mm_s = z_feedrate;
401
       current_position[Z_AXIS] = rz;
397
       current_position[Z_AXIS] = rz;
402
-      line_to_current_position();
398
+      line_to_current_position(z_feedrate);
403
     }
399
     }
404
 
400
 
405
   #endif
401
   #endif
406
 
402
 
407
-  feedrate_mm_s = old_feedrate_mm_s;
408
-
409
   #if ENABLED(DEBUG_LEVELING_FEATURE)
403
   #if ENABLED(DEBUG_LEVELING_FEATURE)
410
     if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< do_blocking_move_to");
404
     if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< do_blocking_move_to");
411
   #endif
405
   #endif
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
 #if HAS_SOFTWARE_ENDSTOPS
435
 #if HAS_SOFTWARE_ENDSTOPS
453
 
436
 

+ 2
- 6
Marlin/src/module/motion.h Parādīt failu

149
  * Move the planner to the current position from wherever it last moved
149
  * Move the planner to the current position from wherever it last moved
150
  * (or from wherever it has been told it is located).
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
  * Move the planner to the position stored in the destination array, which is
155
  * Move the planner to the position stored in the destination array, which is
158
 void buffer_line_to_destination(const float fr_mm_s);
158
 void buffer_line_to_destination(const float fr_mm_s);
159
 
159
 
160
 #if IS_KINEMATIC
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
 #endif
162
 #endif
163
 
163
 
164
 void prepare_move_to_destination();
164
 void prepare_move_to_destination();
182
 void setup_for_endstop_or_probe_move();
182
 void setup_for_endstop_or_probe_move();
183
 void clean_up_after_endstop_or_probe_move();
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
 // Homing
186
 // Homing
191
 //
187
 //

Notiek ielāde…
Atcelt
Saglabāt