Skip to content

Commit

Permalink
Merge branch '17-add-m48-message-about-movement' into 'master'
Browse files Browse the repository at this point in the history
Resolve "Add M48 Message about movement"

Closes MarlinFirmware#17

See merge request lulzbot3d/marlin!17
  • Loading branch information
dcoleman-lulzbot committed Sep 17, 2021
2 parents 78d9ce9 + b97cdbb commit ef77725
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions Marlin/src/gcode/calibrate/M48.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,30 @@ void GcodeSuite::M48() {

const ProbePtRaise raise_after = parser.boolval('E') ? PROBE_PT_STOW : PROBE_PT_RAISE;

constexpr xy_pos_t probe_point = PROBE_SAFE_POINT;
do_blocking_move_to_xy(probe_point); //moving toolhead to a safe probing point

// Test at the current position by default, overridden by X and Y
const xy_pos_t test_position = {
parser.linearval('X', current_position.x + probe.offset_xy.x), // If no X use the probe's current X position
parser.linearval('Y', current_position.y + probe.offset_xy.y) // If no Y, ditto
constexpr xy_pos_t safe_point = PROBE_SAFE_POINT;

// Test at PROBE_SAFE_POINT by default, overridden by X and Y
// If either X or Y is specified, the current position will be used for the
// other coordinate.
xy_pos_t test_position = {
parser.linearval('X', safe_point.x), // If no X use PROBE_SAFE_POINT
parser.linearval('Y', safe_point.y) // If no Y, ditto
};

if (test_position == safe_point) {
SERIAL_ECHOLNPGM("Moving to safe position for probe.");
} else {
// If a coordinate is equal to the safe point coordinate, it was not set by an argument.
// In the case of one coordinate being set, use the current position as the default for the unset coordinate instead of the safe point's coordinate.
if(test_position.x == safe_point.x) {
test_position.x = current_position.x + probe.offset_xy.x;
}
if(test_position.y == safe_point.y) {
test_position.y = current_position.y + probe.offset_xy.y;
}
}


if (!probe.can_reach(test_position)) {
ui.set_status_P(GET_TEXT(MSG_M48_OUT_OF_BOUNDS), 99);
SERIAL_ECHOLNPGM("? (X,Y) out of bounds.");
Expand Down

0 comments on commit ef77725

Please sign in to comment.