Eliminate goto in gcode_M48

master
Scott Lahteine 7 years ago
parent 75e6ead5fd
commit ac76101ec3

@ -7038,8 +7038,9 @@ inline void gcode_M42() {
// 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, stow_probe_after_each, verbose_level);
if (nan_error(t)) goto FAIL; bool probing_good = !isnan(t);
if (probing_good) {
randomSeed(millis()); randomSeed(millis());
for (uint8_t n = 0; n < n_samples; n++) { for (uint8_t n = 0; n < n_samples; n++) {
@ -7113,7 +7114,10 @@ inline void gcode_M42() {
// 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, stow_probe_after_each, 0);
if (nan_error(sample_set[n])) goto FAIL;
// Break the loop if the probe fails
probing_good = !isnan(sample_set[n]);
if (!probing_good) break;
/** /**
* Get the current mean for the data points we have so far * Get the current mean for the data points we have so far
@ -7157,12 +7161,13 @@ inline void gcode_M42() {
} }
} }
} // End of probe loop } // n_samples loop
}
if (STOW_PROBE()) goto FAIL; STOW_PROBE();
SERIAL_PROTOCOLPGM("Finished!"); if (probing_good) {
SERIAL_EOL(); SERIAL_PROTOCOLLNPGM("Finished!");
if (verbose_level > 0) { if (verbose_level > 0) {
SERIAL_PROTOCOLPGM("Mean: "); SERIAL_PROTOCOLPGM("Mean: ");
@ -7180,8 +7185,7 @@ inline void gcode_M42() {
SERIAL_PROTOCOL_F(sigma, 6); SERIAL_PROTOCOL_F(sigma, 6);
SERIAL_EOL(); SERIAL_EOL();
SERIAL_EOL(); SERIAL_EOL();
}
FAIL:
clean_up_after_endstop_or_probe_move(); clean_up_after_endstop_or_probe_move();

Loading…
Cancel
Save