Move reachable test to Probe class

This commit is contained in:
Scott Lahteine
2020-02-27 06:16:33 -06:00
parent 9f8ee31144
commit be62ab2d02
9 changed files with 69 additions and 77 deletions

View File

@ -432,11 +432,11 @@ void GcodeSuite::M422() {
};
if (is_probe_point) {
if (!position_is_reachable_by_probe(pos.x, Y_CENTER)) {
if (!probe.can_reach(pos.x, Y_CENTER)) {
SERIAL_ECHOLNPGM("?(X) out of bounds.");
return;
}
if (!position_is_reachable_by_probe(pos)) {
if (!probe.can_reach(pos)) {
SERIAL_ECHOLNPGM("?(Y) out of bounds.");
return;
}

View File

@ -116,7 +116,7 @@ void GcodeSuite::G76() {
temp_comp.measure_point_x - probe.offset_xy.x,
temp_comp.measure_point_y - probe.offset_xy.y
);
if (!position_is_reachable_by_probe(destination)) {
if (!probe.can_reach(destination)) {
SERIAL_ECHOLNPGM("!Probe position unreachable - aborting.");
return;
}

View File

@ -80,11 +80,11 @@ void GcodeSuite::M48() {
xy_float_t next_pos = current_position;
const xy_pos_t probe_pos = {
parser.linearval('X', next_pos.x + probe.offset_xy.x),
parser.linearval('Y', next_pos.y + probe.offset_xy.y)
parser.linearval('X', next_pos.x + probe.offset_xy.x), // If no X use the probe's current X position
parser.linearval('Y', next_pos.y + probe.offset_xy.y) // If no Y, ditto
};
if (!position_is_reachable_by_probe(probe_pos)) {
if (!probe.can_reach(probe_pos)) {
SERIAL_ECHOLNPGM("? (X,Y) out of bounds.");
return;
}
@ -179,7 +179,7 @@ void GcodeSuite::M48() {
#else
// If we have gone out too far, we can do a simple fix and scale the numbers
// back in closer to the origin.
while (!position_is_reachable_by_probe(next_pos)) {
while (!probe.can_reach(next_pos)) {
next_pos *= 0.8f;
if (verbose_level > 3)
SERIAL_ECHOLNPAIR_P(PSTR("Moving inward: X"), next_pos.x, SP_Y_STR, next_pos.y);