Unify debugging output with debug_out.h (#13388)

2.0.x
Scott Lahteine 6 years ago committed by GitHub
parent cc8a871705
commit f5bcc00570
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,89 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
//
// Serial aliases for debugging.
// Include this header after defining DEBUG_OUT
// (or not) in a given .cpp file
//
#undef DEBUG_ECHO_START
#undef DEBUG_ERROR_START
#undef DEBUG_CHAR
#undef DEBUG_ECHO
#undef DEBUG_ECHO_F
#undef DEBUG_ECHOLN
#undef DEBUG_ECHOPGM
#undef DEBUG_ECHOLNPGM
#undef DEBUG_ECHOPAIR
#undef DEBUG_ECHOPAIR_F
#undef DEBUG_ECHOLNPAIR
#undef DEBUG_ECHOLNPAIR_F
#undef DEBUG_ECHO_MSG
#undef DEBUG_ERROR_MSG
#undef DEBUG_EOL
#undef DEBUG_POS
#undef DEBUG_XYZ
#undef DEBUG_DELAY
#if DEBUG_OUT
#define DEBUG_ECHO_START SERIAL_ECHO_START
#define DEBUG_ERROR_START SERIAL_ERROR_START
#define DEBUG_CHAR SERIAL_CHAR
#define DEBUG_ECHO SERIAL_ECHO
#define DEBUG_ECHO_F SERIAL_ECHO_F
#define DEBUG_ECHOLN SERIAL_ECHOLN
#define DEBUG_ECHOPGM SERIAL_ECHOPGM
#define DEBUG_ECHOLNPGM SERIAL_ECHOLNPGM
#define DEBUG_ECHOPAIR SERIAL_ECHOPAIR
#define DEBUG_ECHOPAIR_F SERIAL_ECHOPAIR_F
#define DEBUG_ECHOLNPAIR SERIAL_ECHOLNPAIR
#define DEBUG_ECHOLNPAIR_F SERIAL_ECHOLNPAIR_F
#define DEBUG_ECHO_MSG SERIAL_ECHO_MSG
#define DEBUG_ERROR_MSG SERIAL_ERROR_MSG
#define DEBUG_EOL SERIAL_EOL
#define DEBUG_POS SERIAL_POS
#define DEBUG_XYZ SERIAL_XYZ
#define DEBUG_DELAY(ms) serial_delay(ms)
#else
#define DEBUG_ECHO_START() NOOP
#define DEBUG_ERROR_START() NOOP
#define DEBUG_CHAR(...) NOOP
#define DEBUG_ECHO(...) NOOP
#define DEBUG_ECHO_F(...) NOOP
#define DEBUG_ECHOLN(...) NOOP
#define DEBUG_ECHOPGM(...) NOOP
#define DEBUG_ECHOLNPGM(...) NOOP
#define DEBUG_ECHOPAIR(...) NOOP
#define DEBUG_ECHOPAIR_F(...) NOOP
#define DEBUG_ECHOLNPAIR(...) NOOP
#define DEBUG_ECHOLNPAIR_F(...) NOOP
#define DEBUG_ECHO_MSG(...) NOOP
#define DEBUG_ERROR_MSG(...) NOOP
#define DEBUG_EOL() NOOP
#define DEBUG_POS(...) NOOP
#define DEBUG_XYZ(...) NOOP
#define DEBUG_DELAY(...) NOOP
#endif
#undef DEBUG_OUT

@ -35,8 +35,13 @@ enum MarlinDebugFlags : uint8_t {
MARLIN_DEBUG_ERRORS = _BV(2), ///< Not implemented MARLIN_DEBUG_ERRORS = _BV(2), ///< Not implemented
MARLIN_DEBUG_DRYRUN = _BV(3), ///< Ignore temperature setting and E movement commands MARLIN_DEBUG_DRYRUN = _BV(3), ///< Ignore temperature setting and E movement commands
MARLIN_DEBUG_COMMUNICATION = _BV(4), ///< Not implemented MARLIN_DEBUG_COMMUNICATION = _BV(4), ///< Not implemented
MARLIN_DEBUG_LEVELING = _BV(5), ///< Print detailed output for homing and leveling #if ENABLED(DEBUG_LEVELING_FEATURE)
MARLIN_DEBUG_MESH_ADJUST = _BV(6), ///< UBL bed leveling MARLIN_DEBUG_LEVELING = _BV(5), ///< Print detailed output for homing and leveling
MARLIN_DEBUG_MESH_ADJUST = _BV(6), ///< UBL bed leveling
#else
MARLIN_DEBUG_LEVELING = 0,
MARLIN_DEBUG_MESH_ADJUST = 0,
#endif
MARLIN_DEBUG_ALL = 0xFF MARLIN_DEBUG_ALL = 0xFF
}; };
@ -178,5 +183,9 @@ void print_bin(const uint16_t val);
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float x, const float y, const float z); void print_xyz(PGM_P const prefix, PGM_P const suffix, const float x, const float y, const float z);
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float xyz[]); void print_xyz(PGM_P const prefix, PGM_P const suffix, const float xyz[]);
#define DEBUG_POS(SUFFIX,VAR) do { print_xyz(PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); } while(0) #define SERIAL_POS(SUFFIX,VAR) do { print_xyz(PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); } while(0)
#define SERIAL_XYZ(PREFIX,...) do { print_xyz(PSTR(PREFIX), NULL, __VA_ARGS__); } while(0)
#else
#define SERIAL_POS(...) NOOP
#define SERIAL_XYZ(...) NOOP
#endif #endif

@ -321,8 +321,11 @@ void safe_delay(millis_t ms) {
); );
#if HAS_BED_PROBE #if HAS_BED_PROBE
SERIAL_ECHOPGM("Probe Offset X:" STRINGIFY(X_PROBE_OFFSET_FROM_EXTRUDER) " Y:" STRINGIFY(Y_PROBE_OFFSET_FROM_EXTRUDER)); SERIAL_ECHOPAIR(
SERIAL_ECHOPAIR(" Z:", zprobe_zoffset); "Probe Offset X:" STRINGIFY(X_PROBE_OFFSET_FROM_EXTRUDER)
" Y:" STRINGIFY(Y_PROBE_OFFSET_FROM_EXTRUDER)
" Z:", zprobe_zoffset
);
if ((X_PROBE_OFFSET_FROM_EXTRUDER) > 0) if ((X_PROBE_OFFSET_FROM_EXTRUDER) > 0)
SERIAL_ECHOPGM(" (Right"); SERIAL_ECHOPGM(" (Right");
else if ((X_PROBE_OFFSET_FROM_EXTRUDER) < 0) else if ((X_PROBE_OFFSET_FROM_EXTRUDER) < 0)

@ -118,6 +118,8 @@ inline void serial_delay(const millis_t ms) {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
void log_machine_info(); void log_machine_info();
#else
#define log_machine_info() NOOP
#endif #endif
template<typename T> template<typename T>

@ -29,6 +29,9 @@
#include "../../../module/motion.h" #include "../../../module/motion.h"
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../../core/debug_out.h"
int bilinear_grid_spacing[2], bilinear_start[2]; int bilinear_grid_spacing[2], bilinear_start[2];
float bilinear_grid_factor[2], float bilinear_grid_factor[2],
z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
@ -37,26 +40,21 @@ float bilinear_grid_factor[2],
* Extrapolate a single point from its neighbors * Extrapolate a single point from its neighbors
*/ */
static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) { static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM("Extrapolate [");
SERIAL_ECHOPGM("Extrapolate ["); if (x < 10) DEBUG_CHAR(' ');
if (x < 10) SERIAL_CHAR(' '); DEBUG_ECHO((int)x);
SERIAL_ECHO((int)x); DEBUG_CHAR(xdir ? (xdir > 0 ? '+' : '-') : ' ');
SERIAL_CHAR(xdir ? (xdir > 0 ? '+' : '-') : ' '); DEBUG_CHAR(' ');
SERIAL_CHAR(' '); if (y < 10) DEBUG_CHAR(' ');
if (y < 10) SERIAL_CHAR(' '); DEBUG_ECHO((int)y);
SERIAL_ECHO((int)y); DEBUG_CHAR(ydir ? (ydir > 0 ? '+' : '-') : ' ');
SERIAL_CHAR(ydir ? (ydir > 0 ? '+' : '-') : ' '); DEBUG_ECHOLNPGM("]");
SERIAL_CHAR(']'); }
}
#endif
if (!isnan(z_values[x][y])) { if (!isnan(z_values[x][y])) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM(" (done)");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" (done)");
#endif
return; // Don't overwrite good values. return; // Don't overwrite good values.
} }
SERIAL_EOL();
// Get X neighbors, Y neighbors, and XY neighbors // Get X neighbors, Y neighbors, and XY neighbors
const uint8_t x1 = x + xdir, y1 = y + ydir, x2 = x1 + xdir, y2 = y1 + ydir; const uint8_t x1 = x + xdir, y1 = y + ydir, x2 = x1 + xdir, y2 = y1 + ydir;

@ -39,6 +39,9 @@
#include "../../lcd/ultralcd.h" #include "../../lcd/ultralcd.h"
#endif #endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"
#if ENABLED(G26_MESH_VALIDATION) #if ENABLED(G26_MESH_VALIDATION)
bool g26_debug_flag; // = false bool g26_debug_flag; // = false
#endif #endif
@ -122,9 +125,7 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
* Reset calibration results to zero. * Reset calibration results to zero.
*/ */
void reset_bed_level() { void reset_bed_level() {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("reset_bed_level");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("reset_bed_level");
#endif
set_bed_leveling_enabled(false); set_bed_leveling_enabled(false);
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
mbl.reset(); mbl.reset();

@ -29,6 +29,9 @@
#include "../../../lcd/ultralcd.h" #include "../../../lcd/ultralcd.h"
#include "../../../Marlin.h" #include "../../../Marlin.h"
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../../core/debug_out.h"
#define UBL_VERSION "1.01" #define UBL_VERSION "1.01"
#define UBL_OK false #define UBL_OK false
#define UBL_ERR true #define UBL_ERR true
@ -199,12 +202,11 @@ class unified_bed_leveling {
*/ */
static inline float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi) { static inline float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi) {
if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) { if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
serialprintPGM( !WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) ? PSTR("x1_i") : PSTR("yi") ); if (WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1)) DEBUG_ECHOPGM("yi"); else DEBUG_ECHOPGM("x1_i");
SERIAL_ECHOLNPAIR(" out of bounds in z_correction_for_x_on_horizontal_mesh_line(rx0=", rx0, ",x1_i=", x1_i, ",yi=", yi, ")"); DEBUG_ECHOLNPAIR(" out of bounds in z_correction_for_x_on_horizontal_mesh_line(rx0=", rx0, ",x1_i=", x1_i, ",yi=", yi, ")");
} }
#endif
// The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN. // The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN.
return ( return (
@ -229,12 +231,11 @@ class unified_bed_leveling {
// //
static inline float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i) { static inline float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i) {
if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) { if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
serialprintPGM(!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) ? PSTR("xi") : PSTR("y1_i")); if (WITHIN(xi, 0, GRID_MAX_POINTS_X - 1)) DEBUG_ECHOPGM("y1_i"); else DEBUG_ECHOPGM("xi");
SERIAL_ECHOLNPAIR(" out of bounds in z_correction_for_y_on_vertical_mesh_line(ry0=", ry0, ", xi=", xi, ", y1_i=", y1_i, ")"); DEBUG_ECHOLNPAIR(" out of bounds in z_correction_for_y_on_vertical_mesh_line(ry0=", ry0, ", xi=", xi, ", y1_i=", y1_i, ")");
} }
#endif
// The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN. // The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN.
return ( return (
@ -285,17 +286,12 @@ class unified_bed_leveling {
mesh_index_to_ypos(cy), z1, mesh_index_to_ypos(cy), z1,
mesh_index_to_ypos(cy + 1), z2); mesh_index_to_ypos(cy + 1), z2);
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(MESH_ADJUST)) {
if (DEBUGGING(MESH_ADJUST)) { DEBUG_ECHOPAIR(" raw get_z_correction(", rx0);
SERIAL_ECHOPAIR(" raw get_z_correction(", rx0); DEBUG_CHAR(','); DEBUG_ECHO(ry0);
SERIAL_CHAR(','); SERIAL_ECHO(ry0); DEBUG_ECHOPAIR_F(") = ", z0, 6);
SERIAL_ECHOPAIR_F(") = ", z0, 6); DEBUG_ECHOLNPAIR_F(" >>>---> ", z0, 6);
} }
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(MESH_ADJUST)) SERIAL_ECHOLNPAIR_F(" >>>---> ", z0, 6);
#endif
if (isnan(z0)) { // if part of the Mesh is undefined, it will show up as NAN if (isnan(z0)) { // if part of the Mesh is undefined, it will show up as NAN
z0 = 0.0; // in ubl.z_values[][] and propagate through the z0 = 0.0; // in ubl.z_values[][] and propagate through the
@ -303,15 +299,13 @@ class unified_bed_leveling {
// because part of the Mesh is undefined and we don't have the // because part of the Mesh is undefined and we don't have the
// information we need to complete the height correction. // information we need to complete the height correction.
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(MESH_ADJUST)) {
if (DEBUGGING(MESH_ADJUST)) { DEBUG_ECHOPAIR("??? Yikes! NAN in get_z_correction(", rx0);
SERIAL_ECHOPAIR("??? Yikes! NAN in get_z_correction(", rx0); DEBUG_CHAR(',');
SERIAL_CHAR(','); DEBUG_ECHO(ry0);
SERIAL_ECHO(ry0); DEBUG_CHAR(')');
SERIAL_CHAR(')'); DEBUG_EOL();
SERIAL_EOL(); }
}
#endif
} }
return z0; return z0;
} }
@ -342,3 +336,6 @@ class unified_bed_leveling {
extern unified_bed_leveling ubl; extern unified_bed_leveling ubl;
#define Z_VALUES(X,Y) ubl.z_values[X][Y] #define Z_VALUES(X,Y) ubl.z_values[X][Y]
// Prevent debugging propagating to other files
#include "../../../core/debug_out.h"

@ -46,6 +46,9 @@
#include "../../../module/tool_change.h" #include "../../../module/tool_change.h"
#endif #endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../../core/debug_out.h"
#include <math.h> #include <math.h>
#define UBL_G29_P31 #define UBL_G29_P31
@ -442,7 +445,7 @@
SERIAL_ECHOLNPGM("Mesh invalidated. Probing mesh."); SERIAL_ECHOLNPGM("Mesh invalidated. Probing mesh.");
} }
if (g29_verbose_level > 1) { if (g29_verbose_level > 1) {
SERIAL_ECHOPAIR("Probing Mesh Points Closest to (", g29_x_pos); SERIAL_ECHOPAIR("Probing around (", g29_x_pos);
SERIAL_CHAR(','); SERIAL_CHAR(',');
SERIAL_ECHO(g29_y_pos); SERIAL_ECHO(g29_y_pos);
SERIAL_ECHOLNPGM(").\n"); SERIAL_ECHOLNPGM(").\n");
@ -1463,27 +1466,24 @@
abort_flag = isnan(measured_z); abort_flag = isnan(measured_z);
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_CHAR('(');
SERIAL_CHAR('('); DEBUG_ECHO_F(rx, 7);
SERIAL_ECHO_F(rx, 7); DEBUG_CHAR(',');
SERIAL_CHAR(','); DEBUG_ECHO_F(ry, 7);
SERIAL_ECHO_F(ry, 7); DEBUG_ECHOPGM(") logical: ");
SERIAL_ECHOPGM(") logical: "); DEBUG_CHAR('(');
SERIAL_CHAR('('); DEBUG_ECHO_F(LOGICAL_X_POSITION(rx), 7);
SERIAL_ECHO_F(LOGICAL_X_POSITION(rx), 7); DEBUG_CHAR(',');
SERIAL_CHAR(','); DEBUG_ECHO_F(LOGICAL_Y_POSITION(ry), 7);
SERIAL_ECHO_F(LOGICAL_Y_POSITION(ry), 7); DEBUG_ECHOPAIR_F(") measured: ", measured_z, 7);
SERIAL_ECHOPAIR_F(") measured: ", measured_z, 7); DEBUG_ECHOPAIR_F(" correction: ", get_z_correction(rx, ry), 7);
SERIAL_ECHOPAIR_F(" correction: ", get_z_correction(rx, ry), 7); }
}
#endif
measured_z -= get_z_correction(rx, ry) /* + zprobe_zoffset */ ; measured_z -= get_z_correction(rx, ry) /* + zprobe_zoffset */ ;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR_F(" final >>>---> ", measured_z, 7);
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR_F(" final >>>---> ", measured_z, 7);
#endif
if (g29_verbose_level > 3) { if (g29_verbose_level > 3) {
serial_spaces(16); serial_spaces(16);
SERIAL_ECHOLNPAIR("Corrected_Z=", measured_z); SERIAL_ECHOLNPAIR("Corrected_Z=", measured_z);
@ -1524,31 +1524,27 @@
y_tmp = mesh_index_to_ypos(j), y_tmp = mesh_index_to_ypos(j),
z_tmp = z_values[i][j]; z_tmp = z_values[i][j];
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOPAIR_F("before rotation = [", x_tmp, 7);
SERIAL_ECHOPAIR_F("before rotation = [", x_tmp, 7); DEBUG_CHAR(',');
SERIAL_CHAR(','); DEBUG_ECHO_F(y_tmp, 7);
SERIAL_ECHO_F(y_tmp, 7); DEBUG_CHAR(',');
SERIAL_CHAR(','); DEBUG_ECHO_F(z_tmp, 7);
SERIAL_ECHO_F(z_tmp, 7); DEBUG_ECHOPGM("] ---> ");
SERIAL_ECHOPGM("] ---> "); DEBUG_DELAY(20);
serial_delay(20); }
}
#endif
apply_rotation_xyz(rotation, x_tmp, y_tmp, z_tmp); apply_rotation_xyz(rotation, x_tmp, y_tmp, z_tmp);
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOPAIR_F("after rotation = [", x_tmp, 7);
SERIAL_ECHOPAIR_F("after rotation = [", x_tmp, 7); DEBUG_CHAR(',');
SERIAL_CHAR(','); DEBUG_ECHO_F(y_tmp, 7);
SERIAL_ECHO_F(y_tmp, 7); DEBUG_CHAR(',');
SERIAL_CHAR(','); DEBUG_ECHO_F(z_tmp, 7);
SERIAL_ECHO_F(z_tmp, 7); DEBUG_ECHOLNPGM("]");
SERIAL_ECHOLNPGM("]"); DEBUG_DELAY(55);
serial_delay(55); }
}
#endif
z_values[i][j] = z_tmp - lsf_results.D; z_values[i][j] = z_tmp - lsf_results.D;
#if ENABLED(EXTENSIBLE_UI) #if ENABLED(EXTENSIBLE_UI)
@ -1557,62 +1553,59 @@
} }
} }
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { rotation.debug(PSTR("rotation matrix:\n"));
rotation.debug(PSTR("rotation matrix:\n")); DEBUG_ECHOPAIR_F("LSF Results A=", lsf_results.A, 7);
SERIAL_ECHOPAIR_F("LSF Results A=", lsf_results.A, 7); DEBUG_ECHOPAIR_F(" B=", lsf_results.B, 7);
SERIAL_ECHOPAIR_F(" B=", lsf_results.B, 7); DEBUG_ECHOLNPAIR_F(" D=", lsf_results.D, 7);
SERIAL_ECHOLNPAIR_F(" D=", lsf_results.D, 7); DEBUG_DELAY(55);
serial_delay(55);
DEBUG_ECHOPAIR_F("bed plane normal = [", normal.x, 7);
SERIAL_ECHOPAIR_F("bed plane normal = [", normal.x, 7); DEBUG_CHAR(',');
SERIAL_CHAR(','); DEBUG_ECHO_F(normal.y, 7);
SERIAL_ECHO_F(normal.y, 7); DEBUG_CHAR(',');
SERIAL_CHAR(','); DEBUG_ECHO_F(normal.z, 7);
SERIAL_ECHO_F(normal.z, 7); DEBUG_ECHOLNPGM("]");
SERIAL_ECHOLNPGM("]"); DEBUG_EOL();
SERIAL_EOL();
/**
/** * The following code can be used to check the validity of the mesh tilting algorithm.
* The following code can be used to check the validity of the mesh tilting algorithm. * When a 3-Point Mesh Tilt is done, the same algorithm is used as the grid based tilting.
* When a 3-Point Mesh Tilt is done, the same algorithm is used as the grid based tilting. * The only difference is just 3 points are used in the calculations. That fact guarantees
* The only difference is just 3 points are used in the calculations. That fact guarantees * each probed point should have an exact match when a get_z_correction() for that location
* each probed point should have an exact match when a get_z_correction() for that location * is calculated. The Z error between the probed point locations and the get_z_correction()
* is calculated. The Z error between the probed point locations and the get_z_correction() * numbers for those locations should be 0.
* numbers for those locations should be 0. */
*/ #if 0
#if 0 float t, t1, d;
float t, t1, d; t = normal.x * (PROBE_PT_1_X) + normal.y * (PROBE_PT_1_Y);
t = normal.x * (PROBE_PT_1_X) + normal.y * (PROBE_PT_1_Y); d = t + normal.z * z1;
d = t + normal.z * z1; DEBUG_ECHOPAIR_F("D from 1st point: ", d, 6);
SERIAL_ECHOPAIR_F("D from 1st point: ", d, 6); DEBUG_ECHOLNPAIR_F(" Z error: ", normal.z*z1-get_z_correction(PROBE_PT_1_X, PROBE_PT_1_Y), 6);
SERIAL_ECHOLNPAIR_F(" Z error: ", normal.z*z1-get_z_correction(PROBE_PT_1_X, PROBE_PT_1_Y), 6);
t = normal.x * (PROBE_PT_2_X) + normal.y * (PROBE_PT_2_Y);
t = normal.x * (PROBE_PT_2_X) + normal.y * (PROBE_PT_2_Y); d = t + normal.z * z2;
d = t + normal.z * z2; DEBUG_EOL();
SERIAL_EOL(); DEBUG_ECHOPAIR_F("D from 2nd point: ", d, 6);
SERIAL_ECHOPAIR_F("D from 2nd point: ", d, 6); DEBUG_ECHOLNPAIR_F(" Z error: ", normal.z*z2-get_z_correction(PROBE_PT_2_X, PROBE_PT_2_Y), 6);
SERIAL_ECHOLNPAIR_F(" Z error: ", normal.z*z2-get_z_correction(PROBE_PT_2_X, PROBE_PT_2_Y), 6);
t = normal.x * (PROBE_PT_3_X) + normal.y * (PROBE_PT_3_Y);
t = normal.x * (PROBE_PT_3_X) + normal.y * (PROBE_PT_3_Y); d = t + normal.z * z3;
d = t + normal.z * z3; DEBUG_ECHOPAIR_F("D from 3rd point: ", d, 6);
SERIAL_ECHOPAIR_F("D from 3rd point: ", d, 6); DEBUG_ECHOLNPAIR_F(" Z error: ", normal.z*z3-get_z_correction(PROBE_PT_3_X, PROBE_PT_3_Y), 6);
SERIAL_ECHOLNPAIR_F(" Z error: ", normal.z*z3-get_z_correction(PROBE_PT_3_X, PROBE_PT_3_Y), 6);
t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT); d = t + normal.z * 0;
d = t + normal.z * 0; DEBUG_ECHOLNPAIR_F("D from home location with Z=0 : ", d, 6);
SERIAL_ECHOLNPAIR_F("D from home location with Z=0 : ", d, 6);
t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT); d = t + get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT); // normal.z * 0;
d = t + get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT); // normal.z * 0; DEBUG_ECHOPAIR_F("D from home location using mesh value for Z: ", d, 6);
SERIAL_ECHOPAIR_F("D from home location using mesh value for Z: ", d, 6);
DEBUG_ECHOPAIR(" Z error: (", Z_SAFE_HOMING_X_POINT, ",", Z_SAFE_HOMING_Y_POINT);
SERIAL_ECHOPAIR(" Z error: (", Z_SAFE_HOMING_X_POINT); DEBUG_ECHOLNPAIR_F(") = ", get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT), 6);
SERIAL_ECHOPAIR(",", Z_SAFE_HOMING_Y_POINT); #endif
SERIAL_ECHOLNPAIR_F(") = ", get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT), 6); } // DEBUGGING(LEVELING)
#endif
} // DEBUGGING(LEVELING)
#endif
} }

@ -42,6 +42,9 @@ MMU2 mmu2;
#include "../../feature/host_actions.h" #include "../../feature/host_actions.h"
#endif #endif
#define DEBUG_OUT ENABLED(MMU2_DEBUG)
#include "../../core/debug_out.h"
#define MMU_TODELAY 100 #define MMU_TODELAY 100
#define MMU_TIMEOUT 10 #define MMU_TIMEOUT 10
#define MMU_CMD_TIMEOUT 60000ul //5min timeout for mmu commands (except P0) #define MMU_CMD_TIMEOUT 60000ul //5min timeout for mmu commands (except P0)
@ -128,9 +131,7 @@ void MMU2::init() {
} }
void MMU2::reset() { void MMU2::reset() {
#if ENABLED(MMU2_DEBUG) DEBUG_ECHOLNPGM("MMU <= reset");
SERIAL_ECHOLNPGM("MMU <= reset");
#endif
#if PIN_EXISTS(MMU2_RST) #if PIN_EXISTS(MMU2_RST)
WRITE(MMU2_RST_PIN, LOW); WRITE(MMU2_RST_PIN, LOW);
@ -153,10 +154,8 @@ void MMU2::mmuLoop() {
case -1: case -1:
if (rx_start()) { if (rx_start()) {
#if ENABLED(MMU2_DEBUG) DEBUG_ECHOLNPGM("MMU => 'start'");
SERIAL_ECHOLNPGM("MMU => 'start'"); DEBUG_ECHOLNPGM("MMU <= 'S1'");
SERIAL_ECHOLNPGM("MMU <= 'S1'");
#endif
// send "read version" request // send "read version" request
tx_str_P(PSTR("S1\n")); tx_str_P(PSTR("S1\n"));
@ -173,9 +172,7 @@ void MMU2::mmuLoop() {
if (rx_ok()) { if (rx_ok()) {
sscanf(rx_buffer, "%uok\n", &version); sscanf(rx_buffer, "%uok\n", &version);
#if ENABLED(MMU2_DEBUG) DEBUG_ECHOLNPAIR("MMU => ", version, "\nMMU <= 'S2'");
SERIAL_ECHOLNPAIR("MMU => ", version, "\nMMU <= 'S2'");
#endif
tx_str_P(PSTR("S2\n")); // read build number tx_str_P(PSTR("S2\n")); // read build number
state = -3; state = -3;
@ -185,24 +182,19 @@ void MMU2::mmuLoop() {
case -3: case -3:
if (rx_ok()) { if (rx_ok()) {
sscanf(rx_buffer, "%uok\n", &buildnr); sscanf(rx_buffer, "%uok\n", &buildnr);
#if ENABLED(MMU2_DEBUG)
SERIAL_ECHOLNPAIR("MMU => ", buildnr); DEBUG_ECHOLNPAIR("MMU => ", buildnr);
#endif
checkVersion(); checkVersion();
#if ENABLED(MMU2_MODE_12V) #if ENABLED(MMU2_MODE_12V)
#if ENABLED(MMU2_DEBUG) DEBUG_ECHOLNPGM("MMU <= 'M1'");
SERIAL_ECHOLNPGM("MMU <= 'M1'");
#endif
tx_str_P(PSTR("M1\n")); // switch to stealth mode tx_str_P(PSTR("M1\n")); // switch to stealth mode
state = -5; state = -5;
#else #else
#if ENABLED(MMU2_DEBUG) DEBUG_ECHOLNPGM("MMU <= 'P0'");
SERIAL_ECHOLNPGM("MMU <= 'P0'");
#endif
tx_str_P(PSTR("P0\n")); // read finda tx_str_P(PSTR("P0\n")); // read finda
state = -4; state = -4;
@ -213,15 +205,11 @@ void MMU2::mmuLoop() {
case -5: case -5:
// response to M1 // response to M1
if (rx_ok()) { if (rx_ok()) {
#if ENABLED(MMU2_DEBUG) DEBUG_ECHOLNPGM("MMU => ok");
SERIAL_ECHOLNPGM("MMU => ok");
#endif
checkVersion(); checkVersion();
#if ENABLED(MMU2_DEBUG) DEBUG_ECHOLNPGM("MMU <= 'P0'");
SERIAL_ECHOLNPGM("MMU <= 'P0'");
#endif
tx_str_P(PSTR("P0\n")); // read finda tx_str_P(PSTR("P0\n")); // read finda
state = -4; state = -4;
@ -232,9 +220,7 @@ void MMU2::mmuLoop() {
if (rx_ok()) { if (rx_ok()) {
sscanf(rx_buffer, "%hhuok\n", &finda); sscanf(rx_buffer, "%hhuok\n", &finda);
#if ENABLED(MMU2_DEBUG) DEBUG_ECHOLNPAIR("MMU => ", finda, "\nMMU - ENABLED");
SERIAL_ECHOLNPAIR("MMU => ", finda, "\nMMU - ENABLED");
#endif
enabled = true; enabled = true;
state = 1; state = 1;
@ -246,40 +232,26 @@ void MMU2::mmuLoop() {
if (WITHIN(cmd, MMU_CMD_T0, MMU_CMD_T4)) { if (WITHIN(cmd, MMU_CMD_T0, MMU_CMD_T4)) {
// tool change // tool change
int filament = cmd - MMU_CMD_T0; int filament = cmd - MMU_CMD_T0;
DEBUG_ECHOLNPAIR("MMU <= T", filament);
#if ENABLED(MMU2_DEBUG)
SERIAL_ECHOLNPAIR("MMU <= T", filament);
#endif
tx_printf_P(PSTR("T%d\n"), filament); tx_printf_P(PSTR("T%d\n"), filament);
state = 3; // wait for response state = 3; // wait for response
} }
else if (WITHIN(cmd, MMU_CMD_L0, MMU_CMD_L4)) { else if (WITHIN(cmd, MMU_CMD_L0, MMU_CMD_L4)) {
// load // load
int filament = cmd - MMU_CMD_L0; int filament = cmd - MMU_CMD_L0;
DEBUG_ECHOLNPAIR("MMU <= L", filament);
#if ENABLED(MMU2_DEBUG)
SERIAL_ECHOLNPAIR("MMU <= L", filament);
#endif
tx_printf_P(PSTR("L%d\n"), filament); tx_printf_P(PSTR("L%d\n"), filament);
state = 3; // wait for response state = 3; // wait for response
} }
else if (cmd == MMU_CMD_C0) { else if (cmd == MMU_CMD_C0) {
// continue loading // continue loading
DEBUG_ECHOLNPGM("MMU <= 'C0'");
#if ENABLED(MMU2_DEBUG)
SERIAL_ECHOLNPGM("MMU <= 'C0'");
#endif
tx_str_P(PSTR("C0\n")); tx_str_P(PSTR("C0\n"));
state = 3; // wait for response state = 3; // wait for response
} }
else if (cmd == MMU_CMD_U0) { else if (cmd == MMU_CMD_U0) {
// unload current // unload current
#if ENABLED(MMU2_DEBUG) DEBUG_ECHOLNPGM("MMU <= 'U0'");
SERIAL_ECHOLNPGM("MMU <= 'U0'");
#endif
tx_str_P(PSTR("U0\n")); tx_str_P(PSTR("U0\n"));
state = 3; // wait for response state = 3; // wait for response
@ -287,31 +259,22 @@ void MMU2::mmuLoop() {
else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E4)) { else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E4)) {
// eject filament // eject filament
int filament = cmd - MMU_CMD_E0; int filament = cmd - MMU_CMD_E0;
DEBUG_ECHOLNPAIR("MMU <= E", filament);
#if ENABLED(MMU2_DEBUG)
SERIAL_ECHOLNPAIR("MMU <= E", filament);
#endif
tx_printf_P(PSTR("E%d\n"), filament); tx_printf_P(PSTR("E%d\n"), filament);
state = 3; // wait for response state = 3; // wait for response
} }
else if (cmd == MMU_CMD_R0) { else if (cmd == MMU_CMD_R0) {
// recover after eject // recover after eject
#if ENABLED(MMU2_DEBUG) DEBUG_ECHOLNPGM("MMU <= 'R0'");
SERIAL_ECHOLNPGM("MMU <= 'R0'");
#endif
tx_str_P(PSTR("R0\n")); tx_str_P(PSTR("R0\n"));
state = 3; // wait for response state = 3; // wait for response
} }
else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F4)) { else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F4)) {
// filament type // filament type
int filament = cmd - MMU_CMD_F0; int filament = cmd - MMU_CMD_F0;
#if ENABLED(MMU2_DEBUG) DEBUG_ECHOPAIR("MMU <= F", filament, " ");
SERIAL_ECHOPAIR("MMU <= F", filament, " "); DEBUG_ECHO_F(cmd_arg, DEC);
SERIAL_ECHO_F(cmd_arg, DEC); DEBUG_EOL();
SERIAL_ECHOPGM("\n");
#endif
tx_printf_P(PSTR("F%d %d\n"), filament, cmd_arg); tx_printf_P(PSTR("F%d %d\n"), filament, cmd_arg);
state = 3; // wait for response state = 3; // wait for response
} }
@ -330,17 +293,8 @@ void MMU2::mmuLoop() {
if (rx_ok()) { if (rx_ok()) {
sscanf(rx_buffer, "%hhuok\n", &finda); sscanf(rx_buffer, "%hhuok\n", &finda);
#if ENABLED(MMU2_DEBUG) // This is super annoying. Only activate if necessary
// This is super annoying. Only activate if necessary // if (findaRunoutValid) DEBUG_ECHOLNPAIR_F("MMU <= 'P0'\nMMU => ", finda, 6);
/*
if (findaRunoutValid) {
SERIAL_ECHOLNPGM("MMU <= 'P0'");
SERIAL_ECHOPGM("MMU => ");
SERIAL_ECHO_F(finda, DEC);
SERIAL_ECHOPGM("\n");
}
*/
#endif
state = 1; state = 1;
@ -355,10 +309,7 @@ void MMU2::mmuLoop() {
case 3: // response to mmu commands case 3: // response to mmu commands
if (rx_ok()) { if (rx_ok()) {
#if ENABLED(MMU2_DEBUG) DEBUG_ECHOLNPGM("MMU => 'ok'");
SERIAL_ECHOLNPGM("MMU => 'ok'");
#endif
ready = true; ready = true;
state = 1; state = 1;
last_cmd = MMU_CMD_NONE; last_cmd = MMU_CMD_NONE;
@ -366,10 +317,7 @@ void MMU2::mmuLoop() {
else if (ELAPSED(millis(), last_request + MMU_CMD_TIMEOUT)) { else if (ELAPSED(millis(), last_request + MMU_CMD_TIMEOUT)) {
// resend request after timeout // resend request after timeout
if (last_cmd) { if (last_cmd) {
#if ENABLED(MMU2_DEBUG) DEBUG_ECHOLNPGM("MMU retry");
SERIAL_ECHOLNPGM("MMU retry");
#endif
cmd = last_cmd; cmd = last_cmd;
last_cmd = MMU_CMD_NONE; last_cmd = MMU_CMD_NONE;
} }
@ -404,10 +352,7 @@ bool MMU2::rx_str_P(const char* str) {
rx_buffer[i] = '\0'; rx_buffer[i] = '\0';
if (i == sizeof(rx_buffer) - 1) { if (i == sizeof(rx_buffer) - 1) {
#if ENABLED(MMU2_DEBUG) DEBUG_ECHOLNPGM("rx buffer overrun");
SERIAL_ECHOLNPGM("rx buffer overrun");
#endif
break; break;
} }
} }
@ -876,12 +821,8 @@ void MMU2::filamentRunout() {
const float es = pgm_read_float(&(step->extrude)), const float es = pgm_read_float(&(step->extrude)),
fr = pgm_read_float(&(step->feedRate)); fr = pgm_read_float(&(step->feedRate));
#if ENABLED(MMU2_DEBUG) DEBUG_ECHO_START();
SERIAL_ECHO_START(); DEBUG_ECHOLNPAIR("E step ", es, "/", fr);
SERIAL_ECHOPAIR("E step ", es);
SERIAL_CHAR('/');
SERIAL_ECHOLN(fr);
#endif
current_position[E_AXIS] += es; current_position[E_AXIS] += es;
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],

@ -48,6 +48,9 @@
#include "../../../libs/vector_3.h" #include "../../../libs/vector_3.h"
#endif #endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../../core/debug_out.h"
#if ABL_GRID #if ABL_GRID
#if ENABLED(PROBE_Y_FIRST) #if ENABLED(PROBE_Y_FIRST)
#define PR_OUTER_VAR xCount #define PR_OUTER_VAR xCount
@ -187,12 +190,7 @@ G29_TYPE GcodeSuite::G29() {
if (axis_unhomed_error()) G29_RETURN(false); if (axis_unhomed_error()) G29_RETURN(false);
if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Auto-level not needed, skip\n<<< G29");
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM("> Auto-level not needed, skip");
SERIAL_ECHOLNPGM("<<< G29");
}
#endif
G29_RETURN(false); G29_RETURN(false);
} }
@ -470,9 +468,7 @@ G29_TYPE GcodeSuite::G29() {
#if ENABLED(AUTO_BED_LEVELING_3POINT) #if ENABLED(AUTO_BED_LEVELING_3POINT)
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> 3-point Leveling");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> 3-point Leveling");
#endif
// Probe at 3 arbitrary points // Probe at 3 arbitrary points
points[0].z = points[1].z = points[2].z = 0; points[0].z = points[1].z = points[2].z = 0;
@ -555,13 +551,7 @@ G29_TYPE GcodeSuite::G29() {
ExtUI::onMeshUpdate(xCount, yCount, z_values[xCount][yCount]); ExtUI::onMeshUpdate(xCount, yCount, z_values[xCount][yCount]);
#endif #endif
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Save X", xCount, " Y", yCount, " Z", measured_z + zoffset);
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("Save X", xCount);
SERIAL_ECHOPAIR(" Y", yCount);
SERIAL_ECHOLNPAIR(" Z", measured_z + zoffset);
}
#endif
#endif #endif
} }
@ -790,9 +780,7 @@ G29_TYPE GcodeSuite::G29() {
// return or loop before this point. // return or loop before this point.
// //
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
#endif
#if ENABLED(PROBE_MANUALLY) #if ENABLED(PROBE_MANUALLY)
g29_in_progress = false; g29_in_progress = false;
@ -929,9 +917,7 @@ G29_TYPE GcodeSuite::G29() {
// Correct the current XYZ position based on the tilted plane. // Correct the current XYZ position based on the tilted plane.
// //
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("G29 uncorrected XYZ", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("G29 uncorrected XYZ", current_position);
#endif
float converted[XYZ]; float converted[XYZ];
COPY(converted, current_position); COPY(converted, current_position);
@ -945,46 +931,32 @@ G29_TYPE GcodeSuite::G29() {
&& NEAR(current_position[Y_AXIS], yProbe - (Y_PROBE_OFFSET_FROM_EXTRUDER)) && NEAR(current_position[Y_AXIS], yProbe - (Y_PROBE_OFFSET_FROM_EXTRUDER))
) { ) {
const float simple_z = current_position[Z_AXIS] - measured_z; const float simple_z = current_position[Z_AXIS] - measured_z;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probed Z", simple_z, " Matrix Z", converted[Z_AXIS], " Discrepancy ", simple_z - converted[Z_AXIS]);
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("Z from Probe:", simple_z);
SERIAL_ECHOPAIR(" Matrix:", converted[Z_AXIS]);
SERIAL_ECHOLNPAIR(" Discrepancy:", simple_z - converted[Z_AXIS]);
}
#endif
converted[Z_AXIS] = simple_z; converted[Z_AXIS] = simple_z;
} }
// The rotated XY and corrected Z are now current_position // The rotated XY and corrected Z are now current_position
COPY(current_position, converted); COPY(current_position, converted);
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("G29 corrected XYZ", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("G29 corrected XYZ", current_position);
#endif
} }
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR) #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
if (!dryrun) { if (!dryrun) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("G29 uncorrected Z:", current_position[Z_AXIS]);
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("G29 uncorrected Z:", current_position[Z_AXIS]);
#endif
// Unapply the offset because it is going to be immediately applied // Unapply the offset because it is going to be immediately applied
// and cause compensation movement in Z // and cause compensation movement in Z
current_position[Z_AXIS] -= bilinear_z_offset(current_position); current_position[Z_AXIS] -= bilinear_z_offset(current_position);
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(" corrected Z:", current_position[Z_AXIS]);
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR(" corrected Z:", current_position[Z_AXIS]);
#endif
} }
#endif // ABL_PLANAR #endif // ABL_PLANAR
#ifdef Z_PROBE_END_SCRIPT #ifdef Z_PROBE_END_SCRIPT
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Z Probe End Script: ", Z_PROBE_END_SCRIPT);
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("Z Probe End Script: ", Z_PROBE_END_SCRIPT);
#endif
planner.synchronize(); planner.synchronize();
enqueue_and_echo_commands_P(PSTR(Z_PROBE_END_SCRIPT)); enqueue_and_echo_commands_P(PSTR(Z_PROBE_END_SCRIPT));
#endif #endif
@ -996,9 +968,7 @@ G29_TYPE GcodeSuite::G29() {
// Restore state after probing // Restore state after probing
if (!faux) clean_up_after_endstop_or_probe_move(); if (!faux) clean_up_after_endstop_or_probe_move();
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G29");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G29");
#endif
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);

@ -49,6 +49,9 @@
#include "../../libs/L6470/L6470_Marlin.h" #include "../../libs/L6470/L6470_Marlin.h"
#endif #endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"
#if ENABLED(QUICK_HOME) #if ENABLED(QUICK_HOME)
static void quick_home_xy() { static void quick_home_xy() {
@ -113,9 +116,7 @@
return; return;
} }
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z_SAFE_HOMING >>>");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Z_SAFE_HOMING >>>");
#endif
sync_plan_position(); sync_plan_position();
@ -133,9 +134,7 @@
if (position_is_reachable(destination[X_AXIS], destination[Y_AXIS])) { if (position_is_reachable(destination[X_AXIS], destination[Y_AXIS])) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("Z_SAFE_HOMING", destination);
if (DEBUGGING(LEVELING)) DEBUG_POS("Z_SAFE_HOMING", destination);
#endif
// This causes the carriage on Dual X to unpark // This causes the carriage on Dual X to unpark
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
@ -154,9 +153,7 @@
SERIAL_ECHO_MSG(MSG_ZPROBE_OUT); SERIAL_ECHO_MSG(MSG_ZPROBE_OUT);
} }
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< Z_SAFE_HOMING");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< Z_SAFE_HOMING");
#endif
} }
#endif // Z_SAFE_HOMING #endif // Z_SAFE_HOMING
@ -182,12 +179,10 @@
*/ */
void GcodeSuite::G28(const bool always_home_all) { void GcodeSuite::G28(const bool always_home_all) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPGM(">>> G28");
SERIAL_ECHOLNPGM(">>> G28"); log_machine_info();
log_machine_info(); }
}
#endif
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
bool IDEX_saved_duplication_state = extruder_duplication_enabled; bool IDEX_saved_duplication_state = extruder_duplication_enabled;
@ -200,9 +195,7 @@ void GcodeSuite::G28(const bool always_home_all) {
sync_plan_position(); sync_plan_position();
SERIAL_ECHOLNPGM("Simulated Homing"); SERIAL_ECHOLNPGM("Simulated Homing");
report_current_position(); report_current_position();
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G28");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G28");
#endif
return; return;
} }
#endif #endif
@ -215,12 +208,7 @@ void GcodeSuite::G28(const bool always_home_all) {
all_axes_homed() // homing needed only if never homed all_axes_homed() // homing needed only if never homed
#endif #endif
) { ) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> homing not needed, skip\n<<< G28");
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM("> homing not needed, skip");
SERIAL_ECHOLNPGM("<<< G28");
}
#endif
return; return;
} }
} }
@ -297,12 +285,7 @@ void GcodeSuite::G28(const bool always_home_all) {
// Raise Z before homing any other axes and z is not already high enough (never lower z) // Raise Z before homing any other axes and z is not already high enough (never lower z)
destination[Z_AXIS] = z_homing_height; destination[Z_AXIS] = z_homing_height;
if (destination[Z_AXIS] > current_position[Z_AXIS]) { if (destination[Z_AXIS] > current_position[Z_AXIS]) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) to ", destination[Z_AXIS]);
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING))
SERIAL_ECHOLNPAIR("Raise Z (before homing) to ", destination[Z_AXIS]);
#endif
do_blocking_move_to_z(destination[Z_AXIS]); do_blocking_move_to_z(destination[Z_AXIS]);
} }
} }
@ -451,9 +434,7 @@ void GcodeSuite::G28(const bool always_home_all) {
SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP); SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP);
#endif #endif
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G28");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G28");
#endif
#if HAS_DRIVER(L6470) #if HAS_DRIVER(L6470)
// Set L6470 absolute position registers to counts // Set L6470 absolute position registers to counts

@ -42,6 +42,9 @@
#include "../../feature/bedlevel/bedlevel.h" #include "../../feature/bedlevel/bedlevel.h"
#endif #endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"
float z_auto_align_xpos[Z_STEPPER_COUNT] = Z_STEPPER_ALIGN_X, float z_auto_align_xpos[Z_STEPPER_COUNT] = Z_STEPPER_ALIGN_X,
z_auto_align_ypos[Z_STEPPER_COUNT] = Z_STEPPER_ALIGN_Y; z_auto_align_ypos[Z_STEPPER_COUNT] = Z_STEPPER_ALIGN_Y;
@ -59,19 +62,15 @@ inline void set_all_z_lock(const bool lock) {
* Parameters: I<iterations> T<accuracy> A<amplification> * Parameters: I<iterations> T<accuracy> A<amplification>
*/ */
void GcodeSuite::G34() { void GcodeSuite::G34() {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPGM(">>> G34");
SERIAL_ECHOLNPGM(">>> G34"); log_machine_info();
log_machine_info(); }
}
#endif
do { // break out on error do { // break out on error
if (!TEST(axis_known_position, X_AXIS) || !TEST(axis_known_position, Y_AXIS)) { if (!TEST(axis_known_position, X_AXIS) || !TEST(axis_known_position, Y_AXIS)) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> XY homing required.");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> XY homing required.");
#endif
break; break;
} }
@ -128,9 +127,7 @@ void GcodeSuite::G34() {
z_measured[Z_STEPPER_COUNT] = { 0 }; z_measured[Z_STEPPER_COUNT] = { 0 };
bool err_break = false; bool err_break = false;
for (uint8_t iteration = 0; iteration < z_auto_align_iterations; ++iteration) { for (uint8_t iteration = 0; iteration < z_auto_align_iterations; ++iteration) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> probing all positions.");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> probing all positions.");
#endif
// Reset minimum value // Reset minimum value
float z_measured_min = 100000.0f; float z_measured_min = 100000.0f;
@ -141,19 +138,12 @@ void GcodeSuite::G34() {
// Stop on error // Stop on error
if (isnan(z_measured[zstepper])) { if (isnan(z_measured[zstepper])) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> PROBING FAILED!");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> PROBING FAILED!");
#endif
err_break = true; err_break = true;
break; break;
} }
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " measured position is ", z_measured[zstepper]);
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("> Z", int(zstepper + 1));
SERIAL_ECHOLNPAIR(" measured position is ", z_measured[zstepper]);
}
#endif
// Remember the maximum position to calculate the correction // Remember the maximum position to calculate the correction
z_measured_min = MIN(z_measured_min, z_measured[zstepper]); z_measured_min = MIN(z_measured_min, z_measured[zstepper]);
@ -178,9 +168,7 @@ void GcodeSuite::G34() {
// Check for lost accuracy compared to last move // Check for lost accuracy compared to last move
if (last_z_align_move[zstepper] < z_align_abs - 1.0) { if (last_z_align_move[zstepper] < z_align_abs - 1.0) {
// Stop here // Stop here
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> detected decreasing accuracy.");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> detected decreasing accuracy.");
#endif
err_break = true; err_break = true;
break; break;
} }
@ -190,12 +178,7 @@ void GcodeSuite::G34() {
// Only stop early if all measured points achieve accuracy target // Only stop early if all measured points achieve accuracy target
if (z_align_abs > z_auto_align_accuracy) success_break = false; if (z_align_abs > z_auto_align_accuracy) success_break = false;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " corrected by ", z_align_move);
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("> Z", int(zstepper + 1));
SERIAL_ECHOLNPAIR(" corrected by ", z_align_move);
}
#endif
switch (zstepper) { switch (zstepper) {
case 0: stepper.set_z_lock(false); break; case 0: stepper.set_z_lock(false); break;
@ -219,9 +202,7 @@ void GcodeSuite::G34() {
stepper.set_separate_multi_axis(false); stepper.set_separate_multi_axis(false);
if (success_break) { if (success_break) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> achieved target accuracy.");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> achieved target accuracy.");
#endif
break; break;
} }
} }
@ -252,9 +233,7 @@ void GcodeSuite::G34() {
} while(0); } while(0);
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G34");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G34");
#endif
} }
/** /**

@ -31,32 +31,22 @@
#include "../../module/delta.h" #include "../../module/delta.h"
#include "../../module/motion.h" #include "../../module/motion.h"
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"
/** /**
* M666: Set delta endstop adjustment * M666: Set delta endstop adjustment
*/ */
void GcodeSuite::M666() { void GcodeSuite::M666() {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM(">>> M666");
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM(">>> M666");
}
#endif
LOOP_XYZ(i) { LOOP_XYZ(i) {
if (parser.seen(axis_codes[i])) { if (parser.seen(axis_codes[i])) {
const float v = parser.value_linear_units(); const float v = parser.value_linear_units();
if (v * Z_HOME_DIR <= 0) delta_endstop_adj[i] = v; if (v * Z_HOME_DIR <= 0) delta_endstop_adj[i] = v;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", axis_codes[i], "] = ", delta_endstop_adj[i]);
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("delta_endstop_adj[", axis_codes[i]);
SERIAL_ECHOLNPAIR("] = ", delta_endstop_adj[i]);
}
#endif
} }
} }
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< M666");
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM("<<< M666");
}
#endif
} }
#elif HAS_EXTRA_ENDSTOPS #elif HAS_EXTRA_ENDSTOPS

@ -34,14 +34,14 @@ void GcodeSuite::M111() {
str_debug_8[] PROGMEM = MSG_DEBUG_DRYRUN, str_debug_8[] PROGMEM = MSG_DEBUG_DRYRUN,
str_debug_16[] PROGMEM = MSG_DEBUG_COMMUNICATION str_debug_16[] PROGMEM = MSG_DEBUG_COMMUNICATION
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
, str_debug_32[] PROGMEM = MSG_DEBUG_LEVELING , str_debug_lvl[] PROGMEM = MSG_DEBUG_LEVELING
#endif #endif
; ;
static PGM_P const debug_strings[] PROGMEM = { static PGM_P const debug_strings[] PROGMEM = {
str_debug_1, str_debug_2, str_debug_4, str_debug_8, str_debug_16 str_debug_1, str_debug_2, str_debug_4, str_debug_8, str_debug_16
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
, str_debug_32 , str_debug_lvl
#endif #endif
}; };

@ -31,6 +31,9 @@
#include "../../feature/prusa_MMU2/mmu2.h" #include "../../feature/prusa_MMU2/mmu2.h"
#endif #endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"
/** /**
* T0-T<n>: Switch tool, usually switching extruders * T0-T<n>: Switch tool, usually switching extruders
* *
@ -45,14 +48,10 @@
*/ */
void GcodeSuite::T(const uint8_t tool_index) { void GcodeSuite::T(const uint8_t tool_index) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPAIR(">>> T(", tool_index, ")");
SERIAL_ECHOPAIR(">>> T(", tool_index); DEBUG_POS("BEFORE", current_position);
SERIAL_CHAR(')'); }
SERIAL_EOL();
DEBUG_POS("BEFORE", current_position);
}
#endif
#if ENABLED(PRUSA_MMU2) #if ENABLED(PRUSA_MMU2)
if (parser.string_arg) { if (parser.string_arg) {
@ -75,10 +74,8 @@ void GcodeSuite::T(const uint8_t tool_index) {
#endif #endif
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_POS("AFTER", current_position);
DEBUG_POS("AFTER", current_position); DEBUG_ECHOLNPGM("<<< T()");
SERIAL_ECHOLNPGM("<<< T()"); }
}
#endif
} }

@ -29,6 +29,9 @@
#include "../../../module/stepper_indirection.h" #include "../../../module/stepper_indirection.h"
#include "../../../module/planner.h" #include "../../../module/planner.h"
#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
#include "../../../core/debug_out.h"
/** /**
* *
* M906: report or set KVAL_HOLD which sets the maximum effective voltage provided by the * M906: report or set KVAL_HOLD which sets the maximum effective voltage provided by the
@ -93,7 +96,7 @@ void L6470_report_current(L6470 &motor, const uint8_t axis) {
L6470.say_axis(axis); L6470.say_axis(axis);
#if ENABLED(L6470_CHITCHAT) #if ENABLED(L6470_CHITCHAT)
sprintf_P(temp_buf, PSTR(" status: %4x "), status); sprintf_P(temp_buf, PSTR(" status: %4x "), status);
SERIAL_ECHO(temp_buf); DEBUG_ECHO(temp_buf);
print_bin(status); print_bin(status);
#endif #endif
sprintf_P(temp_buf, PSTR("\n...OverCurrent Threshold: %2d (%4d mA)"), overcurrent_threshold, (overcurrent_threshold + 1) * 375); sprintf_P(temp_buf, PSTR("\n...OverCurrent Threshold: %2d (%4d mA)"), overcurrent_threshold, (overcurrent_threshold + 1) * 375);
@ -134,7 +137,7 @@ void L6470_report_current(L6470 &motor, const uint8_t axis) {
void GcodeSuite::M906() { void GcodeSuite::M906() {
#define L6470_SET_KVAL_HOLD(Q) stepper##Q.SetParam(L6470_KVAL_HOLD, value) #define L6470_SET_KVAL_HOLD(Q) stepper##Q.SetParam(L6470_KVAL_HOLD, value)
L6470_ECHOLNPGM("M906"); DEBUG_ECHOLNPGM("M906");
bool report_current = true; bool report_current = true;

@ -29,6 +29,9 @@
#include "../../../module/planner.h" #include "../../../module/planner.h"
#include "../../../libs/L6470/L6470_Marlin.h" #include "../../../libs/L6470/L6470_Marlin.h"
#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
#include "../../../core/debug_out.h"
/** /**
* *
* M916: increase KVAL_HOLD until get thermal warning * M916: increase KVAL_HOLD until get thermal warning
@ -59,7 +62,7 @@
void GcodeSuite::M916() { void GcodeSuite::M916() {
L6470_ECHOLNPGM("M916"); DEBUG_ECHOLNPGM("M916");
// Variables used by L6470_get_user_input function - some may not be used // Variables used by L6470_get_user_input function - some may not be used
char axis_mon[3][3] = { " ", " ", " " }; // list of Axes to be monitored char axis_mon[3][3] = { " ", " ", " " }; // list of Axes to be monitored
@ -80,7 +83,7 @@ void GcodeSuite::M916() {
if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold)) if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold))
return; // quit if invalid user input return; // quit if invalid user input
L6470_ECHOLNPAIR("feedrate = ", final_feedrate); DEBUG_ECHOLNPAIR("feedrate = ", final_feedrate);
planner.synchronize(); // wait for all current movement commands to complete planner.synchronize(); // wait for all current movement commands to complete
@ -92,11 +95,11 @@ void GcodeSuite::M916() {
char gcode_string[80]; char gcode_string[80];
uint16_t status_composite = 0; uint16_t status_composite = 0;
L6470_ECHOLNPGM(".\n."); DEBUG_ECHOLNPGM(".\n.");
do { do {
L6470_ECHOLNPAIR("kval_hold = ", kval_hold); // set & report KVAL_HOLD for this run DEBUG_ECHOLNPAIR("kval_hold = ", kval_hold); // set & report KVAL_HOLD for this run
for (j = 0; j < driver_count; j++) for (j = 0; j < driver_count; j++)
L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold); L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
@ -119,9 +122,9 @@ void GcodeSuite::M916() {
} }
if (status_composite && (status_composite & STATUS_UVLO)) { if (status_composite && (status_composite & STATUS_UVLO)) {
L6470_ECHOLNPGM("Test aborted (Undervoltage lockout active)"); DEBUG_ECHOLNPGM("Test aborted (Undervoltage lockout active)");
for (j = 0; j < driver_count; j++) { for (j = 0; j < driver_count; j++) {
L6470_ECHOPGM("..."); DEBUG_ECHOPGM("...");
L6470.error_status_decode(axis_status[j], axis_index[j]); L6470.error_status_decode(axis_status[j], axis_index[j]);
} }
return; return;
@ -133,18 +136,18 @@ void GcodeSuite::M916() {
} while (!(status_composite & (STATUS_TH_WRN | STATUS_TH_SD)) && kval_hold); // exit when kval_hold == 0 (rolls over) } while (!(status_composite & (STATUS_TH_WRN | STATUS_TH_SD)) && kval_hold); // exit when kval_hold == 0 (rolls over)
L6470_ECHOPGM(".\n.\nThermal warning/shutdown "); DEBUG_ECHOPGM(".\n.\nThermal warning/shutdown ");
if ((status_composite & (STATUS_TH_WRN | STATUS_TH_SD))) { if ((status_composite & (STATUS_TH_WRN | STATUS_TH_SD))) {
L6470_ECHOLNPGM("has occurred"); DEBUG_ECHOLNPGM("has occurred");
for (j = 0; j < driver_count; j++) { for (j = 0; j < driver_count; j++) {
L6470_ECHOPGM("..."); DEBUG_ECHOPGM("...");
L6470.error_status_decode(axis_status[j], axis_index[j]); L6470.error_status_decode(axis_status[j], axis_index[j]);
} }
} }
else else
L6470_ECHOLNPGM("(Unable to get)"); DEBUG_ECHOLNPGM("(Unable to get)");
L6470_ECHOLNPGM("."); DEBUG_ECHOLNPGM(".");
} }
/** /**
@ -176,7 +179,7 @@ void GcodeSuite::M916() {
*/ */
void GcodeSuite::M917() { void GcodeSuite::M917() {
L6470_ECHOLNPGM("M917"); DEBUG_ECHOLNPGM("M917");
char axis_mon[3][3] = { " ", " ", " " }; // list of axes to be monitored char axis_mon[3][3] = { " ", " ", " " }; // list of axes to be monitored
uint8_t axis_index[3]; uint8_t axis_index[3];
@ -196,7 +199,7 @@ void GcodeSuite::M917() {
if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold)) if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold))
return; // quit if invalid user input return; // quit if invalid user input
L6470_ECHOLNPAIR("feedrate = ", final_feedrate); DEBUG_ECHOLNPAIR("feedrate = ", final_feedrate);
planner.synchronize(); // wait for all current movement commands to complete planner.synchronize(); // wait for all current movement commands to complete
for (j = 0; j < driver_count; j++) for (j = 0; j < driver_count; j++)
@ -211,16 +214,16 @@ void GcodeSuite::M917() {
// 2 - OCD finalized - decreasing STALL - exit when STALL warning happens // 2 - OCD finalized - decreasing STALL - exit when STALL warning happens
// 3 - OCD finalized - increasing STALL - exit when STALL warning stop // 3 - OCD finalized - increasing STALL - exit when STALL warning stop
// 4 - all testing completed // 4 - all testing completed
L6470_ECHOPAIR(".\n.\n.\nover_current threshold : ", (ocd_th_val + 1) * 375); // first status display DEBUG_ECHOPAIR(".\n.\n.\nover_current threshold : ", (ocd_th_val + 1) * 375); // first status display
L6470_ECHOPAIR(" (OCD_TH: : ", ocd_th_val); DEBUG_ECHOPAIR(" (OCD_TH: : ", ocd_th_val);
L6470_ECHOPAIR(") Stall threshold: ", (stall_th_val + 1) * 31.25); DEBUG_ECHOPAIR(") Stall threshold: ", (stall_th_val + 1) * 31.25);
L6470_ECHOPAIR(" (STALL_TH: ", stall_th_val); DEBUG_ECHOPAIR(" (STALL_TH: ", stall_th_val);
L6470_ECHOLNPGM(")"); DEBUG_ECHOLNPGM(")");
do { do {
L6470_ECHOPAIR("STALL threshold : ", (stall_th_val + 1) * 31.25); DEBUG_ECHOPAIR("STALL threshold : ", (stall_th_val + 1) * 31.25);
L6470_ECHOLNPAIR(" OCD threshold : ", (ocd_th_val + 1) * 375); DEBUG_ECHOLNPAIR(" OCD threshold : ", (ocd_th_val + 1) * 375);
sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_min, final_feedrate); sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_min, final_feedrate);
gcode.process_subcommands_now_P(gcode_string); gcode.process_subcommands_now_P(gcode_string);
@ -238,16 +241,16 @@ void GcodeSuite::M917() {
} }
if (status_composite && (status_composite & STATUS_UVLO)) { if (status_composite && (status_composite & STATUS_UVLO)) {
L6470_ECHOLNPGM("Test aborted (Undervoltage lockout active)"); DEBUG_ECHOLNPGM("Test aborted (Undervoltage lockout active)");
for (j = 0; j < driver_count; j++) { for (j = 0; j < driver_count; j++) {
L6470_ECHOPGM("..."); DEBUG_ECHOPGM("...");
L6470.error_status_decode(axis_status[j], axis_index[j]); L6470.error_status_decode(axis_status[j], axis_index[j]);
} }
return; return;
} }
if (status_composite & (STATUS_TH_WRN | STATUS_TH_SD)) { if (status_composite & (STATUS_TH_WRN | STATUS_TH_SD)) {
L6470_ECHOLNPGM("thermal problem - waiting for chip(s) to cool down "); DEBUG_ECHOLNPGM("thermal problem - waiting for chip(s) to cool down ");
uint16_t status_composite_temp = 0; uint16_t status_composite_temp = 0;
uint8_t k = 0; uint8_t k = 0;
do { do {
@ -255,11 +258,11 @@ void GcodeSuite::M917() {
if (!(k % 4)) { if (!(k % 4)) {
kval_hold *= 0.95; kval_hold *= 0.95;
L6470_EOL(); L6470_EOL();
L6470_ECHOLNPAIR("Lowering KVAL_HOLD by about 5% to ", kval_hold); DEBUG_ECHOLNPAIR("Lowering KVAL_HOLD by about 5% to ", kval_hold);
for (j = 0; j < driver_count; j++) for (j = 0; j < driver_count; j++)
L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold); L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
} }
L6470_ECHOLNPGM("."); DEBUG_ECHOLNPGM(".");
gcode.reset_stepper_timeout(); // reset_stepper_timeout to keep steppers powered gcode.reset_stepper_timeout(); // reset_stepper_timeout to keep steppers powered
watchdog_reset(); // beat the dog watchdog_reset(); // beat the dog
safe_delay(5000); safe_delay(5000);
@ -281,22 +284,22 @@ void GcodeSuite::M917() {
if (ocd_th_val >=15) { if (ocd_th_val >=15) {
ocd_th_val = 15; // limit to max ocd_th_val = 15; // limit to max
test_phase = 2; // at highest value so skip phase 1 test_phase = 2; // at highest value so skip phase 1
L6470_ECHOLNPGM("LOGIC E0A OCD at highest - skip to 2"); DEBUG_ECHOLNPGM("LOGIC E0A OCD at highest - skip to 2");
} }
else { else {
ocd_th_val++; // normal exit to next phase ocd_th_val++; // normal exit to next phase
test_phase = 1; // setup for first pass of phase 1 test_phase = 1; // setup for first pass of phase 1
L6470_ECHOLNPGM("LOGIC E0B - inc OCD & go to 1"); DEBUG_ECHOLNPGM("LOGIC E0B - inc OCD & go to 1");
} }
} }
else { // phase 0 without OCD warning - keep on decrementing if can else { // phase 0 without OCD warning - keep on decrementing if can
if (ocd_th_val) { if (ocd_th_val) {
ocd_th_val--; // try lower value ocd_th_val--; // try lower value
L6470_ECHOLNPGM("LOGIC E0C - dec OCD"); DEBUG_ECHOLNPGM("LOGIC E0C - dec OCD");
} }
else { else {
test_phase = 2; // at lowest value without warning so skip phase 1 test_phase = 2; // at lowest value without warning so skip phase 1
L6470_ECHOLNPGM("LOGIC E0D - OCD at latest - go to 2"); DEBUG_ECHOLNPGM("LOGIC E0D - OCD at latest - go to 2");
} }
} }
} break; } break;
@ -307,16 +310,16 @@ void GcodeSuite::M917() {
if (ocd_th_val >= 15) { if (ocd_th_val >= 15) {
ocd_th_val = 15; // limit to max ocd_th_val = 15; // limit to max
test_phase = 2; // at highest value so go to next phase test_phase = 2; // at highest value so go to next phase
L6470_ECHOLNPGM("LOGIC E1A - OCD at max - go to 2"); DEBUG_ECHOLNPGM("LOGIC E1A - OCD at max - go to 2");
} }
else { else {
ocd_th_val++; // try a higher value ocd_th_val++; // try a higher value
L6470_ECHOLNPGM("LOGIC E1B - inc OCD"); DEBUG_ECHOLNPGM("LOGIC E1B - inc OCD");
} }
} }
else { // phase 1 without OCD warning - normal exit to phase 2 else { // phase 1 without OCD warning - normal exit to phase 2
test_phase = 2; test_phase = 2;
L6470_ECHOLNPGM("LOGIC E1C - no OCD warning - go to 1"); DEBUG_ECHOLNPGM("LOGIC E1C - no OCD warning - go to 1");
} }
} break; } break;
@ -325,25 +328,25 @@ void GcodeSuite::M917() {
// phase 2 with stall warning - time to go to next phase // phase 2 with stall warning - time to go to next phase
if (stall_th_val >= 127) { if (stall_th_val >= 127) {
stall_th_val = 127; // limit to max stall_th_val = 127; // limit to max
L6470_ECHOLNPGM("LOGIC E2A - STALL warning, STALL at max, quit"); DEBUG_ECHOLNPGM("LOGIC E2A - STALL warning, STALL at max, quit");
L6470_ECHOLNPGM("finished - STALL at maximum value but still have stall warning"); DEBUG_ECHOLNPGM("finished - STALL at maximum value but still have stall warning");
test_phase = 4; test_phase = 4;
} }
else { else {
test_phase = 3; // normal exit to next phase (found failing value of STALL) test_phase = 3; // normal exit to next phase (found failing value of STALL)
stall_th_val++; // setup for first pass of phase 3 stall_th_val++; // setup for first pass of phase 3
L6470_ECHOLNPGM("LOGIC E2B - INC - STALL warning, inc Stall, go to 3"); DEBUG_ECHOLNPGM("LOGIC E2B - INC - STALL warning, inc Stall, go to 3");
} }
} }
else { // phase 2 without stall warning - decrement if can else { // phase 2 without stall warning - decrement if can
if (stall_th_val) { if (stall_th_val) {
stall_th_val--; // try a lower value stall_th_val--; // try a lower value
L6470_ECHOLNPGM("LOGIC E2C - no STALL, dec STALL"); DEBUG_ECHOLNPGM("LOGIC E2C - no STALL, dec STALL");
} }
else { else {
L6470_ECHOLNPGM("finished - STALL at lowest value but still do NOT have stall warning"); DEBUG_ECHOLNPGM("finished - STALL at lowest value but still do NOT have stall warning");
test_phase = 4; test_phase = 4;
L6470_ECHOLNPGM("LOGIC E2D - no STALL, at lowest so quit"); DEBUG_ECHOLNPGM("LOGIC E2D - no STALL, at lowest so quit");
} }
} }
} break; } break;
@ -353,19 +356,19 @@ void GcodeSuite::M917() {
// phase 3 with stall warning - increment if can // phase 3 with stall warning - increment if can
if (stall_th_val >= 127) { if (stall_th_val >= 127) {
stall_th_val = 127; // limit to max stall_th_val = 127; // limit to max
L6470_ECHOLNPGM("finished - STALL at maximum value but still have stall warning"); DEBUG_ECHOLNPGM("finished - STALL at maximum value but still have stall warning");
test_phase = 4; test_phase = 4;
L6470_ECHOLNPGM("LOGIC E3A - STALL, at max so quit"); DEBUG_ECHOLNPGM("LOGIC E3A - STALL, at max so quit");
} }
else { else {
stall_th_val++; // still looking for passing value stall_th_val++; // still looking for passing value
L6470_ECHOLNPGM("LOGIC E3B - STALL, inc stall"); DEBUG_ECHOLNPGM("LOGIC E3B - STALL, inc stall");
} }
} }
else { //phase 3 without stall warning but have OCD warning else { //phase 3 without stall warning but have OCD warning
L6470_ECHOLNPGM("Hardware problem - OCD warning without STALL warning"); DEBUG_ECHOLNPGM("Hardware problem - OCD warning without STALL warning");
test_phase = 4; test_phase = 4;
L6470_ECHOLNPGM("LOGIC E3C - not STALLED, hardware problem (quit)"); DEBUG_ECHOLNPGM("LOGIC E3C - not STALLED, hardware problem (quit)");
} }
} break; } break;
@ -377,30 +380,30 @@ void GcodeSuite::M917() {
case 0: { // phase 0 without OCD warning - keep on decrementing if can case 0: { // phase 0 without OCD warning - keep on decrementing if can
if (ocd_th_val) { if (ocd_th_val) {
ocd_th_val--; // try lower value ocd_th_val--; // try lower value
L6470_ECHOLNPGM("LOGIC N0A - DEC OCD"); DEBUG_ECHOLNPGM("LOGIC N0A - DEC OCD");
} }
else { else {
test_phase = 2; // at lowest value without warning so skip phase 1 test_phase = 2; // at lowest value without warning so skip phase 1
L6470_ECHOLNPGM("LOGIC N0B - OCD at lowest (go to phase 2)"); DEBUG_ECHOLNPGM("LOGIC N0B - OCD at lowest (go to phase 2)");
} }
} break; } break;
case 1: L6470_ECHOLNPGM("LOGIC N1 (go directly to 2)"); // phase 1 without OCD warning - drop directly to phase 2 case 1: DEBUG_ECHOLNPGM("LOGIC N1 (go directly to 2)"); // phase 1 without OCD warning - drop directly to phase 2
case 2: { // phase 2 without stall warning - keep on decrementing if can case 2: { // phase 2 without stall warning - keep on decrementing if can
if (stall_th_val) { if (stall_th_val) {
stall_th_val--; // try a lower value (stay in phase 2) stall_th_val--; // try a lower value (stay in phase 2)
L6470_ECHOLNPGM("LOGIC N2B - dec STALL"); DEBUG_ECHOLNPGM("LOGIC N2B - dec STALL");
} }
else { else {
L6470_ECHOLNPGM("finished - STALL at lowest value but still no stall warning"); DEBUG_ECHOLNPGM("finished - STALL at lowest value but still no stall warning");
test_phase = 4; test_phase = 4;
L6470_ECHOLNPGM("LOGIC N2C - STALL at lowest (quit)"); DEBUG_ECHOLNPGM("LOGIC N2C - STALL at lowest (quit)");
} }
} break; } break;
case 3: { test_phase = 4; case 3: { test_phase = 4;
L6470_ECHOLNPGM("LOGIC N3 - finished!"); DEBUG_ECHOLNPGM("LOGIC N3 - finished!");
} break; // phase 3 without any warnings - desired exit } break; // phase 3 without any warnings - desired exit
} // } //
} // end of status checks } // end of status checks
@ -409,22 +412,22 @@ void GcodeSuite::M917() {
for (j = 0; j < driver_count; j++) { // update threshold(s) for (j = 0; j < driver_count; j++) { // update threshold(s)
L6470.set_param(axis_index[j], L6470_OCD_TH, ocd_th_val); L6470.set_param(axis_index[j], L6470_OCD_TH, ocd_th_val);
L6470.set_param(axis_index[j], L6470_STALL_TH, stall_th_val); L6470.set_param(axis_index[j], L6470_STALL_TH, stall_th_val);
if (L6470.get_param(axis_index[j], L6470_OCD_TH) != ocd_th_val) L6470_ECHOLNPGM("OCD mismatch"); if (L6470.get_param(axis_index[j], L6470_OCD_TH) != ocd_th_val) DEBUG_ECHOLNPGM("OCD mismatch");
if (L6470.get_param(axis_index[j], L6470_STALL_TH) != stall_th_val) L6470_ECHOLNPGM("STALL mismatch"); if (L6470.get_param(axis_index[j], L6470_STALL_TH) != stall_th_val) DEBUG_ECHOLNPGM("STALL mismatch");
} }
} }
} while (test_phase != 4); } while (test_phase != 4);
if (status_composite) { if (status_composite) {
L6470_ECHOLNPGM("Completed with errors"); DEBUG_ECHOLNPGM("Completed with errors");
for (j = 0; j < driver_count; j++) { for (j = 0; j < driver_count; j++) {
L6470_ECHOPGM("..."); DEBUG_ECHOPGM("...");
L6470.error_status_decode(axis_status[j], axis_index[j]); L6470.error_status_decode(axis_status[j], axis_index[j]);
} }
} }
else else
L6470_ECHOLNPGM("Completed with no errors"); DEBUG_ECHOLNPGM("Completed with no errors");
} // M917 } // M917
@ -448,7 +451,7 @@ void GcodeSuite::M917() {
*/ */
void GcodeSuite::M918() { void GcodeSuite::M918() {
L6470_ECHOLNPGM("M918"); DEBUG_ECHOLNPGM("M918");
char axis_mon[3][3] = { " ", " ", " " }; // List of axes to monitor char axis_mon[3][3] = { " ", " ", " " }; // List of axes to monitor
uint8_t axis_index[3]; uint8_t axis_index[3];
@ -469,7 +472,7 @@ void GcodeSuite::M918() {
uint8_t m_steps = parser.byteval('M'); uint8_t m_steps = parser.byteval('M');
LIMIT(m_steps, 0, 128); LIMIT(m_steps, 0, 128);
L6470_ECHOLNPAIR("M = ", m_steps); DEBUG_ECHOLNPAIR("M = ", m_steps);
int8_t m_bits = -1; int8_t m_bits = -1;
if (m_steps > 85) m_bits = 7; // 128 (no synch output) if (m_steps > 85) m_bits = 7; // 128 (no synch output)
@ -484,15 +487,15 @@ void GcodeSuite::M918() {
if (m_bits >= 0) { if (m_bits >= 0) {
const int micros = _BV(m_bits); const int micros = _BV(m_bits);
if (micros < 100) { L6470_CHAR(' '); if (micros < 10) L6470_CHAR(' '); } if (micros < 100) { DEBUG_CHAR(' '); if (micros < 10) DEBUG_CHAR(' '); }
L6470_ECHO(micros); DEBUG_ECHO(micros);
L6470_ECHOPGM(" uSTEPS"); DEBUG_ECHOPGM(" uSTEPS");
} }
for (j = 0; j < driver_count; j++) for (j = 0; j < driver_count; j++)
L6470.set_param(axis_index[j], L6470_STEP_MODE, m_bits); // set microsteps L6470.set_param(axis_index[j], L6470_STEP_MODE, m_bits); // set microsteps
L6470_ECHOLNPAIR("target (maximum) feedrate = ",final_feedrate); DEBUG_ECHOLNPAIR("target (maximum) feedrate = ",final_feedrate);
float feedrate_inc = final_feedrate / 10, // start at 1/10 of max & go up by 1/10 per step) float feedrate_inc = final_feedrate / 10, // start at 1/10 of max & go up by 1/10 per step)
current_feedrate = 0; current_feedrate = 0;
@ -508,11 +511,11 @@ void GcodeSuite::M918() {
char gcode_string[80]; char gcode_string[80];
uint16_t status_composite = 0; uint16_t status_composite = 0;
L6470_ECHOLNPGM(".\n.\n."); // make the feedrate prints easier to see DEBUG_ECHOLNPGM(".\n.\n."); // make the feedrate prints easier to see
do { do {
current_feedrate += feedrate_inc; current_feedrate += feedrate_inc;
L6470_ECHOLNPAIR("...feedrate = ", current_feedrate); DEBUG_ECHOLNPAIR("...feedrate = ", current_feedrate);
sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_min, current_feedrate); sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_min, current_feedrate);
gcode.process_subcommands_now_P(gcode_string); gcode.process_subcommands_now_P(gcode_string);
@ -529,15 +532,16 @@ void GcodeSuite::M918() {
if (status_composite) break; // quit if any errors flags are raised if (status_composite) break; // quit if any errors flags are raised
} while (current_feedrate < final_feedrate * 0.99); } while (current_feedrate < final_feedrate * 0.99);
DEBUG_ECHOPGM("Completed with errors");
if (status_composite) { if (status_composite) {
L6470_ECHOLNPGM("Completed with errors"); DEBUG_ECHOLNPGM("errors");
for (j = 0; j < driver_count; j++) { for (j = 0; j < driver_count; j++) {
L6470_ECHOPGM("..."); DEBUG_ECHOPGM("...");
L6470.error_status_decode(axis_status[j], axis_index[j]); L6470.error_status_decode(axis_status[j], axis_index[j]);
} }
} }
else else
L6470_ECHOLNPGM("Completed with no errors"); DEBUG_ECHOLNPGM("no errors");
} // M918 } // M918

@ -32,6 +32,8 @@
//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\gcode\host\M114.cpp //C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\gcode\host\M114.cpp
//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\module\bob_L6470.cpp //C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\module\bob_L6470.cpp
#include "../../module/L6470/L6470_Marlin.h" #include "../../module/L6470/L6470_Marlin.h"
#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
#include "../../core/debug_out.h"
#endif #endif
void report_xyze(const float pos[], const uint8_t n = 4, const uint8_t precision = 3) { void report_xyze(const float pos[], const uint8_t n = 4, const uint8_t precision = 3) {
@ -95,10 +97,10 @@
temp = L6470_GETPARAM(L6470_ABS_POS,Q); \ temp = L6470_GETPARAM(L6470_ABS_POS,Q); \
if (temp & ABS_POS_SIGN_MASK) temp |= ABS_POS_SIGN_MASK; \ if (temp & ABS_POS_SIGN_MASK) temp |= ABS_POS_SIGN_MASK; \
sprintf_P(temp_buf, PSTR(":%8ld "), temp); \ sprintf_P(temp_buf, PSTR(":%8ld "), temp); \
L6470_ECHO(temp_buf); \ DEBUG_ECHO(temp_buf); \
}while(0) }while(0)
L6470_ECHOPGM("\nL6470:"); DEBUG_ECHOPGM("\nL6470:");
#if AXIS_DRIVER_TYPE_X(L6470) #if AXIS_DRIVER_TYPE_X(L6470)
REPORT_ABSOLUTE_POS(X); REPORT_ABSOLUTE_POS(X);
#endif #endif

@ -36,6 +36,9 @@ L6470_Marlin L6470;
#include "../../gcode/gcode.h" #include "../../gcode/gcode.h"
#include "../planner.h" #include "../planner.h"
#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
#include "../../core/debug_out.h"
uint8_t L6470_Marlin::dir_commands[MAX_L6470]; // array to hold direction command for each driver uint8_t L6470_Marlin::dir_commands[MAX_L6470]; // array to hold direction command for each driver
char L6470_Marlin::index_to_axis[MAX_L6470][3] = { "X ", "Y ", "Z ", "X2", "Y2", "Z2", "Z3", "E0", "E1", "E2", "E3", "E4", "E5" }; char L6470_Marlin::index_to_axis[MAX_L6470][3] = { "X ", "Y ", "Z ", "X2", "Y2", "Z2", "Z3", "E0", "E1", "E2", "E3", "E4", "E5" };
@ -286,16 +289,16 @@ void L6470_Marlin::set_param(uint8_t axis, uint8_t param, uint32_t value) {
} }
inline void echo_min_max(const char a, const float &min, const float &max) { inline void echo_min_max(const char a, const float &min, const float &max) {
L6470_CHAR(' '); L6470_CHAR(a); DEBUG_CHAR(' '); DEBUG_CHAR(a);
L6470_ECHOPAIR(" min = ", min); DEBUG_ECHOPAIR(" min = ", min);
L6470_ECHOLNPAIR(" max = ", max); DEBUG_ECHOLNPAIR(" max = ", max);
} }
inline void echo_oct_used(const float &oct, const bool stall) { inline void echo_oct_used(const float &oct, const bool stall) {
L6470_ECHOPAIR("over_current_threshold used : ", oct); DEBUG_ECHOPAIR("over_current_threshold used : ", oct);
serialprintPGM(stall ? PSTR(" (Stall") : PSTR(" (OCD")); serialprintPGM(stall ? PSTR(" (Stall") : PSTR(" (OCD"));
L6470_ECHOLNPGM(" threshold)"); DEBUG_ECHOLNPGM(" threshold)");
} }
inline void err_out_of_bounds() { L6470_ECHOLNPGM("ERROR - motion out of bounds"); } inline void err_out_of_bounds() { DEBUG_ECHOLNPGM("ERROR - motion out of bounds"); }
bool L6470_Marlin::get_user_input(uint8_t &driver_count, uint8_t axis_index[3], char axis_mon[3][3], bool L6470_Marlin::get_user_input(uint8_t &driver_count, uint8_t axis_index[3], char axis_mon[3][3],
float &position_max, float &position_min, float &final_feedrate, uint8_t &kval_hold, float &position_max, float &position_min, float &final_feedrate, uint8_t &kval_hold,
@ -307,7 +310,7 @@ bool L6470_Marlin::get_user_input(uint8_t &driver_count, uint8_t axis_index[3],
uint8_t j; // general purpose counter uint8_t j; // general purpose counter
if (!all_axes_homed()) { if (!all_axes_homed()) {
L6470_ECHOLNPGM("ERROR - home all before running this command"); DEBUG_ECHOLNPGM("ERROR - home all before running this command");
//return true; //return true;
} }
@ -424,12 +427,12 @@ bool L6470_Marlin::get_user_input(uint8_t &driver_count, uint8_t axis_index[3],
} }
if (driver_count == 0) { if (driver_count == 0) {
L6470_ECHOLNPGM("ERROR - not a L6470 axis"); DEBUG_ECHOLNPGM("ERROR - not a L6470 axis");
return true; return true;
} }
L6470_ECHOPGM("Monitoring:"); DEBUG_ECHOPGM("Monitoring:");
for (j = 0; j < driver_count; j++) L6470_ECHOPAIR(" ", axis_mon[j]); for (j = 0; j < driver_count; j++) DEBUG_ECHOPAIR(" ", axis_mon[j]);
L6470_EOL(); L6470_EOL();
// now have a list of driver(s) to monitor // now have a list of driver(s) to monitor
@ -440,14 +443,14 @@ bool L6470_Marlin::get_user_input(uint8_t &driver_count, uint8_t axis_index[3],
kval_hold = parser.byteval('K'); kval_hold = parser.byteval('K');
if (kval_hold) { if (kval_hold) {
L6470_ECHOLNPAIR("kval_hold = ", kval_hold); DEBUG_ECHOLNPAIR("kval_hold = ", kval_hold);
for (j = 0; j < driver_count; j++) for (j = 0; j < driver_count; j++)
set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold); set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
} }
else { else {
// only print the KVAL_HOLD from one of the drivers // only print the KVAL_HOLD from one of the drivers
kval_hold = get_param(axis_index[0], L6470_KVAL_HOLD); kval_hold = get_param(axis_index[0], L6470_KVAL_HOLD);
L6470_ECHOLNPAIR("KVAL_HOLD = ", kval_hold); DEBUG_ECHOLNPAIR("KVAL_HOLD = ", kval_hold);
} }
// //
@ -474,7 +477,7 @@ bool L6470_Marlin::get_user_input(uint8_t &driver_count, uint8_t axis_index[3],
OCD_TH_actual = (OCD_TH_val_local + 1) * 375; OCD_TH_actual = (OCD_TH_val_local + 1) * 375;
} }
L6470_ECHOLNPAIR("over_current_threshold specified: ", over_current_threshold); DEBUG_ECHOLNPAIR("over_current_threshold specified: ", over_current_threshold);
echo_oct_used(STALL_TH_actual, true); echo_oct_used(STALL_TH_actual, true);
echo_oct_used(OCD_TH_actual, false); echo_oct_used(OCD_TH_actual, false);
@ -547,13 +550,13 @@ void L6470_Marlin::error_status_decode(const uint16_t status, const uint8_t axis
char temp_buf[10]; char temp_buf[10];
say_axis(axis); say_axis(axis);
sprintf_P(temp_buf, PSTR(" %4x "), status); sprintf_P(temp_buf, PSTR(" %4x "), status);
L6470_ECHO(temp_buf); DEBUG_ECHO(temp_buf);
print_bin(status); print_bin(status);
L6470_ECHOPGM(" THERMAL: "); DEBUG_ECHOPGM(" THERMAL: ");
serialprintPGM((status & STATUS_TH_SD) ? PSTR("SHUTDOWN") : (status & STATUS_TH_WRN) ? PSTR("WARNING ") : PSTR("OK ")); serialprintPGM((status & STATUS_TH_SD) ? PSTR("SHUTDOWN") : (status & STATUS_TH_WRN) ? PSTR("WARNING ") : PSTR("OK "));
L6470_ECHOPGM(" OVERCURRENT: "); DEBUG_ECHOPGM(" OVERCURRENT: ");
echo_yes_no(status & STATUS_OCD); echo_yes_no(status & STATUS_OCD);
L6470_ECHOPGM(" STALL: "); DEBUG_ECHOPGM(" STALL: ");
echo_yes_no(status & (STATUS_STEP_LOSS_A | STATUS_STEP_LOSS_B)); echo_yes_no(status & (STATUS_STEP_LOSS_A | STATUS_STEP_LOSS_B));
L6470_EOL(); L6470_EOL();
#else #else
@ -642,14 +645,14 @@ void L6470_Marlin::error_status_decode(const uint16_t status, const uint8_t axis
if (driver_L6470_data[j].com_counter == 0) { // warn user when it first happens if (driver_L6470_data[j].com_counter == 0) { // warn user when it first happens
driver_L6470_data[j].com_counter++; driver_L6470_data[j].com_counter++;
append_stepper_err(p, stepper_index, PSTR(" - communications lost\n")); append_stepper_err(p, stepper_index, PSTR(" - communications lost\n"));
L6470_ECHO(temp_buf); DEBUG_ECHO(temp_buf);
} }
else { else {
driver_L6470_data[j].com_counter++; driver_L6470_data[j].com_counter++;
if (driver_L6470_data[j].com_counter > 240) { // remind of com problem about every 2 minutes if (driver_L6470_data[j].com_counter > 240) { // remind of com problem about every 2 minutes
driver_L6470_data[j].com_counter = 1; driver_L6470_data[j].com_counter = 1;
append_stepper_err(p, stepper_index, PSTR(" - still no communications\n")); append_stepper_err(p, stepper_index, PSTR(" - still no communications\n"));
L6470_ECHO(temp_buf); DEBUG_ECHO(temp_buf);
} }
} }
} }
@ -657,7 +660,7 @@ void L6470_Marlin::error_status_decode(const uint16_t status, const uint8_t axis
if (driver_L6470_data[j].com_counter) { // comms re-established if (driver_L6470_data[j].com_counter) { // comms re-established
driver_L6470_data[j].com_counter = 0; driver_L6470_data[j].com_counter = 0;
append_stepper_err(p, stepper_index, PSTR(" - communications re-established\n.. setting all drivers to default values\n")); append_stepper_err(p, stepper_index, PSTR(" - communications re-established\n.. setting all drivers to default values\n"));
L6470_ECHO(temp_buf); DEBUG_ECHO(temp_buf);
init_to_defaults(); init_to_defaults();
} }
else { else {
@ -718,7 +721,7 @@ void L6470_Marlin::error_status_decode(const uint16_t status, const uint8_t axis
p += sprintf_P(p, PSTR("%c\n"), ' '); p += sprintf_P(p, PSTR("%c\n"), ' ');
#endif #endif
L6470_ECHOLN(temp_buf); // print the error message DEBUG_ECHOLN(temp_buf); // print the error message
} }
else { else {
driver_L6470_data[j].is_ot = false; driver_L6470_data[j].is_ot = false;

@ -25,26 +25,6 @@
#include <L6470.h> #include <L6470.h>
#if ENABLED(L6470_CHITCHAT)
#define L6470_EOL() SERIAL_EOL()
#define L6470_CHAR(C) SERIAL_CHAR(C)
#define L6470_ECHO(V) SERIAL_ECHO(V)
#define L6470_ECHOLN(V) SERIAL_ECHOLN(V)
#define L6470_ECHOPGM(S) SERIAL_ECHOPGM(S)
#define L6470_ECHOLNPGM(S) SERIAL_ECHOLNPGM(S)
#define L6470_ECHOPAIR(S,V) SERIAL_ECHOPAIR(S,V)
#define L6470_ECHOLNPAIR(S,V) SERIAL_ECHOLNPAIR(S,V)
#else
#define L6470_EOL() NOOP
#define L6470_CHAR(C) NOOP
#define L6470_ECHO(V) NOOP
#define L6470_ECHOLN(V) NOOP
#define L6470_ECHOPGM(S) NOOP
#define L6470_ECHOLNPGM(S) NOOP
#define L6470_ECHOPAIR(S,V) NOOP
#define L6470_ECHOLNPAIR(S,V) NOOP
#endif
#define L6470_GETPARAM(P,Q) stepper##Q.GetParam(P) #define L6470_GETPARAM(P,Q) stepper##Q.GetParam(P)
#define MAX_L6470 (7 + MAX_EXTRUDERS) // Maximum number of axes in Marlin #define MAX_L6470 (7 + MAX_EXTRUDERS) // Maximum number of axes in Marlin

@ -379,27 +379,8 @@ void MarlinSettings::postprocess() {
#endif // SD_FIRMWARE_UPDATE #endif // SD_FIRMWARE_UPDATE
#if ENABLED(EEPROM_CHITCHAT) #define DEBUG_OUT ENABLED(EEPROM_CHITCHAT)
#define CHITCHAT_ECHO(V) SERIAL_ECHO(V) #include "../core/debug_out.h"
#define CHITCHAT_ECHOLNPGM(STR) SERIAL_ECHOLNPGM(STR)
#define CHITCHAT_ECHOPAIR(...) SERIAL_ECHOPAIR(__VA_ARGS__)
#define CHITCHAT_ECHOLNPAIR(...) SERIAL_ECHOLNPAIR(__VA_ARGS__)
#define CHITCHAT_ECHO_START() SERIAL_ECHO_START()
#define CHITCHAT_ERROR_START() SERIAL_ERROR_START()
#define CHITCHAT_ERROR_MSG(STR) SERIAL_ERROR_MSG(STR)
#define CHITCHAT_ECHOPGM(STR) SERIAL_ECHOPGM(STR)
#define CHITCHAT_EOL() SERIAL_EOL()
#else
#define CHITCHAT_ECHO(V) NOOP
#define CHITCHAT_ECHOLNPGM(STR) NOOP
#define CHITCHAT_ECHOPAIR(...) NOOP
#define CHITCHAT_ECHOLNPAIR(...) NOOP
#define CHITCHAT_ECHO_START() NOOP
#define CHITCHAT_ERROR_START() NOOP
#define CHITCHAT_ERROR_MSG(STR) NOOP
#define CHITCHAT_ECHOPGM(STR) NOOP
#define CHITCHAT_EOL() NOOP
#endif
#if ENABLED(EEPROM_SETTINGS) #if ENABLED(EEPROM_SETTINGS)
@ -427,7 +408,7 @@ void MarlinSettings::postprocess() {
bool MarlinSettings::size_error(const uint16_t size) { bool MarlinSettings::size_error(const uint16_t size) {
if (size != datasize()) { if (size != datasize()) {
CHITCHAT_ERROR_MSG("EEPROM datasize error."); DEBUG_ERROR_MSG("EEPROM datasize error.");
return true; return true;
} }
return false; return false;
@ -1103,8 +1084,8 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(final_crc); EEPROM_WRITE(final_crc);
// Report storage size // Report storage size
CHITCHAT_ECHO_START(); DEBUG_ECHO_START();
CHITCHAT_ECHOLNPAIR("Settings Stored (", eeprom_size, " bytes; crc ", (uint32_t)final_crc, ")"); DEBUG_ECHOLNPAIR("Settings Stored (", eeprom_size, " bytes; crc ", (uint32_t)final_crc, ")");
eeprom_error |= size_error(eeprom_size); eeprom_error |= size_error(eeprom_size);
} }
@ -1141,8 +1122,8 @@ void MarlinSettings::postprocess() {
stored_ver[0] = '?'; stored_ver[0] = '?';
stored_ver[1] = '\0'; stored_ver[1] = '\0';
} }
CHITCHAT_ECHO_START(); DEBUG_ECHO_START();
CHITCHAT_ECHOLNPAIR("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")"); DEBUG_ECHOLNPAIR("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")");
eeprom_error = true; eeprom_error = true;
} }
else { else {
@ -1807,18 +1788,18 @@ void MarlinSettings::postprocess() {
eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET)); eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET));
if (eeprom_error) { if (eeprom_error) {
CHITCHAT_ECHO_START(); DEBUG_ECHO_START();
CHITCHAT_ECHOLNPAIR("Index: ", int(eeprom_index - (EEPROM_OFFSET)), " Size: ", datasize()); DEBUG_ECHOLNPAIR("Index: ", int(eeprom_index - (EEPROM_OFFSET)), " Size: ", datasize());
} }
else if (working_crc != stored_crc) { else if (working_crc != stored_crc) {
eeprom_error = true; eeprom_error = true;
CHITCHAT_ERROR_START(); DEBUG_ERROR_START();
CHITCHAT_ECHOLNPAIR("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!"); DEBUG_ECHOLNPAIR("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!");
} }
else if (!validating) { else if (!validating) {
CHITCHAT_ECHO_START(); DEBUG_ECHO_START();
CHITCHAT_ECHO(version); DEBUG_ECHO(version);
CHITCHAT_ECHOLNPAIR(" stored settings retrieved (", eeprom_index - (EEPROM_OFFSET), " bytes; crc ", (uint32_t)working_crc, ")"); DEBUG_ECHOLNPAIR(" stored settings retrieved (", eeprom_index - (EEPROM_OFFSET), " bytes; crc ", (uint32_t)working_crc, ")");
} }
if (!validating && !eeprom_error) postprocess(); if (!validating && !eeprom_error) postprocess();
@ -1831,26 +1812,26 @@ void MarlinSettings::postprocess() {
SERIAL_EOL(); SERIAL_EOL();
#if ENABLED(EEPROM_CHITCHAT) #if ENABLED(EEPROM_CHITCHAT)
ubl.echo_name(); ubl.echo_name();
CHITCHAT_ECHOLNPGM(" initialized.\n"); DEBUG_ECHOLNPGM(" initialized.\n");
#endif #endif
} }
else { else {
eeprom_error = true; eeprom_error = true;
#if ENABLED(EEPROM_CHITCHAT) #if ENABLED(EEPROM_CHITCHAT)
CHITCHAT_ECHOPGM("?Can't enable "); DEBUG_ECHOPGM("?Can't enable ");
ubl.echo_name(); ubl.echo_name();
CHITCHAT_ECHOLNPGM("."); DEBUG_ECHOLNPGM(".");
#endif #endif
ubl.reset(); ubl.reset();
} }
if (ubl.storage_slot >= 0) { if (ubl.storage_slot >= 0) {
load_mesh(ubl.storage_slot); load_mesh(ubl.storage_slot);
CHITCHAT_ECHOLNPAIR("Mesh ", ubl.storage_slot, " loaded from storage."); DEBUG_ECHOLNPAIR("Mesh ", ubl.storage_slot, " loaded from storage.");
} }
else { else {
ubl.reset(); ubl.reset();
CHITCHAT_ECHOLNPGM("UBL System reset()"); DEBUG_ECHOLNPGM("UBL System reset()");
} }
} }
#endif #endif
@ -1881,9 +1862,9 @@ void MarlinSettings::postprocess() {
inline void ubl_invalid_slot(const int s) { inline void ubl_invalid_slot(const int s) {
#if ENABLED(EEPROM_CHITCHAT) #if ENABLED(EEPROM_CHITCHAT)
CHITCHAT_ECHOLNPGM("?Invalid slot."); DEBUG_ECHOLNPGM("?Invalid slot.");
CHITCHAT_ECHO(s); DEBUG_ECHO(s);
CHITCHAT_ECHOLNPGM(" mesh slots available."); DEBUG_ECHOLNPGM(" mesh slots available.");
#else #else
UNUSED(s); UNUSED(s);
#endif #endif
@ -1912,8 +1893,8 @@ void MarlinSettings::postprocess() {
const int16_t a = calc_num_meshes(); const int16_t a = calc_num_meshes();
if (!WITHIN(slot, 0, a - 1)) { if (!WITHIN(slot, 0, a - 1)) {
ubl_invalid_slot(a); ubl_invalid_slot(a);
CHITCHAT_ECHOLNPAIR("E2END=", persistentStore.capacity() - 1, " meshes_end=", meshes_end, " slot=", slot); DEBUG_ECHOLNPAIR("E2END=", persistentStore.capacity() - 1, " meshes_end=", meshes_end, " slot=", slot);
CHITCHAT_EOL(); DEBUG_EOL();
return; return;
} }
@ -1926,7 +1907,7 @@ void MarlinSettings::postprocess() {
persistentStore.access_finish(); persistentStore.access_finish();
if (status) SERIAL_ECHOLNPGM("?Unable to save mesh data."); if (status) SERIAL_ECHOLNPGM("?Unable to save mesh data.");
else CHITCHAT_ECHOLNPAIR("Mesh saved in slot ", slot); else DEBUG_ECHOLNPAIR("Mesh saved in slot ", slot);
#else #else
@ -1955,7 +1936,7 @@ void MarlinSettings::postprocess() {
persistentStore.access_finish(); persistentStore.access_finish();
if (status) SERIAL_ECHOLNPGM("?Unable to load mesh data."); if (status) SERIAL_ECHOLNPGM("?Unable to load mesh data.");
else CHITCHAT_ECHOLNPAIR("Mesh loaded from slot ", slot); else DEBUG_ECHOLNPAIR("Mesh loaded from slot ", slot);
EEPROM_FINISH(); EEPROM_FINISH();
@ -1974,7 +1955,7 @@ void MarlinSettings::postprocess() {
#else // !EEPROM_SETTINGS #else // !EEPROM_SETTINGS
bool MarlinSettings::save() { bool MarlinSettings::save() {
CHITCHAT_ERROR_MSG("EEPROM disabled"); DEBUG_ERROR_MSG("EEPROM disabled");
return false; return false;
} }
@ -2281,8 +2262,8 @@ void MarlinSettings::reset() {
postprocess(); postprocess();
CHITCHAT_ECHO_START(); DEBUG_ECHO_START();
CHITCHAT_ECHOLNPGM("Hardcoded Default Settings Loaded"); DEBUG_ECHOLNPGM("Hardcoded Default Settings Loaded");
} }
#if DISABLED(DISABLE_M503) #if DISABLED(DISABLE_M503)

@ -46,6 +46,9 @@
#include "stepper_indirection.h" #include "stepper_indirection.h"
#endif #endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../core/debug_out.h"
// Initialized by settings.load() // Initialized by settings.load()
float delta_height, float delta_height,
delta_endstop_adj[ABC] = { 0 }, delta_endstop_adj[ABC] = { 0 },
@ -216,9 +219,7 @@ void forward_kinematics_DELTA(const float &z1, const float &z2, const float &z3)
* This is like quick_home_xy() but for 3 towers. * This is like quick_home_xy() but for 3 towers.
*/ */
void home_delta() { void home_delta() {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position);
#endif
// Init the current position of all carriages to 0,0,0 // Init the current position of all carriages to 0,0,0
ZERO(current_position); ZERO(current_position);
ZERO(destination); ZERO(destination);
@ -264,9 +265,7 @@ void home_delta() {
sync_plan_position(); sync_plan_position();
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("<<< home_delta", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< home_delta", current_position);
#endif
} }
#endif // DELTA #endif // DELTA

@ -59,6 +59,9 @@
#include "../feature/fwretract.h" #include "../feature/fwretract.h"
#endif #endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../core/debug_out.h"
#define XYZ_CONSTS(type, array, CONFIG) const PROGMEM type array##_P[XYZ] = { X_##CONFIG, Y_##CONFIG, Z_##CONFIG } #define XYZ_CONSTS(type, array, CONFIG) const PROGMEM type array##_P[XYZ] = { X_##CONFIG, Y_##CONFIG, Z_##CONFIG }
XYZ_CONSTS(float, base_min_pos, MIN_POS); XYZ_CONSTS(float, base_min_pos, MIN_POS);
@ -205,9 +208,7 @@ void report_current_position() {
* no kinematic translation. Used for homing axes and cartesian/core syncing. * no kinematic translation. Used for homing axes and cartesian/core syncing.
*/ */
void sync_plan_position() { void sync_plan_position() {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("sync_plan_position", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("sync_plan_position", current_position);
#endif
planner.set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); planner.set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
} }
@ -294,9 +295,7 @@ void buffer_line_to_destination(const float fr_mm_s) {
* Calculate delta, start a line, and set current_position to destination * Calculate delta, start a line, and set current_position to destination
*/ */
void prepare_uninterpolated_move_to_destination(const float &fr_mm_s/*=0.0*/) { void prepare_uninterpolated_move_to_destination(const float &fr_mm_s/*=0.0*/) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_uninterpolated_move_to_destination", destination);
if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_uninterpolated_move_to_destination", destination);
#endif
#if UBL_SEGMENTED #if UBL_SEGMENTED
// ubl segmented line will do z-only moves in single segment // ubl segmented line will do z-only moves in single segment
@ -320,9 +319,7 @@ void buffer_line_to_destination(const float fr_mm_s) {
* Plan a move to (X, Y, Z) and set the current_position * Plan a move to (X, Y, Z) and set the current_position
*/ */
void do_blocking_move_to(const float rx, const float ry, const float rz, const float &fr_mm_s/*=0.0*/) { void do_blocking_move_to(const float rx, const float ry, const float rz, const float &fr_mm_s/*=0.0*/) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_XYZ(">>> do_blocking_move_to", rx, ry, rz);
if (DEBUGGING(LEVELING)) print_xyz(PSTR(">>> do_blocking_move_to"), NULL, rx, ry, rz);
#endif
const float z_feedrate = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS), const float z_feedrate = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS),
xy_feedrate = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S; xy_feedrate = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
@ -335,9 +332,7 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f
set_destination_from_current(); // sync destination at the start set_destination_from_current(); // sync destination at the start
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("set_destination_from_current", destination);
if (DEBUGGING(LEVELING)) DEBUG_POS("set_destination_from_current", destination);
#endif
// when in the danger zone // when in the danger zone
if (current_position[Z_AXIS] > delta_clip_start_height) { if (current_position[Z_AXIS] > delta_clip_start_height) {
@ -346,39 +341,29 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f
destination[Y_AXIS] = ry; destination[Y_AXIS] = ry;
destination[Z_AXIS] = rz; destination[Z_AXIS] = rz;
prepare_uninterpolated_move_to_destination(); // set_current_from_destination() prepare_uninterpolated_move_to_destination(); // set_current_from_destination()
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("danger zone move", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("danger zone move", current_position);
#endif
return; return;
} }
destination[Z_AXIS] = delta_clip_start_height; destination[Z_AXIS] = delta_clip_start_height;
prepare_uninterpolated_move_to_destination(); // set_current_from_destination() prepare_uninterpolated_move_to_destination(); // set_current_from_destination()
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("zone border move", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("zone border move", current_position);
#endif
} }
if (rz > current_position[Z_AXIS]) { // raising? if (rz > current_position[Z_AXIS]) { // raising?
destination[Z_AXIS] = rz; destination[Z_AXIS] = rz;
prepare_uninterpolated_move_to_destination(z_feedrate); // set_current_from_destination() prepare_uninterpolated_move_to_destination(z_feedrate); // set_current_from_destination()
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("z raise move", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("z raise move", current_position);
#endif
} }
destination[X_AXIS] = rx; destination[X_AXIS] = rx;
destination[Y_AXIS] = ry; destination[Y_AXIS] = ry;
prepare_move_to_destination(); // set_current_from_destination() prepare_move_to_destination(); // set_current_from_destination()
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("xy move", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("xy move", current_position);
#endif
if (rz < current_position[Z_AXIS]) { // lowering? if (rz < current_position[Z_AXIS]) { // lowering?
destination[Z_AXIS] = rz; destination[Z_AXIS] = rz;
prepare_uninterpolated_move_to_destination(z_feedrate); // set_current_from_destination() prepare_uninterpolated_move_to_destination(z_feedrate); // set_current_from_destination()
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("z lower move", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("z lower move", current_position);
#endif
} }
#elif IS_SCARA #elif IS_SCARA
@ -423,9 +408,7 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f
#endif #endif
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< do_blocking_move_to");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< do_blocking_move_to");
#endif
planner.synchronize(); planner.synchronize();
} }
@ -938,19 +921,12 @@ void clean_up_after_endstop_or_probe_move() {
planner.buffer_line( CUR_X, CUR_Y, CUR_Z, CUR_E, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder); planner.buffer_line( CUR_X, CUR_Y, CUR_Z, CUR_E, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
delayed_move_time = 0; delayed_move_time = 0;
active_extruder_parked = false; active_extruder_parked = false;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Clear active_extruder_parked");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Clear active_extruder_parked");
#endif
break; break;
case DXC_SCALED_DUPLICATION_MODE: case DXC_SCALED_DUPLICATION_MODE:
case DXC_DUPLICATION_MODE: case DXC_DUPLICATION_MODE:
if (active_extruder == 0) { if (active_extruder == 0) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Set planner X", inactive_extruder_x_pos, " ... Line to X", current_position[X_AXIS] + duplicate_extruder_x_offset);
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("Set planner X", inactive_extruder_x_pos);
SERIAL_ECHOLNPAIR(" ... Line to X", current_position[X_AXIS] + duplicate_extruder_x_offset);
}
#endif
// move duplicate extruder into correct duplication position. // move duplicate extruder into correct duplication position.
planner.set_position_mm(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); planner.set_position_mm(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
@ -964,15 +940,9 @@ void clean_up_after_endstop_or_probe_move() {
sync_plan_position(); sync_plan_position();
extruder_duplication_enabled = true; extruder_duplication_enabled = true;
active_extruder_parked = false; active_extruder_parked = false;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Set extruder_duplication_enabled\nClear active_extruder_parked");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Set extruder_duplication_enabled\nClear active_extruder_parked");
#endif
}
else {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Active extruder not 0");
#endif
} }
else if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Active extruder not 0");
break; break;
} }
} }
@ -1189,20 +1159,14 @@ float get_homing_bump_feedrate(const AxisEnum axis) {
*/ */
void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm_s=0.0) { void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm_s=0.0) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOPAIR(">>> do_homing_move(", axis_codes[axis], ", ", distance, ", ");
SERIAL_ECHOPAIR(">>> do_homing_move(", axis_codes[axis]); if (fr_mm_s)
SERIAL_ECHOPAIR(", ", distance); DEBUG_ECHO(fr_mm_s);
SERIAL_ECHOPGM(", "); else
if (fr_mm_s) DEBUG_ECHOPAIR("[", homing_feedrate(axis), "]");
SERIAL_ECHO(fr_mm_s); DEBUG_ECHOLNPGM(")");
else { }
SERIAL_ECHOPAIR("[", homing_feedrate(axis));
SERIAL_CHAR(']');
}
SERIAL_ECHOLNPGM(")");
}
#endif
#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
@ -1279,13 +1243,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm
#endif #endif
} }
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< do_homing_move(", axis_codes[axis], ")");
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("<<< do_homing_move(", axis_codes[axis]);
SERIAL_CHAR(')');
SERIAL_EOL();
}
#endif
} }
/** /**
@ -1307,13 +1265,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm
* Callers must sync the planner position after calling this! * Callers must sync the planner position after calling this!
*/ */
void set_axis_is_at_home(const AxisEnum axis) { void set_axis_is_at_home(const AxisEnum axis) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_at_home(", axis_codes[axis], ")");
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR(">>> set_axis_is_at_home(", axis_codes[axis]);
SERIAL_CHAR(')');
SERIAL_EOL();
}
#endif
SBI(axis_known_position, axis); SBI(axis_known_position, axis);
SBI(axis_homed, axis); SBI(axis_homed, axis);
@ -1351,33 +1303,23 @@ void set_axis_is_at_home(const AxisEnum axis) {
current_position[Z_AXIS] -= zprobe_zoffset; current_position[Z_AXIS] -= zprobe_zoffset;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> zprobe_zoffset = ", zprobe_zoffset);
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***");
SERIAL_ECHOLNPAIR("> zprobe_zoffset = ", zprobe_zoffset);
}
#endif
#elif ENABLED(DEBUG_LEVELING_FEATURE) #else
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("*** Z HOMED TO ENDSTOP ***"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("*** Z HOMED TO ENDSTOP ***");
#endif #endif
} }
#endif #endif
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { #if HAS_HOME_OFFSET
#if HAS_HOME_OFFSET DEBUG_ECHOLNPAIR("> home_offset[", axis_codes[axis], "] = ", home_offset[axis]);
SERIAL_ECHOPAIR("> home_offset[", axis_codes[axis]); #endif
SERIAL_ECHOLNPAIR("] = ", home_offset[axis]); DEBUG_POS("", current_position);
#endif DEBUG_ECHOLNPAIR("<<< set_axis_is_at_home(", axis_codes[axis], ")");
DEBUG_POS("", current_position); }
SERIAL_ECHOPAIR("<<< set_axis_is_at_home(", axis_codes[axis]);
SERIAL_CHAR(')');
SERIAL_EOL();
}
#endif
#if ENABLED(I2C_POSITION_ENCODERS) #if ENABLED(I2C_POSITION_ENCODERS)
I2CPEM.homed(axis); I2CPEM.homed(axis);
@ -1388,24 +1330,12 @@ void set_axis_is_at_home(const AxisEnum axis) {
* Set an axis' to be unhomed. * Set an axis' to be unhomed.
*/ */
void set_axis_is_not_at_home(const AxisEnum axis) { void set_axis_is_not_at_home(const AxisEnum axis) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_not_at_home(", axis_codes[axis], ")");
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR(">>> set_axis_is_not_at_home(", axis_codes[axis]);
SERIAL_CHAR(')');
SERIAL_EOL();
}
#endif
CBI(axis_known_position, axis); CBI(axis_known_position, axis);
CBI(axis_homed, axis); CBI(axis_homed, axis);
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_is_not_at_home(", axis_codes[axis], ")");
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("<<< set_axis_is_not_at_home(", axis_codes[axis]);
SERIAL_CHAR(')');
SERIAL_EOL();
}
#endif
#if ENABLED(I2C_POSITION_ENCODERS) #if ENABLED(I2C_POSITION_ENCODERS)
I2CPEM.unhomed(axis); I2CPEM.unhomed(axis);
@ -1434,13 +1364,7 @@ void homeaxis(const AxisEnum axis) {
if (!CAN_HOME(X) && !CAN_HOME(Y) && !CAN_HOME(Z)) return; if (!CAN_HOME(X) && !CAN_HOME(Y) && !CAN_HOME(Z)) return;
#endif #endif
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> homeaxis(", axis_codes[axis], ")");
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR(">>> homeaxis(", axis_codes[axis]);
SERIAL_CHAR(')');
SERIAL_EOL();
}
#endif
const int axis_home_dir = ( const int axis_home_dir = (
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
@ -1472,9 +1396,7 @@ void homeaxis(const AxisEnum axis) {
#endif #endif
// Fast move towards endstop until triggered // Fast move towards endstop until triggered
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home 1 Fast:");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Home 1 Fast:");
#endif
#if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH) #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
// BLTOUCH needs to be deployed every time // BLTOUCH needs to be deployed every time
@ -1506,9 +1428,7 @@ void homeaxis(const AxisEnum axis) {
// If a second homing move is configured... // If a second homing move is configured...
if (bump) { if (bump) {
// Move away from the endstop by the axis HOME_BUMP_MM // Move away from the endstop by the axis HOME_BUMP_MM
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Move Away:");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Move Away:");
#endif
do_homing_move(axis, -bump do_homing_move(axis, -bump
#if HOMING_Z_WITH_PROBE #if HOMING_Z_WITH_PROBE
, axis == Z_AXIS ? MMM_TO_MMS(Z_PROBE_SPEED_FAST) : 0.0 , axis == Z_AXIS ? MMM_TO_MMS(Z_PROBE_SPEED_FAST) : 0.0
@ -1516,9 +1436,7 @@ void homeaxis(const AxisEnum axis) {
); );
// Slow move towards endstop until triggered // Slow move towards endstop until triggered
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home 2 Slow:");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Home 2 Slow:");
#endif
#if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH) #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
// BLTOUCH needs to be deployed every time // BLTOUCH needs to be deployed every time
@ -1644,9 +1562,7 @@ void homeaxis(const AxisEnum axis) {
// retrace by the amount specified in delta_endstop_adj + additional dist in order to have minimum steps // retrace by the amount specified in delta_endstop_adj + additional dist in order to have minimum steps
if (delta_endstop_adj[axis] * Z_HOME_DIR <= 0) { if (delta_endstop_adj[axis] * Z_HOME_DIR <= 0) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("delta_endstop_adj:");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("delta_endstop_adj:");
#endif
do_homing_move(axis, delta_endstop_adj[axis] - (MIN_STEPS_PER_SEGMENT + 1) * planner.steps_to_mm[axis] * Z_HOME_DIR); do_homing_move(axis, delta_endstop_adj[axis] - (MIN_STEPS_PER_SEGMENT + 1) * planner.steps_to_mm[axis] * Z_HOME_DIR);
} }
@ -1657,9 +1573,7 @@ void homeaxis(const AxisEnum axis) {
destination[axis] = current_position[axis]; destination[axis] = current_position[axis];
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("> AFTER set_axis_is_at_home", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("> AFTER set_axis_is_at_home", current_position);
#endif
#endif #endif
@ -1673,25 +1587,14 @@ void homeaxis(const AxisEnum axis) {
if (axis == Z_AXIS) fwretract.current_hop = 0.0; if (axis == Z_AXIS) fwretract.current_hop = 0.0;
#endif #endif
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< homeaxis(", axis_codes[axis], ")");
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("<<< homeaxis(", axis_codes[axis]);
SERIAL_CHAR(')');
SERIAL_EOL();
}
#endif
} // homeaxis() } // homeaxis()
#if HAS_WORKSPACE_OFFSET #if HAS_WORKSPACE_OFFSET
void update_workspace_offset(const AxisEnum axis) { void update_workspace_offset(const AxisEnum axis) {
workspace_offset[axis] = home_offset[axis] + position_shift[axis]; workspace_offset[axis] = home_offset[axis] + position_shift[axis];
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Axis ", axis_codes[axis], " home_offset = ", home_offset[axis], " position_shift = ", position_shift[axis]);
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("For ", axis_codes[axis]);
SERIAL_ECHOPAIR(" axis:\n home_offset = ", home_offset[axis]);
SERIAL_ECHOLNPAIR("\n position_shift = ", position_shift[axis]);
}
#endif
} }
#endif #endif

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

@ -31,6 +31,9 @@
#include "../Marlin.h" #include "../Marlin.h"
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../core/debug_out.h"
#if EXTRUDERS > 1 #if EXTRUDERS > 1
toolchange_settings_t toolchange_settings; // Initialized by settings.load() toolchange_settings_t toolchange_settings; // Initialized by settings.load()
#endif #endif
@ -169,12 +172,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
current_position[X_AXIS] = mpe_settings.parking_xpos[tmp_extruder] + offsetcompensation; current_position[X_AXIS] = mpe_settings.parking_xpos[tmp_extruder] + offsetcompensation;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOPAIR("(1) Move extruder ", int(tmp_extruder));
SERIAL_ECHOPAIR("(1) Move extruder ", int(tmp_extruder)); DEBUG_POS(" to new extruder ParkPos", current_position);
DEBUG_POS(" to new extruder ParkPos", current_position); }
}
#endif
planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder); planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
planner.synchronize(); planner.synchronize();
@ -183,12 +184,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
current_position[X_AXIS] = grabpos + offsetcompensation; current_position[X_AXIS] = grabpos + offsetcompensation;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOPAIR("(2) Couple extruder ", int(tmp_extruder));
SERIAL_ECHOPAIR("(2) Couple extruder ", int(tmp_extruder)); DEBUG_POS(" to new extruder GrabPos", current_position);
DEBUG_POS(" to new extruder GrabPos", current_position); }
}
#endif
planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder); planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
planner.synchronize(); planner.synchronize();
@ -199,12 +198,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
// STEP 3 // STEP 3
current_position[X_AXIS] = mpe_settings.parking_xpos[tmp_extruder] + offsetcompensation; current_position[X_AXIS] = mpe_settings.parking_xpos[tmp_extruder] + offsetcompensation;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOPAIR("(3) Move extruder ", int(tmp_extruder));
SERIAL_ECHOPAIR("(3) Move extruder ", int(tmp_extruder)); DEBUG_POS(" back to new extruder ParkPos", current_position);
DEBUG_POS(" back to new extruder ParkPos", current_position); }
}
#endif
planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder); planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
planner.synchronize(); planner.synchronize();
@ -212,12 +209,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
// STEP 4 // STEP 4
current_position[X_AXIS] = mpe_settings.parking_xpos[active_extruder] + (active_extruder == 0 ? MPE_TRAVEL_DISTANCE : -MPE_TRAVEL_DISTANCE) + offsetcompensation; current_position[X_AXIS] = mpe_settings.parking_xpos[active_extruder] + (active_extruder == 0 ? MPE_TRAVEL_DISTANCE : -MPE_TRAVEL_DISTANCE) + offsetcompensation;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOPAIR("(4) Move extruder ", int(tmp_extruder));
SERIAL_ECHOPAIR("(4) Move extruder ", int(tmp_extruder)); DEBUG_POS(" close to old extruder ParkPos", current_position);
DEBUG_POS(" close to old extruder ParkPos", current_position); }
}
#endif
planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder); planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
planner.synchronize(); planner.synchronize();
@ -226,12 +221,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
current_position[X_AXIS] = mpe_settings.parking_xpos[active_extruder] + offsetcompensation; current_position[X_AXIS] = mpe_settings.parking_xpos[active_extruder] + offsetcompensation;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOPAIR("(5) Park extruder ", int(tmp_extruder));
SERIAL_ECHOPAIR("(5) Park extruder ", int(tmp_extruder)); DEBUG_POS(" at old extruder ParkPos", current_position);
DEBUG_POS(" at old extruder ParkPos", current_position); }
}
#endif
planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder); planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
planner.synchronize(); planner.synchronize();
@ -240,19 +233,15 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
current_position[X_AXIS] = oldx; current_position[X_AXIS] = oldx;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOPAIR("(6) Move extruder ", int(tmp_extruder));
SERIAL_ECHOPAIR("(6) Move extruder ", int(tmp_extruder)); DEBUG_POS(" to starting position", current_position);
DEBUG_POS(" to starting position", current_position); }
}
#endif
planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder); planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
planner.synchronize(); planner.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Autopark done.");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Autopark done.");
#endif
} }
#elif ENABLED(PARKING_EXTRUDER) #elif ENABLED(PARKING_EXTRUDER)
@ -302,15 +291,11 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
// STEP 1 // STEP 1
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("Start Autopark", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("Start Autopark", current_position);
#endif
current_position[Z_AXIS] += toolchange_settings.z_raise; current_position[Z_AXIS] += toolchange_settings.z_raise;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
#endif
fast_line_to_current(Z_AXIS); fast_line_to_current(Z_AXIS);
planner.synchronize(); planner.synchronize();
@ -319,43 +304,33 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
current_position[X_AXIS] = parkingposx[active_extruder] + x_offset; current_position[X_AXIS] = parkingposx[active_extruder] + x_offset;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPAIR("(2) Park extruder ", int(active_extruder));
SERIAL_ECHOLNPAIR("(2) Park extruder ", int(active_extruder)); DEBUG_POS("Moving ParkPos", current_position);
DEBUG_POS("Moving ParkPos", current_position); }
}
#endif
fast_line_to_current(X_AXIS); fast_line_to_current(X_AXIS);
planner.synchronize(); planner.synchronize();
// STEP 3 // STEP 3
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(3) Disengage magnet ");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Disengage magnet ");
#endif
pe_deactivate_solenoid(active_extruder); pe_deactivate_solenoid(active_extruder);
// STEP 4 // STEP 4
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Move to position near new extruder");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Move to position near new extruder");
#endif
current_position[X_AXIS] += active_extruder ? -10 : 10; // move 10mm away from parked extruder current_position[X_AXIS] += active_extruder ? -10 : 10; // move 10mm away from parked extruder
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("Move away from parked extruder", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("Move away from parked extruder", current_position);
#endif
fast_line_to_current(X_AXIS); fast_line_to_current(X_AXIS);
planner.synchronize(); planner.synchronize();
// STEP 5 // STEP 5
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(5) Engage magnetic field");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(5) Engage magnetic field");
#endif
#if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT) #if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
pe_activate_solenoid(active_extruder); //just save power for inverted magnets pe_activate_solenoid(active_extruder); //just save power for inverted magnets
@ -368,9 +343,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
current_position[X_AXIS] = grabpos + (tmp_extruder ? -10 : 10); current_position[X_AXIS] = grabpos + (tmp_extruder ? -10 : 10);
fast_line_to_current(X_AXIS); fast_line_to_current(X_AXIS);
current_position[X_AXIS] = grabpos; current_position[X_AXIS] = grabpos;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("(6) Unpark extruder", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("(6) Unpark extruder", current_position);
#endif
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS] * 0.5, active_extruder); planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS] * 0.5, active_extruder);
planner.synchronize(); planner.synchronize();
@ -382,16 +355,12 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
#endif #endif
; ;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("(7) Move midway between hotends", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("(7) Move midway between hotends", current_position);
#endif
fast_line_to_current(X_AXIS); fast_line_to_current(X_AXIS);
planner.synchronize(); planner.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE) DEBUG_ECHOLNPGM("Autopark done.");
SERIAL_ECHOLNPGM("Autopark done.");
#endif
} }
else { // nomove == true else { // nomove == true
// Only engage magnetic field for new extruder // Only engage magnetic field for new extruder
@ -405,9 +374,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder]; current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
#endif #endif
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("Applying Z-offset", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("Applying Z-offset", current_position);
#endif
} }
#endif // PARKING_EXTRUDER #endif // PARKING_EXTRUDER
@ -433,15 +400,11 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
// 1. Raise Z to give enough clearance // 1. Raise Z to give enough clearance
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("Starting Toolhead change", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("Starting Toolhead change", current_position);
#endif
current_position[Z_AXIS] += toolchange_settings.z_raise; current_position[Z_AXIS] += toolchange_settings.z_raise;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
#endif
fast_line_to_current(Z_AXIS); fast_line_to_current(Z_AXIS);
planner.synchronize(); planner.synchronize();
@ -450,86 +413,66 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
current_position[X_AXIS] = placexpos; current_position[X_AXIS] = placexpos;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPAIR("(2) Place old tool ", int(active_extruder));
SERIAL_ECHOLNPAIR("(2) Place old tool ", int(active_extruder)); DEBUG_POS("Move X SwitchPos", current_position);
DEBUG_POS("Move X SwitchPos", current_position); }
}
#endif
fast_line_to_current(X_AXIS); fast_line_to_current(X_AXIS);
planner.synchronize(); planner.synchronize();
current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY; current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
#endif
fast_line_to_current(Y_AXIS); fast_line_to_current(Y_AXIS);
planner.synchronize(); planner.synchronize();
// 3. Unlock tool and drop it in the dock // 3. Unlock tool and drop it in the dock
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(3) Unlock and Place Toolhead");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Unlock and Place Toolhead");
#endif
MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]); MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]);
safe_delay(500); safe_delay(500);
current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS; current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
#endif
planner.buffer_line(current_position,(planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5), active_extruder); planner.buffer_line(current_position,(planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5), active_extruder);
planner.synchronize(); planner.synchronize();
safe_delay(200); safe_delay(200);
current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR; current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
#endif
fast_line_to_current(Y_AXIS); // move away from docked toolhead fast_line_to_current(Y_AXIS); // move away from docked toolhead
planner.synchronize(); planner.synchronize();
// 4. Move to the new toolhead // 4. Move to the new toolhead
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Move to new toolhead position");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Move to new toolhead position");
#endif
current_position[X_AXIS] = grabxpos; current_position[X_AXIS] = grabxpos;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
#endif
fast_line_to_current(X_AXIS); fast_line_to_current(X_AXIS);
planner.synchronize(); planner.synchronize();
current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY; current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
#endif
fast_line_to_current(Y_AXIS); fast_line_to_current(Y_AXIS);
planner.synchronize(); planner.synchronize();
// 5. Grab and lock the new toolhead // 5. Grab and lock the new toolhead
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(5) Grab and lock new toolhead ");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(5) Grab and lock new toolhead ");
#endif
current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS; current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
#endif
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5, active_extruder); planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5, active_extruder);
planner.synchronize(); planner.synchronize();
@ -540,16 +483,12 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR; current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
#endif
fast_line_to_current(Y_AXIS); // move away from docked toolhead fast_line_to_current(Y_AXIS); // move away from docked toolhead
planner.synchronize(); planner.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Toolhead change done.");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Toolhead change done.");
#endif
} }
#endif // SWITCHING_TOOLHEAD #endif // SWITCHING_TOOLHEAD
@ -563,17 +502,15 @@ inline void invalid_extruder_error(const uint8_t e) {
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
inline void dualx_tool_change(const uint8_t tmp_extruder, bool &no_move) { inline void dualx_tool_change(const uint8_t tmp_extruder, bool &no_move) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM("Dual X Carriage Mode ");
SERIAL_ECHOPGM("Dual X Carriage Mode "); switch (dual_x_carriage_mode) {
switch (dual_x_carriage_mode) { case DXC_FULL_CONTROL_MODE: DEBUG_ECHOLNPGM("DXC_FULL_CONTROL_MODE"); break;
case DXC_FULL_CONTROL_MODE: SERIAL_ECHOLNPGM("DXC_FULL_CONTROL_MODE"); break; case DXC_AUTO_PARK_MODE: DEBUG_ECHOLNPGM("DXC_AUTO_PARK_MODE"); break;
case DXC_AUTO_PARK_MODE: SERIAL_ECHOLNPGM("DXC_AUTO_PARK_MODE"); break; case DXC_DUPLICATION_MODE: DEBUG_ECHOLNPGM("DXC_DUPLICATION_MODE"); break;
case DXC_DUPLICATION_MODE: SERIAL_ECHOLNPGM("DXC_DUPLICATION_MODE"); break; case DXC_SCALED_DUPLICATION_MODE: DEBUG_ECHOLNPGM("DXC_SCALED_DUPLICATION_MODE"); break;
case DXC_SCALED_DUPLICATION_MODE: SERIAL_ECHOLNPGM("DXC_SCALED_DUPLICATION_MODE"); break;
}
} }
#endif }
const float xhome = x_home_pos(active_extruder); const float xhome = x_home_pos(active_extruder);
if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE
@ -581,9 +518,8 @@ inline void invalid_extruder_error(const uint8_t e) {
&& (delayed_move_time || current_position[X_AXIS] != xhome) && ! no_move && (delayed_move_time || current_position[X_AXIS] != xhome) && ! no_move
) { ) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("MoveX to ", xhome);
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("MoveX to ", xhome);
#endif
// Park old head // Park old head
planner.buffer_line(xhome, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder); planner.buffer_line(xhome, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
planner.synchronize(); planner.synchronize();
@ -599,9 +535,7 @@ inline void invalid_extruder_error(const uint8_t e) {
// This function resets the max/min values - the current position may be overwritten below. // This function resets the max/min values - the current position may be overwritten below.
set_axis_is_at_home(X_AXIS); set_axis_is_at_home(X_AXIS);
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("New Extruder", current_position);
if (DEBUGGING(LEVELING)) DEBUG_POS("New Extruder", current_position);
#endif
switch (dual_x_carriage_mode) { switch (dual_x_carriage_mode) {
case DXC_FULL_CONTROL_MODE: case DXC_FULL_CONTROL_MODE:
@ -620,12 +554,10 @@ inline void invalid_extruder_error(const uint8_t e) {
break; break;
} }
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPAIR("Active extruder parked: ", active_extruder_parked ? "yes" : "no");
SERIAL_ECHOLNPAIR("Active extruder parked: ", active_extruder_parked ? "yes" : "no"); DEBUG_POS("New extruder (parked)", current_position);
DEBUG_POS("New extruder (parked)", current_position); }
}
#endif
} }
#endif // DUAL_X_CARRIAGE #endif // DUAL_X_CARRIAGE
@ -680,9 +612,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
if (!no_move && !all_axes_homed()) { if (!no_move && !all_axes_homed()) {
no_move = true; no_move = true;
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("No move on toolchange");
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("No move on toolchange");
#endif
} }
#if HAS_LCD_MENU #if HAS_LCD_MENU
@ -777,10 +707,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
move_nozzle_servo(tmp_extruder); move_nozzle_servo(tmp_extruder);
#endif #endif
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Offset Tool XY by { ", xdiff, ", ", ydiff, ", ", zdiff, " }");
if (DEBUGGING(LEVELING))
SERIAL_ECHOLNPAIR("Offset Tool XY by { ", xdiff, ", ", ydiff, ", ", zdiff, " }");
#endif
// The newly-selected extruder XY is actually at... // The newly-selected extruder XY is actually at...
current_position[X_AXIS] += xdiff; current_position[X_AXIS] += xdiff;
@ -802,9 +729,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
// Return to position and lower again // Return to position and lower again
if (safe_to_move && !no_move && IsRunning()) { if (safe_to_move && !no_move && IsRunning()) {
#if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("Move back", destination);
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back", destination);
#endif
#if ENABLED(SINGLENOZZLE) #if ENABLED(SINGLENOZZLE)
#if FAN_COUNT > 0 #if FAN_COUNT > 0

Loading…
Cancel
Save