Browse Source

Allow no raise after run_z_probe in probe_pt

pull/1/head
Scott Lahteine 7 years ago
parent
commit
c352954882
  1. 10
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  2. 6
      Marlin/src/gcode/bedlevel/abl/G29.cpp
  3. 2
      Marlin/src/gcode/calibrate/G33.cpp
  4. 6
      Marlin/src/gcode/calibrate/M48.cpp
  5. 6
      Marlin/src/gcode/probe/G30.cpp
  6. 12
      Marlin/src/module/probe.cpp
  7. 7
      Marlin/src/module/probe.h

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

@ -750,7 +750,7 @@
const float rawx = mesh_index_to_xpos(location.x_index), const float rawx = mesh_index_to_xpos(location.x_index),
rawy = mesh_index_to_ypos(location.y_index); rawy = mesh_index_to_ypos(location.y_index);
const float measured_z = probe_pt(rawx, rawy, stow_probe, g29_verbose_level); // TODO: Needs error handling const float measured_z = probe_pt(rawx, rawy, stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
z_values[location.x_index][location.y_index] = measured_z; z_values[location.x_index][location.y_index] = measured_z;
} }
SERIAL_FLUSH(); // Prevent host M105 buffer overrun. SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
@ -1519,7 +1519,7 @@
incremental_LSF_reset(&lsf_results); incremental_LSF_reset(&lsf_results);
if (do_3_pt_leveling) { if (do_3_pt_leveling) {
measured_z = probe_pt(PROBE_PT_1_X, PROBE_PT_1_Y, false, g29_verbose_level); measured_z = probe_pt(PROBE_PT_1_X, PROBE_PT_1_Y, PROBE_PT_RAISE, g29_verbose_level);
if (isnan(measured_z)) if (isnan(measured_z))
abort_flag = true; abort_flag = true;
else { else {
@ -1533,7 +1533,7 @@
} }
if (!abort_flag) { if (!abort_flag) {
measured_z = probe_pt(PROBE_PT_2_X, PROBE_PT_2_Y, false, g29_verbose_level); measured_z = probe_pt(PROBE_PT_2_X, PROBE_PT_2_Y, PROBE_PT_RAISE, g29_verbose_level);
//z2 = measured_z; //z2 = measured_z;
if (isnan(measured_z)) if (isnan(measured_z))
abort_flag = true; abort_flag = true;
@ -1548,7 +1548,7 @@
} }
if (!abort_flag) { if (!abort_flag) {
measured_z = probe_pt(PROBE_PT_3_X, PROBE_PT_3_Y, true, g29_verbose_level); measured_z = probe_pt(PROBE_PT_3_X, PROBE_PT_3_Y, PROBE_PT_STOW, g29_verbose_level);
//z3 = measured_z; //z3 = measured_z;
if (isnan(measured_z)) if (isnan(measured_z))
abort_flag = true; abort_flag = true;
@ -1576,7 +1576,7 @@
const float ry = float(y_min) + dy * (zig_zag ? g29_grid_size - 1 - iy : iy); const float ry = float(y_min) + dy * (zig_zag ? g29_grid_size - 1 - iy : iy);
if (!abort_flag) { if (!abort_flag) {
measured_z = probe_pt(rx, ry, parser.seen('E'), g29_verbose_level); // TODO: Needs error handling measured_z = probe_pt(rx, ry, 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);

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

@ -604,7 +604,7 @@ void GcodeSuite::G29() {
#else // !PROBE_MANUALLY #else // !PROBE_MANUALLY
{ {
const bool stow_probe_after_each = parser.boolval('E'); const ProbePtRaise raise_after = parser.boolval('E') ? PROBE_PT_STOW : PROBE_PT_RAISE;
measured_z = 0; measured_z = 0;
@ -650,7 +650,7 @@ void GcodeSuite::G29() {
if (!position_is_reachable_by_probe(xProbe, yProbe)) continue; if (!position_is_reachable_by_probe(xProbe, yProbe)) continue;
#endif #endif
measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level); measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, 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);
@ -687,7 +687,7 @@ void GcodeSuite::G29() {
// Retain the last probe position // Retain the last probe position
xProbe = points[i].x; xProbe = points[i].x;
yProbe = points[i].y; yProbe = points[i].y;
measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level); measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, 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;

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

@ -137,7 +137,7 @@ static void G33_cleanup(
inline float calibration_probe(const float nx, const float ny, const bool stow) { inline float calibration_probe(const float nx, const float ny, const bool stow) {
#if HAS_BED_PROBE #if HAS_BED_PROBE
return probe_pt(nx, ny, stow, 0, false); return probe_pt(nx, ny, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, false);
#else #else
UNUSED(stow); UNUSED(stow);
return lcd_probe_pt(nx, ny); return lcd_probe_pt(nx, ny);

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

@ -70,7 +70,7 @@ void GcodeSuite::M48() {
return; return;
} }
const bool stow_probe_after_each = parser.boolval('E'); const ProbePtRaise raise_after = parser.boolval('E') ? PROBE_PT_STOW : PROBE_PT_RAISE;
float X_current = current_position[X_AXIS], float X_current = current_position[X_AXIS],
Y_current = current_position[Y_AXIS]; Y_current = current_position[Y_AXIS];
@ -114,7 +114,7 @@ void GcodeSuite::M48() {
double mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples]; double 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_pt(X_probe_location, Y_probe_location, stow_probe_after_each, verbose_level); const float t = probe_pt(X_probe_location, Y_probe_location, raise_after, verbose_level);
bool probing_good = !isnan(t); bool probing_good = !isnan(t);
if (probing_good) { if (probing_good) {
@ -190,7 +190,7 @@ void GcodeSuite::M48() {
} // n_legs } // n_legs
// Probe a single point // Probe a single point
sample_set[n] = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, 0); sample_set[n] = probe_pt(X_probe_location, Y_probe_location, 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]);

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

@ -51,8 +51,8 @@ void GcodeSuite::G30() {
setup_for_endstop_or_probe_move(); setup_for_endstop_or_probe_move();
const bool do_stow = parser.boolval('E'); const ProbePtRaise raise_after = parser.boolval('E') ? PROBE_PT_STOW : PROBE_PT_NONE;
const float measured_z = probe_pt(xpos, ypos, do_stow, 1); const float measured_z = probe_pt(xpos, ypos, raise_after, 1);
if (!isnan(measured_z)) { if (!isnan(measured_z)) {
SERIAL_PROTOCOLPAIR("Bed X: ", FIXFLOAT(xpos)); SERIAL_PROTOCOLPAIR("Bed X: ", FIXFLOAT(xpos));
@ -62,7 +62,7 @@ void GcodeSuite::G30() {
clean_up_after_endstop_or_probe_move(); clean_up_after_endstop_or_probe_move();
if (do_stow) move_z_after_probing(); if (raise_after == PROBE_PT_STOW) move_z_after_probing();
report_current_position(); report_current_position();
} }

12
Marlin/src/module/probe.cpp

@ -631,13 +631,15 @@ 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_pt(const float &rx, const float &ry, const bool stow, const uint8_t verbose_level, const bool probe_relative/*=true*/) { float probe_pt(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 ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR(">>> probe_pt(", LOGICAL_X_POSITION(rx)); SERIAL_ECHOPAIR(">>> probe_pt(", LOGICAL_X_POSITION(rx));
SERIAL_ECHOPAIR(", ", LOGICAL_Y_POSITION(ry)); SERIAL_ECHOPAIR(", ", LOGICAL_Y_POSITION(ry));
SERIAL_ECHOPAIR(", ", stow ? "" : "no "); SERIAL_ECHOPAIR(", ", raise_after == PROBE_PT_RAISE ? "raise" : raise_after == PROBE_PT_STOW ? "stow" : "none");
SERIAL_ECHOLNPGM("stow)"); SERIAL_ECHOPAIR(", ", int(verbose_level));
SERIAL_ECHOPAIR(", ", probe_relative ? "probe" : "nozzle");
SERIAL_ECHOLNPGM("_relative)");
DEBUG_POS("", current_position); DEBUG_POS("", current_position);
} }
#endif #endif
@ -670,9 +672,9 @@ float probe_pt(const float &rx, const float &ry, const bool stow, const uint8_t
if (!DEPLOY_PROBE()) { if (!DEPLOY_PROBE()) {
measured_z = run_z_probe() + zprobe_zoffset; measured_z = run_z_probe() + zprobe_zoffset;
if (!stow) if (raise_after == PROBE_PT_RAISE)
do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST)); do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
else else if (raise_after == PROBE_PT_STOW)
if (STOW_PROBE()) measured_z = NAN; if (STOW_PROBE()) measured_z = NAN;
} }

7
Marlin/src/module/probe.h

@ -37,7 +37,12 @@
#else #else
inline void move_z_after_probing() {} inline void move_z_after_probing() {}
#endif #endif
float probe_pt(const float &rx, const float &ry, const bool, const uint8_t, const bool probe_relative=true); 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
};
float probe_pt(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true);
#define DEPLOY_PROBE() set_probe_deployed(true) #define DEPLOY_PROBE() set_probe_deployed(true)
#define STOW_PROBE() set_probe_deployed(false) #define STOW_PROBE() set_probe_deployed(false)
#else #else

Loading…
Cancel
Save