Add custom types for position (#15204)
This commit is contained in:
@@ -39,10 +39,10 @@
|
||||
* E Engage the probe for each probe (default 1)
|
||||
*/
|
||||
void GcodeSuite::G30() {
|
||||
const float xpos = parser.linearval('X', current_position[X_AXIS] + probe_offset[X_AXIS]),
|
||||
ypos = parser.linearval('Y', current_position[Y_AXIS] + probe_offset[Y_AXIS]);
|
||||
const xy_pos_t pos = { parser.linearval('X', current_position.x + probe_offset.x),
|
||||
parser.linearval('Y', current_position.y + probe_offset.y) };
|
||||
|
||||
if (!position_is_reachable_by_probe(xpos, ypos)) return;
|
||||
if (!position_is_reachable_by_probe(pos)) return;
|
||||
|
||||
// Disable leveling so the planner won't mess with us
|
||||
#if HAS_LEVELING
|
||||
@@ -52,10 +52,9 @@ void GcodeSuite::G30() {
|
||||
remember_feedrate_scaling_off();
|
||||
|
||||
const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
|
||||
const float measured_z = probe_at_point(xpos, ypos, raise_after, 1);
|
||||
|
||||
const float measured_z = probe_at_point(pos, raise_after, 1);
|
||||
if (!isnan(measured_z))
|
||||
SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(xpos), " Y: ", FIXFLOAT(ypos), " Z: ", FIXFLOAT(measured_z));
|
||||
SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(pos.x), " Y: ", FIXFLOAT(pos.y), " Z: ", FIXFLOAT(measured_z));
|
||||
|
||||
restore_feedrate_and_scaling();
|
||||
|
||||
|
@@ -48,7 +48,7 @@ inline bool G38_run_probe() {
|
||||
|
||||
#if MULTIPLE_PROBING > 1
|
||||
// Get direction of move and retract
|
||||
float retract_mm[XYZ];
|
||||
xyz_float_t retract_mm;
|
||||
LOOP_XYZ(i) {
|
||||
const float dist = destination[i] - current_position[i];
|
||||
retract_mm[i] = ABS(dist) < G38_MINIMUM_MOVE ? 0 : home_bump_mm((AxisEnum)i) * (dist > 0 ? -1 : 1);
|
||||
@@ -75,8 +75,7 @@ inline bool G38_run_probe() {
|
||||
|
||||
#if MULTIPLE_PROBING > 1
|
||||
// Move away by the retract distance
|
||||
set_destination_from_current();
|
||||
LOOP_XYZ(i) destination[i] += retract_mm[i];
|
||||
destination = current_position + retract_mm;
|
||||
endstops.enable(false);
|
||||
prepare_move_to_destination();
|
||||
planner.synchronize();
|
||||
@@ -84,7 +83,7 @@ inline bool G38_run_probe() {
|
||||
REMEMBER(fr, feedrate_mm_s, feedrate_mm_s * 0.25);
|
||||
|
||||
// Bump the target more slowly
|
||||
LOOP_XYZ(i) destination[i] -= retract_mm[i] * 2;
|
||||
destination -= retract_mm * 2;
|
||||
|
||||
G38_single_probe(move_value);
|
||||
#endif
|
||||
|
@@ -35,18 +35,18 @@ void GcodeSuite::M851() {
|
||||
|
||||
// Show usage with no parameters
|
||||
if (!parser.seen("XYZ")) {
|
||||
SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET " X", probe_offset[X_AXIS], " Y", probe_offset[Y_AXIS], " Z", probe_offset[Z_AXIS]);
|
||||
SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET " X", probe_offset.x, " Y", probe_offset.y, " Z", probe_offset.z);
|
||||
return;
|
||||
}
|
||||
|
||||
float offs[XYZ] = { probe_offset[X_AXIS], probe_offset[Y_AXIS], probe_offset[Z_AXIS] };
|
||||
xyz_pos_t offs = probe_offset;
|
||||
|
||||
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;
|
||||
offs.x = x;
|
||||
else {
|
||||
SERIAL_ECHOLNPAIR("?X out of range (-", int(X_BED_SIZE), " to ", int(X_BED_SIZE), ")");
|
||||
ok = false;
|
||||
@@ -56,7 +56,7 @@ void GcodeSuite::M851() {
|
||||
if (parser.seenval('Y')) {
|
||||
const float y = parser.value_float();
|
||||
if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE))
|
||||
offs[Y_AXIS] = y;
|
||||
offs.y = y;
|
||||
else {
|
||||
SERIAL_ECHOLNPAIR("?Y out of range (-", int(Y_BED_SIZE), " to ", int(Y_BED_SIZE), ")");
|
||||
ok = false;
|
||||
@@ -66,7 +66,7 @@ void GcodeSuite::M851() {
|
||||
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;
|
||||
offs.z = z;
|
||||
else {
|
||||
SERIAL_ECHOLNPAIR("?Z out of range (", int(Z_PROBE_OFFSET_RANGE_MIN), " to ", int(Z_PROBE_OFFSET_RANGE_MAX), ")");
|
||||
ok = false;
|
||||
@@ -74,7 +74,7 @@ void GcodeSuite::M851() {
|
||||
}
|
||||
|
||||
// Save the new offsets
|
||||
if (ok) COPY(probe_offset, offs);
|
||||
if (ok) probe_offset = offs;
|
||||
}
|
||||
|
||||
#endif // HAS_BED_PROBE
|
||||
|
Reference in New Issue
Block a user