diff --git a/Marlin/G26_Mesh_Validation_Tool.cpp b/Marlin/G26_Mesh_Validation_Tool.cpp index 7e1f73960..e8ca670f0 100644 --- a/Marlin/G26_Mesh_Validation_Tool.cpp +++ b/Marlin/G26_Mesh_Validation_Tool.cpp @@ -137,7 +137,6 @@ #if ENABLED(ULTRA_LCD) extern char lcd_status_message[]; #endif - extern float destination[XYZE]; void set_destination_from_current(); void prepare_move_to_destination(); inline void sync_plan_position_e() { planner.set_e_position_mm(current_position[E_AXIS]); } diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 7c0abe69d..eb10f08c3 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -223,7 +223,7 @@ extern volatile bool wait_for_heatup; extern volatile bool wait_for_user; #endif -extern float current_position[NUM_AXIS]; +extern float current_position[XYZE], destination[XYZE]; // Workspace offsets #if HAS_WORKSPACE_OFFSET diff --git a/Marlin/ubl.cpp b/Marlin/ubl.cpp index bbf51b7e2..11a2a2223 100644 --- a/Marlin/ubl.cpp +++ b/Marlin/ubl.cpp @@ -51,6 +51,59 @@ safe_delay(10); } + #if ENABLED(UBL_DEVEL_DEBUGGING) + + static void debug_echo_axis(const AxisEnum axis) { + if (current_position[axis] == destination[axis]) + SERIAL_ECHOPGM("-------------"); + else + SERIAL_ECHO_F(destination[X_AXIS], 6); + } + + void debug_current_and_destination(const char *title) { + + // if the title message starts with a '!' it is so important, we are going to + // ignore the status of the g26_debug_flag + if (*title != '!' && !g26_debug_flag) return; + + const float de = destination[E_AXIS] - current_position[E_AXIS]; + + if (de == 0.0) return; // Printing moves only + + const float dx = destination[X_AXIS] - current_position[X_AXIS], + dy = destination[Y_AXIS] - current_position[Y_AXIS], + xy_dist = HYPOT(dx, dy); + + if (xy_dist == 0.0) return; + + SERIAL_ECHOPGM(" fpmm="); + const float fpmm = de / xy_dist; + SERIAL_ECHO_F(fpmm, 6); + + SERIAL_ECHOPGM(" current=( "); + SERIAL_ECHO_F(current_position[X_AXIS], 6); + SERIAL_ECHOPGM(", "); + SERIAL_ECHO_F(current_position[Y_AXIS], 6); + SERIAL_ECHOPGM(", "); + SERIAL_ECHO_F(current_position[Z_AXIS], 6); + SERIAL_ECHOPGM(", "); + SERIAL_ECHO_F(current_position[E_AXIS], 6); + SERIAL_ECHOPGM(" ) destination=( "); + debug_echo_axis(X_AXIS); + SERIAL_ECHOPGM(", "); + debug_echo_axis(Y_AXIS); + SERIAL_ECHOPGM(", "); + debug_echo_axis(Z_AXIS); + SERIAL_ECHOPGM(", "); + debug_echo_axis(E_AXIS); + SERIAL_ECHOPGM(" ) "); + SERIAL_ECHO(title); + SERIAL_EOL(); + + } + + #endif // UBL_DEVEL_DEBUGGING + int8_t unified_bed_leveling::storage_slot; float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; @@ -174,7 +227,7 @@ uint8_t error_flag = 0; if (settings.calc_num_meshes() < 1) { - SERIAL_PROTOCOLLNPGM("?Insufficient EEPROM storage for a mesh of this size."); + SERIAL_PROTOCOLLNPGM("?Mesh too big for EEPROM."); error_flag++; } diff --git a/Marlin/ubl.h b/Marlin/ubl.h index 05a22392c..f7c0951ea 100644 --- a/Marlin/ubl.h +++ b/Marlin/ubl.h @@ -26,6 +26,9 @@ #include "MarlinConfig.h" #if ENABLED(AUTO_BED_LEVELING_UBL) + + //#define UBL_DEVEL_DEBUGGING + #include "Marlin.h" #include "planner.h" #include "math.h" @@ -41,7 +44,11 @@ // ubl_motion.cpp - void debug_current_and_destination(const char * const title); + #if ENABLED(UBL_DEVEL_DEBUGGING) + void debug_current_and_destination(const char * const title); + #else + FORCE_INLINE void debug_current_and_destination(const char * const title) { UNUSED(title); } + #endif // ubl_G29.cpp diff --git a/Marlin/ubl_G29.cpp b/Marlin/ubl_G29.cpp index 8800c6e9a..6b56ffafc 100644 --- a/Marlin/ubl_G29.cpp +++ b/Marlin/ubl_G29.cpp @@ -24,8 +24,6 @@ #if ENABLED(AUTO_BED_LEVELING_UBL) - //#define UBL_DEVEL_DEBUGGING - #include "ubl.h" #include "Marlin.h" #include "hex_print_routines.h" @@ -1165,12 +1163,12 @@ static uint8_t ubl_state_at_invocation = 0; - #ifdef UBL_DEVEL_DEBUGGING + #if ENABLED(UBL_DEVEL_DEBUGGING) static uint8_t ubl_state_recursion_chk = 0; #endif void unified_bed_leveling::save_ubl_active_state_and_disable() { - #ifdef UBL_DEVEL_DEBUGGING + #if ENABLED(UBL_DEVEL_DEBUGGING) ubl_state_recursion_chk++; if (ubl_state_recursion_chk != 1) { SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row."); @@ -1186,7 +1184,7 @@ } void unified_bed_leveling::restore_ubl_active_state_and_leave() { - #ifdef UBL_DEVEL_DEBUGGING + #if ENABLED(UBL_DEVEL_DEBUGGING) if (--ubl_state_recursion_chk) { SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times."); #if ENABLED(NEWPANEL) @@ -1267,7 +1265,7 @@ SERIAL_EOL(); safe_delay(50); - #ifdef UBL_DEVEL_DEBUGGING + #if ENABLED(UBL_DEVEL_DEBUGGING) SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation); SERIAL_EOL(); SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk); diff --git a/Marlin/ubl_motion.cpp b/Marlin/ubl_motion.cpp index 3b0c9dc79..ec731d1fd 100644 --- a/Marlin/ubl_motion.cpp +++ b/Marlin/ubl_motion.cpp @@ -30,63 +30,12 @@ #include #include - extern float destination[XYZE]; - #if AVR_AT90USB1286_FAMILY // Teensyduino & Printrboard IDE extensions have compile errors without this inline void set_current_from_destination() { COPY(current_position, destination); } #else extern void set_current_from_destination(); #endif - static void debug_echo_axis(const AxisEnum axis) { - if (current_position[axis] == destination[axis]) - SERIAL_ECHOPGM("-------------"); - else - SERIAL_ECHO_F(destination[X_AXIS], 6); - } - - void debug_current_and_destination(const char *title) { - - // if the title message starts with a '!' it is so important, we are going to - // ignore the status of the g26_debug_flag - if (*title != '!' && !g26_debug_flag) return; - - const float de = destination[E_AXIS] - current_position[E_AXIS]; - - if (de == 0.0) return; // Printing moves only - - const float dx = destination[X_AXIS] - current_position[X_AXIS], - dy = destination[Y_AXIS] - current_position[Y_AXIS], - xy_dist = HYPOT(dx, dy); - - if (xy_dist == 0.0) return; - - SERIAL_ECHOPGM(" fpmm="); - const float fpmm = de / xy_dist; - SERIAL_ECHO_F(fpmm, 6); - - SERIAL_ECHOPGM(" current=( "); - SERIAL_ECHO_F(current_position[X_AXIS], 6); - SERIAL_ECHOPGM(", "); - SERIAL_ECHO_F(current_position[Y_AXIS], 6); - SERIAL_ECHOPGM(", "); - SERIAL_ECHO_F(current_position[Z_AXIS], 6); - SERIAL_ECHOPGM(", "); - SERIAL_ECHO_F(current_position[E_AXIS], 6); - SERIAL_ECHOPGM(" ) destination=( "); - debug_echo_axis(X_AXIS); - SERIAL_ECHOPGM(", "); - debug_echo_axis(Y_AXIS); - SERIAL_ECHOPGM(", "); - debug_echo_axis(Z_AXIS); - SERIAL_ECHOPGM(", "); - debug_echo_axis(E_AXIS); - SERIAL_ECHOPGM(" ) "); - SERIAL_ECHO(title); - SERIAL_EOL(); - - } - void unified_bed_leveling::line_to_destination_cartesian(const float &feed_rate, uint8_t extruder) { /** * Much of the nozzle movement will be within the same cell. So we will do as little computation diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index a20a7b37f..6205ed130 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -2755,7 +2755,6 @@ void kill_screen(const char* lcd_msg) { #if IS_KINEMATIC extern float feedrate_mm_s; - extern float destination[XYZE]; void set_destination_from_current(); void prepare_move_to_destination(); #endif