|
|
|
@ -572,10 +572,6 @@ static uint8_t target_extruder;
|
|
|
|
|
|
|
|
|
|
float delta_safe_distance_from_top();
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
static bool home_all_axis = true;
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
|
|
|
@ -1582,7 +1578,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
|
|
|
|
|
* The final current_position may not be the one that was requested
|
|
|
|
|
*/
|
|
|
|
|
void do_blocking_move_to(const float &x, const float &y, const float &z, const float &fr_mm_s /*=0.0*/) {
|
|
|
|
|
float old_feedrate_mm_s = feedrate_mm_s;
|
|
|
|
|
const float old_feedrate_mm_s = feedrate_mm_s;
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
if (DEBUGGING(LEVELING)) print_xyz(PSTR(">>> do_blocking_move_to"), NULL, x, y, z);
|
|
|
|
@ -2034,8 +2030,8 @@ static void clean_up_after_endstop_or_probe_move() {
|
|
|
|
|
if (axis_unhomed_error(true, true, true )) { stop(); return true; }
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
float oldXpos = current_position[X_AXIS],
|
|
|
|
|
oldYpos = current_position[Y_AXIS];
|
|
|
|
|
const float oldXpos = current_position[X_AXIS],
|
|
|
|
|
oldYpos = current_position[Y_AXIS];
|
|
|
|
|
|
|
|
|
|
#ifdef _TRIGGERED_WHEN_STOWED_TEST
|
|
|
|
|
|
|
|
|
@ -2178,7 +2174,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
|
|
|
|
// - Raise to the BETWEEN height
|
|
|
|
|
// - Return the probed Z position
|
|
|
|
|
//
|
|
|
|
|
static float probe_pt(const float &x, const float &y, bool stow = true, int verbose_level = 1) {
|
|
|
|
|
static float probe_pt(const float &x, const float &y, const bool stow = true, const int verbose_level = 1) {
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
|
SERIAL_ECHOPAIR(">>> probe_pt(", x);
|
|
|
|
@ -2189,7 +2185,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
float old_feedrate_mm_s = feedrate_mm_s;
|
|
|
|
|
const float old_feedrate_mm_s = feedrate_mm_s;
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DELTA)
|
|
|
|
|
if (current_position[Z_AXIS] > delta_clip_start_height)
|
|
|
|
@ -2206,7 +2202,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
|
|
|
|
|
|
|
|
|
if (DEPLOY_PROBE()) return NAN;
|
|
|
|
|
|
|
|
|
|
float measured_z = run_z_probe();
|
|
|
|
|
const float measured_z = run_z_probe();
|
|
|
|
|
|
|
|
|
|
if (!stow)
|
|
|
|
|
do_probe_raise(Z_CLEARANCE_BETWEEN_PROBES);
|
|
|
|
@ -2370,7 +2366,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
|
|
|
|
if (b2 == UNPROBED) b2 = 0.0; if (b1 == UNPROBED) b1 = b2;
|
|
|
|
|
if (c2 == UNPROBED) c2 = 0.0; if (c1 == UNPROBED) c1 = c2;
|
|
|
|
|
|
|
|
|
|
float a = 2 * a1 - a2, b = 2 * b1 - b2, c = 2 * c1 - c2;
|
|
|
|
|
const float a = 2 * a1 - a2, b = 2 * b1 - b2, c = 2 * c1 - c2;
|
|
|
|
|
|
|
|
|
|
// Take the average instead of the median
|
|
|
|
|
bed_level_grid[x][y] = (a + b + c) / 3.0;
|
|
|
|
@ -2416,10 +2412,10 @@ static void clean_up_after_endstop_or_probe_move() {
|
|
|
|
|
for (uint8_t yo = 0; yo <= ylen; yo++) {
|
|
|
|
|
uint8_t x2 = ctrx2 + xo, y2 = ctry2 + yo;
|
|
|
|
|
#ifndef HALF_IN_X
|
|
|
|
|
uint8_t x1 = ctrx1 - xo;
|
|
|
|
|
const uint8_t x1 = ctrx1 - xo;
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef HALF_IN_Y
|
|
|
|
|
uint8_t y1 = ctry1 - yo;
|
|
|
|
|
const uint8_t y1 = ctry1 - yo;
|
|
|
|
|
#ifndef HALF_IN_X
|
|
|
|
|
extrapolate_one_point(x1, y1, +1, +1); // left-below + +
|
|
|
|
|
#endif
|
|
|
|
@ -2586,7 +2582,7 @@ static void do_homing_move(const AxisEnum axis, float distance, float fr_mm_s=0.
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
|
|
|
|
|
bool deploy_bltouch = (axis == Z_AXIS && distance < 0);
|
|
|
|
|
const bool deploy_bltouch = (axis == Z_AXIS && distance < 0);
|
|
|
|
|
if (deploy_bltouch) set_bltouch_deployed(true);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -2634,7 +2630,7 @@ static void do_homing_move(const AxisEnum axis, float distance, float fr_mm_s=0.
|
|
|
|
|
|
|
|
|
|
#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
|
|
|
|
|
|
|
|
|
|
static void homeaxis(AxisEnum axis) {
|
|
|
|
|
static void homeaxis(const AxisEnum axis) {
|
|
|
|
|
|
|
|
|
|
#if IS_SCARA
|
|
|
|
|
// Only Z homing (with probe) is permitted
|
|
|
|
@ -2653,7 +2649,7 @@ static void homeaxis(AxisEnum axis) {
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int axis_home_dir =
|
|
|
|
|
const int axis_home_dir =
|
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
|
(axis == X_AXIS) ? x_home_dir(active_extruder) :
|
|
|
|
|
#endif
|
|
|
|
@ -2769,13 +2765,13 @@ static void homeaxis(AxisEnum axis) {
|
|
|
|
|
|
|
|
|
|
#if ENABLED(FWRETRACT)
|
|
|
|
|
|
|
|
|
|
void retract(bool retracting, bool swapping = false) {
|
|
|
|
|
void retract(const bool retracting, const bool swapping = false) {
|
|
|
|
|
|
|
|
|
|
static float hop_height;
|
|
|
|
|
|
|
|
|
|
if (retracting == retracted[active_extruder]) return;
|
|
|
|
|
|
|
|
|
|
float old_feedrate_mm_s = feedrate_mm_s;
|
|
|
|
|
const float old_feedrate_mm_s = feedrate_mm_s;
|
|
|
|
|
|
|
|
|
|
set_destination_to_current();
|
|
|
|
|
|
|
|
|
@ -2805,7 +2801,7 @@ static void homeaxis(AxisEnum axis) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
feedrate_mm_s = retract_recover_feedrate_mm_s;
|
|
|
|
|
float move_e = swapping ? retract_length_swap + retract_recover_length_swap : retract_length + retract_recover_length;
|
|
|
|
|
const float move_e = swapping ? retract_length_swap + retract_recover_length_swap : retract_length + retract_recover_length;
|
|
|
|
|
current_position[E_AXIS] -= move_e / volumetric_multiplier[active_extruder];
|
|
|
|
|
sync_plan_position_e();
|
|
|
|
|
|
|
|
|
@ -2824,11 +2820,11 @@ static void homeaxis(AxisEnum axis) {
|
|
|
|
|
|
|
|
|
|
void normalize_mix() {
|
|
|
|
|
float mix_total = 0.0;
|
|
|
|
|
for (int i = 0; i < MIXING_STEPPERS; i++) mix_total += RECIPROCAL(mixing_factor[i]);
|
|
|
|
|
for (uint8_t i = 0; i < MIXING_STEPPERS; i++) mix_total += RECIPROCAL(mixing_factor[i]);
|
|
|
|
|
// Scale all values if they don't add up to ~1.0
|
|
|
|
|
if (!NEAR(mix_total, 1.0)) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Warning: Mix factors must add up to 1.0. Scaling.");
|
|
|
|
|
for (int i = 0; i < MIXING_STEPPERS; i++) mixing_factor[i] *= mix_total;
|
|
|
|
|
for (uint8_t i = 0; i < MIXING_STEPPERS; i++) mixing_factor[i] *= mix_total;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2908,7 +2904,7 @@ void unknown_command_error() {
|
|
|
|
|
* while the machine is not accepting commands.
|
|
|
|
|
*/
|
|
|
|
|
void host_keepalive() {
|
|
|
|
|
millis_t ms = millis();
|
|
|
|
|
const millis_t ms = millis();
|
|
|
|
|
if (host_keepalive_interval && busy_state != NOT_BUSY) {
|
|
|
|
|
if (PENDING(ms, next_busy_signal_ms)) return;
|
|
|
|
|
switch (busy_state) {
|
|
|
|
@ -2984,7 +2980,7 @@ inline void gcode_G0_G1(
|
|
|
|
|
#if ENABLED(FWRETRACT)
|
|
|
|
|
|
|
|
|
|
if (autoretract_enabled && !(code_seen('X') || code_seen('Y') || code_seen('Z')) && code_seen('E')) {
|
|
|
|
|
float echange = destination[E_AXIS] - current_position[E_AXIS];
|
|
|
|
|
const float echange = destination[E_AXIS] - current_position[E_AXIS];
|
|
|
|
|
// Is this move an attempt to retract or recover?
|
|
|
|
|
if ((echange < -MIN_RETRACT && !retracted[active_extruder]) || (echange > MIN_RETRACT && retracted[active_extruder])) {
|
|
|
|
|
current_position[E_AXIS] = destination[E_AXIS]; // hide the slicer-generated retract/recover from calculations
|
|
|
|
@ -3032,7 +3028,7 @@ inline void gcode_G0_G1(
|
|
|
|
|
if (IsRunning()) {
|
|
|
|
|
|
|
|
|
|
#if ENABLED(SF_ARC_FIX)
|
|
|
|
|
bool relative_mode_backup = relative_mode;
|
|
|
|
|
const bool relative_mode_backup = relative_mode;
|
|
|
|
|
relative_mode = true;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -3113,7 +3109,7 @@ inline void gcode_G4() {
|
|
|
|
|
|
|
|
|
|
gcode_get_destination();
|
|
|
|
|
|
|
|
|
|
float offset[] = {
|
|
|
|
|
const float offset[] = {
|
|
|
|
|
code_seen('I') ? code_value_axis_units(X_AXIS) : 0.0,
|
|
|
|
|
code_seen('J') ? code_value_axis_units(Y_AXIS) : 0.0,
|
|
|
|
|
code_seen('P') ? code_value_axis_units(X_AXIS) : 0.0,
|
|
|
|
@ -3155,9 +3151,9 @@ inline void gcode_G4() {
|
|
|
|
|
// Don't allow nozzle cleaning without homing first
|
|
|
|
|
if (axis_unhomed_error(true, true, true)) { return; }
|
|
|
|
|
|
|
|
|
|
uint8_t const pattern = code_seen('P') ? code_value_ushort() : 0;
|
|
|
|
|
uint8_t const strokes = code_seen('S') ? code_value_ushort() : NOZZLE_CLEAN_STROKES;
|
|
|
|
|
uint8_t const objects = code_seen('T') ? code_value_ushort() : NOZZLE_CLEAN_TRIANGLES;
|
|
|
|
|
const uint8_t pattern = code_seen('P') ? code_value_ushort() : 0,
|
|
|
|
|
strokes = code_seen('S') ? code_value_ushort() : NOZZLE_CLEAN_STROKES,
|
|
|
|
|
objects = code_seen('T') ? code_value_ushort() : NOZZLE_CLEAN_TRIANGLES;
|
|
|
|
|
|
|
|
|
|
Nozzle::clean(pattern, strokes, objects);
|
|
|
|
|
}
|
|
|
|
@ -3181,9 +3177,8 @@ inline void gcode_G4() {
|
|
|
|
|
*/
|
|
|
|
|
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);
|
|
|
|
|
if (axis_unhomed_error(true, true, true)) return;
|
|
|
|
|
Nozzle::park(code_seen('P') ? code_value_ushort() : 0);
|
|
|
|
|
}
|
|
|
|
|
#endif // NOZZLE_PARK_FEATURE
|
|
|
|
|
|
|
|
|
@ -3195,7 +3190,7 @@ inline void gcode_G4() {
|
|
|
|
|
current_position[X_AXIS] = current_position[Y_AXIS] = 0.0;
|
|
|
|
|
sync_plan_position();
|
|
|
|
|
|
|
|
|
|
int x_axis_home_dir =
|
|
|
|
|
const int x_axis_home_dir =
|
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
|
x_home_dir(active_extruder)
|
|
|
|
|
#else
|
|
|
|
@ -3203,15 +3198,14 @@ inline void gcode_G4() {
|
|
|
|
|
#endif
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
float mlx = max_length(X_AXIS),
|
|
|
|
|
mly = max_length(Y_AXIS),
|
|
|
|
|
mlratio = mlx > mly ? mly / mlx : mlx / mly,
|
|
|
|
|
fr_mm_s = min(homing_feedrate_mm_s[X_AXIS], homing_feedrate_mm_s[Y_AXIS]) * sqrt(sq(mlratio) + 1.0);
|
|
|
|
|
const float mlx = max_length(X_AXIS),
|
|
|
|
|
mly = max_length(Y_AXIS),
|
|
|
|
|
mlratio = mlx > mly ? mly / mlx : mlx / mly,
|
|
|
|
|
fr_mm_s = min(homing_feedrate_mm_s[X_AXIS], homing_feedrate_mm_s[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_s);
|
|
|
|
|
endstops.hit_on_purpose(); // clear endstop hit flags
|
|
|
|
|
current_position[X_AXIS] = current_position[Y_AXIS] = 0.0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // QUICK_HOME
|
|
|
|
@ -3459,7 +3453,7 @@ inline void gcode_G28() {
|
|
|
|
|
|
|
|
|
|
// Always home with tool 0 active
|
|
|
|
|
#if HOTENDS > 1
|
|
|
|
|
uint8_t old_tool_index = active_extruder;
|
|
|
|
|
const uint8_t old_tool_index = active_extruder;
|
|
|
|
|
tool_change(0, 0, true);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -3504,9 +3498,8 @@ inline void gcode_G28() {
|
|
|
|
|
|
|
|
|
|
#else // NOT DELTA
|
|
|
|
|
|
|
|
|
|
bool homeX = code_seen('X'), homeY = code_seen('Y'), homeZ = code_seen('Z');
|
|
|
|
|
|
|
|
|
|
home_all_axis = (!homeX && !homeY && !homeZ) || (homeX && homeY && homeZ);
|
|
|
|
|
const bool homeX = code_seen('X'), homeY = code_seen('Y'), homeZ = code_seen('Z'),
|
|
|
|
|
home_all_axis = (!homeX && !homeY && !homeZ) || (homeX && homeY && homeZ);
|
|
|
|
|
|
|
|
|
|
set_destination_to_current();
|
|
|
|
|
|
|
|
|
@ -3692,8 +3685,8 @@ inline void gcode_G28() {
|
|
|
|
|
|
|
|
|
|
#if ENABLED(MESH_BED_LEVELING)
|
|
|
|
|
|
|
|
|
|
inline void _mbl_goto_xy(float x, float y) {
|
|
|
|
|
float old_feedrate_mm_s = feedrate_mm_s;
|
|
|
|
|
inline void _mbl_goto_xy(const float &x, const float &y) {
|
|
|
|
|
const float old_feedrate_mm_s = feedrate_mm_s;
|
|
|
|
|
feedrate_mm_s = homing_feedrate_mm_s[Z_AXIS];
|
|
|
|
|
|
|
|
|
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
|
|
|
|
@ -3760,8 +3753,8 @@ inline void gcode_G28() {
|
|
|
|
|
*/
|
|
|
|
|
inline void gcode_G29() {
|
|
|
|
|
|
|
|
|
|
static int probe_point = -1;
|
|
|
|
|
MeshLevelingState state = code_seen('S') ? (MeshLevelingState)code_value_byte() : MeshReport;
|
|
|
|
|
static int probe_index = -1;
|
|
|
|
|
const MeshLevelingState state = code_seen('S') ? (MeshLevelingState)code_value_byte() : MeshReport;
|
|
|
|
|
if (state < 0 || state > 5) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("S out of range (0-5).");
|
|
|
|
|
return;
|
|
|
|
@ -3781,17 +3774,17 @@ inline void gcode_G28() {
|
|
|
|
|
|
|
|
|
|
case MeshStart:
|
|
|
|
|
mbl.reset();
|
|
|
|
|
probe_point = 0;
|
|
|
|
|
probe_index = 0;
|
|
|
|
|
enqueue_and_echo_commands_P(PSTR("G28\nG29 S2"));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MeshNext:
|
|
|
|
|
if (probe_point < 0) {
|
|
|
|
|
if (probe_index < 0) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Start mesh probing with \"G29 S1\" first.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// For each G29 S2...
|
|
|
|
|
if (probe_point == 0) {
|
|
|
|
|
if (probe_index == 0) {
|
|
|
|
|
// For the initial G29 S2 make Z a positive value (e.g., 4.0)
|
|
|
|
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
|
|
|
|
|
#if Z_HOME_DIR > 0
|
|
|
|
@ -3802,13 +3795,13 @@ inline void gcode_G28() {
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// For G29 S2 after adjusting Z.
|
|
|
|
|
mbl.set_zigzag_z(probe_point - 1, current_position[Z_AXIS]);
|
|
|
|
|
mbl.set_zigzag_z(probe_index - 1, current_position[Z_AXIS]);
|
|
|
|
|
}
|
|
|
|
|
// If there's another point to sample, move there with optional lift.
|
|
|
|
|
if (probe_point < (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
|
|
|
|
|
mbl.zigzag(probe_point, px, py);
|
|
|
|
|
if (probe_index < (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
|
|
|
|
|
mbl.zigzag(probe_index, px, py);
|
|
|
|
|
_mbl_goto_xy(mbl.get_probe_x(px), mbl.get_probe_y(py));
|
|
|
|
|
probe_point++;
|
|
|
|
|
probe_index++;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// One last "return to the bed" (as originally coded) at completion
|
|
|
|
@ -3824,7 +3817,7 @@ inline void gcode_G28() {
|
|
|
|
|
|
|
|
|
|
// After recording the last point, activate the mbl and home
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("Mesh probing done.");
|
|
|
|
|
probe_point = -1;
|
|
|
|
|
probe_index = -1;
|
|
|
|
|
mbl.set_has_mesh(true);
|
|
|
|
|
enqueue_and_echo_commands_P(PSTR("G28"));
|
|
|
|
|
}
|
|
|
|
@ -3936,8 +3929,8 @@ inline void gcode_G28() {
|
|
|
|
|
inline void gcode_G29() {
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
bool query = code_seen('Q');
|
|
|
|
|
uint8_t old_debug_flags = marlin_debug_flags;
|
|
|
|
|
const bool query = code_seen('Q');
|
|
|
|
|
const uint8_t old_debug_flags = marlin_debug_flags;
|
|
|
|
|
if (query) marlin_debug_flags |= DEBUG_LEVELING;
|
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
|
DEBUG_POS(">>> gcode_G29", current_position);
|
|
|
|
@ -3950,7 +3943,7 @@ inline void gcode_G28() {
|
|
|
|
|
// Don't allow auto-leveling without homing first
|
|
|
|
|
if (axis_unhomed_error(true, true, true)) return;
|
|
|
|
|
|
|
|
|
|
int verbose_level = code_seen('V') ? code_value_int() : 1;
|
|
|
|
|
const int verbose_level = code_seen('V') ? code_value_int() : 1;
|
|
|
|
|
if (verbose_level < 0 || verbose_level > 4) {
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("?(V)erbose Level is implausible (0-4).");
|
|
|
|
|
return;
|
|
|
|
@ -3995,14 +3988,14 @@ inline void gcode_G28() {
|
|
|
|
|
front_probe_bed_position = code_seen('F') ? (int)code_value_axis_units(Y_AXIS) : LOGICAL_Y_POSITION(FRONT_PROBE_BED_POSITION),
|
|
|
|
|
back_probe_bed_position = code_seen('B') ? (int)code_value_axis_units(Y_AXIS) : LOGICAL_Y_POSITION(BACK_PROBE_BED_POSITION);
|
|
|
|
|
|
|
|
|
|
bool left_out_l = left_probe_bed_position < LOGICAL_X_POSITION(MIN_PROBE_X),
|
|
|
|
|
left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - (MIN_PROBE_EDGE),
|
|
|
|
|
right_out_r = right_probe_bed_position > LOGICAL_X_POSITION(MAX_PROBE_X),
|
|
|
|
|
right_out = right_out_r || right_probe_bed_position < left_probe_bed_position + MIN_PROBE_EDGE,
|
|
|
|
|
front_out_f = front_probe_bed_position < LOGICAL_Y_POSITION(MIN_PROBE_Y),
|
|
|
|
|
front_out = front_out_f || front_probe_bed_position > back_probe_bed_position - (MIN_PROBE_EDGE),
|
|
|
|
|
back_out_b = back_probe_bed_position > LOGICAL_Y_POSITION(MAX_PROBE_Y),
|
|
|
|
|
back_out = back_out_b || back_probe_bed_position < front_probe_bed_position + MIN_PROBE_EDGE;
|
|
|
|
|
const bool left_out_l = left_probe_bed_position < LOGICAL_X_POSITION(MIN_PROBE_X),
|
|
|
|
|
left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - (MIN_PROBE_EDGE),
|
|
|
|
|
right_out_r = right_probe_bed_position > LOGICAL_X_POSITION(MAX_PROBE_X),
|
|
|
|
|
right_out = right_out_r || right_probe_bed_position < left_probe_bed_position + MIN_PROBE_EDGE,
|
|
|
|
|
front_out_f = front_probe_bed_position < LOGICAL_Y_POSITION(MIN_PROBE_Y),
|
|
|
|
|
front_out = front_out_f || front_probe_bed_position > back_probe_bed_position - (MIN_PROBE_EDGE),
|
|
|
|
|
back_out_b = back_probe_bed_position > LOGICAL_Y_POSITION(MAX_PROBE_Y),
|
|
|
|
|
back_out = back_out_b || back_probe_bed_position < front_probe_bed_position + MIN_PROBE_EDGE;
|
|
|
|
|
|
|
|
|
|
if (left_out || right_out || front_out || back_out) {
|
|
|
|
|
if (left_out) {
|
|
|
|
@ -4068,8 +4061,10 @@ inline void gcode_G28() {
|
|
|
|
|
|| left_probe_bed_position != bilinear_start[X_AXIS]
|
|
|
|
|
|| front_probe_bed_position != bilinear_start[Y_AXIS]
|
|
|
|
|
) {
|
|
|
|
|
// Before reset bed level, re-enable to correct the position
|
|
|
|
|
planner.abl_enabled = abl_should_enable;
|
|
|
|
|
if (dryrun) {
|
|
|
|
|
// Before reset bed level, re-enable to correct the position
|
|
|
|
|
planner.abl_enabled = abl_should_enable;
|
|
|
|
|
}
|
|
|
|
|
// Reset grid to 0.0 or "not probed". (Also disables ABL)
|
|
|
|
|
reset_bed_level();
|
|
|
|
|
|
|
|
|
@ -4097,9 +4092,10 @@ inline void gcode_G28() {
|
|
|
|
|
* so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int abl2 = abl_grid_points_x * abl_grid_points_y,
|
|
|
|
|
indexIntoAB[abl_grid_points_x][abl_grid_points_y],
|
|
|
|
|
probePointCounter = -1;
|
|
|
|
|
const int abl2 = abl_grid_points_x * abl_grid_points_y;
|
|
|
|
|
|
|
|
|
|
int indexIntoAB[abl_grid_points_x][abl_grid_points_y],
|
|
|
|
|
probe_index = -1;
|
|
|
|
|
|
|
|
|
|
float eqnAMatrix[abl2 * 3], // "A" matrix of the linear system of equations
|
|
|
|
|
eqnBVector[abl2], // "B" vector of Z points
|
|
|
|
@ -4109,30 +4105,30 @@ inline void gcode_G28() {
|
|
|
|
|
|
|
|
|
|
#if ENABLED(PROBE_Y_FIRST)
|
|
|
|
|
#define PR_OUTER_VAR xCount
|
|
|
|
|
#define PR_OUTER_END abl_grid_points_x
|
|
|
|
|
#define PR_OUTER_NUM abl_grid_points_x
|
|
|
|
|
#define PR_INNER_VAR yCount
|
|
|
|
|
#define PR_INNER_END abl_grid_points_y
|
|
|
|
|
#define PR_INNER_NUM abl_grid_points_y
|
|
|
|
|
#else
|
|
|
|
|
#define PR_OUTER_VAR yCount
|
|
|
|
|
#define PR_OUTER_END abl_grid_points_y
|
|
|
|
|
#define PR_OUTER_NUM abl_grid_points_y
|
|
|
|
|
#define PR_INNER_VAR xCount
|
|
|
|
|
#define PR_INNER_END abl_grid_points_x
|
|
|
|
|
#define PR_INNER_NUM abl_grid_points_x
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
bool zig = PR_OUTER_END & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION
|
|
|
|
|
bool zig = PR_OUTER_NUM & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION
|
|
|
|
|
|
|
|
|
|
// Outer loop is Y with PROBE_Y_FIRST disabled
|
|
|
|
|
for (uint8_t PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_END; PR_OUTER_VAR++) {
|
|
|
|
|
for (uint8_t PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_NUM; PR_OUTER_VAR++) {
|
|
|
|
|
|
|
|
|
|
int8_t inStart, inStop, inInc;
|
|
|
|
|
|
|
|
|
|
if (zig) { // away from origin
|
|
|
|
|
inStart = 0;
|
|
|
|
|
inStop = PR_INNER_END;
|
|
|
|
|
inStop = PR_INNER_NUM;
|
|
|
|
|
inInc = 1;
|
|
|
|
|
}
|
|
|
|
|
else { // towards origin
|
|
|
|
|
inStart = PR_INNER_END - 1;
|
|
|
|
|
inStart = PR_INNER_NUM - 1;
|
|
|
|
|
inStop = -1;
|
|
|
|
|
inInc = -1;
|
|
|
|
|
}
|
|
|
|
@ -4149,7 +4145,7 @@ inline void gcode_G28() {
|
|
|
|
|
yProbe = floor(yBase + (yBase < 0 ? 0 : 0.5));
|
|
|
|
|
|
|
|
|
|
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
|
|
|
|
indexIntoAB[xCount][yCount] = ++probePointCounter;
|
|
|
|
|
indexIntoAB[xCount][yCount] = ++probe_index;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if IS_KINEMATIC
|
|
|
|
@ -4168,10 +4164,10 @@ inline void gcode_G28() {
|
|
|
|
|
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
|
|
|
|
|
|
|
|
|
mean += measured_z;
|
|
|
|
|
eqnBVector[probePointCounter] = measured_z;
|
|
|
|
|
eqnAMatrix[probePointCounter + 0 * abl2] = xProbe;
|
|
|
|
|
eqnAMatrix[probePointCounter + 1 * abl2] = yProbe;
|
|
|
|
|
eqnAMatrix[probePointCounter + 2 * abl2] = 1;
|
|
|
|
|
eqnBVector[probe_index] = measured_z;
|
|
|
|
|
eqnAMatrix[probe_index + 0 * abl2] = xProbe;
|
|
|
|
|
eqnAMatrix[probe_index + 1 * abl2] = yProbe;
|
|
|
|
|
eqnAMatrix[probe_index + 2 * abl2] = 1;
|
|
|
|
|
|
|
|
|
|
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
|
|
|
|
|
|
|
|
@ -4181,8 +4177,8 @@ inline void gcode_G28() {
|
|
|
|
|
|
|
|
|
|
idle();
|
|
|
|
|
|
|
|
|
|
} //xProbe
|
|
|
|
|
} //yProbe
|
|
|
|
|
} // inner
|
|
|
|
|
} // outer
|
|
|
|
|
|
|
|
|
|
#elif ENABLED(AUTO_BED_LEVELING_3POINT)
|
|
|
|
|
|
|
|
|
@ -7860,9 +7856,9 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
|
|
|
|
if (tmp_extruder >= EXTRUDERS)
|
|
|
|
|
return invalid_extruder_error(tmp_extruder);
|
|
|
|
|
|
|
|
|
|
float old_feedrate_mm_s = feedrate_mm_s;
|
|
|
|
|
const float old_feedrate_mm_s = fr_mm_s > 0.0 ? fr_mm_s : feedrate_mm_s;
|
|
|
|
|
|
|
|
|
|
feedrate_mm_s = fr_mm_s > 0.0 ? (old_feedrate_mm_s = fr_mm_s) : XY_PROBE_FEEDRATE_MM_S;
|
|
|
|
|
feedrate_mm_s = fr_mm_s > 0.0 ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
|
|
|
|
|
|
|
|
|
|
if (tmp_extruder != active_extruder) {
|
|
|
|
|
if (!no_move && axis_unhomed_error(true, true, true)) {
|
|
|
|
|