diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index a8bff9a790..dec731532d 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -650,7 +650,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { // travel moves have been received so enact them delayed_move_time = 0xFFFFFFFFUL; // force moves to be done destination = current_position; - prepare_move_to_destination(); + prepare_line_to_destination(); } #endif diff --git a/Marlin/src/gcode/feature/pause/G61.cpp b/Marlin/src/gcode/feature/pause/G61.cpp index 2ec2f85fe5..60e6bcf040 100644 --- a/Marlin/src/gcode/feature/pause/G61.cpp +++ b/Marlin/src/gcode/feature/pause/G61.cpp @@ -65,7 +65,7 @@ void GcodeSuite::G61(void) { SERIAL_EOL(); // Move to the saved position - prepare_move_to_destination(); + prepare_line_to_destination(); } #endif // SAVED_POSITIONS diff --git a/Marlin/src/gcode/motion/G0_G1.cpp b/Marlin/src/gcode/motion/G0_G1.cpp index 8f0dfc71b2..069d76fdad 100644 --- a/Marlin/src/gcode/motion/G0_G1.cpp +++ b/Marlin/src/gcode/motion/G0_G1.cpp @@ -100,9 +100,9 @@ void GcodeSuite::G0_G1( #endif // FWRETRACT #if IS_SCARA - fast_move ? prepare_fast_move_to_destination() : prepare_move_to_destination(); + fast_move ? prepare_fast_move_to_destination() : prepare_line_to_destination(); #else - prepare_move_to_destination(); + prepare_line_to_destination(); #endif #ifdef G0_FEEDRATE diff --git a/Marlin/src/gcode/probe/G38.cpp b/Marlin/src/gcode/probe/G38.cpp index 11b7ce5af7..512e1ff89f 100644 --- a/Marlin/src/gcode/probe/G38.cpp +++ b/Marlin/src/gcode/probe/G38.cpp @@ -34,7 +34,7 @@ inline void G38_single_probe(const uint8_t move_value) { endstops.enable(true); G38_move = move_value; - prepare_move_to_destination(); + prepare_line_to_destination(); planner.synchronize(); G38_move = 0; endstops.hit_on_purpose(); @@ -77,7 +77,7 @@ inline bool G38_run_probe() { // Move away by the retract distance destination = current_position + retract_mm; endstops.enable(false); - prepare_move_to_destination(); + prepare_line_to_destination(); planner.synchronize(); REMEMBER(fr, feedrate_mm_s, feedrate_mm_s * 0.25); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index e15e955367..ecfb5233d2 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -104,7 +104,7 @@ xyze_pos_t current_position = { X_HOME_POS, Y_HOME_POS, Z_HOME_POS }; /** * Cartesian Destination * The destination for a move, filled in by G-code movement commands, - * and expected by functions like 'prepare_move_to_destination'. + * and expected by functions like 'prepare_line_to_destination'. * G-codes can set destination using 'get_destination_from_command' */ xyze_pos_t destination; // {0} @@ -340,7 +340,7 @@ void _internal_move_to_destination(const feedRate_t &fr_mm_s/*=0.0f*/ prepare_fast_move_to_destination(); else #endif - prepare_move_to_destination(); + prepare_line_to_destination(); feedrate_mm_s = old_feedrate; feedrate_percentage = old_pct; @@ -660,6 +660,16 @@ void restore_feedrate_and_scaling() { #endif // HAS_SOFTWARE_ENDSTOPS #if !UBL_SEGMENTED + +FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { + const millis_t ms = millis(); + thermalManager.manage_heater(); // This returns immediately if not really needed. + if (ELAPSED(ms, next_idle_ms)) { + next_idle_ms = ms + 200UL; + idle(); + } +} + #if IS_KINEMATIC #if IS_SCARA @@ -679,7 +689,7 @@ void restore_feedrate_and_scaling() { /** * Prepare a linear move in a DELTA or SCARA setup. * - * Called from prepare_move_to_destination as the + * Called from prepare_line_to_destination as the * default Delta/SCARA segmenter. * * This calls planner.buffer_line several times, adding @@ -752,17 +762,10 @@ void restore_feedrate_and_scaling() { xyze_pos_t raw = current_position; // Calculate and execute the segments + millis_t next_idle_ms = millis() + 200UL; while (--segments) { - - static millis_t next_idle_ms = millis() + 200UL; - thermalManager.manage_heater(); // This returns immediately if not really needed. - if (ELAPSED(millis(), next_idle_ms)) { - next_idle_ms = millis() + 200UL; - idle(); - } - + segment_idle(next_idle_ms); raw += segment_distance; - if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, cartesian_segment_mm #if ENABLED(SCARA_FEEDRATE_SCALING) , inv_duration @@ -831,13 +834,9 @@ void restore_feedrate_and_scaling() { xyze_pos_t raw = current_position; // Calculate and execute the segments + millis_t next_idle_ms = millis() + 200UL; while (--segments) { - static millis_t next_idle_ms = millis() + 200UL; - thermalManager.manage_heater(); // This returns immediately if not really needed. - if (ELAPSED(millis(), next_idle_ms)) { - next_idle_ms = millis() + 200UL; - idle(); - } + segment_idle(next_idle_ms); raw += segment_distance; if (!planner.buffer_line(raw, fr_mm_s, active_extruder, cartesian_segment_mm #if ENABLED(SCARA_FEEDRATE_SCALING) @@ -866,7 +865,7 @@ void restore_feedrate_and_scaling() { * * Return true if 'current_position' was set to 'destination' */ - inline bool prepare_move_to_destination_cartesian() { + inline bool line_to_destination_cartesian() { const float scaled_fr_mm_s = MMS_SCALED(feedrate_mm_s); #if HAS_MESH if (planner.leveling_active && planner.leveling_active_at_z(destination.z)) { @@ -1009,7 +1008,7 @@ void restore_feedrate_and_scaling() { * * Before exit, current_position is set to destination. */ -void prepare_move_to_destination() { +void prepare_line_to_destination() { apply_motion_limits(destination); #if EITHER(PREVENT_COLD_EXTRUSION, PREVENT_LENGTHY_EXTRUDE) @@ -1059,12 +1058,12 @@ void prepare_move_to_destination() { #if IS_KINEMATIC // UBL using Kinematic / Cartesian cases as a workaround for now. ubl.line_to_destination_segmented(MMS_SCALED(feedrate_mm_s)) #else - prepare_move_to_destination_cartesian() + line_to_destination_cartesian() #endif #elif IS_KINEMATIC line_to_destination_kinematic() #else - prepare_move_to_destination_cartesian() + line_to_destination_cartesian() #endif ) return; diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index f1c2dc069c..8e0eee7e33 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -182,7 +182,7 @@ void sync_plan_position_e(); */ void line_to_current_position(const feedRate_t &fr_mm_s=feedrate_mm_s); -void prepare_move_to_destination(); +void prepare_line_to_destination(); void _internal_move_to_destination(const feedRate_t &fr_mm_s=0.0f #if IS_KINEMATIC