Unify debugging output with debug_out.h (#13388)

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

View File

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

View File

@ -46,6 +46,9 @@
#include "stepper_indirection.h"
#endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../core/debug_out.h"
// Initialized by settings.load()
float delta_height,
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.
*/
void home_delta() {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position);
// Init the current position of all carriages to 0,0,0
ZERO(current_position);
ZERO(destination);
@ -264,9 +265,7 @@ void home_delta() {
sync_plan_position();
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< home_delta", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< home_delta", current_position);
}
#endif // DELTA

View File

@ -59,6 +59,9 @@
#include "../feature/fwretract.h"
#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 }
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.
*/
void sync_plan_position() {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("sync_plan_position", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("sync_plan_position", current_position);
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
*/
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);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_uninterpolated_move_to_destination", destination);
#if UBL_SEGMENTED
// 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
*/
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)) print_xyz(PSTR(">>> do_blocking_move_to"), NULL, rx, ry, rz);
#endif
if (DEBUGGING(LEVELING)) DEBUG_XYZ(">>> do_blocking_move_to", rx, ry, rz);
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;
@ -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
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("set_destination_from_current", destination);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("set_destination_from_current", destination);
// when in the danger zone
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[Z_AXIS] = rz;
prepare_uninterpolated_move_to_destination(); // set_current_from_destination()
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("danger zone move", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("danger zone move", current_position);
return;
}
destination[Z_AXIS] = delta_clip_start_height;
prepare_uninterpolated_move_to_destination(); // set_current_from_destination()
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("zone border move", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("zone border move", current_position);
}
if (rz > current_position[Z_AXIS]) { // raising?
destination[Z_AXIS] = rz;
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);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("z raise move", current_position);
}
destination[X_AXIS] = rx;
destination[Y_AXIS] = ry;
prepare_move_to_destination(); // set_current_from_destination()
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("xy move", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("xy move", current_position);
if (rz < current_position[Z_AXIS]) { // lowering?
destination[Z_AXIS] = rz;
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);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("z lower move", current_position);
}
#elif IS_SCARA
@ -423,9 +408,7 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< do_blocking_move_to");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< do_blocking_move_to");
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);
delayed_move_time = 0;
active_extruder_parked = false;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Clear active_extruder_parked");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Clear active_extruder_parked");
break;
case DXC_SCALED_DUPLICATION_MODE:
case DXC_DUPLICATION_MODE:
if (active_extruder == 0) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
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
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Set planner X", inactive_extruder_x_pos, " ... Line to X", current_position[X_AXIS] + duplicate_extruder_x_offset);
// 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]);
@ -964,15 +940,9 @@ void clean_up_after_endstop_or_probe_move() {
sync_plan_position();
extruder_duplication_enabled = true;
active_extruder_parked = false;
#if ENABLED(DEBUG_LEVELING_FEATURE)
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
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Set extruder_duplication_enabled\nClear active_extruder_parked");
}
else if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Active extruder not 0");
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) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR(">>> do_homing_move(", axis_codes[axis]);
SERIAL_ECHOPAIR(", ", distance);
SERIAL_ECHOPGM(", ");
if (fr_mm_s)
SERIAL_ECHO(fr_mm_s);
else {
SERIAL_ECHOPAIR("[", homing_feedrate(axis));
SERIAL_CHAR(']');
}
SERIAL_ECHOLNPGM(")");
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOPAIR(">>> do_homing_move(", axis_codes[axis], ", ", distance, ", ");
if (fr_mm_s)
DEBUG_ECHO(fr_mm_s);
else
DEBUG_ECHOPAIR("[", homing_feedrate(axis), "]");
DEBUG_ECHOLNPGM(")");
}
#if HOMING_Z_WITH_PROBE && HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
// 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
}
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("<<< do_homing_move(", axis_codes[axis]);
SERIAL_CHAR(')');
SERIAL_EOL();
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< do_homing_move(", axis_codes[axis], ")");
}
/**
@ -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!
*/
void set_axis_is_at_home(const AxisEnum axis) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR(">>> set_axis_is_at_home(", axis_codes[axis]);
SERIAL_CHAR(')');
SERIAL_EOL();
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_at_home(", axis_codes[axis], ")");
SBI(axis_known_position, axis);
SBI(axis_homed, axis);
@ -1351,33 +1303,23 @@ void set_axis_is_at_home(const AxisEnum axis) {
current_position[Z_AXIS] -= zprobe_zoffset;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***");
SERIAL_ECHOLNPAIR("> zprobe_zoffset = ", zprobe_zoffset);
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> zprobe_zoffset = ", zprobe_zoffset);
#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
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
#if HAS_HOME_OFFSET
SERIAL_ECHOPAIR("> home_offset[", axis_codes[axis]);
SERIAL_ECHOLNPAIR("] = ", home_offset[axis]);
#endif
DEBUG_POS("", current_position);
SERIAL_ECHOPAIR("<<< set_axis_is_at_home(", axis_codes[axis]);
SERIAL_CHAR(')');
SERIAL_EOL();
}
#endif
if (DEBUGGING(LEVELING)) {
#if HAS_HOME_OFFSET
DEBUG_ECHOLNPAIR("> home_offset[", axis_codes[axis], "] = ", home_offset[axis]);
#endif
DEBUG_POS("", current_position);
DEBUG_ECHOLNPAIR("<<< set_axis_is_at_home(", axis_codes[axis], ")");
}
#if ENABLED(I2C_POSITION_ENCODERS)
I2CPEM.homed(axis);
@ -1388,24 +1330,12 @@ void set_axis_is_at_home(const AxisEnum axis) {
* Set an axis' to be unhomed.
*/
void set_axis_is_not_at_home(const AxisEnum axis) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR(">>> set_axis_is_not_at_home(", axis_codes[axis]);
SERIAL_CHAR(')');
SERIAL_EOL();
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_not_at_home(", axis_codes[axis], ")");
CBI(axis_known_position, axis);
CBI(axis_homed, axis);
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("<<< set_axis_is_not_at_home(", axis_codes[axis]);
SERIAL_CHAR(')');
SERIAL_EOL();
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_is_not_at_home(", axis_codes[axis], ")");
#if ENABLED(I2C_POSITION_ENCODERS)
I2CPEM.unhomed(axis);
@ -1434,13 +1364,7 @@ void homeaxis(const AxisEnum axis) {
if (!CAN_HOME(X) && !CAN_HOME(Y) && !CAN_HOME(Z)) return;
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR(">>> homeaxis(", axis_codes[axis]);
SERIAL_CHAR(')');
SERIAL_EOL();
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> homeaxis(", axis_codes[axis], ")");
const int axis_home_dir = (
#if ENABLED(DUAL_X_CARRIAGE)
@ -1472,9 +1396,7 @@ void homeaxis(const AxisEnum axis) {
#endif
// Fast move towards endstop until triggered
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Home 1 Fast:");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home 1 Fast:");
#if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
// BLTOUCH needs to be deployed every time
@ -1506,9 +1428,7 @@ void homeaxis(const AxisEnum axis) {
// If a second homing move is configured...
if (bump) {
// Move away from the endstop by the axis HOME_BUMP_MM
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Move Away:");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Move Away:");
do_homing_move(axis, -bump
#if HOMING_Z_WITH_PROBE
, 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
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Home 2 Slow:");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home 2 Slow:");
#if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
// 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
if (delta_endstop_adj[axis] * Z_HOME_DIR <= 0) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("delta_endstop_adj:");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("delta_endstop_adj:");
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];
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("> AFTER set_axis_is_at_home", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("> AFTER set_axis_is_at_home", current_position);
#endif
@ -1673,25 +1587,14 @@ void homeaxis(const AxisEnum axis) {
if (axis == Z_AXIS) fwretract.current_hop = 0.0;
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("<<< homeaxis(", axis_codes[axis]);
SERIAL_CHAR(')');
SERIAL_EOL();
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< homeaxis(", axis_codes[axis], ")");
} // homeaxis()
#if HAS_WORKSPACE_OFFSET
void update_workspace_offset(const AxisEnum axis) {
workspace_offset[axis] = home_offset[axis] + position_shift[axis];
#if ENABLED(DEBUG_LEVELING_FEATURE)
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
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Axis ", axis_codes[axis], " home_offset = ", home_offset[axis], " position_shift = ", position_shift[axis]);
}
#endif

View File

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

View File

@ -31,6 +31,9 @@
#include "../Marlin.h"
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../core/debug_out.h"
#if EXTRUDERS > 1
toolchange_settings_t toolchange_settings; // Initialized by settings.load()
#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;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("(1) Move extruder ", int(tmp_extruder));
DEBUG_POS(" to new extruder ParkPos", current_position);
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOPAIR("(1) Move extruder ", int(tmp_extruder));
DEBUG_POS(" to new extruder ParkPos", current_position);
}
planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
planner.synchronize();
@ -183,12 +184,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
current_position[X_AXIS] = grabpos + offsetcompensation;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("(2) Couple extruder ", int(tmp_extruder));
DEBUG_POS(" to new extruder GrabPos", current_position);
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOPAIR("(2) Couple extruder ", int(tmp_extruder));
DEBUG_POS(" to new extruder GrabPos", current_position);
}
planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
planner.synchronize();
@ -199,12 +198,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
// STEP 3
current_position[X_AXIS] = mpe_settings.parking_xpos[tmp_extruder] + offsetcompensation;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("(3) Move extruder ", int(tmp_extruder));
DEBUG_POS(" back to new extruder ParkPos", current_position);
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOPAIR("(3) Move extruder ", int(tmp_extruder));
DEBUG_POS(" back to new extruder ParkPos", current_position);
}
planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
planner.synchronize();
@ -212,12 +209,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
// STEP 4
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)) {
SERIAL_ECHOPAIR("(4) Move extruder ", int(tmp_extruder));
DEBUG_POS(" close to old extruder ParkPos", current_position);
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOPAIR("(4) Move extruder ", int(tmp_extruder));
DEBUG_POS(" close to old extruder ParkPos", current_position);
}
planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
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;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("(5) Park extruder ", int(tmp_extruder));
DEBUG_POS(" at old extruder ParkPos", current_position);
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOPAIR("(5) Park extruder ", int(tmp_extruder));
DEBUG_POS(" at old extruder ParkPos", current_position);
}
planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
planner.synchronize();
@ -240,19 +233,15 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
current_position[X_AXIS] = oldx;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("(6) Move extruder ", int(tmp_extruder));
DEBUG_POS(" to starting position", current_position);
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOPAIR("(6) Move extruder ", int(tmp_extruder));
DEBUG_POS(" to starting position", current_position);
}
planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
planner.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Autopark done.");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Autopark done.");
}
#elif ENABLED(PARKING_EXTRUDER)
@ -302,15 +291,11 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
// STEP 1
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("Start Autopark", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("Start Autopark", current_position);
current_position[Z_AXIS] += toolchange_settings.z_raise;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
fast_line_to_current(Z_AXIS);
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;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPAIR("(2) Park extruder ", int(active_extruder));
DEBUG_POS("Moving ParkPos", current_position);
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPAIR("(2) Park extruder ", int(active_extruder));
DEBUG_POS("Moving ParkPos", current_position);
}
fast_line_to_current(X_AXIS);
planner.synchronize();
// STEP 3
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Disengage magnet ");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(3) Disengage magnet ");
pe_deactivate_solenoid(active_extruder);
// STEP 4
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Move to position near new extruder");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Move to position near new 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);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("Move away from parked extruder", current_position);
fast_line_to_current(X_AXIS);
planner.synchronize();
// STEP 5
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(5) Engage magnetic field");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(5) Engage magnetic field");
#if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
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);
fast_line_to_current(X_AXIS);
current_position[X_AXIS] = grabpos;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("(6) Unpark extruder", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("(6) Unpark extruder", current_position);
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS] * 0.5, active_extruder);
planner.synchronize();
@ -382,16 +355,12 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
#endif
;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("(7) Move midway between hotends", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("(7) Move midway between hotends", current_position);
fast_line_to_current(X_AXIS);
planner.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE)
SERIAL_ECHOLNPGM("Autopark done.");
#endif
DEBUG_ECHOLNPGM("Autopark done.");
}
else { // nomove == true
// 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];
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("Applying Z-offset", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("Applying Z-offset", current_position);
}
#endif // PARKING_EXTRUDER
@ -433,15 +400,11 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
// 1. Raise Z to give enough clearance
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("Starting Toolhead change", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("Starting Toolhead change", current_position);
current_position[Z_AXIS] += toolchange_settings.z_raise;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
fast_line_to_current(Z_AXIS);
planner.synchronize();
@ -450,86 +413,66 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
current_position[X_AXIS] = placexpos;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPAIR("(2) Place old tool ", int(active_extruder));
DEBUG_POS("Move X SwitchPos", current_position);
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPAIR("(2) Place old tool ", int(active_extruder));
DEBUG_POS("Move X SwitchPos", current_position);
}
fast_line_to_current(X_AXIS);
planner.synchronize();
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);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
fast_line_to_current(Y_AXIS);
planner.synchronize();
// 3. Unlock tool and drop it in the dock
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Unlock and Place Toolhead");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(3) Unlock and Place Toolhead");
MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]);
safe_delay(500);
current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
planner.buffer_line(current_position,(planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5), active_extruder);
planner.synchronize();
safe_delay(200);
current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
fast_line_to_current(Y_AXIS); // move away from docked toolhead
planner.synchronize();
// 4. Move to the new toolhead
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Move to new toolhead position");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Move to new toolhead position");
current_position[X_AXIS] = grabxpos;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
fast_line_to_current(X_AXIS);
planner.synchronize();
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);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
fast_line_to_current(Y_AXIS);
planner.synchronize();
// 5. Grab and lock the new toolhead
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(5) Grab and lock new toolhead ");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(5) Grab and lock new toolhead ");
current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5, active_extruder);
planner.synchronize();
@ -540,16 +483,12 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
fast_line_to_current(Y_AXIS); // move away from docked toolhead
planner.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Toolhead change done.");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Toolhead change done.");
}
#endif // SWITCHING_TOOLHEAD
@ -563,17 +502,15 @@ inline void invalid_extruder_error(const uint8_t e) {
#if ENABLED(DUAL_X_CARRIAGE)
inline void dualx_tool_change(const uint8_t tmp_extruder, bool &no_move) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPGM("Dual X Carriage Mode ");
switch (dual_x_carriage_mode) {
case DXC_FULL_CONTROL_MODE: SERIAL_ECHOLNPGM("DXC_FULL_CONTROL_MODE"); break;
case DXC_AUTO_PARK_MODE: SERIAL_ECHOLNPGM("DXC_AUTO_PARK_MODE"); break;
case DXC_DUPLICATION_MODE: SERIAL_ECHOLNPGM("DXC_DUPLICATION_MODE"); break;
case DXC_SCALED_DUPLICATION_MODE: SERIAL_ECHOLNPGM("DXC_SCALED_DUPLICATION_MODE"); break;
}
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOPGM("Dual X Carriage Mode ");
switch (dual_x_carriage_mode) {
case DXC_FULL_CONTROL_MODE: DEBUG_ECHOLNPGM("DXC_FULL_CONTROL_MODE"); break;
case DXC_AUTO_PARK_MODE: DEBUG_ECHOLNPGM("DXC_AUTO_PARK_MODE"); break;
case DXC_DUPLICATION_MODE: DEBUG_ECHOLNPGM("DXC_DUPLICATION_MODE"); break;
case DXC_SCALED_DUPLICATION_MODE: DEBUG_ECHOLNPGM("DXC_SCALED_DUPLICATION_MODE"); break;
}
#endif
}
const float xhome = x_home_pos(active_extruder);
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
) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("MoveX to ", xhome);
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("MoveX to ", xhome);
// 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.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.
set_axis_is_at_home(X_AXIS);
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("New Extruder", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("New Extruder", current_position);
switch (dual_x_carriage_mode) {
case DXC_FULL_CONTROL_MODE:
@ -620,12 +554,10 @@ inline void invalid_extruder_error(const uint8_t e) {
break;
}
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPAIR("Active extruder parked: ", active_extruder_parked ? "yes" : "no");
DEBUG_POS("New extruder (parked)", current_position);
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPAIR("Active extruder parked: ", active_extruder_parked ? "yes" : "no");
DEBUG_POS("New extruder (parked)", current_position);
}
}
#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()) {
no_move = true;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("No move on toolchange");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("No move on toolchange");
}
#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);
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING))
SERIAL_ECHOLNPAIR("Offset Tool XY by { ", xdiff, ", ", ydiff, ", ", zdiff, " }");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Offset Tool XY by { ", xdiff, ", ", ydiff, ", ", zdiff, " }");
// The newly-selected extruder XY is actually at...
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
if (safe_to_move && !no_move && IsRunning()) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back", destination);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("Move back", destination);
#if ENABLED(SINGLENOZZLE)
#if FAN_COUNT > 0