diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index b652b0ff38..ffe9cdc868 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -349,8 +349,6 @@ bool Running = true; -uint8_t marlin_debug_flags = DEBUG_NONE; - /** * Cartesian Current Position * Used to track the logical position as moves are queued. @@ -732,31 +730,6 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s=0.0, bool no_mo void report_current_position(); void report_current_position_detail(); -#if ENABLED(DEBUG_LEVELING_FEATURE) - void print_xyz(const char* prefix, const char* suffix, const float x, const float y, const float z) { - serialprintPGM(prefix); - SERIAL_CHAR('('); - SERIAL_ECHO(x); - SERIAL_ECHOPAIR(", ", y); - SERIAL_ECHOPAIR(", ", z); - SERIAL_CHAR(')'); - if (suffix) serialprintPGM(suffix); else SERIAL_EOL(); - } - - void print_xyz(const char* prefix, const char* suffix, const float xyz[]) { - print_xyz(prefix, suffix, xyz[X_AXIS], xyz[Y_AXIS], xyz[Z_AXIS]); - } - - #if HAS_ABL - void print_xyz(const char* prefix, const char* suffix, const vector_3 &xyz) { - print_xyz(prefix, suffix, xyz.x, xyz.y, xyz.z); - } - #endif - - #define DEBUG_POS(SUFFIX,VAR) do { \ - print_xyz(PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); }while(0) -#endif - /** * sync_plan_position * diff --git a/Marlin/src/Marlin.h b/Marlin/src/Marlin.h index 4292ccddb4..590450ea1b 100644 --- a/Marlin/src/Marlin.h +++ b/Marlin/src/Marlin.h @@ -184,9 +184,6 @@ void quickstop_stepper(); void handle_filament_runout(); #endif -extern uint8_t marlin_debug_flags; -#define DEBUGGING(F) (marlin_debug_flags & (DEBUG_## F)) - extern bool Running; inline bool IsRunning() { return Running; } inline bool IsStopped() { return !Running; } diff --git a/Marlin/src/core/enum.h b/Marlin/src/core/enum.h index c02e597f8b..9bee5db459 100644 --- a/Marlin/src/core/enum.h +++ b/Marlin/src/core/enum.h @@ -69,22 +69,6 @@ typedef enum { TEMPUNIT_F } TempUnit; -/** - * Debug flags - * Not yet widely applied - */ -enum DebugFlags { - DEBUG_NONE = 0, - DEBUG_ECHO = _BV(0), ///< Echo commands in order as they are processed - DEBUG_INFO = _BV(1), ///< Print messages for code that has debug output - DEBUG_ERRORS = _BV(2), ///< Not implemented - DEBUG_DRYRUN = _BV(3), ///< Ignore temperature setting and E movement commands - DEBUG_COMMUNICATION = _BV(4), ///< Not implemented - DEBUG_LEVELING = _BV(5), ///< Print detailed output for homing and leveling - DEBUG_MESH_ADJUST = _BV(6), ///< UBL bed leveling - DEBUG_ALL = 0xFF -}; - enum EndstopEnum { X_MIN, Y_MIN, diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 15528c4506..b46f398d71 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -22,6 +22,8 @@ #include "serial.h" +uint8_t marlin_debug_flags = DEBUG_NONE; + const char errormagic[] PROGMEM = "Error:"; const char echomagic[] PROGMEM = "echo:"; @@ -43,3 +45,27 @@ void serial_echopair_P(const char* s_P, double v) { serialprintPGM(s_P); void serial_echopair_P(const char* s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) MYSERIAL.write(' '); } + +#if ENABLED(DEBUG_LEVELING_FEATURE) + + void print_xyz(const char* prefix, const char* suffix, const float x, const float y, const float z) { + serialprintPGM(prefix); + SERIAL_CHAR('('); + SERIAL_ECHO(x); + SERIAL_ECHOPAIR(", ", y); + SERIAL_ECHOPAIR(", ", z); + SERIAL_CHAR(')'); + if (suffix) serialprintPGM(suffix); else SERIAL_EOL(); + } + + void print_xyz(const char* prefix, const char* suffix, const float xyz[]) { + print_xyz(prefix, suffix, xyz[X_AXIS], xyz[Y_AXIS], xyz[Z_AXIS]); + } + + #if HAS_ABL + void print_xyz(const char* prefix, const char* suffix, const vector_3 &xyz) { + print_xyz(prefix, suffix, xyz.x, xyz.y, xyz.z); + } + #endif + +#endif diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index e860c9c05f..81c35a75e1 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -41,6 +41,26 @@ #endif #endif +#include "../libs/vector_3.h" + +/** + * Define debug bit-masks + */ +enum DebugFlags { + DEBUG_NONE = 0, + DEBUG_ECHO = _BV(0), ///< Echo commands in order as they are processed + DEBUG_INFO = _BV(1), ///< Print messages for code that has debug output + DEBUG_ERRORS = _BV(2), ///< Not implemented + DEBUG_DRYRUN = _BV(3), ///< Ignore temperature setting and E movement commands + DEBUG_COMMUNICATION = _BV(4), ///< Not implemented + DEBUG_LEVELING = _BV(5), ///< Print detailed output for homing and leveling + DEBUG_MESH_ADJUST = _BV(6), ///< UBL bed leveling + DEBUG_ALL = 0xFF +}; + +extern uint8_t marlin_debug_flags; +#define DEBUGGING(F) (marlin_debug_flags & (DEBUG_## F)) + extern const char echomagic[] PROGMEM; extern const char errormagic[] PROGMEM; @@ -100,4 +120,14 @@ void serial_spaces(uint8_t count); // void serialprintPGM(const char* str); +#if ENABLED(DEBUG_LEVELING_FEATURE) + void print_xyz(const char* prefix, const char* suffix, const float x, const float y, const float z); + void print_xyz(const char* prefix, const char* suffix, const float xyz[]); + #if HAS_ABL + void print_xyz(const char* prefix, const char* suffix, const vector_3 &xyz); + #endif + #define DEBUG_POS(SUFFIX,VAR) do { \ + print_xyz(PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); }while(0) +#endif + #endif // __SERIAL_H__