Parcourir la source

Save and restore feedrate in more places

Scott Lahteine il y a 9 ans
Parent
révision
6fdd5ba246
1 fichiers modifiés avec 30 ajouts et 17 suppressions
  1. 30
    17
      Marlin/Marlin_main.cpp

+ 30
- 17
Marlin/Marlin_main.cpp Voir le fichier

@@ -366,6 +366,8 @@ static uint8_t target_extruder;
366 366
   float zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
367 367
 #endif
368 368
 
369
+#define PLANNER_XY_FEEDRATE() (min(planner.max_feedrate[X_AXIS], planner.max_feedrate[Y_AXIS]))
370
+
369 371
 #if ENABLED(AUTO_BED_LEVELING_FEATURE)
370 372
   int xy_probe_speed = XY_PROBE_SPEED;
371 373
   bool bed_leveling_in_progress = false;
@@ -373,7 +375,7 @@ static uint8_t target_extruder;
373 375
 #elif defined(XY_PROBE_SPEED)
374 376
   #define XY_PROBE_FEEDRATE XY_PROBE_SPEED
375 377
 #else
376
-  #define XY_PROBE_FEEDRATE (min(planner.max_feedrate[X_AXIS], planner.max_feedrate[Y_AXIS]) * 60)
378
+  #define XY_PROBE_FEEDRATE (PLANNER_XY_FEEDRATE() * 60)
377 379
 #endif
378 380
 
379 381
 #if ENABLED(Z_DUAL_ENDSTOPS) && DISABLED(DELTA)
@@ -1712,8 +1714,12 @@ static void clean_up_after_endstop_or_probe_move() {
1712 1714
     if ((Z_HOME_DIR) < 0 && zprobe_zoffset < 0)
1713 1715
       z_dest -= zprobe_zoffset;
1714 1716
 
1715
-    if (z_dest > current_position[Z_AXIS])
1717
+    if (z_dest > current_position[Z_AXIS]) {
1718
+      float old_feedrate = feedrate;
1719
+      feedrate = homing_feedrate[Z_AXIS];
1716 1720
       do_blocking_move_to_z(z_dest);
1721
+      feedrate = old_feedrate;
1722
+    }
1717 1723
   }
1718 1724
 
1719 1725
   inline void raise_z_after_probing() {
@@ -1766,19 +1772,24 @@ static void clean_up_after_endstop_or_probe_move() {
1766 1772
     if (endstops.z_probe_enabled == !dock) return; // already docked/undocked?
1767 1773
 
1768 1774
     float oldXpos = current_position[X_AXIS]; // save x position
1775
+    float old_feedrate = feedrate;
1769 1776
     if (dock) {
1770 1777
       raise_z_after_probing(); // raise Z
1771 1778
       // Dock sled a bit closer to ensure proper capturing
1779
+      feedrate = XY_PROBE_FEEDRATE;
1772 1780
       do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1);
1773 1781
       digitalWrite(SLED_PIN, LOW); // turn off magnet
1774 1782
     }
1775 1783
     else {
1784
+      feedrate = XY_PROBE_FEEDRATE;
1776 1785
       float z_loc = current_position[Z_AXIS];
1777 1786
       if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING;
1778 1787
       do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], z_loc); // this also updates current_position
1779 1788
       digitalWrite(SLED_PIN, HIGH); // turn on magnet
1780 1789
     }
1781 1790
     do_blocking_move_to_x(oldXpos); // return to position before docking
1791
+
1792
+    feedrate = old_feedrate;
1782 1793
   }
1783 1794
 
1784 1795
 #endif // Z_PROBE_SLED
@@ -2102,7 +2113,10 @@ static void clean_up_after_endstop_or_probe_move() {
2102 2113
       }
2103 2114
     #endif
2104 2115
 
2116
+    float old_feedrate = feedrate;
2117
+
2105 2118
     // Move Z up to the z_before height, then move the Z probe to the given XY
2119
+    feedrate = homing_feedrate[Z_AXIS];
2106 2120
     do_blocking_move_to_z(z_before); // this also updates current_position
2107 2121
 
2108 2122
     #if ENABLED(DEBUG_LEVELING_FEATURE)
@@ -2114,6 +2128,7 @@ static void clean_up_after_endstop_or_probe_move() {
2114 2128
     #endif
2115 2129
 
2116 2130
     // this also updates current_position
2131
+    feedrate = XY_PROBE_FEEDRATE;
2117 2132
     do_blocking_move_to_xy(x - (X_PROBE_OFFSET_FROM_EXTRUDER), y - (Y_PROBE_OFFSET_FROM_EXTRUDER));
2118 2133
 
2119 2134
     if (probe_action & ProbeDeploy) {
@@ -2147,6 +2162,8 @@ static void clean_up_after_endstop_or_probe_move() {
2147 2162
       if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< probe_pt");
2148 2163
     #endif
2149 2164
 
2165
+    feedrate = old_feedrate;
2166
+
2150 2167
     return measured_z;
2151 2168
   }
2152 2169
 
@@ -3473,8 +3490,6 @@ inline void gcode_G28() {
3473 3490
     // Deploy the probe. Servo will raise if needed.
3474 3491
     deploy_z_probe();
3475 3492
 
3476
-    feedrate = homing_feedrate[Z_AXIS];
3477
-
3478 3493
     bed_leveling_in_progress = true;
3479 3494
 
3480 3495
     #if ENABLED(AUTO_BED_LEVELING_GRID)
@@ -4227,7 +4242,7 @@ inline void gcode_M42() {
4227 4242
 
4228 4243
     bool seen_L = code_seen('L');
4229 4244
     uint8_t n_legs = seen_L ? code_value_byte() : 0;
4230
-    if (n_legs < 0 || n_legs > 15) {
4245
+    if (n_legs > 15) {
4231 4246
       SERIAL_PROTOCOLPGM("?Number of legs in movement not plausible (0-15).\n");
4232 4247
       return;
4233 4248
     }
@@ -4252,16 +4267,20 @@ inline void gcode_M42() {
4252 4267
       planner.bed_level_matrix.set_to_identity();
4253 4268
     #endif
4254 4269
 
4255
-    if (Z_start_location < Z_RAISE_BEFORE_PROBING * 2.0)
4270
+    setup_for_endstop_or_probe_move();
4271
+
4272
+    if (Z_start_location < Z_RAISE_BEFORE_PROBING * 2.0) {
4273
+      feedrate = homing_feedrate[Z_AXIS];
4256 4274
       do_blocking_move_to_z(Z_start_location);
4275
+    }
4257 4276
 
4277
+    feedrate = XY_PROBE_FEEDRATE;
4258 4278
     do_blocking_move_to_xy(X_probe_location - (X_PROBE_OFFSET_FROM_EXTRUDER), Y_probe_location - (Y_PROBE_OFFSET_FROM_EXTRUDER));
4259 4279
 
4260 4280
     /**
4261 4281
      * OK, do the initial probe to get us close to the bed.
4262 4282
      * Then retrace the right amount and use that in subsequent probes
4263 4283
      */
4264
-    setup_for_endstop_or_probe_move();
4265 4284
 
4266 4285
     // Height before each probe (except the first)
4267 4286
     float z_between = home_offset[Z_AXIS] + (deploy_probe_for_each_reading ? Z_RAISE_BEFORE_PROBING : Z_RAISE_BETWEEN_PROBINGS);
@@ -4399,6 +4418,7 @@ inline void gcode_M42() {
4399 4418
       // Raise before the next loop for the legs,
4400 4419
       // or do the final raise after the last probe
4401 4420
       if (n_legs || last_probe) {
4421
+        feedrate = homing_feedrate[Z_AXIS];
4402 4422
         do_blocking_move_to_z(last_probe ? home_offset[Z_AXIS] + Z_RAISE_AFTER_PROBING : z_between);
4403 4423
         if (!last_probe) delay(500);
4404 4424
       }
@@ -6551,15 +6571,8 @@ inline void gcode_T(uint8_t tmp_extruder) {
6551 6571
       float next_feedrate = code_value_axis_units(X_AXIS);
6552 6572
       if (next_feedrate > 0.0) stored_feedrate = feedrate = next_feedrate;
6553 6573
     }
6554
-    else {
6555
-      feedrate =
6556
-        #ifdef XY_PROBE_SPEED
6557
-          XY_PROBE_SPEED
6558
-        #else
6559
-          min(planner.max_feedrate[X_AXIS], planner.max_feedrate[Y_AXIS]) * 60
6560
-        #endif
6561
-      ;
6562
-    }
6574
+    else
6575
+      feedrate = XY_PROBE_FEEDRATE;
6563 6576
 
6564 6577
     if (tmp_extruder != active_extruder) {
6565 6578
       bool no_move = code_seen('S') && code_value_bool();
@@ -7668,7 +7681,7 @@ void mesh_buffer_line(float x, float y, float z, const float e, float feed_rate,
7668 7681
         delayed_move_time = 0;
7669 7682
         // unpark extruder: 1) raise, 2) move into starting XY position, 3) lower
7670 7683
         planner.buffer_line(raised_parked_position[X_AXIS], raised_parked_position[Y_AXIS], raised_parked_position[Z_AXIS], current_position[E_AXIS], planner.max_feedrate[Z_AXIS], active_extruder);
7671
-        planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS], current_position[E_AXIS], min(planner.max_feedrate[X_AXIS], planner.max_feedrate[Y_AXIS]), active_extruder);
7684
+        planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS], current_position[E_AXIS], PLANNER_XY_FEEDRATE(), active_extruder);
7672 7685
         planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], planner.max_feedrate[Z_AXIS], active_extruder);
7673 7686
         active_extruder_parked = false;
7674 7687
       }

Chargement…
Annuler
Enregistrer