Encapsulate probe as singleton class (#16751)
This commit is contained in:
@ -133,7 +133,7 @@
|
||||
destination.set(safe_homing_xy, current_position.z);
|
||||
|
||||
#if HOMING_Z_WITH_PROBE
|
||||
destination -= probe_offset_xy;
|
||||
destination -= probe.offset_xy;
|
||||
#endif
|
||||
|
||||
if (position_is_reachable(destination)) {
|
||||
@ -416,7 +416,7 @@ void GcodeSuite::G28(const bool always_home_all) {
|
||||
#endif
|
||||
|
||||
#if HOMING_Z_WITH_PROBE && defined(Z_AFTER_PROBING)
|
||||
move_z_after_probing();
|
||||
probe.move_z_after_probing();
|
||||
#endif
|
||||
|
||||
} // doZ
|
||||
|
@ -100,7 +100,7 @@ void ac_cleanup(
|
||||
do_blocking_move_to_z(delta_clip_start_height);
|
||||
#endif
|
||||
#if HAS_BED_PROBE
|
||||
STOW_PROBE();
|
||||
probe.stow();
|
||||
#endif
|
||||
restore_feedrate_and_scaling();
|
||||
#if HOTENDS > 1
|
||||
@ -190,7 +190,7 @@ static float std_dev_points(float z_pt[NPP + 1], const bool _0p_cal, const bool
|
||||
*/
|
||||
static float calibration_probe(const xy_pos_t &xy, const bool stow) {
|
||||
#if HAS_BED_PROBE
|
||||
return probe_at_point(xy, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true);
|
||||
return probe.probe_at_point(xy, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true);
|
||||
#else
|
||||
UNUSED(stow);
|
||||
return lcd_probe_pt(xy);
|
||||
|
@ -133,8 +133,8 @@ void GcodeSuite::G34() {
|
||||
|
||||
do { // break out on error
|
||||
|
||||
#if NUM_Z_STEPPER_DRIVERS == 4
|
||||
SERIAL_ECHOLNPGM("Quad Z Stepper Leveling not Yet Supported");
|
||||
#if NUM_Z_STEPPER_DRIVERS >= 4
|
||||
SERIAL_ECHOLNPGM("Alignment not supported for over 3 steppers");
|
||||
break;
|
||||
#endif
|
||||
|
||||
@ -240,7 +240,7 @@ void GcodeSuite::G34() {
|
||||
if (iteration == 0 || i > 0) do_blocking_move_to_z(z_probe);
|
||||
|
||||
// Probe a Z height for each stepper.
|
||||
const float z_probed_height = probe_at_point(z_stepper_align_pos[iprobe], raise_after, 0, true);
|
||||
const float z_probed_height = probe.probe_at_point(z_stepper_align_pos[iprobe], raise_after, 0, true);
|
||||
if (isnan(z_probed_height)) {
|
||||
SERIAL_ECHOLNPGM("Probing failed.");
|
||||
err_break = true;
|
||||
@ -314,7 +314,7 @@ void GcodeSuite::G34() {
|
||||
|
||||
#if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
|
||||
// Optimize one iteration's correction based on the first measurements
|
||||
if (z_align_abs > 0.0f) amplification = iteration == 1 ? _MIN(last_z_align_move[zstepper] / z_align_abs, 2.0f) : z_auto_align_amplification;
|
||||
if (z_align_abs) amplification = (iteration == 1) ? _MIN(last_z_align_move[zstepper] / z_align_abs, 2.0f) : z_auto_align_amplification;
|
||||
#endif
|
||||
|
||||
// Check for less accuracy compared to last move
|
||||
@ -379,9 +379,9 @@ void GcodeSuite::G34() {
|
||||
// After this operation the z position needs correction
|
||||
set_axis_is_not_at_home(Z_AXIS);
|
||||
|
||||
// Stow the probe, as the last call to probe_at_point(...) left
|
||||
// Stow the probe, as the last call to probe.probe_at_point(...) left
|
||||
// the probe deployed if it was successful.
|
||||
STOW_PROBE();
|
||||
probe.stow();
|
||||
|
||||
// Home Z after the alignment procedure
|
||||
process_subcommands_now_P(PSTR("G28 Z"));
|
||||
|
@ -113,8 +113,8 @@ void GcodeSuite::G76() {
|
||||
}
|
||||
// Ensure probe position is reachable
|
||||
destination.set(
|
||||
temp_comp.measure_point_x - probe_offset.x,
|
||||
temp_comp.measure_point_y - probe_offset.y
|
||||
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)) {
|
||||
SERIAL_ECHOLNPGM("!Probe position unreachable - aborting.");
|
||||
@ -209,9 +209,9 @@ void GcodeSuite::G76() {
|
||||
|
||||
// Do a single probe
|
||||
remember_feedrate_scaling_off();
|
||||
const float measured_z = probe_at_point(
|
||||
destination.x + probe_offset.x,
|
||||
destination.y + probe_offset.y,
|
||||
const float measured_z = probe.probe_at_point(
|
||||
destination.x + probe.offset_xy.x,
|
||||
destination.y + probe.offset_xy.y,
|
||||
PROBE_PT_NONE
|
||||
);
|
||||
restore_feedrate_and_scaling();
|
||||
@ -318,9 +318,9 @@ void GcodeSuite::G76() {
|
||||
|
||||
// Do a single probe
|
||||
remember_feedrate_scaling_off();
|
||||
const float measured_z = probe_at_point(
|
||||
destination.x + probe_offset.x,
|
||||
destination.y + probe_offset.y,
|
||||
const float measured_z = probe.probe_at_point(
|
||||
destination.x + probe.offset_xy.x,
|
||||
destination.y + probe.offset_xy.y,
|
||||
PROBE_PT_NONE
|
||||
);
|
||||
restore_feedrate_and_scaling();
|
||||
|
@ -80,8 +80,8 @@ 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),
|
||||
parser.linearval('Y', next_pos.y + probe.offset_xy.y)
|
||||
};
|
||||
|
||||
if (!position_is_reachable_by_probe(probe_pos)) {
|
||||
@ -120,7 +120,7 @@ void GcodeSuite::M48() {
|
||||
float mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples];
|
||||
|
||||
// Move to the first point, deploy, and probe
|
||||
const float t = probe_at_point(probe_pos, raise_after, verbose_level);
|
||||
const float t = probe.probe_at_point(probe_pos, raise_after, verbose_level);
|
||||
bool probing_good = !isnan(t);
|
||||
|
||||
if (probing_good) {
|
||||
@ -169,7 +169,7 @@ void GcodeSuite::M48() {
|
||||
while (angle < 0.0) angle += 360.0; // outside of this range. It looks like they behave correctly with
|
||||
// numbers outside of the range, but just to be safe we clamp them.
|
||||
|
||||
const xy_pos_t noz_pos = probe_pos - probe_offset_xy;
|
||||
const xy_pos_t noz_pos = probe_pos - probe.offset_xy;
|
||||
next_pos.set(noz_pos.x + cos(RADIANS(angle)) * radius,
|
||||
noz_pos.y + sin(RADIANS(angle)) * radius);
|
||||
|
||||
@ -194,7 +194,7 @@ void GcodeSuite::M48() {
|
||||
} // n_legs
|
||||
|
||||
// Probe a single point
|
||||
sample_set[n] = probe_at_point(probe_pos, raise_after, 0);
|
||||
sample_set[n] = probe.probe_at_point(probe_pos, raise_after, 0);
|
||||
|
||||
// Break the loop if the probe fails
|
||||
probing_good = !isnan(sample_set[n]);
|
||||
@ -238,7 +238,7 @@ void GcodeSuite::M48() {
|
||||
} // n_samples loop
|
||||
}
|
||||
|
||||
STOW_PROBE();
|
||||
probe.stow();
|
||||
|
||||
if (probing_good) {
|
||||
SERIAL_ECHOLNPGM("Finished!");
|
||||
|
Reference in New Issue
Block a user