From 0ca6abce72415c500713714e47980423e9b20b47 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Sat, 28 Sep 2019 17:58:48 -0400 Subject: [PATCH] Add reporting to M290 (#15376) --- Marlin/src/feature/babystep.cpp | 17 +++++------- Marlin/src/feature/babystep.h | 27 ++++++++------------ Marlin/src/gcode/motion/M290.cpp | 44 +++++++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 28 deletions(-) diff --git a/Marlin/src/feature/babystep.cpp b/Marlin/src/feature/babystep.cpp index e16912d69..1fc249911 100644 --- a/Marlin/src/feature/babystep.cpp +++ b/Marlin/src/feature/babystep.cpp @@ -36,13 +36,10 @@ Babystep babystep; volatile int16_t Babystep::steps[BS_TODO_AXIS(Z_AXIS) + 1]; - -#if HAS_LCD_MENU || ENABLED(EXTENSIBLE_UI) - int16_t Babystep::accum; - #if ENABLED(BABYSTEP_DISPLAY_TOTAL) - int16_t Babystep::axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1]; - #endif +#if ENABLED(BABYSTEP_DISPLAY_TOTAL) + int16_t Babystep::axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1]; #endif +int16_t Babystep::accum; void Babystep::step_axis(const AxisEnum axis) { const int16_t curTodo = steps[BS_TODO_AXIS(axis)]; // get rid of volatile for performance @@ -75,11 +72,9 @@ void Babystep::add_steps(const AxisEnum axis, const int16_t distance) { if (!CAN_BABYSTEP(axis)) return; - #if HAS_LCD_MENU || ENABLED(EXTENSIBLE_UI) - accum += distance; // Count up babysteps for the UI - #if ENABLED(BABYSTEP_DISPLAY_TOTAL) - axis_total[BS_TOTAL_AXIS(axis)] += distance; - #endif + accum += distance; // Count up babysteps for the UI + #if ENABLED(BABYSTEP_DISPLAY_TOTAL) + axis_total[BS_TOTAL_AXIS(axis)] += distance; #endif #if ENABLED(BABYSTEP_ALWAYS_AVAILABLE) diff --git a/Marlin/src/feature/babystep.h b/Marlin/src/feature/babystep.h index 617108316..fbf04a03f 100644 --- a/Marlin/src/feature/babystep.h +++ b/Marlin/src/feature/babystep.h @@ -29,7 +29,7 @@ #define BS_TODO_AXIS(A) 0 #endif -#if (HAS_LCD_MENU || ENABLED(EXTENSIBLE_UI)) && ENABLED(BABYSTEP_DISPLAY_TOTAL) +#if ENABLED(BABYSTEP_DISPLAY_TOTAL) #if ENABLED(BABYSTEP_XY) #define BS_TOTAL_AXIS(A) A #else @@ -40,22 +40,17 @@ class Babystep { public: static volatile int16_t steps[BS_TODO_AXIS(Z_AXIS) + 1]; + static int16_t accum; // Total babysteps in current edit - #if HAS_LCD_MENU || ENABLED(EXTENSIBLE_UI) - - static int16_t accum; // Total babysteps in current edit - - #if ENABLED(BABYSTEP_DISPLAY_TOTAL) - static int16_t axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1]; // Total babysteps since G28 - static inline void reset_total(const AxisEnum axis) { - if (true - #if ENABLED(BABYSTEP_XY) - && axis == Z_AXIS - #endif - ) axis_total[BS_TOTAL_AXIS(axis)] = 0; - } - #endif - + #if ENABLED(BABYSTEP_DISPLAY_TOTAL) + static int16_t axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1]; // Total babysteps since G28 + static inline void reset_total(const AxisEnum axis) { + if (true + #if ENABLED(BABYSTEP_XY) + && axis == Z_AXIS + #endif + ) axis_total[BS_TOTAL_AXIS(axis)] = 0; + } #endif static void add_steps(const AxisEnum axis, const int16_t distance); diff --git a/Marlin/src/gcode/motion/M290.cpp b/Marlin/src/gcode/motion/M290.cpp index a2ac85cd0..7763f965c 100644 --- a/Marlin/src/gcode/motion/M290.cpp +++ b/Marlin/src/gcode/motion/M290.cpp @@ -34,6 +34,10 @@ #include "../../core/serial.h" #endif +#if ENABLED(MESH_BED_LEVELING) + #include "../../feature/bedlevel/bedlevel.h" +#endif + #if ENABLED(BABYSTEP_ZPROBE_OFFSET) FORCE_INLINE void mod_zprobe_zoffset(const float &offs) { @@ -60,13 +64,15 @@ /** * M290: Babystepping * + * Send 'R' or no parameters for a report. + * * X - Distance to step X * Y - Distance to step Y * Z - Distance to step Z * S - Distance to step Z (alias for Z) * * With BABYSTEP_ZPROBE_OFFSET: - * P0 - Don't adjust the Z probe offset. + * P0 - Don't adjust the Z probe offset */ void GcodeSuite::M290() { #if ENABLED(BABYSTEP_XY) @@ -87,6 +93,42 @@ void GcodeSuite::M290() { #endif } #endif + + if (!parser.seen("XYZ") || parser.seen('R')) { + SERIAL_ECHO_START(); + + #if ENABLED(BABYSTEP_ZPROBE_OFFSET) + SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET " " MSG_Z, probe_offset[Z_AXIS]); + #endif + + #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET) + { + SERIAL_ECHOLNPAIR("Hotend ", int(active_extruder), "Offset" + #if ENABLED(BABYSTEP_XY) + " X", hotend_offset[X_AXIS][active_extruder], + " Y", hotend_offset[Y_AXIS][active_extruder], + #endif + " Z", hotend_offset[Z_AXIS][active_extruder] + ); + } + #endif + + #if ENABLED(MESH_BED_LEVELING) + SERIAL_ECHOLNPAIR("MBL Adjust Z", mbl.z_offset); + #endif + + #if ENABLED(BABYSTEP_DISPLAY_TOTAL) + { + SERIAL_ECHOLNPAIR("Babystep" + #if ENABLED(BABYSTEP_XY) + " X", babystep.axis_total[X_AXIS], + " Y", babystep.axis_total[Y_AXIS], + #endif + " Z", babystep.axis_total[Z_AXIS] + ); + } + #endif + } } #endif // BABYSTEPPING