Apply home offsets to probing, Z Safe Homing (#19423)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
InsanityAutomation 2020-10-18 16:53:12 -04:00 committed by GitHub
parent b0f0dc683d
commit 6375829448
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 57 deletions

View File

@ -361,32 +361,24 @@ G29_TYPE GcodeSuite::G29() {
if (parser.seen('H')) { if (parser.seen('H')) {
const int16_t size = (int16_t)parser.value_linear_units(); const int16_t size = (int16_t)parser.value_linear_units();
probe_position_lf.set( probe_position_lf.set(_MAX((X_CENTER) - size / 2, x_min), _MAX((Y_CENTER) - size / 2, y_min));
_MAX(X_CENTER - size / 2, x_min), probe_position_rb.set(_MIN(probe_position_lf.x + size, x_max), _MIN(probe_position_lf.y + size, y_max));
_MAX(Y_CENTER - size / 2, y_min)
);
probe_position_rb.set(
_MIN(probe_position_lf.x + size, x_max),
_MIN(probe_position_lf.y + size, y_max)
);
} }
else { else {
probe_position_lf.set( probe_position_lf.set(parser.linearval('L', x_min), parser.linearval('F', y_min));
parser.seenval('L') ? RAW_X_POSITION(parser.value_linear_units()) : x_min, probe_position_rb.set(parser.linearval('R', x_max), parser.linearval('B', y_max));
parser.seenval('F') ? RAW_Y_POSITION(parser.value_linear_units()) : y_min
);
probe_position_rb.set(
parser.seenval('R') ? RAW_X_POSITION(parser.value_linear_units()) : x_max,
parser.seenval('B') ? RAW_Y_POSITION(parser.value_linear_units()) : y_max
);
} }
if (!probe.good_bounds(probe_position_lf, probe_position_rb)) { if (!probe.good_bounds(probe_position_lf, probe_position_rb)) {
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPAIR("G29 L", probe_position_lf.x, " R", probe_position_rb.x,
" F", probe_position_lf.y, " B", probe_position_rb.y);
}
SERIAL_ECHOLNPGM("? (L,R,F,B) out of bounds."); SERIAL_ECHOLNPGM("? (L,R,F,B) out of bounds.");
G29_RETURN(false); G29_RETURN(false);
} }
// probe at the points of a lattice grid // Probe at the points of a lattice grid
gridSpacing.set((probe_position_rb.x - probe_position_lf.x) / (abl_grid_points.x - 1), gridSpacing.set((probe_position_rb.x - probe_position_lf.x) / (abl_grid_points.x - 1),
(probe_position_rb.y - probe_position_lf.y) / (abl_grid_points.y - 1)); (probe_position_rb.y - probe_position_lf.y) / (abl_grid_points.y - 1));

View File

@ -126,7 +126,15 @@
* Move the Z probe (or just the nozzle) to the safe homing point * Move the Z probe (or just the nozzle) to the safe homing point
* (Z is already at the right height) * (Z is already at the right height)
*/ */
destination.set(safe_homing_xy, current_position.z); constexpr xy_float_t safe_homing_xy = { Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT };
#if HAS_HOME_OFFSET
xy_float_t okay_homing_xy = safe_homing_xy;
okay_homing_xy -= home_offset;
#else
constexpr xy_float_t okay_homing_xy = safe_homing_xy;
#endif
destination.set(okay_homing_xy, current_position.z);
TERN_(HOMING_Z_WITH_PROBE, destination -= probe.offset_xy); TERN_(HOMING_Z_WITH_PROBE, destination -= probe.offset_xy);

View File

@ -28,6 +28,13 @@
#include "../../module/motion.h" #include "../../module/motion.h"
#include "../../lcd/marlinui.h" #include "../../lcd/marlinui.h"
#include "../../libs/buzzer.h" #include "../../libs/buzzer.h"
#include "../../MarlinCore.h"
extern const char SP_Y_STR[], SP_Z_STR[];
void m206_report() {
SERIAL_ECHOLNPAIR_P(PSTR("M206 X"), home_offset.x, SP_Y_STR, home_offset.y, SP_Z_STR, home_offset.z);
}
/** /**
* M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y * M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y
@ -46,6 +53,9 @@ void GcodeSuite::M206() {
if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_float()); // Psi if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_float()); // Psi
#endif #endif
if (!parser.seen("XYZ"))
m206_report();
else
report_current_position(); report_current_position();
} }

View File

@ -78,10 +78,6 @@ extern xyz_pos_t cartes;
#define XY_PROBE_FEEDRATE_MM_S PLANNER_XY_FEEDRATE() #define XY_PROBE_FEEDRATE_MM_S PLANNER_XY_FEEDRATE()
#endif #endif
#if ENABLED(Z_SAFE_HOMING)
constexpr xy_float_t safe_homing_xy = { Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT };
#endif
/** /**
* Feed rates are often configured with mm/m * Feed rates are often configured with mm/m
* but the planner and stepper like mm/s units. * but the planner and stepper like mm/s units.

View File

@ -133,53 +133,37 @@ public:
#if HAS_BED_PROBE || HAS_LEVELING #if HAS_BED_PROBE || HAS_LEVELING
#if IS_KINEMATIC #if IS_KINEMATIC
static constexpr float printable_radius = ( static constexpr float printable_radius = (
#if ENABLED(DELTA) TERN_(DELTA, DELTA_PRINTABLE_RADIUS)
DELTA_PRINTABLE_RADIUS TERN_(IS_SCARA, SCARA_PRINTABLE_RADIUS)
#elif IS_SCARA
SCARA_PRINTABLE_RADIUS
#endif
); );
static inline float probe_radius() { static inline float probe_radius() {
return printable_radius - _MAX(PROBING_MARGIN, HYPOT(offset_xy.x, offset_xy.y)); return printable_radius - _MAX(PROBING_MARGIN, HYPOT(offset_xy.x, offset_xy.y));
} }
#endif #endif
static inline float min_x() { static inline float min_x() {
return ( return TERN(IS_KINEMATIC,
#if IS_KINEMATIC (X_CENTER) - probe_radius(),
(X_CENTER) - probe_radius()
#else
_MAX((X_MIN_BED) + (PROBING_MARGIN_LEFT), (X_MIN_POS) + offset_xy.x) _MAX((X_MIN_BED) + (PROBING_MARGIN_LEFT), (X_MIN_POS) + offset_xy.x)
#endif ) - TERN0(NOZZLE_AS_PROBE, home_offset.x);
);
} }
static inline float max_x() { static inline float max_x() {
return ( return TERN(IS_KINEMATIC,
#if IS_KINEMATIC (X_CENTER) + probe_radius(),
(X_CENTER) + probe_radius()
#else
_MIN((X_MAX_BED) - (PROBING_MARGIN_RIGHT), (X_MAX_POS) + offset_xy.x) _MIN((X_MAX_BED) - (PROBING_MARGIN_RIGHT), (X_MAX_POS) + offset_xy.x)
#endif ) - TERN0(NOZZLE_AS_PROBE, home_offset.x);
);
} }
static inline float min_y() { static inline float min_y() {
return ( return TERN(IS_KINEMATIC,
#if IS_KINEMATIC (Y_CENTER) - probe_radius(),
(Y_CENTER) - probe_radius()
#else
_MAX((Y_MIN_BED) + (PROBING_MARGIN_FRONT), (Y_MIN_POS) + offset_xy.y) _MAX((Y_MIN_BED) + (PROBING_MARGIN_FRONT), (Y_MIN_POS) + offset_xy.y)
#endif ) - TERN0(NOZZLE_AS_PROBE, home_offset.y);
);
} }
static inline float max_y() { static inline float max_y() {
return ( return TERN(IS_KINEMATIC,
#if IS_KINEMATIC (Y_CENTER) + probe_radius(),
(Y_CENTER) + probe_radius()
#else
_MIN((Y_MAX_BED) - (PROBING_MARGIN_BACK), (Y_MAX_POS) + offset_xy.y) _MIN((Y_MAX_BED) - (PROBING_MARGIN_BACK), (Y_MAX_POS) + offset_xy.y)
#endif ) - TERN0(NOZZLE_AS_PROBE, home_offset.y);
);
} }
#if NEEDS_THREE_PROBE_POINTS #if NEEDS_THREE_PROBE_POINTS