Apply Marlin conventions to M851

2.0.x
Scott Lahteine 5 years ago
parent e9cf46a9a5
commit da1bda493e

@ -35,36 +35,46 @@ void GcodeSuite::M851() {
// Show usage with no parameters
if (!parser.seen("XYZ")) {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET " X", probe_offset[X_AXIS],
" Y", probe_offset[Y_AXIS],
" Z", probe_offset[Z_AXIS]);
SERIAL_ECHO_MSG(MSG_PROBE_OFFSET " X", probe_offset[X_AXIS], " Y", probe_offset[Y_AXIS], " Z", probe_offset[Z_AXIS]);
return;
}
// Get the modified offsets
const float offs[] = {
parser.floatval('X', probe_offset[X_AXIS]),
parser.floatval('Y', probe_offset[Y_AXIS]),
parser.floatval('Z', probe_offset[Z_AXIS])
};
float offs[XYZ] = { probe_offset[X_AXIS], probe_offset[Y_AXIS], probe_offset[Z_AXIS] };
// Error-check
if (!WITHIN(offs[X_AXIS], -(X_BED_SIZE), X_BED_SIZE)) {
SERIAL_ERROR_MSG("?X out of range (-" STRINGIFY(X_BED_SIZE) " to " STRINGIFY(X_BED_SIZE) ")");
return;
const bool ok = true;
if (parser.seenval('X')) {
const float x = parser.value_float();
if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE))
offs[X_AXIS] = x;
else {
SERIAL_ECHOLNPAIR("?X out of range (-", int(X_BED_SIZE), " to ", int(X_BED_SIZE), ")");
ok = false;
}
if (!WITHIN(offs[Y_AXIS], -(Y_BED_SIZE), Y_BED_SIZE)) {
SERIAL_ERROR_MSG("?Y out of range (-" STRINGIFY(Y_BED_SIZE) " to " STRINGIFY(Y_BED_SIZE) ")");
return;
}
if (!WITHIN(offs[Z_AXIS], Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
SERIAL_ERROR_MSG("?Z out of range (" STRINGIFY(Z_PROBE_OFFSET_RANGE_MIN) " to " STRINGIFY(Z_PROBE_OFFSET_RANGE_MAX) ")");
return;
if (parser.seenval('Y')) {
const float y = parser.value_float();
if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE))
offs[Y_AXIS] = y;
else {
SERIAL_ECHOLNPAIR("?Y out of range (-", int(Y_BED_SIZE), " to ", int(Y_BED_SIZE), ")");
ok = false;
}
}
if (parser.seenval('Z')) {
const float z = parser.value_float();
if (WITHIN(z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX))
offs[Z_AXIS] = z;
else {
SERIAL_ECHOLNPAIR("?Z out of range (", int(Z_PROBE_OFFSET_RANGE_MIN), " to ", int(Z_PROBE_OFFSET_RANGE_MAX), ")");
ok = false;
}
}
// Save the new offsets
LOOP_XYZ(a) probe_offset[a] = offs[a];
if (ok) COPY(probe_offset, offs);
}
#endif // HAS_BED_PROBE

Loading…
Cancel
Save