Browse Source

Encapsulate probe as singleton class (#16751)

pull/1/head
Scott Lahteine 5 years ago
committed by GitHub
parent
commit
90b6324563
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Marlin/src/MarlinCore.cpp
  2. 20
      Marlin/src/core/utility.cpp
  3. 4
      Marlin/src/feature/bedlevel/ubl/ubl.cpp
  4. 52
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  5. 6
      Marlin/src/gcode/bedlevel/G42.cpp
  6. 4
      Marlin/src/gcode/bedlevel/M420.cpp
  7. 20
      Marlin/src/gcode/bedlevel/abl/G29.cpp
  8. 4
      Marlin/src/gcode/calibrate/G28.cpp
  9. 4
      Marlin/src/gcode/calibrate/G33.cpp
  10. 12
      Marlin/src/gcode/calibrate/G34_M422.cpp
  11. 16
      Marlin/src/gcode/calibrate/G76_M871.cpp
  12. 12
      Marlin/src/gcode/calibrate/M48.cpp
  13. 7
      Marlin/src/gcode/config/M304.cpp
  14. 6
      Marlin/src/gcode/motion/M290.cpp
  15. 8
      Marlin/src/gcode/probe/G30.cpp
  16. 4
      Marlin/src/gcode/probe/G31_G32.cpp
  17. 6
      Marlin/src/gcode/probe/M401_M402.cpp
  18. 8
      Marlin/src/gcode/probe/M851.cpp
  19. 2
      Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionFYSETC.cpp
  20. 2
      Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionHIPRECY.cpp
  21. 2
      Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionOrigin.cpp
  22. 6
      Marlin/src/lcd/extensible_ui/ui_api.cpp
  23. 8
      Marlin/src/lcd/menu/menu.cpp
  24. 8
      Marlin/src/lcd/menu/menu_advanced.cpp
  25. 2
      Marlin/src/lcd/menu/menu_bed_leveling.cpp
  26. 5
      Marlin/src/lcd/menu/menu_configuration.cpp
  27. 35
      Marlin/src/module/configuration_store.cpp
  28. 4
      Marlin/src/module/delta.cpp
  29. 20
      Marlin/src/module/motion.cpp
  30. 8
      Marlin/src/module/motion.h
  31. 4
      Marlin/src/module/planner.cpp
  32. 105
      Marlin/src/module/probe.cpp
  33. 232
      Marlin/src/module/probe.h

2
Marlin/src/MarlinCore.cpp

@ -977,7 +977,7 @@ void setup() {
#endif #endif
#if HAS_Z_SERVO_PROBE #if HAS_Z_SERVO_PROBE
servo_probe_init(); probe.servo_probe_init();
#endif #endif
#if HAS_PHOTOGRAPH #if HAS_PHOTOGRAPH

20
Marlin/src/core/utility.cpp

@ -83,42 +83,42 @@ void safe_delay(millis_t ms) {
#if HAS_BED_PROBE #if HAS_BED_PROBE
#if !HAS_PROBE_XY_OFFSET #if !HAS_PROBE_XY_OFFSET
SERIAL_ECHOPAIR("Probe Offset X0 Y0 Z", probe_offset.z, " ("); SERIAL_ECHOPAIR("Probe Offset X0 Y0 Z", probe.offset.z, " (");
#else #else
SERIAL_ECHOPAIR_P(PSTR("Probe Offset X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR, probe_offset.z); SERIAL_ECHOPAIR_P(PSTR("Probe Offset X"), probe.offset_xy.x, SP_Y_STR, probe.offset_xy.y, SP_Z_STR, probe.offset.z);
if (probe_offset.x > 0) if (probe.offset_xy.x > 0)
SERIAL_ECHOPGM(" (Right"); SERIAL_ECHOPGM(" (Right");
else if (probe_offset.x < 0) else if (probe.offset_xy.x < 0)
SERIAL_ECHOPGM(" (Left"); SERIAL_ECHOPGM(" (Left");
else if (probe_offset.y != 0) else if (probe.offset_xy.y != 0)
SERIAL_ECHOPGM(" (Middle"); SERIAL_ECHOPGM(" (Middle");
else else
SERIAL_ECHOPGM(" (Aligned With"); SERIAL_ECHOPGM(" (Aligned With");
if (probe_offset.y > 0) { if (probe.offset_xy.y > 0) {
#if IS_SCARA #if IS_SCARA
SERIAL_ECHOPGM("-Distal"); SERIAL_ECHOPGM("-Distal");
#else #else
SERIAL_ECHOPGM("-Back"); SERIAL_ECHOPGM("-Back");
#endif #endif
} }
else if (probe_offset.y < 0) { else if (probe.offset_xy.y < 0) {
#if IS_SCARA #if IS_SCARA
SERIAL_ECHOPGM("-Proximal"); SERIAL_ECHOPGM("-Proximal");
#else #else
SERIAL_ECHOPGM("-Front"); SERIAL_ECHOPGM("-Front");
#endif #endif
} }
else if (probe_offset.x != 0) else if (probe.offset_xy.x != 0)
SERIAL_ECHOPGM("-Center"); SERIAL_ECHOPGM("-Center");
SERIAL_ECHOPGM(" & "); SERIAL_ECHOPGM(" & ");
#endif #endif
if (probe_offset.z < 0) if (probe.offset.z < 0)
SERIAL_ECHOPGM("Below"); SERIAL_ECHOPGM("Below");
else if (probe_offset.z > 0) else if (probe.offset.z > 0)
SERIAL_ECHOPGM("Above"); SERIAL_ECHOPGM("Above");
else else
SERIAL_ECHOPGM("Same Z as"); SERIAL_ECHOPGM("Same Z as");

4
Marlin/src/feature/bedlevel/ubl/ubl.cpp

@ -173,10 +173,10 @@
serialprintPGM(csv ? PSTR("CSV:\n") : PSTR("LCD:\n")); serialprintPGM(csv ? PSTR("CSV:\n") : PSTR("LCD:\n"));
} }
// Add XY probe offset from extruder because probe_at_point() subtracts them when // Add XY probe offset from extruder because probe.probe_at_point() subtracts them when
// moving to the XY position to be measured. This ensures better agreement between // moving to the XY position to be measured. This ensures better agreement between
// the current Z position after G28 and the mesh values. // the current Z position after G28 and the mesh values.
const xy_int8_t curr = closest_indexes(xy_pos_t(current_position) + probe_offset_xy); const xy_int8_t curr = closest_indexes(xy_pos_t(current_position) + probe.offset_xy);
if (!lcd) SERIAL_EOL(); if (!lcd) SERIAL_EOL();
for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) { for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) {

52
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp

@ -450,7 +450,7 @@
SERIAL_ECHO(g29_pos.y); SERIAL_ECHO(g29_pos.y);
SERIAL_ECHOLNPGM(").\n"); SERIAL_ECHOLNPGM(").\n");
} }
const xy_pos_t near = g29_pos + probe_offset_xy; const xy_pos_t near = g29_pos + probe.offset_xy;
probe_entire_mesh(near, parser.seen('T'), parser.seen('E'), parser.seen('U')); probe_entire_mesh(near, parser.seen('T'), parser.seen('E'), parser.seen('U'));
report_current_position(); report_current_position();
@ -480,8 +480,8 @@
#if IS_KINEMATIC #if IS_KINEMATIC
X_HOME_POS, Y_HOME_POS X_HOME_POS, Y_HOME_POS
#else #else
probe_offset_xy.x > 0 ? X_BED_SIZE : 0, probe.offset_xy.x > 0 ? X_BED_SIZE : 0,
probe_offset_xy.y < 0 ? Y_BED_SIZE : 0 probe.offset_xy.y < 0 ? Y_BED_SIZE : 0
#endif #endif
); );
} }
@ -742,7 +742,7 @@
* This attempts to fill in locations closest to the nozzle's start location first. * This attempts to fill in locations closest to the nozzle's start location first.
*/ */
void unified_bed_leveling::probe_entire_mesh(const xy_pos_t &near, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) { void unified_bed_leveling::probe_entire_mesh(const xy_pos_t &near, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) {
DEPLOY_PROBE(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW probe.deploy(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW
#if HAS_LCD_MENU #if HAS_LCD_MENU
ui.capture(); ui.capture();
@ -768,7 +768,7 @@
ui.wait_for_release(); ui.wait_for_release();
ui.quick_feedback(); ui.quick_feedback();
ui.release(); ui.release();
STOW_PROBE(); // Release UI before stow to allow for PAUSE_BEFORE_DEPLOY_STOW probe.stow(); // Release UI before stow to allow for PAUSE_BEFORE_DEPLOY_STOW
return restore_ubl_active_state_and_leave(); return restore_ubl_active_state_and_leave();
} }
#endif #endif
@ -778,7 +778,7 @@
: find_closest_mesh_point_of_type(INVALID, near, true); : find_closest_mesh_point_of_type(INVALID, near, true);
if (best.pos.x >= 0) { // mesh point found and is reachable by probe if (best.pos.x >= 0) { // mesh point found and is reachable by probe
const float measured_z = probe_at_point( const float measured_z = probe.probe_at_point(
best.meshpos(), best.meshpos(),
stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level
); );
@ -794,20 +794,20 @@
#if HAS_LCD_MENU #if HAS_LCD_MENU
ui.release(); ui.release();
#endif #endif
STOW_PROBE(); // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW probe.stow(); // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW
#if HAS_LCD_MENU #if HAS_LCD_MENU
ui.capture(); ui.capture();
#endif #endif
#ifdef Z_AFTER_PROBING #ifdef Z_AFTER_PROBING
move_z_after_probing(); probe.move_z_after_probing();
#endif #endif
restore_ubl_active_state_and_leave(); restore_ubl_active_state_and_leave();
do_blocking_move_to_xy( do_blocking_move_to_xy(
constrain(near.x - probe_offset_xy.x, MESH_MIN_X, MESH_MAX_X), constrain(near.x - probe.offset_xy.x, MESH_MIN_X, MESH_MAX_X),
constrain(near.y - probe_offset_xy.y, MESH_MIN_Y, MESH_MAX_Y) constrain(near.y - probe.offset_xy.y, MESH_MIN_Y, MESH_MAX_Y)
); );
} }
@ -907,7 +907,7 @@
ui.return_to_status(); ui.return_to_status();
mesh_index_pair location; mesh_index_pair location;
xy_int8_t &lpos = location.pos; const xy_int8_t &lpos = location.pos;
do { do {
location = find_closest_mesh_point_of_type(INVALID, pos); location = find_closest_mesh_point_of_type(INVALID, pos);
// It doesn't matter if the probe can't reach the NAN location. This is a manual probe. // It doesn't matter if the probe can't reach the NAN location. This is a manual probe.
@ -1006,7 +1006,7 @@
#endif #endif
MeshFlags done_flags{0}; MeshFlags done_flags{0};
xy_int8_t &lpos = location.pos; const xy_int8_t &lpos = location.pos;
do { do {
location = find_closest_mesh_point_of_type(SET_IN_BITMAP, pos, false, &done_flags); location = find_closest_mesh_point_of_type(SET_IN_BITMAP, pos, false, &done_flags);
@ -1294,7 +1294,7 @@
closest.distance = -99999.9f; closest.distance = -99999.9f;
// Get the reference position, either nozzle or probe // Get the reference position, either nozzle or probe
const xy_pos_t ref = probe_relative ? pos + probe_offset_xy : pos; const xy_pos_t ref = probe_relative ? pos + probe.offset_xy : pos;
float best_so_far = 99999.99f; float best_so_far = 99999.99f;
@ -1393,13 +1393,13 @@
#include "../../../libs/vector_3.h" #include "../../../libs/vector_3.h"
void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_3_pt_leveling) { void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_3_pt_leveling) {
const float x_min = probe_min_x(), x_max = probe_max_x(), const float x_min = probe.min_x(), x_max = probe.max_x(),
y_min = probe_min_y(), y_max = probe_max_y(), y_min = probe.min_y(), y_max = probe.max_y(),
dx = (x_max - x_min) / (g29_grid_size - 1), dx = (x_max - x_min) / (g29_grid_size - 1),
dy = (y_max - y_min) / (g29_grid_size - 1); dy = (y_max - y_min) / (g29_grid_size - 1);
xy_float_t points[3]; xy_float_t points[3];
get_three_probe_points(points); probe.get_three_points(points);
float measured_z; float measured_z;
bool abort_flag = false; bool abort_flag = false;
@ -1417,7 +1417,7 @@
ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH)); ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
#endif #endif
measured_z = probe_at_point(points[0], PROBE_PT_RAISE, g29_verbose_level); measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, g29_verbose_level);
if (isnan(measured_z)) if (isnan(measured_z))
abort_flag = true; abort_flag = true;
else { else {
@ -1438,7 +1438,7 @@
ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH)); ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
#endif #endif
measured_z = probe_at_point(points[1], PROBE_PT_RAISE, g29_verbose_level); measured_z = probe.probe_at_point(points[1], PROBE_PT_RAISE, g29_verbose_level);
#ifdef VALIDATE_MESH_TILT #ifdef VALIDATE_MESH_TILT
z2 = measured_z; z2 = measured_z;
#endif #endif
@ -1460,7 +1460,7 @@
ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH)); ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
#endif #endif
measured_z = probe_at_point(points[2], PROBE_PT_STOW, g29_verbose_level); measured_z = probe.probe_at_point(points[2], PROBE_PT_STOW, g29_verbose_level);
#ifdef VALIDATE_MESH_TILT #ifdef VALIDATE_MESH_TILT
z3 = measured_z; z3 = measured_z;
#endif #endif
@ -1476,9 +1476,9 @@
} }
} }
STOW_PROBE(); probe.stow();
#ifdef Z_AFTER_PROBING #ifdef Z_AFTER_PROBING
move_z_after_probing(); probe.move_z_after_probing();
#endif #endif
if (abort_flag) { if (abort_flag) {
@ -1504,7 +1504,7 @@
ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points); ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points);
#endif #endif
measured_z = probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
abort_flag = isnan(measured_z); abort_flag = isnan(measured_z);
@ -1523,7 +1523,7 @@
} }
#endif #endif
measured_z -= get_z_correction(rpos) /* + probe_offset.z */ ; measured_z -= get_z_correction(rpos) /* + probe.offset.z */ ;
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR_F(" final >>>---> ", measured_z, 7); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR_F(" final >>>---> ", measured_z, 7);
@ -1540,9 +1540,9 @@
zig_zag ^= true; zig_zag ^= true;
} }
} }
STOW_PROBE(); probe.stow();
#ifdef Z_AFTER_PROBING #ifdef Z_AFTER_PROBING
move_z_after_probing(); probe.move_z_after_probing();
#endif #endif
if (abort_flag || finish_incremental_LSF(&lsf_results)) { if (abort_flag || finish_incremental_LSF(&lsf_results)) {
@ -1728,7 +1728,7 @@
adjust_mesh_to_mean(g29_c_flag, g29_constant); adjust_mesh_to_mean(g29_c_flag, g29_constant);
#if HAS_BED_PROBE #if HAS_BED_PROBE
SERIAL_ECHOLNPAIR_F("Probe Offset M851 Z", probe_offset.z, 7); SERIAL_ECHOLNPAIR_F("Probe Offset M851 Z", probe.offset.z, 7);
#endif #endif
SERIAL_ECHOLNPAIR("MESH_MIN_X " STRINGIFY(MESH_MIN_X) "=", MESH_MIN_X); serial_delay(50); SERIAL_ECHOLNPAIR("MESH_MIN_X " STRINGIFY(MESH_MIN_X) "=", MESH_MIN_X); serial_delay(50);

6
Marlin/src/gcode/bedlevel/G42.cpp

@ -27,7 +27,7 @@
#include "../gcode.h" #include "../gcode.h"
#include "../../MarlinCore.h" // for IsRunning() #include "../../MarlinCore.h" // for IsRunning()
#include "../../module/motion.h" #include "../../module/motion.h"
#include "../../module/probe.h" // for probe_offset #include "../../module/probe.h" // for probe.offset
#include "../../feature/bedlevel/bedlevel.h" #include "../../feature/bedlevel/bedlevel.h"
/** /**
@ -53,8 +53,8 @@ void GcodeSuite::G42() {
#if HAS_PROBE_XY_OFFSET #if HAS_PROBE_XY_OFFSET
if (parser.boolval('P')) { if (parser.boolval('P')) {
if (hasI) destination.x -= probe_offset_xy.x; if (hasI) destination.x -= probe.offset_xy.x;
if (hasJ) destination.y -= probe_offset_xy.y; if (hasJ) destination.y -= probe.offset_xy.y;
} }
#endif #endif

4
Marlin/src/gcode/bedlevel/M420.cpp

@ -64,8 +64,8 @@ void GcodeSuite::M420() {
#if ENABLED(MARLIN_DEV_MODE) #if ENABLED(MARLIN_DEV_MODE)
if (parser.intval('S') == 2) { if (parser.intval('S') == 2) {
const float x_min = probe_min_x(), x_max = probe_max_x(), const float x_min = probe.min_x(), x_max = probe.max_x(),
y_min = probe_min_y(), y_max = probe_max_y(); y_min = probe.min_y(), y_max = probe.max_y();
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
bilinear_start.set(x_min, y_min); bilinear_start.set(x_min, y_min);
bilinear_grid_spacing.set((x_max - x_min) / (GRID_MAX_POINTS_X - 1), bilinear_grid_spacing.set((x_max - x_min) / (GRID_MAX_POINTS_X - 1),

20
Marlin/src/gcode/bedlevel/abl/G29.cpp

@ -269,7 +269,7 @@ G29_TYPE GcodeSuite::G29() {
#endif #endif
vector_3 points[3]; vector_3 points[3];
get_three_probe_points(points); probe.get_three_points(points);
#endif // AUTO_BED_LEVELING_3POINT #endif // AUTO_BED_LEVELING_3POINT
@ -392,8 +392,8 @@ G29_TYPE GcodeSuite::G29() {
xy_probe_feedrate_mm_s = MMM_TO_MMS(parser.linearval('S', XY_PROBE_SPEED)); xy_probe_feedrate_mm_s = MMM_TO_MMS(parser.linearval('S', XY_PROBE_SPEED));
const float x_min = probe_min_x(), x_max = probe_max_x(), const float x_min = probe.min_x(), x_max = probe.max_x(),
y_min = probe_min_y(), y_max = probe_max_y(); y_min = probe.min_y(), y_max = probe.max_y();
if (parser.seen('H')) { if (parser.seen('H')) {
const int16_t size = (int16_t)parser.value_linear_units(); const int16_t size = (int16_t)parser.value_linear_units();
@ -452,7 +452,7 @@ G29_TYPE GcodeSuite::G29() {
#if HAS_BED_PROBE #if HAS_BED_PROBE
// Deploy the probe. Probe will raise if needed. // Deploy the probe. Probe will raise if needed.
if (DEPLOY_PROBE()) { if (probe.deploy()) {
set_bed_leveling_enabled(abl_should_enable); set_bed_leveling_enabled(abl_should_enable);
G29_RETURN(false); G29_RETURN(false);
} }
@ -712,7 +712,7 @@ G29_TYPE GcodeSuite::G29() {
ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(GRID_MAX_POINTS)); ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(GRID_MAX_POINTS));
#endif #endif
measured_z = faux ? 0.001f * random(-100, 101) : probe_at_point(probePos, raise_after, verbose_level); measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(probePos, raise_after, verbose_level);
if (isnan(measured_z)) { if (isnan(measured_z)) {
set_bed_leveling_enabled(abl_should_enable); set_bed_leveling_enabled(abl_should_enable);
@ -764,7 +764,7 @@ G29_TYPE GcodeSuite::G29() {
// Retain the last probe position // Retain the last probe position
probePos = points[i]; probePos = points[i];
measured_z = faux ? 0.001 * random(-100, 101) : probe_at_point(probePos, raise_after, verbose_level); measured_z = faux ? 0.001 * random(-100, 101) : probe.probe_at_point(probePos, raise_after, verbose_level);
if (isnan(measured_z)) { if (isnan(measured_z)) {
set_bed_leveling_enabled(abl_should_enable); set_bed_leveling_enabled(abl_should_enable);
break; break;
@ -788,7 +788,7 @@ G29_TYPE GcodeSuite::G29() {
#endif #endif
// Stow the probe. No raise for FIX_MOUNTED_PROBE. // Stow the probe. No raise for FIX_MOUNTED_PROBE.
if (STOW_PROBE()) { if (probe.stow()) {
set_bed_leveling_enabled(abl_should_enable); set_bed_leveling_enabled(abl_should_enable);
measured_z = NAN; measured_z = NAN;
} }
@ -923,8 +923,8 @@ G29_TYPE GcodeSuite::G29() {
planner.force_unapply_leveling(converted); // use conversion machinery planner.force_unapply_leveling(converted); // use conversion machinery
// Use the last measured distance to the bed, if possible // Use the last measured distance to the bed, if possible
if ( NEAR(current_position.x, probePos.x - probe_offset_xy.x) if ( NEAR(current_position.x, probePos.x - probe.offset_xy.x)
&& NEAR(current_position.y, probePos.y - probe_offset_xy.y) && NEAR(current_position.y, probePos.y - probe.offset_xy.y)
) { ) {
const float simple_z = current_position.z - measured_z; const float simple_z = current_position.z - measured_z;
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probed Z", simple_z, " Matrix Z", converted.z, " Discrepancy ", simple_z - converted.z); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probed Z", simple_z, " Matrix Z", converted.z, " Discrepancy ", simple_z - converted.z);
@ -964,7 +964,7 @@ G29_TYPE GcodeSuite::G29() {
sync_plan_position(); sync_plan_position();
#if HAS_BED_PROBE && defined(Z_AFTER_PROBING) #if HAS_BED_PROBE && defined(Z_AFTER_PROBING)
move_z_after_probing(); probe.move_z_after_probing();
#endif #endif
#ifdef Z_PROBE_END_SCRIPT #ifdef Z_PROBE_END_SCRIPT

4
Marlin/src/gcode/calibrate/G28.cpp

@ -133,7 +133,7 @@
destination.set(safe_homing_xy, current_position.z); destination.set(safe_homing_xy, current_position.z);
#if HOMING_Z_WITH_PROBE #if HOMING_Z_WITH_PROBE
destination -= probe_offset_xy; destination -= probe.offset_xy;
#endif #endif
if (position_is_reachable(destination)) { if (position_is_reachable(destination)) {
@ -416,7 +416,7 @@ void GcodeSuite::G28(const bool always_home_all) {
#endif #endif
#if HOMING_Z_WITH_PROBE && defined(Z_AFTER_PROBING) #if HOMING_Z_WITH_PROBE && defined(Z_AFTER_PROBING)
move_z_after_probing(); probe.move_z_after_probing();
#endif #endif
} // doZ } // doZ

4
Marlin/src/gcode/calibrate/G33.cpp

@ -100,7 +100,7 @@ void ac_cleanup(
do_blocking_move_to_z(delta_clip_start_height); do_blocking_move_to_z(delta_clip_start_height);
#endif #endif
#if HAS_BED_PROBE #if HAS_BED_PROBE
STOW_PROBE(); probe.stow();
#endif #endif
restore_feedrate_and_scaling(); restore_feedrate_and_scaling();
#if HOTENDS > 1 #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) { static float calibration_probe(const xy_pos_t &xy, const bool stow) {
#if HAS_BED_PROBE #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 #else
UNUSED(stow); UNUSED(stow);
return lcd_probe_pt(xy); return lcd_probe_pt(xy);

12
Marlin/src/gcode/calibrate/G34_M422.cpp

@ -133,8 +133,8 @@ void GcodeSuite::G34() {
do { // break out on error do { // break out on error
#if NUM_Z_STEPPER_DRIVERS == 4 #if NUM_Z_STEPPER_DRIVERS >= 4
SERIAL_ECHOLNPGM("Quad Z Stepper Leveling not Yet Supported"); SERIAL_ECHOLNPGM("Alignment not supported for over 3 steppers");
break; break;
#endif #endif
@ -240,7 +240,7 @@ void GcodeSuite::G34() {
if (iteration == 0 || i > 0) do_blocking_move_to_z(z_probe); if (iteration == 0 || i > 0) do_blocking_move_to_z(z_probe);
// Probe a Z height for each stepper. // 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)) { if (isnan(z_probed_height)) {
SERIAL_ECHOLNPGM("Probing failed."); SERIAL_ECHOLNPGM("Probing failed.");
err_break = true; err_break = true;
@ -314,7 +314,7 @@ void GcodeSuite::G34() {
#if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
// Optimize one iteration's correction based on the first measurements // 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 #endif
// Check for less accuracy compared to last move // Check for less accuracy compared to last move
@ -379,9 +379,9 @@ void GcodeSuite::G34() {
// After this operation the z position needs correction // After this operation the z position needs correction
set_axis_is_not_at_home(Z_AXIS); 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. // the probe deployed if it was successful.
STOW_PROBE(); probe.stow();
// Home Z after the alignment procedure // Home Z after the alignment procedure
process_subcommands_now_P(PSTR("G28 Z")); process_subcommands_now_P(PSTR("G28 Z"));

16
Marlin/src/gcode/calibrate/G76_M871.cpp

@ -113,8 +113,8 @@ void GcodeSuite::G76() {
} }
// Ensure probe position is reachable // Ensure probe position is reachable
destination.set( destination.set(
temp_comp.measure_point_x - probe_offset.x, temp_comp.measure_point_x - probe.offset_xy.x,
temp_comp.measure_point_y - probe_offset.y temp_comp.measure_point_y - probe.offset_xy.y
); );
if (!position_is_reachable_by_probe(destination)) { if (!position_is_reachable_by_probe(destination)) {
SERIAL_ECHOLNPGM("!Probe position unreachable - aborting."); SERIAL_ECHOLNPGM("!Probe position unreachable - aborting.");
@ -209,9 +209,9 @@ void GcodeSuite::G76() {
// Do a single probe // Do a single probe
remember_feedrate_scaling_off(); remember_feedrate_scaling_off();
const float measured_z = probe_at_point( const float measured_z = probe.probe_at_point(
destination.x + probe_offset.x, destination.x + probe.offset_xy.x,
destination.y + probe_offset.y, destination.y + probe.offset_xy.y,
PROBE_PT_NONE PROBE_PT_NONE
); );
restore_feedrate_and_scaling(); restore_feedrate_and_scaling();
@ -318,9 +318,9 @@ void GcodeSuite::G76() {
// Do a single probe // Do a single probe
remember_feedrate_scaling_off(); remember_feedrate_scaling_off();
const float measured_z = probe_at_point( const float measured_z = probe.probe_at_point(
destination.x + probe_offset.x, destination.x + probe.offset_xy.x,
destination.y + probe_offset.y, destination.y + probe.offset_xy.y,
PROBE_PT_NONE PROBE_PT_NONE
); );
restore_feedrate_and_scaling(); restore_feedrate_and_scaling();

12
Marlin/src/gcode/calibrate/M48.cpp

@ -80,8 +80,8 @@ void GcodeSuite::M48() {
xy_float_t next_pos = current_position; xy_float_t next_pos = current_position;
const xy_pos_t probe_pos = { const xy_pos_t probe_pos = {
parser.linearval('X', next_pos.x + probe_offset_xy.x), parser.linearval('X', next_pos.x + probe.offset_xy.x),
parser.linearval('Y', next_pos.y + probe_offset_xy.y) parser.linearval('Y', next_pos.y + probe.offset_xy.y)
}; };
if (!position_is_reachable_by_probe(probe_pos)) { 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]; 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 // 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); bool probing_good = !isnan(t);
if (probing_good) { 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 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. // 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, next_pos.set(noz_pos.x + cos(RADIANS(angle)) * radius,
noz_pos.y + sin(RADIANS(angle)) * radius); noz_pos.y + sin(RADIANS(angle)) * radius);
@ -194,7 +194,7 @@ void GcodeSuite::M48() {
} // n_legs } // n_legs
// Probe a single point // 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 // Break the loop if the probe fails
probing_good = !isnan(sample_set[n]); probing_good = !isnan(sample_set[n]);
@ -238,7 +238,7 @@ void GcodeSuite::M48() {
} // n_samples loop } // n_samples loop
} }
STOW_PROBE(); probe.stow();
if (probing_good) { if (probing_good) {
SERIAL_ECHOLNPGM("Finished!"); SERIAL_ECHOLNPGM("Finished!");

7
Marlin/src/gcode/config/M304.cpp

@ -27,6 +27,13 @@
#include "../gcode.h" #include "../gcode.h"
#include "../../module/temperature.h" #include "../../module/temperature.h"
/**
* M304 - Set and/or Report the current Bed PID values
*
* P<pval> - Set the P value
* I<ival> - Set the I value
* D<dval> - Set the D value
*/
void GcodeSuite::M304() { void GcodeSuite::M304() {
if (parser.seen('P')) thermalManager.temp_bed.pid.Kp = parser.value_float(); if (parser.seen('P')) thermalManager.temp_bed.pid.Kp = parser.value_float();
if (parser.seen('I')) thermalManager.temp_bed.pid.Ki = scalePID_i(parser.value_float()); if (parser.seen('I')) thermalManager.temp_bed.pid.Ki = scalePID_i(parser.value_float());

6
Marlin/src/gcode/motion/M290.cpp

@ -46,9 +46,9 @@
&& active_extruder == 0 && active_extruder == 0
#endif #endif
) { ) {
probe_offset.z += offs; probe.offset.z += offs;
SERIAL_ECHO_START(); SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET MSG_Z ": ", probe_offset.z); SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET MSG_Z ": ", probe.offset.z);
} }
else { else {
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET) #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
@ -98,7 +98,7 @@ void GcodeSuite::M290() {
SERIAL_ECHO_START(); SERIAL_ECHO_START();
#if ENABLED(BABYSTEP_ZPROBE_OFFSET) #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET " " MSG_Z, probe_offset.z); SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET " " MSG_Z, probe.offset.z);
#endif #endif
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET) #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)

8
Marlin/src/gcode/probe/G30.cpp

@ -40,8 +40,8 @@
*/ */
void GcodeSuite::G30() { void GcodeSuite::G30() {
const xy_pos_t pos = { parser.linearval('X', current_position.x + probe_offset_xy.x), const xy_pos_t pos = { parser.linearval('X', current_position.x + probe.offset_xy.x),
parser.linearval('Y', current_position.y + probe_offset_xy.y) }; parser.linearval('Y', current_position.y + probe.offset_xy.y) };
if (!position_is_reachable_by_probe(pos)) return; if (!position_is_reachable_by_probe(pos)) return;
@ -53,14 +53,14 @@ void GcodeSuite::G30() {
remember_feedrate_scaling_off(); remember_feedrate_scaling_off();
const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
const float measured_z = probe_at_point(pos, raise_after, 1); const float measured_z = probe.probe_at_point(pos, raise_after, 1);
if (!isnan(measured_z)) if (!isnan(measured_z))
SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(pos.x), " Y: ", FIXFLOAT(pos.y), " Z: ", FIXFLOAT(measured_z)); SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(pos.x), " Y: ", FIXFLOAT(pos.y), " Z: ", FIXFLOAT(measured_z));
restore_feedrate_and_scaling(); restore_feedrate_and_scaling();
#ifdef Z_AFTER_PROBING #ifdef Z_AFTER_PROBING
if (raise_after == PROBE_PT_STOW) move_z_after_probing(); if (raise_after == PROBE_PT_STOW) probe.move_z_after_probing();
#endif #endif
report_current_position(); report_current_position();

4
Marlin/src/gcode/probe/G31_G32.cpp

@ -30,11 +30,11 @@
/** /**
* G31: Deploy the Z probe * G31: Deploy the Z probe
*/ */
void GcodeSuite::G31() { DEPLOY_PROBE(); } void GcodeSuite::G31() { probe.deploy(); }
/** /**
* G32: Stow the Z probe * G32: Stow the Z probe
*/ */
void GcodeSuite::G32() { STOW_PROBE(); } void GcodeSuite::G32() { probe.stow(); }
#endif // Z_PROBE_SLED #endif // Z_PROBE_SLED

6
Marlin/src/gcode/probe/M401_M402.cpp

@ -32,7 +32,7 @@
* M401: Deploy and activate the Z probe * M401: Deploy and activate the Z probe
*/ */
void GcodeSuite::M401() { void GcodeSuite::M401() {
DEPLOY_PROBE(); probe.deploy();
report_current_position(); report_current_position();
} }
@ -40,9 +40,9 @@ void GcodeSuite::M401() {
* M402: Deactivate and stow the Z probe * M402: Deactivate and stow the Z probe
*/ */
void GcodeSuite::M402() { void GcodeSuite::M402() {
STOW_PROBE(); probe.stow();
#ifdef Z_AFTER_PROBING #ifdef Z_AFTER_PROBING
move_z_after_probing(); probe.move_z_after_probing();
#endif #endif
report_current_position(); report_current_position();
} }

8
Marlin/src/gcode/probe/M851.cpp

@ -39,17 +39,17 @@ void GcodeSuite::M851() {
if (!parser.seen("XYZ")) { if (!parser.seen("XYZ")) {
SERIAL_ECHOLNPAIR_P( SERIAL_ECHOLNPAIR_P(
#if HAS_PROBE_XY_OFFSET #if HAS_PROBE_XY_OFFSET
PSTR(MSG_PROBE_OFFSET " X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR PSTR(MSG_PROBE_OFFSET " X"), probe.offset_xy.x, SP_Y_STR, probe.offset_xy.y, SP_Z_STR
#else #else
PSTR(MSG_PROBE_OFFSET " X0 Y0 Z") PSTR(MSG_PROBE_OFFSET " X0 Y0 Z")
#endif #endif
, probe_offset.z , probe.offset.z
); );
return; return;
} }
// Start with current offsets and modify // Start with current offsets and modify
xyz_pos_t offs = probe_offset; xyz_pos_t offs = probe.offset;
// Assume no errors // Assume no errors
bool ok = true; bool ok = true;
@ -93,7 +93,7 @@ void GcodeSuite::M851() {
} }
// Save the new offsets // Save the new offsets
if (ok) probe_offset = offs; if (ok) probe.offset = offs;
} }
#endif // HAS_BED_PROBE #endif // HAS_BED_PROBE

2
Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionFYSETC.cpp

@ -453,7 +453,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr), VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr),
VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr), VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr),
#if HAS_BED_PROBE #if HAS_BED_PROBE
VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe_offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>), VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>),
#if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEPPING)
VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr), VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr),
#endif #endif

2
Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionHIPRECY.cpp

@ -453,7 +453,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr), VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr),
VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr), VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr),
#if HAS_BED_PROBE #if HAS_BED_PROBE
VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe_offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>), VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>),
#if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEPPING)
VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr), VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr),
#endif #endif

2
Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionOrigin.cpp

@ -285,7 +285,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr), VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr),
VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr), VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr),
#if HAS_BED_PROBE #if HAS_BED_PROBE
VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe_offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>), VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>),
#if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEPPING)
VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr), VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr),
#endif #endif

6
Marlin/src/lcd/extensible_ui/ui_api.cpp

@ -733,7 +733,7 @@ namespace ExtUI {
#if EXTRUDERS > 1 #if EXTRUDERS > 1
&& (linked_nozzles || active_extruder == 0) && (linked_nozzles || active_extruder == 0)
#endif #endif
) probe_offset.z += mm; ) probe.offset.z += mm;
#else #else
UNUSED(mm); UNUSED(mm);
#endif #endif
@ -771,7 +771,7 @@ namespace ExtUI {
float getZOffset_mm() { float getZOffset_mm() {
#if HAS_BED_PROBE #if HAS_BED_PROBE
return probe_offset.z; return probe.offset.z;
#elif ENABLED(BABYSTEP_DISPLAY_TOTAL) #elif ENABLED(BABYSTEP_DISPLAY_TOTAL)
return (planner.steps_to_mm[Z_AXIS] * babystep.axis_total[BS_TODO_AXIS(Z_AXIS)]); return (planner.steps_to_mm[Z_AXIS] * babystep.axis_total[BS_TODO_AXIS(Z_AXIS)]);
#else #else
@ -782,7 +782,7 @@ namespace ExtUI {
void setZOffset_mm(const float value) { void setZOffset_mm(const float value) {
#if HAS_BED_PROBE #if HAS_BED_PROBE
if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX))
probe_offset.z = value; probe.offset.z = value;
#elif ENABLED(BABYSTEP_DISPLAY_TOTAL) #elif ENABLED(BABYSTEP_DISPLAY_TOTAL)
babystep.add_mm(Z_AXIS, (value - getZOffset_mm())); babystep.add_mm(Z_AXIS, (value - getZOffset_mm()));
#else #else

8
Marlin/src/lcd/menu/menu.cpp

@ -406,7 +406,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
ui.encoderPosition = 0; ui.encoderPosition = 0;
const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment, const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
new_probe_offset = probe_offset.z + diff, new_probe_offset = probe.offset.z + diff,
new_offs = new_offs =
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET) #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
do_probe ? new_probe_offset : hotend_offset[active_extruder].z - diff do_probe ? new_probe_offset : hotend_offset[active_extruder].z - diff
@ -418,7 +418,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
babystep.add_steps(Z_AXIS, babystep_increment); babystep.add_steps(Z_AXIS, babystep_increment);
if (do_probe) probe_offset.z = new_offs; if (do_probe) probe.offset.z = new_offs;
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET) #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
else hotend_offset[active_extruder].z = new_offs; else hotend_offset[active_extruder].z = new_offs;
#endif #endif
@ -432,10 +432,10 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_HOTEND_OFFSET_Z), LCD_Z_OFFSET_FUNC(hotend_offset[active_extruder].z)); MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_HOTEND_OFFSET_Z), LCD_Z_OFFSET_FUNC(hotend_offset[active_extruder].z));
else else
#endif #endif
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), LCD_Z_OFFSET_FUNC(probe_offset.z)); MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), LCD_Z_OFFSET_FUNC(probe.offset.z));
#if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY) #if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY)
if (do_probe) _lcd_zoffset_overlay_gfx(probe_offset.z); if (do_probe) _lcd_zoffset_overlay_gfx(probe.offset.z);
#endif #endif
} }
} }

8
Marlin/src/lcd/menu/menu_advanced.cpp

@ -497,9 +497,11 @@ void menu_cancelobject();
void menu_probe_offsets() { void menu_probe_offsets() {
START_MENU(); START_MENU();
BACK_ITEM(MSG_ADVANCED_SETTINGS); BACK_ITEM(MSG_ADVANCED_SETTINGS);
EDIT_ITEM(float51sign, MSG_ZPROBE_XOFFSET, &probe_offset.x, -(X_BED_SIZE), X_BED_SIZE); #if HAS_PROBE_XY_OFFSET
EDIT_ITEM(float51sign, MSG_ZPROBE_YOFFSET, &probe_offset.y, -(Y_BED_SIZE), Y_BED_SIZE); EDIT_ITEM(float51sign, MSG_ZPROBE_XOFFSET, &probe.offset.x, -(X_BED_SIZE), X_BED_SIZE);
EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); EDIT_ITEM(float51sign, MSG_ZPROBE_YOFFSET, &probe.offset.y, -(Y_BED_SIZE), Y_BED_SIZE);
#endif
EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
END_MENU(); END_MENU();
} }
#endif #endif

2
Marlin/src/lcd/menu/menu_bed_leveling.cpp

@ -279,7 +279,7 @@ void menu_bed_leveling() {
#if ENABLED(BABYSTEP_ZPROBE_OFFSET) #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset); SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
#elif HAS_BED_PROBE #elif HAS_BED_PROBE
EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
#endif #endif
#if ENABLED(LEVEL_BED_CORNERS) #if ENABLED(LEVEL_BED_CORNERS)

5
Marlin/src/lcd/menu/menu_configuration.cpp

@ -317,14 +317,11 @@ void menu_configuration() {
#if ENABLED(BABYSTEP_ZPROBE_OFFSET) #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset); SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
#elif HAS_BED_PROBE #elif HAS_BED_PROBE
EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
#endif #endif
const bool busy = printer_busy(); const bool busy = printer_busy();
if (!busy) { if (!busy) {
//
// Delta Calibration
//
#if EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION) #if EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION)
SUBMENU(MSG_DELTA_CALIBRATE, menu_delta_calibrate); SUBMENU(MSG_DELTA_CALIBRATE, menu_delta_calibrate);
#endif #endif

35
Marlin/src/module/configuration_store.cpp

@ -587,12 +587,12 @@ void MarlinSettings::postprocess() {
#if HAS_FILAMENT_SENSOR #if HAS_FILAMENT_SENSOR
const bool &runout_sensor_enabled = runout.enabled; const bool &runout_sensor_enabled = runout.enabled;
#else #else
const bool runout_sensor_enabled = true; constexpr bool runout_sensor_enabled = true;
#endif #endif
#if HAS_FILAMENT_SENSOR && defined(FILAMENT_RUNOUT_DISTANCE_MM) #if HAS_FILAMENT_SENSOR && defined(FILAMENT_RUNOUT_DISTANCE_MM)
const float &runout_distance_mm = runout.runout_distance(); const float &runout_distance_mm = runout.runout_distance();
#else #else
const float runout_distance_mm = 0; constexpr float runout_distance_mm = 0;
#endif #endif
_FIELD_TEST(runout_sensor_enabled); _FIELD_TEST(runout_sensor_enabled);
EEPROM_WRITE(runout_sensor_enabled); EEPROM_WRITE(runout_sensor_enabled);
@ -643,7 +643,12 @@ void MarlinSettings::postprocess() {
// //
{ {
_FIELD_TEST(probe_offset); _FIELD_TEST(probe_offset);
EEPROM_WRITE(probe_offset); #if HAS_BED_PROBE
const xyz_pos_t &zpo = probe.offset;
#else
constexpr xyz_pos_t zpo{0};
#endif
EEPROM_WRITE(zpo);
} }
// //
@ -1458,7 +1463,7 @@ void MarlinSettings::postprocess() {
// //
{ {
#if HAS_FILAMENT_SENSOR #if HAS_FILAMENT_SENSOR
bool &runout_sensor_enabled = runout.enabled; const bool &runout_sensor_enabled = runout.enabled;
#else #else
bool runout_sensor_enabled; bool runout_sensor_enabled;
#endif #endif
@ -1515,7 +1520,7 @@ void MarlinSettings::postprocess() {
{ {
_FIELD_TEST(probe_offset); _FIELD_TEST(probe_offset);
#if HAS_BED_PROBE #if HAS_BED_PROBE
xyz_pos_t &zpo = probe_offset; const xyz_pos_t &zpo = probe.offset;
#else #else
xyz_pos_t zpo; xyz_pos_t zpo;
#endif #endif
@ -1609,7 +1614,7 @@ void MarlinSettings::postprocess() {
{ {
_FIELD_TEST(bltouch_last_written_mode); _FIELD_TEST(bltouch_last_written_mode);
#if ENABLED(BLTOUCH) #if ENABLED(BLTOUCH)
bool &bltouch_last_written_mode = bltouch.last_written_mode; const bool &bltouch_last_written_mode = bltouch.last_written_mode;
#else #else
bool bltouch_last_written_mode; bool bltouch_last_written_mode;
#endif #endif
@ -2120,14 +2125,14 @@ void MarlinSettings::postprocess() {
// //
{ {
#if ENABLED(BACKLASH_GCODE) #if ENABLED(BACKLASH_GCODE)
xyz_float_t &backlash_distance_mm = backlash.distance_mm; const xyz_float_t &backlash_distance_mm = backlash.distance_mm;
uint8_t &backlash_correction = backlash.correction; const uint8_t &backlash_correction = backlash.correction;
#else #else
float backlash_distance_mm[XYZ]; float backlash_distance_mm[XYZ];
uint8_t backlash_correction; uint8_t backlash_correction;
#endif #endif
#if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM) #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM)
float &backlash_smoothing_mm = backlash.smoothing_mm; const float &backlash_smoothing_mm = backlash.smoothing_mm;
#else #else
float backlash_smoothing_mm; float backlash_smoothing_mm;
#endif #endif
@ -2461,10 +2466,10 @@ void MarlinSettings::reset() {
constexpr float dpo[] = NOZZLE_TO_PROBE_OFFSET; constexpr float dpo[] = NOZZLE_TO_PROBE_OFFSET;
static_assert(COUNT(dpo) == 3, "NOZZLE_TO_PROBE_OFFSET must contain offsets for X, Y, and Z."); static_assert(COUNT(dpo) == 3, "NOZZLE_TO_PROBE_OFFSET must contain offsets for X, Y, and Z.");
#if HAS_PROBE_XY_OFFSET #if HAS_PROBE_XY_OFFSET
LOOP_XYZ(a) probe_offset[a] = dpo[a]; LOOP_XYZ(a) probe.offset[a] = dpo[a];
#else #else
probe_offset.x = probe_offset.y = 0; probe.offset.x = probe.offset.y = 0;
probe_offset.z = dpo[Z_AXIS]; probe.offset.z = dpo[Z_AXIS];
#endif #endif
#endif #endif
@ -3216,13 +3221,13 @@ void MarlinSettings::reset() {
CONFIG_ECHO_START(); CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR_P( SERIAL_ECHOLNPAIR_P(
#if HAS_PROBE_XY_OFFSET #if HAS_PROBE_XY_OFFSET
PSTR(" M851 X"), LINEAR_UNIT(probe_offset_xy.x), PSTR(" M851 X"), LINEAR_UNIT(probe.offset_xy.x),
SP_Y_STR, LINEAR_UNIT(probe_offset_xy.y), SP_Y_STR, LINEAR_UNIT(probe.offset_xy.y),
SP_Z_STR SP_Z_STR
#else #else
PSTR(" M851 X0 Y0 Z") PSTR(" M851 X0 Y0 Z")
#endif #endif
, LINEAR_UNIT(probe_offset.z) , LINEAR_UNIT(probe.offset.z)
); );
#endif #endif

4
Marlin/src/module/delta.cpp

@ -95,7 +95,7 @@ void recalc_delta_settings() {
float delta_calibration_radius() { float delta_calibration_radius() {
return calibration_radius_factor * ( return calibration_radius_factor * (
#if HAS_BED_PROBE #if HAS_BED_PROBE
FLOOR((DELTA_PRINTABLE_RADIUS) - _MAX(HYPOT(probe_offset_xy.x, probe_offset_xy.y), MIN_PROBE_EDGE)) FLOOR((DELTA_PRINTABLE_RADIUS) - _MAX(HYPOT(probe.offset_xy.x, probe.offset_xy.y), MIN_PROBE_EDGE))
#else #else
DELTA_PRINTABLE_RADIUS DELTA_PRINTABLE_RADIUS
#endif #endif
@ -251,7 +251,7 @@ void home_delta() {
// Move all carriages together linearly until an endstop is hit. // Move all carriages together linearly until an endstop is hit.
current_position.z = (delta_height + 10 current_position.z = (delta_height + 10
#if HAS_BED_PROBE #if HAS_BED_PROBE
- probe_offset.z - probe.offset.z
#endif #endif
); );
line_to_current_position(homing_feedrate(Z_AXIS)); line_to_current_position(homing_feedrate(Z_AXIS));

20
Marlin/src/module/motion.cpp

@ -280,7 +280,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
, true , true
#endif #endif
); );
xyze_pos_t &cartes = pos; const xyze_pos_t &cartes = pos;
#endif #endif
if (axis == ALL_AXES) if (axis == ALL_AXES)
current_position = cartes; current_position = cartes;
@ -547,7 +547,7 @@ void restore_feedrate_and_scaling() {
soft_endstop.min[axis] = base_min_pos(axis); soft_endstop.min[axis] = base_min_pos(axis);
soft_endstop.max[axis] = (axis == Z_AXIS ? delta_height soft_endstop.max[axis] = (axis == Z_AXIS ? delta_height
#if HAS_BED_PROBE #if HAS_BED_PROBE
- probe_offset.z - probe.offset.z
#endif #endif
: base_max_pos(axis)); : base_max_pos(axis));
@ -1281,7 +1281,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
#if HOMING_Z_WITH_PROBE && HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER) #if HOMING_Z_WITH_PROBE && HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
// Wait for bed to heat back up between probing points // Wait for bed to heat back up between probing points
if (axis == Z_AXIS && distance < 0 && thermalManager.isHeatingBed()) { if (axis == Z_AXIS && distance < 0 && thermalManager.isHeatingBed()) {
serialprintPGM(msg_wait_for_bed_heating); serialprintPGM(probe.msg_wait_for_bed_heating);
#if HAS_DISPLAY #if HAS_DISPLAY
LCD_MESSAGEPGM(MSG_BED_HEATING); LCD_MESSAGEPGM(MSG_BED_HEATING);
#endif #endif
@ -1307,7 +1307,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
if (is_home_dir) { if (is_home_dir) {
#if HOMING_Z_WITH_PROBE && QUIET_PROBING #if HOMING_Z_WITH_PROBE && QUIET_PROBING
if (axis == Z_AXIS) probing_pause(true); if (axis == Z_AXIS) probe.set_probing_paused(true);
#endif #endif
// Disable stealthChop if used. Enable diag1 pin on driver. // Disable stealthChop if used. Enable diag1 pin on driver.
@ -1347,7 +1347,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
if (is_home_dir) { if (is_home_dir) {
#if HOMING_Z_WITH_PROBE && QUIET_PROBING #if HOMING_Z_WITH_PROBE && QUIET_PROBING
if (axis == Z_AXIS) probing_pause(false); if (axis == Z_AXIS) probe.set_probing_paused(false);
#endif #endif
endstops.validate_homing_move(); endstops.validate_homing_move();
@ -1397,7 +1397,7 @@ void set_axis_is_at_home(const AxisEnum axis) {
#elif ENABLED(DELTA) #elif ENABLED(DELTA)
current_position[axis] = (axis == Z_AXIS ? delta_height current_position[axis] = (axis == Z_AXIS ? delta_height
#if HAS_BED_PROBE #if HAS_BED_PROBE
- probe_offset.z - probe.offset.z
#endif #endif
: base_home_pos(axis)); : base_home_pos(axis));
#else #else
@ -1411,9 +1411,9 @@ void set_axis_is_at_home(const AxisEnum axis) {
if (axis == Z_AXIS) { if (axis == Z_AXIS) {
#if HOMING_Z_WITH_PROBE #if HOMING_Z_WITH_PROBE
current_position.z -= probe_offset.z; current_position.z -= probe.offset.z;
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> probe_offset.z = ", probe_offset.z); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> probe.offset.z = ", probe.offset.z);
#else #else
@ -1509,7 +1509,7 @@ void homeaxis(const AxisEnum axis) {
// Homing Z towards the bed? Deploy the Z probe or endstop. // Homing Z towards the bed? Deploy the Z probe or endstop.
#if HOMING_Z_WITH_PROBE #if HOMING_Z_WITH_PROBE
if (axis == Z_AXIS && DEPLOY_PROBE()) return; if (axis == Z_AXIS && probe.deploy()) return;
#endif #endif
// Set flags for X, Y, Z motor locking // Set flags for X, Y, Z motor locking
@ -1751,7 +1751,7 @@ void homeaxis(const AxisEnum axis) {
// Put away the Z probe // Put away the Z probe
#if HOMING_Z_WITH_PROBE #if HOMING_Z_WITH_PROBE
if (axis == Z_AXIS && STOW_PROBE()) return; if (axis == Z_AXIS && probe.stow()) return;
#endif #endif
#if DISABLED(DELTA) && defined(HOMING_BACKOFF_MM) #if DISABLED(DELTA) && defined(HOMING_BACKOFF_MM)

8
Marlin/src/module/motion.h

@ -329,7 +329,7 @@ void homeaxis(const AxisEnum axis);
// Return true if the both nozzle and the probe can reach the given point. // Return true if the both nozzle and the probe can reach the given point.
// Note: This won't work on SCARA since the probe offset rotates with the arm. // Note: This won't work on SCARA since the probe offset rotates with the arm.
inline bool position_is_reachable_by_probe(const float &rx, const float &ry) { inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
return position_is_reachable(rx - probe_offset.x, ry - probe_offset.y) return position_is_reachable(rx - probe.offset_xy.x, ry - probe.offset_xy.y)
&& position_is_reachable(rx, ry, ABS(MIN_PROBE_EDGE)); && position_is_reachable(rx, ry, ABS(MIN_PROBE_EDGE));
} }
@ -369,9 +369,9 @@ void homeaxis(const AxisEnum axis);
* nozzle must be be able to reach +10,-10. * nozzle must be be able to reach +10,-10.
*/ */
inline bool position_is_reachable_by_probe(const float &rx, const float &ry) { inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
return position_is_reachable(rx - probe_offset_xy.x, ry - probe_offset_xy.y) return position_is_reachable(rx - probe.offset_xy.x, ry - probe.offset_xy.y)
&& WITHIN(rx, probe_min_x() - slop, probe_max_x() + slop) && WITHIN(rx, probe.min_x() - slop, probe.max_x() + slop)
&& WITHIN(ry, probe_min_y() - slop, probe_max_y() + slop); && WITHIN(ry, probe.min_y() - slop, probe.max_y() + slop);
} }
#endif // HAS_BED_PROBE #endif // HAS_BED_PROBE

4
Marlin/src/module/planner.cpp

@ -2779,7 +2779,7 @@ void Planner::set_max_acceleration(const uint8_t axis, float targetValue) {
const xyze_float_t &max_acc_edit_scaled = max_accel_edit; const xyze_float_t &max_acc_edit_scaled = max_accel_edit;
#else #else
constexpr xyze_float_t max_accel_edit = DEFAULT_MAX_ACCELERATION; constexpr xyze_float_t max_accel_edit = DEFAULT_MAX_ACCELERATION;
const xyze_float_t max_acc_edit_scaled = max_accel_edit * 2; constexpr xyze_float_t max_acc_edit_scaled = max_accel_edit * 2;
#endif #endif
limit_and_warn(targetValue, axis, PSTR("Acceleration"), max_acc_edit_scaled); limit_and_warn(targetValue, axis, PSTR("Acceleration"), max_acc_edit_scaled);
#endif #endif
@ -2796,7 +2796,7 @@ void Planner::set_max_feedrate(const uint8_t axis, float targetValue) {
const xyze_float_t &max_fr_edit_scaled = max_fr_edit; const xyze_float_t &max_fr_edit_scaled = max_fr_edit;
#else #else
constexpr xyze_float_t max_fr_edit = DEFAULT_MAX_FEEDRATE; constexpr xyze_float_t max_fr_edit = DEFAULT_MAX_FEEDRATE;
const xyze_float_t max_fr_edit_scaled = max_fr_edit * 2; constexpr xyze_float_t max_fr_edit_scaled = max_fr_edit * 2;
#endif #endif
limit_and_warn(targetValue, axis, PSTR("Feedrate"), max_fr_edit_scaled); limit_and_warn(targetValue, axis, PSTR("Feedrate"), max_fr_edit_scaled);
#endif #endif

105
Marlin/src/module/probe.cpp

@ -21,7 +21,7 @@
*/ */
/** /**
* probe.cpp * module/probe.cpp
*/ */
#include "../inc/MarlinConfig.h" #include "../inc/MarlinConfig.h"
@ -84,14 +84,14 @@
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../core/debug_out.h" #include "../core/debug_out.h"
Probe probe;
xyz_pos_t probe_offset; // Initialized by settings.load() xyz_pos_t Probe::offset; // Initialized by settings.load()
#if HAS_PROBE_XY_OFFSET #if HAS_PROBE_XY_OFFSET
xyz_pos_t &probe_offset_xy = probe_offset; const xyz_pos_t &Probe::offset_xy = probe.offset;
#endif #endif
#if ENABLED(Z_PROBE_SLED) #if ENABLED(Z_PROBE_SLED)
#ifndef SLED_DOCKING_OFFSET #ifndef SLED_DOCKING_OFFSET
@ -104,7 +104,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load()
* stow[in] If false, move to MAX_X and engage the solenoid * stow[in] If false, move to MAX_X and engage the solenoid
* If true, move to MAX_X and release the solenoid * If true, move to MAX_X and release the solenoid
*/ */
static void dock_sled(bool stow) { static void dock_sled(const bool stow) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("dock_sled(", stow, ")"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("dock_sled(", stow, ")");
// Dock sled a bit closer to ensure proper capturing // Dock sled a bit closer to ensure proper capturing
@ -118,7 +118,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load()
#elif ENABLED(TOUCH_MI_PROBE) #elif ENABLED(TOUCH_MI_PROBE)
// Move to the magnet to unlock the probe // Move to the magnet to unlock the probe
void run_deploy_moves_script() { inline void run_deploy_moves_script() {
#ifndef TOUCH_MI_DEPLOY_XPOS #ifndef TOUCH_MI_DEPLOY_XPOS
#define TOUCH_MI_DEPLOY_XPOS X_MIN_POS #define TOUCH_MI_DEPLOY_XPOS X_MIN_POS
#elif TOUCH_MI_DEPLOY_XPOS > X_MAX_BED #elif TOUCH_MI_DEPLOY_XPOS > X_MAX_BED
@ -153,7 +153,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load()
} }
// Move down to the bed to stow the probe // Move down to the bed to stow the probe
void run_stow_moves_script() { inline void run_stow_moves_script() {
const xyz_pos_t oldpos = current_position; const xyz_pos_t oldpos = current_position;
endstops.enable_z_probe(false); endstops.enable_z_probe(false);
do_blocking_move_to_z(TOUCH_MI_RETRACT_Z, MMM_TO_MMS(HOMING_FEEDRATE_Z)); do_blocking_move_to_z(TOUCH_MI_RETRACT_Z, MMM_TO_MMS(HOMING_FEEDRATE_Z));
@ -162,7 +162,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load()
#elif ENABLED(Z_PROBE_ALLEN_KEY) #elif ENABLED(Z_PROBE_ALLEN_KEY)
void run_deploy_moves_script() { inline void run_deploy_moves_script() {
#ifdef Z_PROBE_ALLEN_KEY_DEPLOY_1 #ifdef Z_PROBE_ALLEN_KEY_DEPLOY_1
#ifndef Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE
#define Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE 0.0 #define Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE 0.0
@ -200,7 +200,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load()
#endif #endif
} }
void run_stow_moves_script() { inline void run_stow_moves_script() {
#ifdef Z_PROBE_ALLEN_KEY_STOW_1 #ifdef Z_PROBE_ALLEN_KEY_STOW_1
#ifndef Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE #ifndef Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE
#define Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE 0.0 #define Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE 0.0
@ -241,7 +241,8 @@ xyz_pos_t probe_offset; // Initialized by settings.load()
#endif // Z_PROBE_ALLEN_KEY #endif // Z_PROBE_ALLEN_KEY
#if QUIET_PROBING #if QUIET_PROBING
void probing_pause(const bool p) {
void Probe::set_probing_paused(const bool p) {
#if ENABLED(PROBING_HEATERS_OFF) #if ENABLED(PROBING_HEATERS_OFF)
thermalManager.pause(p); thermalManager.pause(p);
#endif #endif
@ -262,16 +263,17 @@ xyz_pos_t probe_offset; // Initialized by settings.load()
#endif #endif
); );
} }
#endif // QUIET_PROBING #endif // QUIET_PROBING
/** /**
* Raise Z to a minimum height to make room for a probe to move * Raise Z to a minimum height to make room for a probe to move
*/ */
inline void do_probe_raise(const float z_raise) { void Probe::do_z_raise(const float z_raise) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("do_probe_raise(", z_raise, ")"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probe::move_z(", z_raise, ")");
float z_dest = z_raise; float z_dest = z_raise;
if (probe_offset.z < 0) z_dest -= probe_offset.z; if (offset.z < 0) z_dest -= offset.z;
NOMORE(z_dest, Z_MAX_POS); NOMORE(z_dest, Z_MAX_POS);
@ -351,11 +353,15 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
#endif #endif
} }
// returns false for ok and true for failure /**
bool set_probe_deployed(const bool deploy) { * Attempt to deploy or stow the probe
*
* Return TRUE if the probe could not be deployed/stowed
*/
bool Probe::set_deployed(const bool deploy) {
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
DEBUG_POS("set_probe_deployed", current_position); DEBUG_POS("Probe::set_deployed", current_position);
DEBUG_ECHOLNPAIR("deploy: ", deploy); DEBUG_ECHOLNPAIR("deploy: ", deploy);
} }
@ -378,7 +384,7 @@ bool set_probe_deployed(const bool deploy) {
#endif #endif
if (deploy_stow_condition && unknown_condition) if (deploy_stow_condition && unknown_condition)
do_probe_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE)); do_z_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
#if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY) #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)
if (axis_unhomed_error( if (axis_unhomed_error(
@ -433,7 +439,7 @@ bool set_probe_deployed(const bool deploy) {
#ifdef Z_AFTER_PROBING #ifdef Z_AFTER_PROBING
// After probing move to a preferred Z position // After probing move to a preferred Z position
void move_z_after_probing() { void Probe::move_z_after_probing() {
if (current_position.z != Z_AFTER_PROBING) { if (current_position.z != Z_AFTER_PROBING) {
do_blocking_move_to_z(Z_AFTER_PROBING); do_blocking_move_to_z(Z_AFTER_PROBING);
current_position.z = Z_AFTER_PROBING; current_position.z = Z_AFTER_PROBING;
@ -450,11 +456,11 @@ bool set_probe_deployed(const bool deploy) {
*/ */
#if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER) #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
const char msg_wait_for_bed_heating[25] PROGMEM = "Wait for bed heating...\n"; PGM_P Probe::msg_wait_for_bed_heating[25] PROGMEM = "Wait for bed heating...\n";
#endif #endif
static bool do_probe_move(const float z, const feedRate_t fr_mm_s) { bool Probe::move_to_z(const float z, const feedRate_t fr_mm_s) {
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS(">>> Probe::move_to_z", current_position);
#if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER) #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
// Wait for bed to heat back up between probing points // Wait for bed to heat back up between probing points
@ -482,7 +488,7 @@ static bool do_probe_move(const float z, const feedRate_t fr_mm_s) {
#endif #endif
#if QUIET_PROBING #if QUIET_PROBING
probing_pause(true); set_probing_paused(true);
#endif #endif
// Move down until the probe is triggered // Move down until the probe is triggered
@ -504,7 +510,7 @@ static bool do_probe_move(const float z, const feedRate_t fr_mm_s) {
; ;
#if QUIET_PROBING #if QUIET_PROBING
probing_pause(false); set_probing_paused(false);
#endif #endif
// Re-enable stealthChop if used. Disable diag1 pin on driver. // Re-enable stealthChop if used. Disable diag1 pin on driver.
@ -530,7 +536,7 @@ static bool do_probe_move(const float z, const feedRate_t fr_mm_s) {
// Tell the planner where we actually are // Tell the planner where we actually are
sync_plan_position(); sync_plan_position();
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("<<< Probe::move_to_z", current_position);
return !probe_triggered; return !probe_triggered;
} }
@ -543,19 +549,19 @@ static bool do_probe_move(const float z, const feedRate_t fr_mm_s) {
* *
* @return The Z position of the bed at the current XY or NAN on error. * @return The Z position of the bed at the current XY or NAN on error.
*/ */
static float run_z_probe() { float Probe::run_z_probe() {
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> run_z_probe", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS(">>> Probe::run_z_probe", current_position);
// Stop the probe before it goes too low to prevent damage. // Stop the probe before it goes too low to prevent damage.
// If Z isn't known then probe to -10mm. // If Z isn't known then probe to -10mm.
const float z_probe_low_point = TEST(axis_known_position, Z_AXIS) ? -probe_offset.z + Z_PROBE_LOW_POINT : -10.0; const float z_probe_low_point = TEST(axis_known_position, Z_AXIS) ? -offset.z + Z_PROBE_LOW_POINT : -10.0;
// Double-probing does a fast probe followed by a slow probe // Double-probing does a fast probe followed by a slow probe
#if TOTAL_PROBING == 2 #if TOTAL_PROBING == 2
// Do a first probe at the fast speed // Do a first probe at the fast speed
if (do_probe_move(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) { if (move_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) {
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPGM("FAST Probe fail!"); DEBUG_ECHOLNPGM("FAST Probe fail!");
DEBUG_POS("<<< run_z_probe", current_position); DEBUG_POS("<<< run_z_probe", current_position);
@ -574,10 +580,10 @@ static float run_z_probe() {
// If the nozzle is well over the travel height then // If the nozzle is well over the travel height then
// move down quickly before doing the slow probe // move down quickly before doing the slow probe
const float z = Z_CLEARANCE_DEPLOY_PROBE + 5.0 + (probe_offset.z < 0 ? -probe_offset.z : 0); const float z = Z_CLEARANCE_DEPLOY_PROBE + 5.0 + (offset.z < 0 ? -offset.z : 0);
if (current_position.z > z) { if (current_position.z > z) {
// Probe down fast. If the probe never triggered, raise for probe clearance // Probe down fast. If the probe never triggered, raise for probe clearance
if (!do_probe_move(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) if (!move_to_z(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST)))
do_blocking_move_to_z(current_position.z + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST)); do_blocking_move_to_z(current_position.z + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
} }
#endif #endif
@ -587,7 +593,7 @@ static float run_z_probe() {
#endif #endif
#if TOTAL_PROBING > 2 #if TOTAL_PROBING > 2
float probes_total = 0; float probes_z_sum = 0;
for ( for (
#if EXTRA_PROBING #if EXTRA_PROBING
uint8_t p = 0; p < TOTAL_PROBING; p++ uint8_t p = 0; p < TOTAL_PROBING; p++
@ -598,7 +604,7 @@ static float run_z_probe() {
#endif #endif
{ {
// Probe downward slowly to find the bed // Probe downward slowly to find the bed
if (do_probe_move(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW))) { if (move_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW))) {
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPGM("SLOW Probe fail!"); DEBUG_ECHOLNPGM("SLOW Probe fail!");
DEBUG_POS("<<< run_z_probe", current_position); DEBUG_POS("<<< run_z_probe", current_position);
@ -622,7 +628,7 @@ static float run_z_probe() {
} }
} }
#elif TOTAL_PROBING > 2 #elif TOTAL_PROBING > 2
probes_total += z; probes_z_sum += z;
#else #else
UNUSED(z); UNUSED(z);
#endif #endif
@ -653,11 +659,11 @@ static float run_z_probe() {
// Return the average value of all remaining probes. // Return the average value of all remaining probes.
for (uint8_t i = min_avg_idx; i <= max_avg_idx; i++) for (uint8_t i = min_avg_idx; i <= max_avg_idx; i++)
probes_total += probes[i]; probes_z_sum += probes[i];
#endif #endif
const float measured_z = probes_total * RECIPROCAL(MULTIPLE_PROBING); const float measured_z = probes_z_sum * RECIPROCAL(MULTIPLE_PROBING);
#elif TOTAL_PROBING == 2 #elif TOTAL_PROBING == 2
@ -689,10 +695,10 @@ static float run_z_probe() {
* - Raise to the BETWEEN height * - Raise to the BETWEEN height
* - Return the probed Z position * - Return the probed Z position
*/ */
float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/) { float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/) {
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPAIR( DEBUG_ECHOLNPAIR(
">>> probe_at_point(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry), ">>> Probe::probe_at_point(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry),
", ", raise_after == PROBE_PT_RAISE ? "raise" : raise_after == PROBE_PT_STOW ? "stow" : "none", ", ", raise_after == PROBE_PT_RAISE ? "raise" : raise_after == PROBE_PT_STOW ? "stow" : "none",
", ", int(verbose_level), ", ", int(verbose_level),
", ", probe_relative ? "probe" : "nozzle", "_relative)" ", ", probe_relative ? "probe" : "nozzle", "_relative)"
@ -702,9 +708,12 @@ float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_
// TODO: Adapt for SCARA, where the offset rotates // TODO: Adapt for SCARA, where the offset rotates
xyz_pos_t npos = { rx, ry }; xyz_pos_t npos = { rx, ry };
if (probe_relative) { if (probe_relative) { // The given position is in terms of the probe
if (!position_is_reachable_by_probe(npos)) return NAN; // The given position is in terms of the probe if (!position_is_reachable_by_probe(npos)) {
npos -= probe_offset_xy; // Get the nozzle position if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Position Not Reachable");
return NAN;
}
npos -= offset_xy; // Get the nozzle position
} }
else if (!position_is_reachable(npos)) return NAN; // The given position is in terms of the nozzle else if (!position_is_reachable(npos)) return NAN; // The given position is in terms of the nozzle
@ -724,38 +733,38 @@ float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_
do_blocking_move_to(npos); do_blocking_move_to(npos);
float measured_z = NAN; float measured_z = NAN;
if (!DEPLOY_PROBE()) { if (!deploy()) {
measured_z = run_z_probe() + probe_offset.z; measured_z = run_z_probe() + offset.z;
const bool big_raise = raise_after == PROBE_PT_BIG_RAISE; const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;
if (big_raise || raise_after == PROBE_PT_RAISE) if (big_raise || raise_after == PROBE_PT_RAISE)
do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), MMM_TO_MMS(Z_PROBE_SPEED_FAST)); do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), MMM_TO_MMS(Z_PROBE_SPEED_FAST));
else if (raise_after == PROBE_PT_STOW) else if (raise_after == PROBE_PT_STOW)
if (STOW_PROBE()) measured_z = NAN; if (stow()) measured_z = NAN;
} }
if (verbose_level > 2) { if (verbose_level > 2) {
SERIAL_ECHOPAIR_F("Bed X: ", LOGICAL_X_POSITION(rx), 3); SERIAL_ECHOPAIR_F("Bed X: ", LOGICAL_X_POSITION(rx), 3);
SERIAL_ECHOPAIR_F(" Y: ", LOGICAL_Y_POSITION(ry), 3); SERIAL_ECHOPAIR_F( " Y: ", LOGICAL_Y_POSITION(ry), 3);
SERIAL_ECHOLNPAIR_F(" Z: ", measured_z, 3); SERIAL_ECHOLNPAIR_F( " Z: ", measured_z, 3);
} }
feedrate_mm_s = old_feedrate_mm_s; feedrate_mm_s = old_feedrate_mm_s;
if (isnan(measured_z)) { if (isnan(measured_z)) {
STOW_PROBE(); stow();
LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED); LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);
SERIAL_ERROR_MSG(MSG_ERR_PROBING_FAILED); SERIAL_ERROR_MSG(MSG_ERR_PROBING_FAILED);
} }
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< probe_at_point"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< Probe::probe_at_point");
return measured_z; return measured_z;
} }
#if HAS_Z_SERVO_PROBE #if HAS_Z_SERVO_PROBE
void servo_probe_init() { void Probe::servo_probe_init() {
/** /**
* Set position of Z Servo Endstop * Set position of Z Servo Endstop
* *

232
Marlin/src/module/probe.h

@ -22,132 +22,150 @@
#pragma once #pragma once
/** /**
* probe.h - Move, deploy, enable, etc. * module/probe.h - Move, deploy, enable, etc.
*/ */
#include "../inc/MarlinConfig.h" #include "../inc/MarlinConfig.h"
#if HAS_BED_PROBE #if HAS_BED_PROBE
enum ProbePtRaise : uint8_t {
extern xyz_pos_t probe_offset; PROBE_PT_NONE, // No raise or stow after run_z_probe
PROBE_PT_STOW, // Do a complete stow after run_z_probe
#if HAS_PROBE_XY_OFFSET PROBE_PT_RAISE, // Raise to "between" clearance after run_z_probe
extern xyz_pos_t &probe_offset_xy;
#else
constexpr xy_pos_t probe_offset_xy{0};
#endif
bool set_probe_deployed(const bool deploy);
#ifdef Z_AFTER_PROBING
void move_z_after_probing();
#endif
enum ProbePtRaise : unsigned char {
PROBE_PT_NONE, // No raise or stow after run_z_probe
PROBE_PT_STOW, // Do a complete stow after run_z_probe
PROBE_PT_RAISE, // Raise to "between" clearance after run_z_probe
PROBE_PT_BIG_RAISE // Raise to big clearance after run_z_probe PROBE_PT_BIG_RAISE // Raise to big clearance after run_z_probe
}; };
float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true); #endif
inline float probe_at_point(const xy_pos_t &pos, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true) {
return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative);
}
#define DEPLOY_PROBE() set_probe_deployed(true)
#define STOW_PROBE() set_probe_deployed(false)
#if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
extern const char msg_wait_for_bed_heating[25];
#endif
#else class Probe {
public:
constexpr xyz_pos_t probe_offset{0}; #if HAS_BED_PROBE
constexpr xy_pos_t probe_offset_xy{0};
#define DEPLOY_PROBE() static xyz_pos_t offset;
#define STOW_PROBE()
#endif // Use offset_xy for read only access
// More optimal the XY offset is known to always be zero.
#if HAS_PROBE_XY_OFFSET
static const xyz_pos_t &offset_xy;
#else
static constexpr xy_pos_t offset_xy{0};
#endif
#if HAS_BED_PROBE || HAS_LEVELING static bool set_deployed(const bool deploy);
#if IS_KINEMATIC
constexpr float printable_radius = ( #ifdef Z_AFTER_PROBING
#if ENABLED(DELTA) static void move_z_after_probing();
DELTA_PRINTABLE_RADIUS #endif
#elif IS_SCARA static float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true);
SCARA_PRINTABLE_RADIUS static inline float probe_at_point(const xy_pos_t &pos, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true) {
#endif return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative);
);
inline float probe_radius() {
return printable_radius - _MAX(MIN_PROBE_EDGE, HYPOT(probe_offset_xy.x, probe_offset_xy.y));
} }
#if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
static PGM_P msg_wait_for_bed_heating[25];
#endif
#else
static constexpr xyz_pos_t offset{0};
static constexpr xy_pos_t offset_xy{0};
static bool set_deployed(const bool) { return false; }
#endif #endif
inline float probe_min_x() { static inline bool deploy() { return set_deployed(true); }
return ( static inline bool stow() { return set_deployed(false); }
#if IS_KINEMATIC
(X_CENTER) - probe_radius() #if HAS_BED_PROBE || HAS_LEVELING
#else #if IS_KINEMATIC
_MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + probe_offset_xy.x) static constexpr float printable_radius = (
#endif #if ENABLED(DELTA)
); DELTA_PRINTABLE_RADIUS
} #elif IS_SCARA
inline float probe_max_x() { SCARA_PRINTABLE_RADIUS
return ( #endif
#if IS_KINEMATIC );
(X_CENTER) + probe_radius()
#else static inline float probe_radius() {
_MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + probe_offset_xy.x) return printable_radius - _MAX(MIN_PROBE_EDGE, HYPOT(offset_xy.x, offset_xy.y));
#endif }
); #endif
}
inline float probe_min_y() { static inline float min_x() {
return ( return (
#if IS_KINEMATIC
(Y_CENTER) - probe_radius()
#else
_MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + probe_offset_xy.y)
#endif
);
}
inline float probe_max_y() {
return (
#if IS_KINEMATIC
(Y_CENTER) + probe_radius()
#else
_MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + probe_offset_xy.y)
#endif
);
}
#if NEEDS_THREE_PROBE_POINTS
// Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used.
template <typename T>
inline void get_three_probe_points(T points[3]) {
#if ENABLED(HAS_FIXED_3POINT)
points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y);
points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y);
points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y);
#else
#if IS_KINEMATIC #if IS_KINEMATIC
constexpr float SIN0 = 0.0, SIN120 = 0.866025, SIN240 = -0.866025, (X_CENTER) - probe_radius()
COS0 = 1.0, COS120 = -0.5 , COS240 = -0.5;
points[0].set((X_CENTER) + probe_radius() * COS0, (Y_CENTER) + probe_radius() * SIN0);
points[1].set((X_CENTER) + probe_radius() * COS120, (Y_CENTER) + probe_radius() * SIN120);
points[2].set((X_CENTER) + probe_radius() * COS240, (Y_CENTER) + probe_radius() * SIN240);
#else #else
points[0].set(probe_min_x(), probe_min_y()); _MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + offset_xy.x)
points[1].set(probe_max_x(), probe_min_y());
points[2].set((probe_max_x() - probe_min_x()) / 2, probe_max_y());
#endif #endif
#endif );
} }
static inline float max_x() {
return (
#if IS_KINEMATIC
(X_CENTER) + probe_radius()
#else
_MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + offset_xy.x)
#endif
);
}
static inline float min_y() {
return (
#if IS_KINEMATIC
(Y_CENTER) - probe_radius()
#else
_MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + offset_xy.y)
#endif
);
}
static inline float max_y() {
return (
#if IS_KINEMATIC
(Y_CENTER) + probe_radius()
#else
_MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + offset_xy.y)
#endif
);
}
#if NEEDS_THREE_PROBE_POINTS
// Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used.
template <typename T>
static inline void get_three_points(T points[3]) {
#if ENABLED(HAS_FIXED_3POINT)
points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y);
points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y);
points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y);
#else
#if IS_KINEMATIC
constexpr float SIN0 = 0.0, SIN120 = 0.866025, SIN240 = -0.866025,
COS0 = 1.0, COS120 = -0.5 , COS240 = -0.5;
points[0].set((X_CENTER) + probe_radius() * COS0, (Y_CENTER) + probe_radius() * SIN0);
points[1].set((X_CENTER) + probe_radius() * COS120, (Y_CENTER) + probe_radius() * SIN120);
points[2].set((X_CENTER) + probe_radius() * COS240, (Y_CENTER) + probe_radius() * SIN240);
#else
points[0].set(min_x(), min_y());
points[1].set(max_x(), min_y());
points[2].set((max_x() - min_x()) / 2, max_y());
#endif
#endif
}
#endif
#endif // HAS_BED_PROBE
#if HAS_Z_SERVO_PROBE
static void servo_probe_init();
#endif #endif
#endif
#if HAS_Z_SERVO_PROBE #if QUIET_PROBING
void servo_probe_init(); static void set_probing_paused(const bool p);
#endif #endif
#if QUIET_PROBING private:
void probing_pause(const bool p); static bool move_to_z(const float z, const feedRate_t fr_mm_s);
#endif static void do_z_raise(const float z_raise);
static float run_z_probe();
};
extern Probe probe;

Loading…
Cancel
Save