Clean up some motion code
This commit is contained in:
parent
808b076000
commit
5d28575d4d
4 changed files with 26 additions and 49 deletions
|
@ -142,7 +142,7 @@ void FWRetract::retract(const bool retracting
|
||||||
set_destination_from_current();
|
set_destination_from_current();
|
||||||
|
|
||||||
#if ENABLED(RETRACT_SYNC_MIXING)
|
#if ENABLED(RETRACT_SYNC_MIXING)
|
||||||
uint8_t old_mixing_tool = mixer.get_current_vtool();
|
const uint8_t old_mixing_tool = mixer.get_current_vtool();
|
||||||
mixer.T(MIXER_AUTORETRACT_TOOL);
|
mixer.T(MIXER_AUTORETRACT_TOOL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -263,9 +263,7 @@ void GcodeSuite::G28(const bool always_home_all) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
setup_for_endstop_or_probe_move();
|
setup_for_endstop_or_probe_move();
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
||||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(true)");
|
|
||||||
#endif
|
|
||||||
endstops.enable(true); // Enable endstops for next homing move
|
endstops.enable(true); // Enable endstops for next homing move
|
||||||
|
|
||||||
#if ENABLED(DELTA)
|
#if ENABLED(DELTA)
|
||||||
|
|
|
@ -253,8 +253,8 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
||||||
* Move the planner to the current position from wherever it last moved
|
* Move the planner to the current position from wherever it last moved
|
||||||
* (or from wherever it has been told it is located).
|
* (or from wherever it has been told it is located).
|
||||||
*/
|
*/
|
||||||
void line_to_current_position() {
|
void line_to_current_position(const float &fr_mm_s/*=feedrate_mm_s*/) {
|
||||||
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate_mm_s, active_extruder);
|
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], fr_mm_s, active_extruder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -270,7 +270,7 @@ void buffer_line_to_destination(const float fr_mm_s) {
|
||||||
/**
|
/**
|
||||||
* Calculate delta, start a line, and set current_position to destination
|
* Calculate delta, start a line, and set current_position to destination
|
||||||
*/
|
*/
|
||||||
void prepare_uninterpolated_move_to_destination(const float fr_mm_s/*=0.0*/) {
|
void prepare_uninterpolated_move_to_destination(const float &fr_mm_s/*=0.0*/) {
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||||
if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_uninterpolated_move_to_destination", destination);
|
if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_uninterpolated_move_to_destination", destination);
|
||||||
#endif
|
#endif
|
||||||
|
@ -297,19 +297,18 @@ void buffer_line_to_destination(const float fr_mm_s) {
|
||||||
* Plan a move to (X, Y, Z) and set the current_position
|
* Plan a move to (X, Y, Z) and set the current_position
|
||||||
*/
|
*/
|
||||||
void do_blocking_move_to(const float rx, const float ry, const float rz, const float &fr_mm_s/*=0.0*/) {
|
void do_blocking_move_to(const float rx, const float ry, const float rz, const float &fr_mm_s/*=0.0*/) {
|
||||||
const float old_feedrate_mm_s = feedrate_mm_s;
|
|
||||||
|
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||||
if (DEBUGGING(LEVELING)) print_xyz(PSTR(">>> do_blocking_move_to"), NULL, rx, ry, rz);
|
if (DEBUGGING(LEVELING)) print_xyz(PSTR(">>> do_blocking_move_to"), NULL, rx, ry, rz);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const float z_feedrate = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS);
|
const float z_feedrate = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS),
|
||||||
|
xy_feedrate = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
|
||||||
|
|
||||||
#if ENABLED(DELTA)
|
#if ENABLED(DELTA)
|
||||||
|
|
||||||
if (!position_is_reachable(rx, ry)) return;
|
if (!position_is_reachable(rx, ry)) return;
|
||||||
|
|
||||||
feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
|
REMEMBER(fr, feedrate_mm_s, xy_feedrate);
|
||||||
|
|
||||||
set_destination_from_current(); // sync destination at the start
|
set_destination_from_current(); // sync destination at the start
|
||||||
|
|
||||||
|
@ -373,7 +372,7 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f
|
||||||
|
|
||||||
destination[X_AXIS] = rx;
|
destination[X_AXIS] = rx;
|
||||||
destination[Y_AXIS] = ry;
|
destination[Y_AXIS] = ry;
|
||||||
prepare_uninterpolated_move_to_destination(fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S);
|
prepare_uninterpolated_move_to_destination(xy_feedrate);
|
||||||
|
|
||||||
// If Z needs to lower, do it after moving XY
|
// If Z needs to lower, do it after moving XY
|
||||||
if (destination[Z_AXIS] > rz) {
|
if (destination[Z_AXIS] > rz) {
|
||||||
|
@ -385,27 +384,22 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f
|
||||||
|
|
||||||
// If Z needs to raise, do it before moving XY
|
// If Z needs to raise, do it before moving XY
|
||||||
if (current_position[Z_AXIS] < rz) {
|
if (current_position[Z_AXIS] < rz) {
|
||||||
feedrate_mm_s = z_feedrate;
|
|
||||||
current_position[Z_AXIS] = rz;
|
current_position[Z_AXIS] = rz;
|
||||||
line_to_current_position();
|
line_to_current_position(z_feedrate);
|
||||||
}
|
}
|
||||||
|
|
||||||
feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
|
|
||||||
current_position[X_AXIS] = rx;
|
current_position[X_AXIS] = rx;
|
||||||
current_position[Y_AXIS] = ry;
|
current_position[Y_AXIS] = ry;
|
||||||
line_to_current_position();
|
line_to_current_position(xy_feedrate);
|
||||||
|
|
||||||
// If Z needs to lower, do it after moving XY
|
// If Z needs to lower, do it after moving XY
|
||||||
if (current_position[Z_AXIS] > rz) {
|
if (current_position[Z_AXIS] > rz) {
|
||||||
feedrate_mm_s = z_feedrate;
|
|
||||||
current_position[Z_AXIS] = rz;
|
current_position[Z_AXIS] = rz;
|
||||||
line_to_current_position();
|
line_to_current_position(z_feedrate);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
feedrate_mm_s = old_feedrate_mm_s;
|
|
||||||
|
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< do_blocking_move_to");
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< do_blocking_move_to");
|
||||||
#endif
|
#endif
|
||||||
|
@ -423,31 +417,20 @@ void do_blocking_move_to_xy(const float &rx, const float &ry, const float &fr_mm
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Prepare to do endstop or probe moves
|
// Prepare to do endstop or probe moves with custom feedrates.
|
||||||
// with custom feedrates.
|
// - Save / restore current feedrate and multiplier
|
||||||
//
|
//
|
||||||
// - Save current feedrates
|
static float saved_feedrate_mm_s;
|
||||||
// - Reset the rate multiplier
|
static int16_t saved_feedrate_percentage;
|
||||||
//
|
void setup_for_endstop_or_probe_move() {
|
||||||
void bracket_probe_move(const bool before) {
|
saved_feedrate_mm_s = feedrate_mm_s;
|
||||||
static float saved_feedrate_mm_s;
|
saved_feedrate_percentage = feedrate_percentage;
|
||||||
static int16_t saved_feedrate_percentage;
|
feedrate_percentage = 100;
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
}
|
||||||
if (DEBUGGING(LEVELING)) DEBUG_POS("bracket_probe_move", current_position);
|
void clean_up_after_endstop_or_probe_move() {
|
||||||
#endif
|
feedrate_mm_s = saved_feedrate_mm_s;
|
||||||
if (before) {
|
feedrate_percentage = saved_feedrate_percentage;
|
||||||
saved_feedrate_mm_s = feedrate_mm_s;
|
|
||||||
saved_feedrate_percentage = feedrate_percentage;
|
|
||||||
feedrate_percentage = 100;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
feedrate_mm_s = saved_feedrate_mm_s;
|
|
||||||
feedrate_percentage = saved_feedrate_percentage;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup_for_endstop_or_probe_move() { bracket_probe_move(true); }
|
|
||||||
void clean_up_after_endstop_or_probe_move() { bracket_probe_move(false); }
|
|
||||||
|
|
||||||
#if HAS_SOFTWARE_ENDSTOPS
|
#if HAS_SOFTWARE_ENDSTOPS
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ void sync_plan_position_e();
|
||||||
* Move the planner to the current position from wherever it last moved
|
* Move the planner to the current position from wherever it last moved
|
||||||
* (or from wherever it has been told it is located).
|
* (or from wherever it has been told it is located).
|
||||||
*/
|
*/
|
||||||
void line_to_current_position();
|
void line_to_current_position(const float &fr_mm_s=feedrate_mm_s);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the planner to the position stored in the destination array, which is
|
* Move the planner to the position stored in the destination array, which is
|
||||||
|
@ -158,7 +158,7 @@ void line_to_current_position();
|
||||||
void buffer_line_to_destination(const float fr_mm_s);
|
void buffer_line_to_destination(const float fr_mm_s);
|
||||||
|
|
||||||
#if IS_KINEMATIC
|
#if IS_KINEMATIC
|
||||||
void prepare_uninterpolated_move_to_destination(const float fr_mm_s=0);
|
void prepare_uninterpolated_move_to_destination(const float &fr_mm_s=0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void prepare_move_to_destination();
|
void prepare_move_to_destination();
|
||||||
|
@ -182,10 +182,6 @@ FORCE_INLINE void do_blocking_move_to(const float (&raw)[XYZE], const float &fr_
|
||||||
void setup_for_endstop_or_probe_move();
|
void setup_for_endstop_or_probe_move();
|
||||||
void clean_up_after_endstop_or_probe_move();
|
void clean_up_after_endstop_or_probe_move();
|
||||||
|
|
||||||
void bracket_probe_move(const bool before);
|
|
||||||
void setup_for_endstop_or_probe_move();
|
|
||||||
void clean_up_after_endstop_or_probe_move();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Homing
|
// Homing
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue