瀏覽代碼

Save and restore feedrate in more places

Scott Lahteine 9 年之前
父節點
當前提交
6fdd5ba246
共有 1 個文件被更改,包括 30 次插入17 次删除
  1. 30
    17
      Marlin/Marlin_main.cpp

+ 30
- 17
Marlin/Marlin_main.cpp 查看文件

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

Loading…
取消
儲存