Browse Source

Use homing_feedrate function

Scott Lahteine 3 years ago
parent
commit
20b3af1cc2

+ 0
- 1
Marlin/src/core/types.h View File

@@ -75,7 +75,6 @@ typedef float feedRate_t;
75 75
 // Conversion macros
76 76
 #define MMM_TO_MMS(MM_M) feedRate_t(float(MM_M) / 60.0f)
77 77
 #define MMS_TO_MMM(MM_S) (float(MM_S) * 60.0f)
78
-#define MMS_SCALED(V)    ((V) * 0.01f * feedrate_percentage)
79 78
 
80 79
 //
81 80
 // Coordinates structures for XY, XYZ, XYZE...

+ 2
- 2
Marlin/src/feature/encoder_i2c.cpp View File

@@ -332,7 +332,7 @@ bool I2CPositionEncoder::test_axis() {
332 332
 
333 333
   const float startPosition = soft_endstop.min[encoderAxis] + 10,
334 334
               endPosition = soft_endstop.max[encoderAxis] - 10;
335
-  const feedRate_t fr_mm_s = FLOOR(MMM_TO_MMS((encoderAxis == Z_AXIS) ? HOMING_FEEDRATE_Z : HOMING_FEEDRATE_XY));
335
+  const feedRate_t fr_mm_s = FLOOR(homing_feedrate(encoderAxis));
336 336
 
337 337
   ec = false;
338 338
 
@@ -382,7 +382,7 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) {
382 382
 
383 383
   int32_t startCount, stopCount;
384 384
 
385
-  const feedRate_t fr_mm_s = MMM_TO_MMS((encoderAxis == Z_AXIS) ? HOMING_FEEDRATE_Z : HOMING_FEEDRATE_XY);
385
+  const feedRate_t fr_mm_s = homing_feedrate(encoderAxis);
386 386
 
387 387
   bool oldec = ec;
388 388
   ec = false;

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

@@ -180,7 +180,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
180 180
 
181 181
     // Machine state
182 182
     info.current_position = current_position;
183
-    info.feedrate = uint16_t(feedrate_mm_s * 60.0f);
183
+    info.feedrate = uint16_t(MMS_TO_MMM(feedrate_mm_s));
184 184
     info.zraise = zraise;
185 185
 
186 186
     TERN_(GCODE_REPEAT_MARKERS, info.stored_repeat = repeat);

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

@@ -63,7 +63,7 @@ void GcodeSuite::G34() {
63 63
 
64 64
   // Move Z to pounce position
65 65
   if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Setting Z Pounce");
66
-  do_blocking_move_to_z(zpounce, MMM_TO_MMS(HOMING_FEEDRATE_Z));
66
+  do_blocking_move_to_z(zpounce, homing_feedrate(Z_AXIS));
67 67
 
68 68
   // Store current motor settings, then apply reduced value
69 69
 

+ 7
- 4
Marlin/src/gcode/feature/pause/G61.cpp View File

@@ -49,10 +49,6 @@ void GcodeSuite::G61(void) {
49 49
   // No saved position? No axes being restored?
50 50
   if (!TEST(saved_slots[slot >> 3], slot & 0x07) || !parser.seen("XYZ")) return;
51 51
 
52
-  // Apply any given feedrate over 0.0
53
-  const float fr = parser.linearval('F');
54
-  if (fr > 0.0) feedrate_mm_s = MMM_TO_MMS(fr);
55
-
56 52
   SERIAL_ECHOPAIR(STR_RESTORING_POS " S", int(slot));
57 53
   LOOP_XYZ(i) {
58 54
     destination[i] = parser.seen(XYZ_CHAR(i))
@@ -63,8 +59,15 @@ void GcodeSuite::G61(void) {
63 59
   }
64 60
   SERIAL_EOL();
65 61
 
62
+  // Apply any given feedrate over 0.0
63
+  feedRate_t saved_feedrate = feedrate_mm_s;
64
+  const float fr = parser.linearval('F');
65
+  if (fr > 0.0) feedrate_mm_s = MMM_TO_MMS(fr);
66
+
66 67
   // Move to the saved position
67 68
   prepare_line_to_destination();
69
+
70
+  feedrate_mm_s = saved_feedrate;
68 71
 }
69 72
 
70 73
 #endif // SAVED_POSITIONS

+ 3
- 3
Marlin/src/lcd/dwin/e3v2/dwin.cpp View File

@@ -1166,7 +1166,7 @@ void HMI_Move_X() {
1166 1166
       if (!planner.is_full()) {
1167 1167
         // Wait for planner moves to finish!
1168 1168
         planner.synchronize();
1169
-        planner.buffer_line(current_position, MMM_TO_MMS(HOMING_FEEDRATE_XY), active_extruder);
1169
+        planner.buffer_line(current_position, homing_feedrate(X_AXIS), active_extruder);
1170 1170
       }
1171 1171
       DWIN_UpdateLCD();
1172 1172
       return;
@@ -1189,7 +1189,7 @@ void HMI_Move_Y() {
1189 1189
       if (!planner.is_full()) {
1190 1190
         // Wait for planner moves to finish!
1191 1191
         planner.synchronize();
1192
-        planner.buffer_line(current_position, MMM_TO_MMS(HOMING_FEEDRATE_XY), active_extruder);
1192
+        planner.buffer_line(current_position, homing_feedrate(Y_AXIS), active_extruder);
1193 1193
       }
1194 1194
       DWIN_UpdateLCD();
1195 1195
       return;
@@ -1212,7 +1212,7 @@ void HMI_Move_Z() {
1212 1212
       if (!planner.is_full()) {
1213 1213
         // Wait for planner moves to finish!
1214 1214
         planner.synchronize();
1215
-        planner.buffer_line(current_position, MMM_TO_MMS(HOMING_FEEDRATE_Z), active_extruder);
1215
+        planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
1216 1216
       }
1217 1217
       DWIN_UpdateLCD();
1218 1218
       return;

+ 0
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp View File

@@ -45,8 +45,6 @@ enum {
45 45
   ID_FILAMNT_RETURN
46 46
 };
47 47
 
48
-extern feedRate_t feedrate_mm_s;
49
-
50 48
 static void event_handler(lv_obj_t *obj, lv_event_t event) {
51 49
   if (event != LV_EVENT_RELEASED) return;
52 50
   switch (obj->mks_obj_id) {

+ 0
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp View File

@@ -53,8 +53,6 @@ enum {
53 53
 static lv_obj_t *label_PowerOff;
54 54
 static lv_obj_t *buttonPowerOff;
55 55
 
56
-extern feedRate_t feedrate_mm_s;
57
-
58 56
 static void event_handler(lv_obj_t *obj, lv_event_t event) {
59 57
   if (event != LV_EVENT_RELEASED) return;
60 58
   switch (obj->mks_obj_id) {

+ 1
- 1
Marlin/src/lcd/menu/menu_probe_offset.cpp View File

@@ -146,7 +146,7 @@ void prepare_for_probe_offset_wizard() {
146 146
   // Move Nozzle to Probing/Homing Position
147 147
   ui.wait_for_move = true;
148 148
   current_position += probe.offset_xy;
149
-  line_to_current_position(MMM_TO_MMS(HOMING_FEEDRATE_XY));
149
+  line_to_current_position(MMM_TO_MMS(XY_PROBE_SPEED));
150 150
   ui.synchronize(GET_TEXT(MSG_PROBE_WIZARD_MOVING));
151 151
   ui.wait_for_move = false;
152 152
 

+ 1
- 1
Marlin/src/module/motion.cpp View File

@@ -510,7 +510,7 @@ void do_z_clearance(const float &zclear, const bool z_trusted/*=true*/, const bo
510 510
   const bool rel = raise_on_untrusted && !z_trusted;
511 511
   float zdest = zclear + (rel ? current_position.z : 0.0f);
512 512
   if (!lower_allowed) NOLESS(zdest, current_position.z);
513
-  do_blocking_move_to_z(_MIN(zdest, Z_MAX_POS), MMM_TO_MMS(TERN(HAS_BED_PROBE, Z_PROBE_SPEED_FAST, HOMING_FEEDRATE_Z)));
513
+  do_blocking_move_to_z(_MIN(zdest, Z_MAX_POS), TERN(HAS_BED_PROBE, MMM_TO_MMS(Z_PROBE_SPEED_FAST), homing_feedrate(Z_AXIS)));
514 514
 }
515 515
 
516 516
 //

+ 5
- 1
Marlin/src/module/motion.h View File

@@ -73,12 +73,16 @@ extern const feedRate_t homing_feedrate_mm_s[XYZ];
73 73
 FORCE_INLINE feedRate_t homing_feedrate(const AxisEnum a) { return pgm_read_float(&homing_feedrate_mm_s[a]); }
74 74
 feedRate_t get_homing_bump_feedrate(const AxisEnum axis);
75 75
 
76
+/**
77
+ * The default feedrate for many moves, set by the most recent move
78
+ */
76 79
 extern feedRate_t feedrate_mm_s;
77 80
 
78 81
 /**
79
- * Feedrate scaling
82
+ * Feedrate scaling is applied to all G0/G1, G2/G3, and G5 moves
80 83
  */
81 84
 extern int16_t feedrate_percentage;
85
+#define MMS_SCALED(V) ((V) * 0.01f * feedrate_percentage)
82 86
 
83 87
 // The active extruder (tool). Set with T<extruder> command.
84 88
 #if HAS_MULTI_EXTRUDER

+ 1
- 1
Marlin/src/module/planner.h View File

@@ -978,6 +978,6 @@ class Planner {
978 978
     #endif // !CLASSIC_JERK
979 979
 };
980 980
 
981
-#define PLANNER_XY_FEEDRATE() (_MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS]))
981
+#define PLANNER_XY_FEEDRATE() _MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS])
982 982
 
983 983
 extern Planner planner;

+ 3
- 8
Marlin/src/module/probe.cpp View File

@@ -152,8 +152,8 @@ xyz_pos_t Probe::offset; // Initialized by settings.load()
152 152
   inline void run_stow_moves_script() {
153 153
     const xyz_pos_t oldpos = current_position;
154 154
     endstops.enable_z_probe(false);
155
-    do_blocking_move_to_z(TOUCH_MI_RETRACT_Z, MMM_TO_MMS(HOMING_FEEDRATE_Z));
156
-    do_blocking_move_to(oldpos, MMM_TO_MMS(HOMING_FEEDRATE_Z));
155
+    do_blocking_move_to_z(TOUCH_MI_RETRACT_Z, homing_feedrate(Z_AXIS));
156
+    do_blocking_move_to(oldpos, homing_feedrate(Z_AXIS));
157 157
   }
158 158
 
159 159
 #elif ENABLED(Z_PROBE_ALLEN_KEY)
@@ -664,11 +664,8 @@ float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise
664 664
   }
665 665
   else if (!position_is_reachable(npos)) return NAN;        // The given position is in terms of the nozzle
666 666
 
667
-  const float old_feedrate_mm_s = feedrate_mm_s;
668
-  feedrate_mm_s = XY_PROBE_FEEDRATE_MM_S;
669
-
670 667
   // Move the probe to the starting XYZ
671
-  do_blocking_move_to(npos);
668
+  do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S));
672 669
 
673 670
   float measured_z = NAN;
674 671
   if (!deploy()) measured_z = run_z_probe(sanity_check) + offset.z;
@@ -683,8 +680,6 @@ float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise
683 680
       SERIAL_ECHOLNPAIR("Bed X: ", LOGICAL_X_POSITION(rx), " Y: ", LOGICAL_Y_POSITION(ry), " Z: ", measured_z);
684 681
   }
685 682
 
686
-  feedrate_mm_s = old_feedrate_mm_s;
687
-
688 683
   if (isnan(measured_z)) {
689 684
     stow();
690 685
     LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);

Loading…
Cancel
Save