Unify debugging output with debug_out.h (#13388)

This commit is contained in:
Scott Lahteine
2019-03-14 02:25:42 -05:00
committed by GitHub
parent cc8a871705
commit f5bcc00570
25 changed files with 627 additions and 904 deletions

View File

@ -69,6 +69,9 @@ float zprobe_zoffset; // Initialized by settings.load()
#include "stepper_indirection.h"
#endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../core/debug_out.h"
#if ENABLED(Z_PROBE_SLED)
#ifndef SLED_DOCKING_OFFSET
@ -82,9 +85,7 @@ float zprobe_zoffset; // Initialized by settings.load()
* If true, move to MAX_X and release the solenoid
*/
static void dock_sled(bool stow) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("dock_sled(", stow, ")");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("dock_sled(", stow, ")");
// Dock sled a bit closer to ensure proper capturing
do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET - ((stow) ? 1 : 0));
@ -312,9 +313,7 @@ float zprobe_zoffset; // Initialized by settings.load()
bltouch_command(deploy ? BLTOUCH_DEPLOY : BLTOUCH_STOW);
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("set_bltouch_deployed(", deploy, ")");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("set_bltouch_deployed(", deploy, ")");
return false;
}
@ -325,9 +324,7 @@ float zprobe_zoffset; // Initialized by settings.load()
* Raise Z to a minimum height to make room for a probe to move
*/
inline void do_probe_raise(const float z_raise) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("do_probe_raise(", z_raise, ")");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("do_probe_raise(", z_raise, ")");
float z_dest = z_raise;
if (zprobe_zoffset < 0) z_dest -= zprobe_zoffset;
@ -393,12 +390,10 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
// returns false for ok and true for failure
bool set_probe_deployed(const bool deploy) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
DEBUG_POS("set_probe_deployed", current_position);
SERIAL_ECHOLNPAIR("deploy: ", deploy);
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_POS("set_probe_deployed", current_position);
DEBUG_ECHOLNPAIR("deploy: ", deploy);
}
if (endstops.z_probe_enabled == deploy) return false;
@ -521,9 +516,7 @@ bool set_probe_deployed(const bool deploy) {
#endif
static bool do_probe_move(const float z, const float fr_mm_s) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position);
#if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
// Wait for bed to heat back up between probing points
@ -601,9 +594,7 @@ static bool do_probe_move(const float z, const float fr_mm_s) {
// Tell the planner where we actually are
sync_plan_position();
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position);
return !probe_triggered;
}
@ -616,9 +607,7 @@ static bool do_probe_move(const float z, const float fr_mm_s) {
*/
static float run_z_probe() {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> run_z_probe", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> run_z_probe", current_position);
// Stop the probe before it goes too low to prevent damage.
// If Z isn't known then probe to -10mm.
@ -629,20 +618,16 @@ static float run_z_probe() {
// Do a first probe at the fast speed
if (do_probe_move(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM("FAST Probe fail!");
DEBUG_POS("<<< run_z_probe", current_position);
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPGM("FAST Probe fail!");
DEBUG_POS("<<< run_z_probe", current_position);
}
return NAN;
}
float first_probe_z = current_position[Z_AXIS];
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("1st Probe Z:", first_probe_z);
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("1st Probe Z:", first_probe_z);
// move up to make clearance for the probe
do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_MULTI_PROBE, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
@ -666,12 +651,10 @@ static float run_z_probe() {
// move down slowly to find bed
if (do_probe_move(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW))) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM("SLOW Probe fail!");
DEBUG_POS("<<< run_z_probe", current_position);
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPGM("SLOW Probe fail!");
DEBUG_POS("<<< run_z_probe", current_position);
}
return NAN;
}
@ -694,9 +677,7 @@ static float run_z_probe() {
const float z2 = current_position[Z_AXIS];
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("2nd Probe Z:", z2, " Discrepancy:", first_probe_z - z2);
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("2nd Probe Z:", z2, " Discrepancy:", first_probe_z - z2);
// Return a weighted average of the fast and slow probes
const float measured_z = (z2 * 3.0 + first_probe_z * 2.0) * 0.2;
@ -708,9 +689,7 @@ static float run_z_probe() {
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
return measured_z;
}
@ -725,19 +704,15 @@ static float run_z_probe() {
* - Return the probed Z position
*/
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 (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPAIR(
">>> probe_pt(", LOGICAL_X_POSITION(rx),
", ", LOGICAL_Y_POSITION(ry),
", ", raise_after == PROBE_PT_RAISE ? "raise" : raise_after == PROBE_PT_STOW ? "stow" : "none",
", ", int(verbose_level),
", ", probe_relative ? "probe" : "nozzle",
"_relative)"
);
DEBUG_POS("", current_position);
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPAIR(
">>> probe_pt(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry),
", ", raise_after == PROBE_PT_RAISE ? "raise" : raise_after == PROBE_PT_STOW ? "stow" : "none",
", ", int(verbose_level),
", ", probe_relative ? "probe" : "nozzle", "_relative)"
);
DEBUG_POS("", current_position);
}
// TODO: Adapt for SCARA, where the offset rotates
float nx = rx, ny = ry;
@ -788,9 +763,7 @@ float probe_pt(const float &rx, const float &ry, const ProbePtRaise raise_after/
SERIAL_ERROR_MSG(MSG_ERR_PROBING_FAILED);
}
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< probe_pt");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< probe_pt");
return measured_z;
}