-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce line_to_axis_pos() for use in homeaxis() #4342
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1613,9 +1613,20 @@ inline float set_homing_bump_feedrate(AxisEnum axis) { | |
inline void line_to_current_position() { | ||
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMM_TO_MMS(feedrate_mm_m), active_extruder); | ||
} | ||
|
||
inline void line_to_z(float zPosition) { | ||
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], MMM_TO_MMS(feedrate_mm_m), active_extruder); | ||
} | ||
|
||
inline void line_to_axis_pos(AxisEnum axis, float where, float fr_mm_m = 0.0) { | ||
float old_feedrate_mm_m = feedrate_mm_m; | ||
current_position[axis] = where; | ||
feedrate_mm_m = (fr_mm_m != 0.0) ? fr_mm_m : homing_feedrate_mm_m[axis]; | ||
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMM_TO_MMS(feedrate_mm_m), active_extruder); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replacing this with |
||
stepper.synchronize(); // The lost one | ||
feedrate_mm_m = old_feedrate_mm_m; | ||
} | ||
|
||
// | ||
// line_to_destination | ||
// Move the planner, not necessarily synced with current_position | ||
|
@@ -1708,11 +1719,6 @@ static void do_blocking_move_to(float x, float y, float z, float fr_mm_m = 0.0) | |
feedrate_mm_m = old_feedrate_mm_m; | ||
} | ||
|
||
inline void do_blocking_move_to_axis_pos(AxisEnum axis, float where, float fr_mm_m = 0.0) { | ||
current_position[axis] = where; | ||
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_m); | ||
} | ||
|
||
inline void do_blocking_move_to_x(float x, float fr_mm_m = 0.0) { | ||
do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_m); | ||
} | ||
|
@@ -2425,19 +2431,17 @@ static void homeaxis(AxisEnum axis) { | |
#endif | ||
|
||
// Move towards the endstop until an endstop is triggered | ||
do_blocking_move_to_axis_pos(axis, 1.5 * max_length(axis) * axis_home_dir, homing_feedrate_mm_m[axis]); | ||
line_to_axis_pos(axis, 1.5 * max_length(axis) * axis_home_dir); | ||
|
||
// Set the axis position as setup for the move | ||
current_position[axis] = 0; | ||
sync_plan_position(); | ||
|
||
// Move away from the endstop by the axis HOME_BUMP_MM | ||
do_blocking_move_to_axis_pos(axis, -home_bump_mm(axis) * axis_home_dir, homing_feedrate_mm_m[axis]); | ||
|
||
// Slow down the feedrate for the next move | ||
line_to_axis_pos(axis, -home_bump_mm(axis) * axis_home_dir); | ||
|
||
// Move slowly towards the endstop until triggered | ||
do_blocking_move_to_axis_pos(axis, 2 * home_bump_mm(axis) * axis_home_dir, set_homing_bump_feedrate(axis)); | ||
line_to_axis_pos(axis, 2 * home_bump_mm(axis) * axis_home_dir, set_homing_bump_feedrate(axis)); | ||
|
||
#if ENABLED(DEBUG_LEVELING_FEATURE) | ||
if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position); | ||
|
@@ -2458,7 +2462,7 @@ static void homeaxis(AxisEnum axis) { | |
sync_plan_position(); | ||
|
||
// Move to the adjusted endstop height | ||
do_blocking_move_to_z(adj, homing_feedrate_mm_m[axis]); | ||
line_to_axis_pos(axis, adj); | ||
|
||
if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false); | ||
stepper.set_homing_flag(false); | ||
|
@@ -2475,7 +2479,7 @@ static void homeaxis(AxisEnum axis) { | |
DEBUG_POS("", current_position); | ||
} | ||
#endif | ||
do_blocking_move_to_axis_pos(axis, endstop_adj[axis], set_homing_bump_feedrate(axis)); | ||
line_to_axis_pos(axis, endstop_adj[axis]); | ||
} | ||
#endif | ||
|
||
|
@@ -2825,10 +2829,28 @@ inline void gcode_G4() { | |
} | ||
#endif | ||
|
||
#if ENABLED(NOZZLE_PARK_FEATURE) | ||
#include "nozzle.h" | ||
|
||
/** | ||
* G27: Park the nozzle | ||
*/ | ||
inline void gcode_G27() { | ||
// Don't allow nozzle parking without homing first | ||
if (axis_unhomed_error(true, true, true)) { return; } | ||
uint8_t const z_action = code_seen('P') ? code_value_ushort() : 0; | ||
Nozzle::park(z_action); | ||
} | ||
#endif // NOZZLE_PARK_FEATURE | ||
|
||
#if ENABLED(QUICK_HOME) | ||
|
||
static void quick_home_xy() { | ||
|
||
// Pretend the current position is 0,0 | ||
current_position[X_AXIS] = current_position[Y_AXIS] = 0.0; | ||
sync_plan_position(); | ||
|
||
#if ENABLED(DUAL_X_CARRIAGE) | ||
int x_axis_home_dir = x_home_dir(active_extruder); | ||
extruder_duplication_enabled = false; | ||
|
@@ -2839,30 +2861,16 @@ inline void gcode_G4() { | |
float mlx = max_length(X_AXIS), | ||
mly = max_length(Y_AXIS), | ||
mlratio = mlx > mly ? mly / mlx : mlx / mly, | ||
fr_mm_m = min(homing_feedrate_mm_m[X_AXIS], homing_feedrate_mm_m[Y_AXIS]) * sqrt(sq(mlratio) + 1); | ||
fr_mm_m = min(homing_feedrate_mm_m[X_AXIS], homing_feedrate_mm_m[Y_AXIS]) * sqrt(sq(mlratio) + 1.0); | ||
|
||
do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_m); | ||
endstops.hit_on_purpose(); // clear endstop hit flags | ||
current_position[X_AXIS] = current_position[Y_AXIS] = 0; | ||
current_position[X_AXIS] = current_position[Y_AXIS] = 0.0; | ||
|
||
} | ||
|
||
#endif // QUICK_HOME | ||
|
||
#if ENABLED(NOZZLE_PARK_FEATURE) | ||
#include "nozzle.h" | ||
|
||
/** | ||
* G27: Park the nozzle | ||
*/ | ||
inline void gcode_G27() { | ||
// Don't allow nozzle parking without homing first | ||
if (axis_unhomed_error(true, true, true)) { return; } | ||
uint8_t const z_action = code_seen('P') ? code_value_ushort() : 0; | ||
Nozzle::park(z_action); | ||
} | ||
#endif // NOZZLE_PARK_FEATURE | ||
|
||
/** | ||
* G28: Home all axes according to settings | ||
* | ||
|
@@ -2931,20 +2939,19 @@ inline void gcode_G28() { | |
*/ | ||
|
||
// Pretend the current position is 0,0,0 | ||
for (int i = X_AXIS; i <= Z_AXIS; i++) current_position[i] = 0; | ||
// This is like quick_home_xy() but for 3 towers. | ||
current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = 0.0; | ||
sync_plan_position(); | ||
|
||
// Move all carriages up together until the first endstop is hit. | ||
for (int i = X_AXIS; i <= Z_AXIS; i++) destination[i] = 3 * (Z_MAX_LENGTH); | ||
current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = 3.0 * (Z_MAX_LENGTH); | ||
feedrate_mm_m = 1.732 * homing_feedrate_mm_m[X_AXIS]; | ||
line_to_destination(); | ||
line_to_current_position(); | ||
stepper.synchronize(); | ||
endstops.hit_on_purpose(); // clear endstop hit flags | ||
current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = 0.0; | ||
|
||
// Destination reached | ||
for (int i = X_AXIS; i <= Z_AXIS; i++) current_position[i] = destination[i]; | ||
|
||
// take care of back off and rehome now we are all at the top | ||
// take care of back off and rehome. Now one carriage is at the top. | ||
HOMEAXIS(X); | ||
HOMEAXIS(Y); | ||
HOMEAXIS(Z); | ||
|
@@ -5325,7 +5332,7 @@ inline void gcode_M200() { | |
if (volumetric_enabled) { | ||
filament_size[target_extruder] = code_value_linear_units(); | ||
// make sure all extruders have some sane value for the filament size | ||
for (int i = 0; i < COUNT(filament_size); i++) | ||
for (uint8_t i = 0; i < COUNT(filament_size); i++) | ||
if (! filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA; | ||
} | ||
} | ||
|
@@ -8695,6 +8702,6 @@ float calculate_volumetric_multiplier(float diameter) { | |
} | ||
|
||
void calculate_volumetric_multipliers() { | ||
for (int i = 0; i < COUNT(filament_size); i++) | ||
for (uint8_t i = 0; i < COUNT(filament_size); i++) | ||
volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that
line_to_z(z)
does not updatecurrent_position[Z_AXIS]
. It's called only inrun_z_probe
for the probing moves (where it doesn't need to updatecurrent_position
). Thecurrent_position
is set fromstepper.get_axis_position_mm(Z_AXIS)
at the end.