From 6d96c221bd8c3c6119870c6d90dc976c9e81dde2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 7 Sep 2021 18:06:10 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Standardize=20G-code=20reporting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/AVR/pinsDebug.h | 10 +- Marlin/src/core/language.h | 47 +- Marlin/src/core/types.h | 2 + Marlin/src/feature/fwretract.cpp | 11 +- Marlin/src/feature/fwretract.h | 6 +- Marlin/src/gcode/bedlevel/M420.cpp | 14 + Marlin/src/gcode/calibrate/G34_M422.cpp | 34 +- Marlin/src/gcode/calibrate/M425.cpp | 18 + Marlin/src/gcode/calibrate/M665.cpp | 36 + Marlin/src/gcode/calibrate/M666.cpp | 68 +- Marlin/src/gcode/calibrate/M852.cpp | 34 +- Marlin/src/gcode/config/M200-M205.cpp | 142 ++- Marlin/src/gcode/config/M217.cpp | 73 +- Marlin/src/gcode/config/M218.cpp | 29 +- Marlin/src/gcode/config/M281.cpp | 37 +- Marlin/src/gcode/config/M301.cpp | 63 +- Marlin/src/gcode/config/M304.cpp | 14 +- Marlin/src/gcode/config/M305.cpp | 4 +- Marlin/src/gcode/config/M309.cpp | 13 +- Marlin/src/gcode/config/M575.cpp | 6 +- Marlin/src/gcode/config/M92.cpp | 73 +- Marlin/src/gcode/control/M17_M18_M84.cpp | 4 +- Marlin/src/gcode/control/M211.cpp | 18 +- Marlin/src/gcode/feature/advance/M900.cpp | 13 + .../src/gcode/feature/controllerfan/M710.cpp | 24 +- .../src/gcode/feature/digipot/M907-M910.cpp | 42 +- .../src/gcode/feature/fwretract/M207-M209.cpp | 25 + .../src/gcode/feature/network/M552-M554.cpp | 36 +- Marlin/src/gcode/feature/pause/M603.cpp | 18 + Marlin/src/gcode/feature/powerloss/M413.cpp | 13 +- Marlin/src/gcode/feature/runout/M412.cpp | 12 + Marlin/src/gcode/feature/trinamic/M569.cpp | 62 ++ Marlin/src/gcode/feature/trinamic/M906.cpp | 95 ++ .../src/gcode/feature/trinamic/M911-M914.cpp | 160 +++ Marlin/src/gcode/gcode.cpp | 20 +- Marlin/src/gcode/gcode.h | 81 +- Marlin/src/gcode/geometry/M206_M428.cpp | 38 +- Marlin/src/gcode/lcd/M145.cpp | 19 + Marlin/src/gcode/lcd/M250.cpp | 12 +- Marlin/src/gcode/lcd/M256.cpp | 11 +- Marlin/src/gcode/lcd/M414.cpp | 7 + Marlin/src/gcode/parser.h | 17 +- Marlin/src/gcode/probe/M851.cpp | 31 +- Marlin/src/gcode/units/M149.cpp | 7 + Marlin/src/module/endstops.cpp | 4 +- Marlin/src/module/settings.cpp | 992 +++--------------- Marlin/src/module/temperature.cpp | 31 +- Marlin/src/module/temperature.h | 2 +- 48 files changed, 1359 insertions(+), 1169 deletions(-) diff --git a/Marlin/src/HAL/AVR/pinsDebug.h b/Marlin/src/HAL/AVR/pinsDebug.h index 6923e1f902f3..50da32292b2b 100644 --- a/Marlin/src/HAL/AVR/pinsDebug.h +++ b/Marlin/src/HAL/AVR/pinsDebug.h @@ -235,7 +235,7 @@ static void print_is_also_tied() { SERIAL_ECHOPGM(" is also tied to this pin"); inline void com_print(const uint8_t N, const uint8_t Z) { const uint8_t *TCCRA = (uint8_t*)TCCR_A(N); - SERIAL_ECHOPAIR(" COM", AS_CHAR('0' + N)); + SERIAL_ECHOPAIR(" COM", AS_DIGIT(N)); SERIAL_CHAR(Z); SERIAL_ECHOPAIR(": ", int((*TCCRA >> (6 - Z * 2)) & 0x03)); } @@ -247,7 +247,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N - uint8_t WGM = (((*TCCRB & _BV(WGM_2)) >> 1) | (*TCCRA & (_BV(WGM_0) | _BV(WGM_1)))); if (N == 4) WGM |= ((*TCCRB & _BV(WGM_3)) >> 1); - SERIAL_ECHOPAIR(" TIMER", AS_CHAR(T + '0')); + SERIAL_ECHOPAIR(" TIMER", AS_DIGIT(T)); SERIAL_CHAR(L); SERIAL_ECHO_SP(3); @@ -262,11 +262,11 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N - SERIAL_ECHOPAIR(" WGM: ", WGM); com_print(T,L); SERIAL_ECHOPAIR(" CS: ", (*TCCRB & (_BV(CS_0) | _BV(CS_1) | _BV(CS_2)) )); - SERIAL_ECHOPAIR(" TCCR", AS_CHAR(T + '0'), "A: ", *TCCRA); - SERIAL_ECHOPAIR(" TCCR", AS_CHAR(T + '0'), "B: ", *TCCRB); + SERIAL_ECHOPAIR(" TCCR", AS_DIGIT(T), "A: ", *TCCRA); + SERIAL_ECHOPAIR(" TCCR", AS_DIGIT(T), "B: ", *TCCRB); const uint8_t *TMSK = (uint8_t*)TIMSK(T); - SERIAL_ECHOPAIR(" TIMSK", AS_CHAR(T + '0'), ": ", *TMSK); + SERIAL_ECHOPAIR(" TIMSK", AS_DIGIT(T), ": ", *TMSK); const uint8_t OCIE = L - 'A' + 1; if (N == 3) { if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) err_is_counter(); } diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index 8de839759322..334165667109 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -158,9 +158,7 @@ #define STR_OFF "OFF" #define STR_ENDSTOP_HIT "TRIGGERED" #define STR_ENDSTOP_OPEN "open" -#define STR_HOTEND_OFFSET "Hotend offsets:" #define STR_DUPLICATION_MODE "Duplication mode: " -#define STR_SOFT_ENDSTOPS "Soft endstops: " #define STR_SOFT_MIN " Min: " #define STR_SOFT_MAX " Max: " @@ -262,6 +260,49 @@ #define STR_REMINDER_SAVE_SETTINGS "Remember to save!" #define STR_PASSWORD_SET "Password is " +// Settings Report Strings +#define STR_Z_AUTO_ALIGN "Z Auto-Align" +#define STR_BACKLASH_COMPENSATION "Backlash compensation" +#define STR_DELTA_SETTINGS "Delta settings (L R H S XYZ ABC)" +#define STR_SCARA_SETTINGS "SCARA settings" +#define STR_SCARA_S "S" +#define STR_SCARA_P_T_Z "P T Z" +#define STR_ENDSTOP_ADJUSTMENT "Endstop adjustment" +#define STR_SKEW_FACTOR "Skew Factor" +#define STR_FILAMENT_SETTINGS "Filament settings" +#define STR_MAX_ACCELERATION "Max Acceleration (units/s2)" +#define STR_MAX_FEEDRATES "Max feedrates (units/s)" +#define STR_ACCELERATION_P_R_T "Acceleration (units/s2) (P R T)" +#define STR_TOOL_CHANGING "Tool-changing" +#define STR_HOTEND_OFFSETS "Hotend offsets" +#define STR_SERVO_ANGLES "Servo Angles" +#define STR_HOTEND_PID "Hotend PID" +#define STR_BED_PID "Bed PID" +#define STR_CHAMBER_PID "Chamber PID" +#define STR_STEPS_PER_UNIT "Steps per unit" +#define STR_LINEAR_ADVANCE "Linear Advance" +#define STR_CONTROLLER_FAN "Controller Fan" +#define STR_STEPPER_MOTOR_CURRENTS "Stepper motor currents" +#define STR_RETRACT_S_F_Z "Retract (S F Z)" +#define STR_RECOVER_S_F "Recover (S F)" +#define STR_AUTO_RETRACT_S "Auto-Retract (S)" +#define STR_FILAMENT_LOAD_UNLOAD "Filament load/unload" +#define STR_POWER_LOSS_RECOVERY "Power-loss recovery" +#define STR_FILAMENT_RUNOUT_SENSOR "Filament runout sensor" +#define STR_DRIVER_STEPPING_MODE "Driver stepping mode" +#define STR_STEPPER_DRIVER_CURRENT "Stepper driver current" +#define STR_HYBRID_THRESHOLD "Hybrid Threshold" +#define STR_STALLGUARD_THRESHOLD "StallGuard threshold" +#define STR_HOME_OFFSET "Home offset" +#define STR_SOFT_ENDSTOPS "Soft endstops" +#define STR_MATERIAL_HEATUP "Material heatup parameters" +#define STR_LCD_CONTRAST "LCD Contrast" +#define STR_LCD_BRIGHTNESS "LCD Brightness" +#define STR_UI_LANGUAGE "UI Language" +#define STR_Z_PROBE_OFFSET "Z-Probe Offset" +#define STR_TEMPERATURE_UNITS "Temperature Units" +#define STR_USER_THERMISTORS "User thermistors" + // // Endstop Names used by Endstops::report_states // @@ -290,7 +331,7 @@ #define STR_Z_PROBE "z_probe" #define STR_PROBE_EN "probe_en" -#define STR_FILAMENT_RUNOUT_SENSOR "filament" +#define STR_FILAMENT "filament" // General axis names #define STR_X "X" diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 833167a7a196..372b4b1e666a 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -55,6 +55,8 @@ struct IF { typedef L type; }; #define LOGICAL_AXIS_ELEM(O) LOGICAL_AXIS_LIST(O.e, O.x, O.y, O.z, O.i, O.j, O.k) #define LOGICAL_AXIS_DECL(T,V) LOGICAL_AXIS_LIST(T e=V, T x=V, T y=V, T z=V, T i=V, T j=V, T k=V) +#define LOGICAL_AXES_STRING LOGICAL_AXIS_GANG("E", "X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR) + #if HAS_EXTRUDERS #define LIST_ITEM_E(N) , N #define CODE_ITEM_E(N) ; N diff --git a/Marlin/src/feature/fwretract.cpp b/Marlin/src/feature/fwretract.cpp index 41dbf430e829..71630d30acab 100644 --- a/Marlin/src/feature/fwretract.cpp +++ b/Marlin/src/feature/fwretract.cpp @@ -36,7 +36,7 @@ FWRetract fwretract; // Single instance - this calls the constructor #include "../module/planner.h" #include "../module/stepper.h" -#include "../gcode/parser.h" +#include "../gcode/gcode.h" #if ENABLED(RETRACT_SYNC_MIXING) #include "mixing.h" @@ -214,8 +214,7 @@ void FWRetract::M207() { if (parser.seenval('W')) settings.swap_retract_length = parser.value_axis_units(E_AXIS); } -void FWRetract::M207_report(const bool forReplay/*=false*/) { - if (!forReplay) { SERIAL_ECHO_MSG("; Retract: S F Z"); SERIAL_ECHO_START(); } +void FWRetract::M207_report() { SERIAL_ECHOLNPAIR_P( PSTR(" M207 S"), LINEAR_UNIT(settings.retract_length) , PSTR(" W"), LINEAR_UNIT(settings.swap_retract_length) @@ -240,8 +239,7 @@ void FWRetract::M208() { if (parser.seen('W')) settings.swap_retract_recover_extra = parser.value_axis_units(E_AXIS); } -void FWRetract::M208_report(const bool forReplay/*=false*/) { - if (!forReplay) { SERIAL_ECHO_MSG("; Recover: S F"); SERIAL_ECHO_START(); } +void FWRetract::M208_report() { SERIAL_ECHOLNPAIR( " M208 S", LINEAR_UNIT(settings.retract_recover_extra) , " W", LINEAR_UNIT(settings.swap_retract_recover_extra) @@ -262,8 +260,7 @@ void FWRetract::M208_report(const bool forReplay/*=false*/) { enable_autoretract(parser.value_bool()); } - void FWRetract::M209_report(const bool forReplay/*=false*/) { - if (!forReplay) { SERIAL_ECHO_MSG("; Auto-Retract: S=0 to disable, 1 to interpret E-only moves as retract/recover"); SERIAL_ECHO_START(); } + void FWRetract::M209_report() { SERIAL_ECHOLNPAIR(" M209 S", AS_DIGIT(autoretract_enabled)); } diff --git a/Marlin/src/feature/fwretract.h b/Marlin/src/feature/fwretract.h index cd93e9cf39ed..9b0ff19c8bb6 100644 --- a/Marlin/src/feature/fwretract.h +++ b/Marlin/src/feature/fwretract.h @@ -76,13 +76,13 @@ class FWRetract { static void retract(const bool retracting OPTARG(HAS_MULTI_EXTRUDER, bool swapping = false)); + static void M207_report(); static void M207(); - static void M207_report(const bool forReplay=false); + static void M208_report(); static void M208(); - static void M208_report(const bool forReplay=false); #if ENABLED(FWRETRACT_AUTORETRACT) + static void M209_report(); static void M209(); - static void M209_report(const bool forReplay=false); #endif }; diff --git a/Marlin/src/gcode/bedlevel/M420.cpp b/Marlin/src/gcode/bedlevel/M420.cpp index 703e73b5a4ce..55055a5b025a 100644 --- a/Marlin/src/gcode/bedlevel/M420.cpp +++ b/Marlin/src/gcode/bedlevel/M420.cpp @@ -242,4 +242,18 @@ void GcodeSuite::M420() { report_current_position(); } +void GcodeSuite::M420_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR( + TERN(MESH_BED_LEVELING, "Mesh Bed Leveling", TERN(AUTO_BED_LEVELING_UBL, "Unified Bed Leveling", "Auto Bed Leveling")) + )); + SERIAL_ECHOPAIR_P( + PSTR(" M420 S"), planner.leveling_active + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + , SP_Z_STR, LINEAR_UNIT(planner.z_fade_height) + #endif + , " ; Leveling " + ); + serialprintln_onoff(planner.leveling_active); +} + #endif // HAS_LEVELING diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 50f3419c8960..c5f5e582a91a 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -475,21 +475,13 @@ void GcodeSuite::G34() { */ void GcodeSuite::M422() { + if (!parser.seen_any()) return M422_report(); + if (parser.seen('R')) { z_stepper_align.reset_to_default(); return; } - if (!parser.seen_any()) { - LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) - SERIAL_ECHOLNPAIR_P(PSTR("M422 S"), i + 1, SP_X_STR, z_stepper_align.xy[i].x, SP_Y_STR, z_stepper_align.xy[i].y); - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) - SERIAL_ECHOLNPAIR_P(PSTR("M422 W"), i + 1, SP_X_STR, z_stepper_align.stepper_xy[i].x, SP_Y_STR, z_stepper_align.stepper_xy[i].y); - #endif - return; - } - const bool is_probe_point = parser.seen('S'); if (TERN0(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, is_probe_point && parser.seen('W'))) { @@ -545,4 +537,26 @@ void GcodeSuite::M422() { pos_dest[position_index] = pos; } +void GcodeSuite::M422_report(const bool forReplay/*=true*/) { + report_heading(forReplay, PSTR(STR_Z_AUTO_ALIGN)); + LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) { + report_echo_start(forReplay); + SERIAL_ECHOLNPAIR_P( + PSTR(" M422 S"), i + 1, + SP_X_STR, z_stepper_align.xy[i].x, + SP_Y_STR, z_stepper_align.xy[i].y + ); + } + #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) { + report_echo_start(forReplay); + SERIAL_ECHOLNPAIR_P( + PSTR(" M422 W"), i + 1, + SP_X_STR, z_stepper_align.stepper_xy[i].x, + SP_Y_STR, z_stepper_align.stepper_xy[i].y + ); + } + #endif +} + #endif // Z_STEPPER_AUTO_ALIGN diff --git a/Marlin/src/gcode/calibrate/M425.cpp b/Marlin/src/gcode/calibrate/M425.cpp index f30de00a0fdf..9f7e00738b26 100644 --- a/Marlin/src/gcode/calibrate/M425.cpp +++ b/Marlin/src/gcode/calibrate/M425.cpp @@ -113,4 +113,22 @@ void GcodeSuite::M425() { } } +void GcodeSuite::M425_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_BACKLASH_COMPENSATION)); + SERIAL_ECHOLNPAIR_P( + PSTR(" M425 F"), backlash.get_correction() + #ifdef BACKLASH_SMOOTHING_MM + , PSTR(" S"), LINEAR_UNIT(backlash.smoothing_mm) + #endif + , LIST_N(DOUBLE(LINEAR_AXES), + SP_X_STR, LINEAR_UNIT(backlash.distance_mm.x), + SP_Y_STR, LINEAR_UNIT(backlash.distance_mm.y), + SP_Z_STR, LINEAR_UNIT(backlash.distance_mm.z), + SP_I_STR, LINEAR_UNIT(backlash.distance_mm.i), + SP_J_STR, LINEAR_UNIT(backlash.distance_mm.j), + SP_K_STR, LINEAR_UNIT(backlash.distance_mm.k) + ) + ); +} + #endif // BACKLASH_GCODE diff --git a/Marlin/src/gcode/calibrate/M665.cpp b/Marlin/src/gcode/calibrate/M665.cpp index 0d0c4146d931..d4d49d6a6c97 100644 --- a/Marlin/src/gcode/calibrate/M665.cpp +++ b/Marlin/src/gcode/calibrate/M665.cpp @@ -30,6 +30,7 @@ #if ENABLED(DELTA) #include "../../module/delta.h" + /** * M665: Set delta configurations * @@ -45,6 +46,8 @@ * C = Gamma (Tower 3) diagonal rod trim */ void GcodeSuite::M665() { + if (!parser.seen_any()) return M665_report(); + if (parser.seenval('H')) delta_height = parser.value_linear_units(); if (parser.seenval('L')) delta_diagonal_rod = parser.value_linear_units(); if (parser.seenval('R')) delta_radius = parser.value_linear_units(); @@ -58,6 +61,22 @@ recalc_delta_settings(); } + void GcodeSuite::M665_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_DELTA_SETTINGS)); + SERIAL_ECHOLNPAIR_P( + PSTR(" M665 L"), LINEAR_UNIT(delta_diagonal_rod) + , PSTR(" R"), LINEAR_UNIT(delta_radius) + , PSTR(" H"), LINEAR_UNIT(delta_height) + , PSTR(" S"), segments_per_second + , SP_X_STR, LINEAR_UNIT(delta_tower_angle_trim.a) + , SP_Y_STR, LINEAR_UNIT(delta_tower_angle_trim.b) + , SP_Z_STR, LINEAR_UNIT(delta_tower_angle_trim.c) + , PSTR(" A"), LINEAR_UNIT(delta_diagonal_rod_trim.a) + , PSTR(" B"), LINEAR_UNIT(delta_diagonal_rod_trim.b) + , PSTR(" C"), LINEAR_UNIT(delta_diagonal_rod_trim.c) + ); + } + #elif IS_SCARA #include "../../module/scara.h" @@ -68,6 +87,9 @@ * Parameters: * * S[segments-per-second] - Segments-per-second + * + * Without NO_WORKSPACE_OFFSETS: + * * P[theta-psi-offset] - Theta-Psi offset, added to the shoulder (A/X) angle * T[theta-offset] - Theta offset, added to the elbow (B/Y) angle * Z[z-offset] - Z offset, added to Z @@ -76,6 +98,8 @@ * B, T, and Y are all aliases for the elbow angle */ void GcodeSuite::M665() { + if (!parser.seen_any()) return M665_report(); + if (parser.seenval('S')) segments_per_second = parser.value_float(); #if HAS_SCARA_OFFSET @@ -107,6 +131,18 @@ #endif // HAS_SCARA_OFFSET } + void GcodeSuite::M665_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_SCARA_SETTINGS " (" STR_SCARA_S TERN_(HAS_SCARA_OFFSET, " " STR_SCARA_P_T_Z) ")")); + SERIAL_ECHOLNPAIR_P( + PSTR(" M665 S"), segments_per_second + #if HAS_SCARA_OFFSET + , SP_P_STR, scara_home_offset.a + , SP_T_STR, scara_home_offset.b + , SP_Z_STR, LINEAR_UNIT(scara_home_offset.z) + #endif + ); + } + #endif #endif // IS_KINEMATIC diff --git a/Marlin/src/gcode/calibrate/M666.cpp b/Marlin/src/gcode/calibrate/M666.cpp index 872344e4e923..6e1ebfb5db59 100644 --- a/Marlin/src/gcode/calibrate/M666.cpp +++ b/Marlin/src/gcode/calibrate/M666.cpp @@ -36,38 +36,6 @@ #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../../core/debug_out.h" -void M666_report(const bool forReplay=true) { - if (!forReplay) { SERIAL_ECHOLNPGM("; Endstop adjustment:"); SERIAL_ECHO_START(); } - #if ENABLED(DELTA) - SERIAL_ECHOLNPAIR_P( - PSTR(" M666 X"), LINEAR_UNIT(delta_endstop_adj.a) - , SP_Y_STR, LINEAR_UNIT(delta_endstop_adj.b) - , SP_Z_STR, LINEAR_UNIT(delta_endstop_adj.c) - ); - #else - SERIAL_ECHOPGM(" M666"); - #if ENABLED(X_DUAL_ENDSTOPS) - SERIAL_ECHOLNPAIR_P(SP_X_STR, LINEAR_UNIT(endstops.x2_endstop_adj)); - #endif - #if ENABLED(Y_DUAL_ENDSTOPS) - SERIAL_ECHOLNPAIR_P(SP_Y_STR, LINEAR_UNIT(endstops.y2_endstop_adj)); - #endif - #if ENABLED(Z_MULTI_ENDSTOPS) - #if NUM_Z_STEPPER_DRIVERS >= 3 - SERIAL_ECHOPAIR(" S2 Z", LINEAR_UNIT(endstops.z3_endstop_adj)); - if (!forReplay) SERIAL_ECHO_START(); - SERIAL_ECHOPAIR(" M666 S3 Z", LINEAR_UNIT(endstops.z3_endstop_adj)); - #if NUM_Z_STEPPER_DRIVERS >= 4 - if (!forReplay) SERIAL_ECHO_START(); - SERIAL_ECHOPAIR(" M666 S4 Z", LINEAR_UNIT(endstops.z4_endstop_adj)); - #endif - #else - SERIAL_ECHOLNPAIR_P(SP_Z_STR, LINEAR_UNIT(endstops.z2_endstop_adj)); - #endif - #endif - #endif -} - #if ENABLED(DELTA) /** @@ -92,6 +60,15 @@ void M666_report(const bool forReplay=true) { if (!is_set) M666_report(); } + void GcodeSuite::M666_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_ENDSTOP_ADJUSTMENT)); + SERIAL_ECHOLNPAIR_P( + PSTR(" M666 X"), LINEAR_UNIT(delta_endstop_adj.a) + , SP_Y_STR, LINEAR_UNIT(delta_endstop_adj.b) + , SP_Z_STR, LINEAR_UNIT(delta_endstop_adj.c) + ); + } + #else /** @@ -105,6 +82,8 @@ void M666_report(const bool forReplay=true) { * Set All: M666 Z */ void GcodeSuite::M666() { + if (!parser.seen_any()) return M666_report(); + #if ENABLED(X_DUAL_ENDSTOPS) if (parser.seenval('X')) endstops.x2_endstop_adj = parser.value_linear_units(); #endif @@ -123,7 +102,30 @@ void M666_report(const bool forReplay=true) { #endif } #endif - if (!parser.seen("XYZ")) M666_report(); + } + + void GcodeSuite::M666_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_ENDSTOP_ADJUSTMENT)); + SERIAL_ECHOPGM(" M666"); + #if ENABLED(X_DUAL_ENDSTOPS) + SERIAL_ECHOLNPAIR_P(SP_X_STR, LINEAR_UNIT(endstops.x2_endstop_adj)); + #endif + #if ENABLED(Y_DUAL_ENDSTOPS) + SERIAL_ECHOLNPAIR_P(SP_Y_STR, LINEAR_UNIT(endstops.y2_endstop_adj)); + #endif + #if ENABLED(Z_MULTI_ENDSTOPS) + #if NUM_Z_STEPPER_DRIVERS >= 3 + SERIAL_ECHOPAIR(" S2 Z", LINEAR_UNIT(endstops.z3_endstop_adj)); + report_echo_start(forReplay); + SERIAL_ECHOPAIR(" M666 S3 Z", LINEAR_UNIT(endstops.z3_endstop_adj)); + #if NUM_Z_STEPPER_DRIVERS >= 4 + report_echo_start(forReplay); + SERIAL_ECHOPAIR(" M666 S4 Z", LINEAR_UNIT(endstops.z4_endstop_adj)); + #endif + #else + SERIAL_ECHOLNPAIR_P(SP_Z_STR, LINEAR_UNIT(endstops.z2_endstop_adj)); + #endif + #endif } #endif // HAS_EXTRA_ENDSTOPS diff --git a/Marlin/src/gcode/calibrate/M852.cpp b/Marlin/src/gcode/calibrate/M852.cpp index 73b18ad4665e..c4361b89f315 100644 --- a/Marlin/src/gcode/calibrate/M852.cpp +++ b/Marlin/src/gcode/calibrate/M852.cpp @@ -36,10 +36,11 @@ * K[yz_factor] - New YZ skew factor */ void GcodeSuite::M852() { - uint8_t ijk = 0, badval = 0, setval = 0; + if (!parser.seen("SIJK")) return M852_report(); - if (parser.seen('I') || parser.seen('S')) { - ++ijk; + uint8_t badval = 0, setval = 0; + + if (parser.seenval('I') || parser.seenval('S')) { const float value = parser.value_linear_units(); if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) { if (planner.skew_factor.xy != value) { @@ -53,8 +54,7 @@ void GcodeSuite::M852() { #if ENABLED(SKEW_CORRECTION_FOR_Z) - if (parser.seen('J')) { - ++ijk; + if (parser.seenval('J')) { const float value = parser.value_linear_units(); if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) { if (planner.skew_factor.xz != value) { @@ -66,8 +66,7 @@ void GcodeSuite::M852() { ++badval; } - if (parser.seen('K')) { - ++ijk; + if (parser.seenval('K')) { const float value = parser.value_linear_units(); if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) { if (planner.skew_factor.yz != value) { @@ -90,17 +89,18 @@ void GcodeSuite::M852() { sync_plan_position(); report_current_position(); } +} - if (!ijk) { - SERIAL_ECHO_START(); - SERIAL_ECHOPGM("Skew Factor"); - SERIAL_ECHOPAIR_F(" XY: ", planner.skew_factor.xy, 6); - #if ENABLED(SKEW_CORRECTION_FOR_Z) - SERIAL_ECHOPAIR_F(" XZ: ", planner.skew_factor.xz, 6); - SERIAL_ECHOPAIR_F(" YZ: ", planner.skew_factor.yz, 6); - #endif - SERIAL_EOL(); - } +void GcodeSuite::M852_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_SKEW_FACTOR)); + SERIAL_ECHOPAIR_F(" M851 I", planner.skew_factor.xy, 6); + #if ENABLED(SKEW_CORRECTION_FOR_Z) + SERIAL_ECHOPAIR_F(" J", planner.skew_factor.xz, 6); + SERIAL_ECHOPAIR_F(" K", planner.skew_factor.yz, 6); + SERIAL_ECHOLNPGM(" ; XY, XZ, YZ"); + #else + SERIAL_ECHOLNPGM(" ; XY"); + #endif } #endif // SKEW_CORRECTION_GCODE diff --git a/Marlin/src/gcode/config/M200-M205.cpp b/Marlin/src/gcode/config/M200-M205.cpp index a2bcb8bb86a8..048a2887e62e 100644 --- a/Marlin/src/gcode/config/M200-M205.cpp +++ b/Marlin/src/gcode/config/M200-M205.cpp @@ -32,9 +32,14 @@ * T - Optional extruder number. Current extruder if omitted. * D - Set filament diameter and enable. D0 disables volumetric. * S - Turn volumetric ON or OFF. + * + * With VOLUMETRIC_EXTRUDER_LIMIT: + * * L - Volumetric extruder limit (in mm^3/sec). L0 disables the limit. */ void GcodeSuite::M200() { + if (!parser.seen("DST" TERN_(VOLUMETRIC_EXTRUDER_LIMIT, "L"))) + return M200_report(); const int8_t target_extruder = get_target_extruder_from_command(); if (target_extruder < 0) return; @@ -69,6 +74,37 @@ planner.calculate_volumetric_multipliers(); } + void GcodeSuite::M200_report(const bool forReplay/*=true*/) { + if (!forReplay) { + report_heading(forReplay, PSTR(STR_FILAMENT_SETTINGS), false); + if (!parser.volumetric_enabled) SERIAL_ECHOPGM(" (Disabled):"); + SERIAL_EOL(); + report_echo_start(forReplay); + } + + #if EXTRUDERS == 1 + { + SERIAL_ECHOLNPAIR( + " M200 S", parser.volumetric_enabled, " D", LINEAR_UNIT(planner.filament_size[0]) + #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) + , " L", LINEAR_UNIT(planner.volumetric_extruder_limit[0]) + #endif + ); + } + #else + SERIAL_ECHOLNPAIR(" M200 S", parser.volumetric_enabled); + LOOP_L_N(i, EXTRUDERS) { + report_echo_start(forReplay); + SERIAL_ECHOLNPAIR( + " M200 T", i, " D", LINEAR_UNIT(planner.filament_size[i]) + #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) + , " L", LINEAR_UNIT(planner.volumetric_extruder_limit[i]) + #endif + ); + } + #endif + } + #endif // !NO_VOLUMETRICS /** @@ -77,6 +113,8 @@ * With multiple extruders use T to specify which one. */ void GcodeSuite::M201() { + if (!parser.seen("T" LOGICAL_AXES_STRING)) + return M201_report(); const int8_t target_extruder = get_target_extruder_from_command(); if (target_extruder < 0) return; @@ -94,12 +132,40 @@ void GcodeSuite::M201() { } } +void GcodeSuite::M201_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_MAX_ACCELERATION)); + SERIAL_ECHOLNPAIR_P( + LIST_N(DOUBLE(LINEAR_AXES), + PSTR(" M201 X"), LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[X_AXIS]), + SP_Y_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Y_AXIS]), + SP_Z_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Z_AXIS]), + SP_I_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[I_AXIS]), + SP_J_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[J_AXIS]), + SP_K_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[K_AXIS]) + ) + #if HAS_EXTRUDERS && DISABLED(DISTINCT_E_FACTORS) + , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_acceleration_mm_per_s2[E_AXIS]) + #endif + ); + #if ENABLED(DISTINCT_E_FACTORS) + LOOP_L_N(i, E_STEPPERS) { + report_echo_start(forReplay); + SERIAL_ECHOLNPAIR_P( + PSTR(" M201 T"), i + , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(i)]) + ); + } + #endif +} + /** * M203: Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in units/sec * * With multiple extruders use T to specify which one. */ void GcodeSuite::M203() { + if (!parser.seen("T" LOGICAL_AXES_STRING)) + return M203_report(); const int8_t target_extruder = get_target_extruder_from_command(); if (target_extruder < 0) return; @@ -111,6 +177,32 @@ void GcodeSuite::M203() { } } +void GcodeSuite::M203_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_MAX_FEEDRATES)); + SERIAL_ECHOLNPAIR_P( + LIST_N(DOUBLE(LINEAR_AXES), + PSTR(" M203 X"), LINEAR_UNIT(planner.settings.max_feedrate_mm_s[X_AXIS]), + SP_Y_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Y_AXIS]), + SP_Z_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Z_AXIS]), + SP_I_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[I_AXIS]), + SP_J_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[J_AXIS]), + SP_K_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[K_AXIS]) + ) + #if HAS_EXTRUDERS && DISABLED(DISTINCT_E_FACTORS) + , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS]) + #endif + ); + #if ENABLED(DISTINCT_E_FACTORS) + LOOP_L_N(i, E_STEPPERS) { + SERIAL_ECHO_START(); + SERIAL_ECHOLNPAIR_P( + PSTR(" M203 T"), i + , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS_N(i)]) + ); + } + #endif +} + /** * M204: Set Accelerations in units/sec^2 (M204 P1200 R3000 T3000) * @@ -119,11 +211,8 @@ void GcodeSuite::M203() { * T = Travel (non printing) moves */ void GcodeSuite::M204() { - if (!parser.seen("PRST")) { - SERIAL_ECHOPAIR("Acceleration: P", planner.settings.acceleration); - SERIAL_ECHOPAIR(" R", planner.settings.retract_acceleration); - SERIAL_ECHOLNPAIR_P(SP_T_STR, planner.settings.travel_acceleration); - } + if (!parser.seen("PRST")) + return M204_report(); else { //planner.synchronize(); // 'S' for legacy compatibility. Should NOT BE USED for new development @@ -134,6 +223,15 @@ void GcodeSuite::M204() { } } +void GcodeSuite::M204_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_ACCELERATION_P_R_T)); + SERIAL_ECHOLNPAIR_P( + PSTR(" M204 P"), LINEAR_UNIT(planner.settings.acceleration) + , PSTR(" R"), LINEAR_UNIT(planner.settings.retract_acceleration) + , SP_T_STR, LINEAR_UNIT(planner.settings.travel_acceleration) + ); +} + /** * M205: Set Advanced Settings * @@ -147,7 +245,8 @@ void GcodeSuite::M204() { * J = Junction Deviation (mm) (If not using CLASSIC_JERK) */ void GcodeSuite::M205() { - if (!parser.seen("BST" TERN_(HAS_JUNCTION_DEVIATION, "J") TERN_(HAS_CLASSIC_JERK, "XYZE"))) return; + if (!parser.seen("BST" TERN_(HAS_JUNCTION_DEVIATION, "J") TERN_(HAS_CLASSIC_JERK, "XYZE"))) + return M205_report(); //planner.synchronize(); if (parser.seenval('B')) planner.settings.min_segment_time_us = parser.value_ulong(); @@ -184,3 +283,34 @@ void GcodeSuite::M205() { #endif #endif // HAS_CLASSIC_JERK } + +void GcodeSuite::M205_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR( + "Advanced (B S T" + TERN_(HAS_JUNCTION_DEVIATION, " J") + TERN_(HAS_CLASSIC_JERK, " X Y Z") + TERN_(HAS_CLASSIC_E_JERK, " E") + ")" + )); + SERIAL_ECHOLNPAIR_P( + PSTR(" M205 B"), LINEAR_UNIT(planner.settings.min_segment_time_us) + , PSTR(" S"), LINEAR_UNIT(planner.settings.min_feedrate_mm_s) + , SP_T_STR, LINEAR_UNIT(planner.settings.min_travel_feedrate_mm_s) + #if HAS_JUNCTION_DEVIATION + , PSTR(" J"), LINEAR_UNIT(planner.junction_deviation_mm) + #endif + #if HAS_CLASSIC_JERK + , LIST_N(DOUBLE(LINEAR_AXES), + SP_X_STR, LINEAR_UNIT(planner.max_jerk.x), + SP_Y_STR, LINEAR_UNIT(planner.max_jerk.y), + SP_Z_STR, LINEAR_UNIT(planner.max_jerk.z), + SP_I_STR, LINEAR_UNIT(planner.max_jerk.i), + SP_J_STR, LINEAR_UNIT(planner.max_jerk.j), + SP_K_STR, LINEAR_UNIT(planner.max_jerk.k) + ) + #if HAS_CLASSIC_E_JERK + , SP_E_STR, LINEAR_UNIT(planner.max_jerk.e) + #endif + #endif + ); +} diff --git a/Marlin/src/gcode/config/M217.cpp b/Marlin/src/gcode/config/M217.cpp index 2035ae55abeb..72b7d16ac015 100644 --- a/Marlin/src/gcode/config/M217.cpp +++ b/Marlin/src/gcode/config/M217.cpp @@ -33,44 +33,6 @@ #include "../../MarlinCore.h" // for SP_X_STR, etc. -void M217_report(const bool eeprom=false) { - - #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) - SERIAL_ECHOPGM_P(eeprom ? PSTR(" M217") : PSTR("Toolchange:")); - SERIAL_ECHOPAIR(" S", LINEAR_UNIT(toolchange_settings.swap_length)); - SERIAL_ECHOPAIR_P(SP_B_STR, LINEAR_UNIT(toolchange_settings.extra_resume), - SP_E_STR, LINEAR_UNIT(toolchange_settings.extra_prime), - SP_P_STR, LINEAR_UNIT(toolchange_settings.prime_speed)); - SERIAL_ECHOPAIR(" R", LINEAR_UNIT(toolchange_settings.retract_speed), - " U", LINEAR_UNIT(toolchange_settings.unretract_speed), - " F", toolchange_settings.fan_speed, - " G", toolchange_settings.fan_time); - - #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) - SERIAL_ECHOPAIR(" A", migration.automode); - SERIAL_ECHOPAIR(" L", LINEAR_UNIT(migration.last)); - #endif - - #if ENABLED(TOOLCHANGE_PARK) - SERIAL_ECHOPAIR(" W", LINEAR_UNIT(toolchange_settings.enable_park)); - SERIAL_ECHOPAIR_P(SP_X_STR, LINEAR_UNIT(toolchange_settings.change_point.x)); - SERIAL_ECHOPAIR_P(SP_Y_STR, LINEAR_UNIT(toolchange_settings.change_point.y)); - #endif - - #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED) - SERIAL_ECHOPAIR(" V", LINEAR_UNIT(enable_first_prime)); - #endif - - #else - - UNUSED(eeprom); - - #endif - - SERIAL_ECHOPAIR_P(SP_Z_STR, LINEAR_UNIT(toolchange_settings.z_raise)); - SERIAL_EOL(); -} - /** * M217 - Set SINGLENOZZLE toolchange parameters * @@ -168,4 +130,39 @@ void GcodeSuite::M217() { M217_report(); } +void GcodeSuite::M217_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_TOOL_CHANGING)); + + SERIAL_ECHOPGM(" M217"); + + #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) + SERIAL_ECHOPAIR(" S", LINEAR_UNIT(toolchange_settings.swap_length)); + SERIAL_ECHOPAIR_P(SP_B_STR, LINEAR_UNIT(toolchange_settings.extra_resume), + SP_E_STR, LINEAR_UNIT(toolchange_settings.extra_prime), + SP_P_STR, LINEAR_UNIT(toolchange_settings.prime_speed)); + SERIAL_ECHOPAIR(" R", LINEAR_UNIT(toolchange_settings.retract_speed), + " U", LINEAR_UNIT(toolchange_settings.unretract_speed), + " F", toolchange_settings.fan_speed, + " G", toolchange_settings.fan_time); + + #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) + SERIAL_ECHOPAIR(" A", migration.automode); + SERIAL_ECHOPAIR(" L", LINEAR_UNIT(migration.last)); + #endif + + #if ENABLED(TOOLCHANGE_PARK) + SERIAL_ECHOPAIR(" W", LINEAR_UNIT(toolchange_settings.enable_park)); + SERIAL_ECHOPAIR_P(SP_X_STR, LINEAR_UNIT(toolchange_settings.change_point.x)); + SERIAL_ECHOPAIR_P(SP_Y_STR, LINEAR_UNIT(toolchange_settings.change_point.y)); + #endif + + #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED) + SERIAL_ECHOPAIR(" V", LINEAR_UNIT(enable_first_prime)); + #endif + + #endif + + SERIAL_ECHOLNPAIR_P(SP_Z_STR, LINEAR_UNIT(toolchange_settings.z_raise)); +} + #endif // HAS_MULTI_EXTRUDER diff --git a/Marlin/src/gcode/config/M218.cpp b/Marlin/src/gcode/config/M218.cpp index 7701320e9eae..249c16622fe1 100644 --- a/Marlin/src/gcode/config/M218.cpp +++ b/Marlin/src/gcode/config/M218.cpp @@ -41,6 +41,8 @@ */ void GcodeSuite::M218() { + if (!parser.seen_any()) return M218_report(); + const int8_t target_extruder = get_target_extruder_from_command(); if (target_extruder < 0) return; @@ -48,24 +50,23 @@ void GcodeSuite::M218() { if (parser.seenval('Y')) hotend_offset[target_extruder].y = parser.value_linear_units(); if (parser.seenval('Z')) hotend_offset[target_extruder].z = parser.value_linear_units(); - if (!parser.seen("XYZ")) { - SERIAL_ECHO_START(); - SERIAL_ECHOPGM(STR_HOTEND_OFFSET); - HOTEND_LOOP() { - SERIAL_CHAR(' '); - SERIAL_ECHO(hotend_offset[e].x); - SERIAL_CHAR(','); - SERIAL_ECHO(hotend_offset[e].y); - SERIAL_CHAR(','); - SERIAL_ECHO_F(hotend_offset[e].z, 3); - } - SERIAL_EOL(); - } - #if ENABLED(DELTA) if (target_extruder == active_extruder) do_blocking_move_to_xy(current_position, planner.settings.max_feedrate_mm_s[X_AXIS]); #endif } +void GcodeSuite::M218_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_HOTEND_OFFSETS)); + LOOP_S_L_N(e, 1, HOTENDS) { + report_echo_start(forReplay); + SERIAL_ECHOPAIR_P( + PSTR(" M218 T"), e, + SP_X_STR, LINEAR_UNIT(hotend_offset[e].x), + SP_Y_STR, LINEAR_UNIT(hotend_offset[e].y) + ); + SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(hotend_offset[e].z), 3); + } +} + #endif // HAS_HOTEND_OFFSET diff --git a/Marlin/src/gcode/config/M281.cpp b/Marlin/src/gcode/config/M281.cpp index eeb0fcc470e1..36b62f516360 100644 --- a/Marlin/src/gcode/config/M281.cpp +++ b/Marlin/src/gcode/config/M281.cpp @@ -34,6 +34,7 @@ * U - Stowed Angle */ void GcodeSuite::M281() { + if (!parser.seen_any()) return M281_report(); if (!parser.seenval('P')) return; @@ -45,24 +46,32 @@ void GcodeSuite::M281() { return; } #endif - bool angle_change = false; - if (parser.seen('L')) { - servo_angles[servo_index][0] = parser.value_int(); - angle_change = true; - } - if (parser.seen('U')) { - servo_angles[servo_index][1] = parser.value_int(); - angle_change = true; - } - if (!angle_change) { - SERIAL_ECHO_MSG(" Servo ", servo_index, - " L", servo_angles[servo_index][0], - " U", servo_angles[servo_index][1]); - } + if (parser.seen('L')) servo_angles[servo_index][0] = parser.value_int(); + if (parser.seen('U')) servo_angles[servo_index][1] = parser.value_int(); } else SERIAL_ERROR_MSG("Servo ", servo_index, " out of range"); +} +void GcodeSuite::M281_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_SERVO_ANGLES)); + LOOP_L_N(i, NUM_SERVOS) { + switch (i) { + default: break; + #if ENABLED(SWITCHING_EXTRUDER) + case SWITCHING_EXTRUDER_SERVO_NR: + #if EXTRUDERS > 3 + case SWITCHING_EXTRUDER_E23_SERVO_NR: + #endif + #elif ENABLED(SWITCHING_NOZZLE) + case SWITCHING_NOZZLE_SERVO_NR: + #elif ENABLED(BLTOUCH) || (HAS_Z_SERVO_PROBE && defined(Z_SERVO_ANGLES)) + case Z_PROBE_SERVO_NR: + #endif + report_echo_start(forReplay); + SERIAL_ECHOLNPAIR(" M281 P", i, " L", servo_angles[i][0], " U", servo_angles[i][1]); + } + } } #endif // EDITABLE_SERVO_ANGLES diff --git a/Marlin/src/gcode/config/M301.cpp b/Marlin/src/gcode/config/M301.cpp index 7b3f57608bad..904744c95817 100644 --- a/Marlin/src/gcode/config/M301.cpp +++ b/Marlin/src/gcode/config/M301.cpp @@ -46,46 +46,63 @@ * F[float] Kf term */ void GcodeSuite::M301() { - // multi-extruder PID patch: M301 updates or prints a single extruder's PID values // default behavior (omitting E parameter) is to update for extruder 0 only - const uint8_t e = parser.byteval('E'); // extruder being updated + int8_t e = parser.byteval('E', -1); // extruder being updated + + if (!parser.seen("PID" TERN_(PID_EXTRUSION_SCALING, "CL") TERN_(PID_FAN_SCALING, "F"))) + return M301_report(true, e); + + if (e == -1) e = 0; if (e < HOTENDS) { // catch bad input value - if (parser.seen('P')) PID_PARAM(Kp, e) = parser.value_float(); - if (parser.seen('I')) PID_PARAM(Ki, e) = scalePID_i(parser.value_float()); - if (parser.seen('D')) PID_PARAM(Kd, e) = scalePID_d(parser.value_float()); + + if (parser.seenval('P')) PID_PARAM(Kp, e) = parser.value_float(); + if (parser.seenval('I')) PID_PARAM(Ki, e) = scalePID_i(parser.value_float()); + if (parser.seenval('D')) PID_PARAM(Kd, e) = scalePID_d(parser.value_float()); + #if ENABLED(PID_EXTRUSION_SCALING) - if (parser.seen('C')) PID_PARAM(Kc, e) = parser.value_float(); + if (parser.seenval('C')) PID_PARAM(Kc, e) = parser.value_float(); if (parser.seenval('L')) thermalManager.lpq_len = parser.value_int(); NOMORE(thermalManager.lpq_len, LPQ_MAX_LEN); NOLESS(thermalManager.lpq_len, 0); #endif #if ENABLED(PID_FAN_SCALING) - if (parser.seen('F')) PID_PARAM(Kf, e) = parser.value_float(); + if (parser.seenval('F')) PID_PARAM(Kf, e) = parser.value_float(); #endif thermalManager.updatePID(); - - SERIAL_ECHO_START(); - #if ENABLED(PID_PARAMS_PER_HOTEND) - SERIAL_ECHOPAIR(" e:", e); // specify extruder in serial output - #endif - SERIAL_ECHOPAIR(" p:", PID_PARAM(Kp, e), - " i:", unscalePID_i(PID_PARAM(Ki, e)), - " d:", unscalePID_d(PID_PARAM(Kd, e))); - #if ENABLED(PID_EXTRUSION_SCALING) - SERIAL_ECHOPAIR(" c:", PID_PARAM(Kc, e)); - #endif - #if ENABLED(PID_FAN_SCALING) - SERIAL_ECHOPAIR(" f:", PID_PARAM(Kf, e)); - #endif - - SERIAL_EOL(); } else SERIAL_ERROR_MSG(STR_INVALID_EXTRUDER); } +void GcodeSuite::M301_report(const bool forReplay/*=true*/, const int8_t eindex/*=-1*/) { + report_heading(forReplay, PSTR(STR_HOTEND_PID)); + HOTEND_LOOP() { + if (e == eindex || eindex == -1) { + report_echo_start(forReplay); + SERIAL_ECHOPAIR_P( + #if ENABLED(PID_PARAMS_PER_HOTEND) + PSTR(" M301 E"), e, SP_P_STR + #else + PSTR(" M301 P") + #endif + , PID_PARAM(Kp, e) + , PSTR(" I"), unscalePID_i(PID_PARAM(Ki, e)) + , PSTR(" D"), unscalePID_d(PID_PARAM(Kd, e)) + ); + #if ENABLED(PID_EXTRUSION_SCALING) + SERIAL_ECHOPAIR_P(SP_C_STR, PID_PARAM(Kc, e)); + if (e == 0) SERIAL_ECHOPAIR(" L", thermalManager.lpq_len); + #endif + #if ENABLED(PID_FAN_SCALING) + SERIAL_ECHOPAIR(" F", PID_PARAM(Kf, e)); + #endif + SERIAL_EOL(); + } + } +} + #endif // PIDTEMP diff --git a/Marlin/src/gcode/config/M304.cpp b/Marlin/src/gcode/config/M304.cpp index b1af5a5ae21f..05ee4bad8061 100644 --- a/Marlin/src/gcode/config/M304.cpp +++ b/Marlin/src/gcode/config/M304.cpp @@ -35,15 +35,19 @@ * D - Set the D value */ void GcodeSuite::M304() { - + if (!parser.seen("PID")) return M304_report(); if (parser.seen('P')) thermalManager.temp_bed.pid.Kp = parser.value_float(); if (parser.seen('I')) thermalManager.temp_bed.pid.Ki = scalePID_i(parser.value_float()); if (parser.seen('D')) thermalManager.temp_bed.pid.Kd = scalePID_d(parser.value_float()); +} - SERIAL_ECHO_MSG(" p:", thermalManager.temp_bed.pid.Kp, - " i:", unscalePID_i(thermalManager.temp_bed.pid.Ki), - " d:", unscalePID_d(thermalManager.temp_bed.pid.Kd)); - +void GcodeSuite::M304_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_BED_PID)); + SERIAL_ECHO_MSG( + " M304 P", thermalManager.temp_bed.pid.Kp + , " I", unscalePID_i(thermalManager.temp_bed.pid.Ki) + , " D", unscalePID_d(thermalManager.temp_bed.pid.Kd) + ); } #endif // PIDTEMPBED diff --git a/Marlin/src/gcode/config/M305.cpp b/Marlin/src/gcode/config/M305.cpp index 10ef55c17341..6957eef050dd 100644 --- a/Marlin/src/gcode/config/M305.cpp +++ b/Marlin/src/gcode/config/M305.cpp @@ -70,10 +70,10 @@ void GcodeSuite::M305() { } // If not setting then report parameters else if (t_index < 0) { // ...all user thermistors LOOP_L_N(i, USER_THERMISTORS) - thermalManager.log_user_thermistor(i); + thermalManager.M305_report(i); } else // ...one user thermistor - thermalManager.log_user_thermistor(t_index); + thermalManager.M305_report(t_index); } #endif // HAS_USER_THERMISTORS diff --git a/Marlin/src/gcode/config/M309.cpp b/Marlin/src/gcode/config/M309.cpp index 2247481b2579..d5297e956393 100644 --- a/Marlin/src/gcode/config/M309.cpp +++ b/Marlin/src/gcode/config/M309.cpp @@ -35,14 +35,19 @@ * D - Set the D value */ void GcodeSuite::M309() { + if (!parser.seen("PID")) return M309_report(); if (parser.seen('P')) thermalManager.temp_chamber.pid.Kp = parser.value_float(); if (parser.seen('I')) thermalManager.temp_chamber.pid.Ki = scalePID_i(parser.value_float()); if (parser.seen('D')) thermalManager.temp_chamber.pid.Kd = scalePID_d(parser.value_float()); +} - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(" p:", thermalManager.temp_chamber.pid.Kp, - " i:", unscalePID_i(thermalManager.temp_chamber.pid.Ki), - " d:", unscalePID_d(thermalManager.temp_chamber.pid.Kd)); +void GcodeSuite::M309_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_CHAMBER_PID)); + SERIAL_ECHOLNPAIR( + " M309 P", thermalManager.temp_chamber.pid.Kp + , " I", unscalePID_i(thermalManager.temp_chamber.pid.Ki) + , " D", unscalePID_d(thermalManager.temp_chamber.pid.Kd) + ); } #endif // PIDTEMPCHAMBER diff --git a/Marlin/src/gcode/config/M575.cpp b/Marlin/src/gcode/config/M575.cpp index 7739510cf3cf..2c12428d982a 100644 --- a/Marlin/src/gcode/config/M575.cpp +++ b/Marlin/src/gcode/config/M575.cpp @@ -53,13 +53,13 @@ void GcodeSuite::M575() { case 115200: case 250000: case 500000: case 1000000: { const int8_t port = parser.intval('P', -99); const bool set1 = (port == -99 || port == 0); - if (set1) SERIAL_ECHO_MSG(" Serial ", AS_CHAR('0'), " baud rate set to ", baud); + if (set1) SERIAL_ECHO_MSG(" Serial ", AS_DIGIT(0), " baud rate set to ", baud); #if HAS_MULTI_SERIAL const bool set2 = (port == -99 || port == 1); - if (set2) SERIAL_ECHO_MSG(" Serial ", AS_CHAR('1'), " baud rate set to ", baud); + if (set2) SERIAL_ECHO_MSG(" Serial ", AS_DIGIT(1), " baud rate set to ", baud); #ifdef SERIAL_PORT_3 const bool set3 = (port == -99 || port == 2); - if (set3) SERIAL_ECHO_MSG(" Serial ", AS_CHAR('2'), " baud rate set to ", baud); + if (set3) SERIAL_ECHO_MSG(" Serial ", AS_DIGIT(2), " baud rate set to ", baud); #endif #endif diff --git a/Marlin/src/gcode/config/M92.cpp b/Marlin/src/gcode/config/M92.cpp index 544c66a0768a..9f4f2ac65b13 100644 --- a/Marlin/src/gcode/config/M92.cpp +++ b/Marlin/src/gcode/config/M92.cpp @@ -23,33 +23,6 @@ #include "../gcode.h" #include "../../module/planner.h" -void report_M92(const bool echo=true, const int8_t e=-1) { - if (echo) SERIAL_ECHO_START(); else SERIAL_CHAR(' '); - SERIAL_ECHOPAIR_P(LIST_N(DOUBLE(LINEAR_AXES), - PSTR(" M92 X"), LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]), - SP_Y_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]), - SP_Z_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Z_AXIS]), - SP_I_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[I_AXIS]), - SP_J_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[J_AXIS]), - SP_K_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[K_AXIS])) - ); - #if HAS_EXTRUDERS && DISABLED(DISTINCT_E_FACTORS) - SERIAL_ECHOPAIR_P(SP_E_STR, VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS])); - #endif - SERIAL_EOL(); - - #if ENABLED(DISTINCT_E_FACTORS) - LOOP_L_N(i, E_STEPPERS) { - if (e >= 0 && i != e) continue; - if (echo) SERIAL_ECHO_START(); else SERIAL_CHAR(' '); - SERIAL_ECHOLNPAIR_P(PSTR(" M92 T"), i, - SP_E_STR, VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS_N(i)])); - } - #endif - - UNUSED(e); -} - /** * M92: Set axis steps-per-unit for one or more axes, X, Y, Z, and E. * (Follows the same syntax as G92) @@ -58,10 +31,11 @@ void report_M92(const bool echo=true, const int8_t e=-1) { * * If no argument is given print the current values. * - * With MAGIC_NUMBERS_GCODE: - * Use 'H' and/or 'L' to get ideal layer-height information. - * 'H' specifies micro-steps to use. We guess if it's not supplied. - * 'L' specifies a desired layer height. Nearest good heights are shown. + * With MAGIC_NUMBERS_GCODE: + * + * Use 'H' and/or 'L' to get ideal layer-height information. + * H - Specify micro-steps to use. Best guess if not supplied. + * L - Desired layer height in current units. Nearest good heights are shown. */ void GcodeSuite::M92() { @@ -69,10 +43,8 @@ void GcodeSuite::M92() { if (target_extruder < 0) return; // No arguments? Show M92 report. - if (!parser.seen( - LOGICAL_AXIS_GANG("E", "X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR) - TERN_(MAGIC_NUMBERS_GCODE, "HL") - )) return report_M92(true, target_extruder); + if (!parser.seen(LOGICAL_AXES_STRING TERN_(MAGIC_NUMBERS_GCODE, "HL"))) + return M92_report(true, target_extruder); LOOP_LOGICAL_AXES(i) { if (parser.seenval(axis_codes[i])) { @@ -100,7 +72,7 @@ void GcodeSuite::M92() { #ifndef Z_MICROSTEPS #define Z_MICROSTEPS 16 #endif - const float wanted = parser.floatval('L'); + const float wanted = parser.linearval('L'); if (parser.seen('H') || wanted) { const uint16_t argH = parser.ushortval('H'), micro_steps = argH ?: Z_MICROSTEPS; @@ -117,3 +89,32 @@ void GcodeSuite::M92() { } #endif } + +void GcodeSuite::M92_report(const bool forReplay/*=true*/, const int8_t e/*=-1*/) { + report_heading_etc(forReplay, PSTR(STR_STEPS_PER_UNIT)); + SERIAL_ECHOPAIR_P(LIST_N(DOUBLE(LINEAR_AXES), + PSTR(" M92 X"), LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]), + SP_Y_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]), + SP_Z_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Z_AXIS]), + SP_I_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[I_AXIS]), + SP_J_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[J_AXIS]), + SP_K_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[K_AXIS])) + ); + #if HAS_EXTRUDERS && DISABLED(DISTINCT_E_FACTORS) + SERIAL_ECHOPAIR_P(SP_E_STR, VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS])); + #endif + SERIAL_EOL(); + + #if ENABLED(DISTINCT_E_FACTORS) + LOOP_L_N(i, E_STEPPERS) { + if (e >= 0 && i != e) continue; + report_echo_start(forReplay); + SERIAL_ECHOLNPAIR_P( + PSTR(" M92 T"), i, + SP_E_STR, VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS_N(i)]) + ); + } + #else + UNUSED(e); + #endif +} diff --git a/Marlin/src/gcode/control/M17_M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp index 4ebb81cf7ea7..e6e0f033ecac 100644 --- a/Marlin/src/gcode/control/M17_M18_M84.cpp +++ b/Marlin/src/gcode/control/M17_M18_M84.cpp @@ -33,7 +33,7 @@ * M17: Enable stepper motors */ void GcodeSuite::M17() { - if (parser.seen(LOGICAL_AXIS_GANG("E", "X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR))) { + if (parser.seen_axis()) { LOGICAL_AXIS_CODE( if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen_test('E'))) enable_e_steppers(), if (parser.seen_test('X')) ENABLE_AXIS_X(), @@ -59,7 +59,7 @@ void GcodeSuite::M18_M84() { stepper_inactive_time = parser.value_millis_from_seconds(); } else { - if (parser.seen(LOGICAL_AXIS_GANG("E", "X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR))) { + if (parser.seen_axis()) { planner.synchronize(); LOGICAL_AXIS_CODE( if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen_test('E'))) disable_e_steppers(), diff --git a/Marlin/src/gcode/control/M211.cpp b/Marlin/src/gcode/control/M211.cpp index 2ba777ba650e..b15cb6ef0a8c 100644 --- a/Marlin/src/gcode/control/M211.cpp +++ b/Marlin/src/gcode/control/M211.cpp @@ -33,14 +33,22 @@ * Usage: M211 S1 to enable, M211 S0 to disable, M211 alone for report */ void GcodeSuite::M211() { + if (parser.seen('S')) + soft_endstop._enabled = parser.value_bool(); + else + M211_report(); +} + +void GcodeSuite::M211_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_SOFT_ENDSTOPS)); + SERIAL_ECHOPAIR(" M211 S", AS_DIGIT(soft_endstop._enabled), " ; "); + serialprintln_onoff(soft_endstop._enabled); + + report_echo_start(forReplay); const xyz_pos_t l_soft_min = soft_endstop.min.asLogical(), l_soft_max = soft_endstop.max.asLogical(); - SERIAL_ECHO_START(); - SERIAL_ECHOPGM(STR_SOFT_ENDSTOPS); - if (parser.seen('S')) soft_endstop._enabled = parser.value_bool(); - serialprint_onoff(soft_endstop._enabled); print_pos(l_soft_min, PSTR(STR_SOFT_MIN), PSTR(" ")); print_pos(l_soft_max, PSTR(STR_SOFT_MAX)); } -#endif +#endif // HAS_SOFTWARE_ENDSTOPS diff --git a/Marlin/src/gcode/feature/advance/M900.cpp b/Marlin/src/gcode/feature/advance/M900.cpp index 1d76ebf7d531..e1859fb7d9ea 100644 --- a/Marlin/src/gcode/feature/advance/M900.cpp +++ b/Marlin/src/gcode/feature/advance/M900.cpp @@ -144,4 +144,17 @@ void GcodeSuite::M900() { } +void GcodeSuite::M900_report(const bool forReplay/*=true*/) { + report_heading(forReplay, PSTR(STR_LINEAR_ADVANCE)); + #if EXTRUDERS < 2 + report_echo_start(forReplay); + SERIAL_ECHOLNPAIR(" M900 K", planner.extruder_advance_K[0]); + #else + LOOP_L_N(i, EXTRUDERS) { + report_echo_start(forReplay); + SERIAL_ECHOLNPAIR(" M900 T", i, " K", planner.extruder_advance_K[i]); + } + #endif +} + #endif // LIN_ADVANCE diff --git a/Marlin/src/gcode/feature/controllerfan/M710.cpp b/Marlin/src/gcode/feature/controllerfan/M710.cpp index aa382a3ea9eb..3b72ee002cfa 100644 --- a/Marlin/src/gcode/feature/controllerfan/M710.cpp +++ b/Marlin/src/gcode/feature/controllerfan/M710.cpp @@ -27,18 +27,6 @@ #include "../../gcode.h" #include "../../../feature/controllerfan.h" -void M710_report(const bool forReplay=true) { - if (!forReplay) { SERIAL_ECHOLNPGM("; Controller Fan"); SERIAL_ECHO_START(); } - SERIAL_ECHOLNPAIR(" M710" - " S", int(controllerFan.settings.active_speed), - " I", int(controllerFan.settings.idle_speed), - " A", int(controllerFan.settings.auto_mode), - " D", controllerFan.settings.duration, - " ; (", (int(controllerFan.settings.active_speed) * 100) / 255, "%" - " ", (int(controllerFan.settings.idle_speed) * 100) / 255, "%)" - ); -} - /** * M710: Set controller fan settings * @@ -78,4 +66,16 @@ void GcodeSuite::M710() { M710_report(); } +void GcodeSuite::M710_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_CONTROLLER_FAN)); + SERIAL_ECHOLNPAIR(" M710" + " S", int(controllerFan.settings.active_speed), + " I", int(controllerFan.settings.idle_speed), + " A", int(controllerFan.settings.auto_mode), + " D", controllerFan.settings.duration, + " ; (", (int(controllerFan.settings.active_speed) * 100) / 255, "%" + " ", (int(controllerFan.settings.idle_speed) * 100) / 255, "%)" + ); +} + #endif // CONTROLLER_FAN_EDITABLE diff --git a/Marlin/src/gcode/feature/digipot/M907-M910.cpp b/Marlin/src/gcode/feature/digipot/M907-M910.cpp index bd741f8a64b4..cde73ff271b8 100644 --- a/Marlin/src/gcode/feature/digipot/M907-M910.cpp +++ b/Marlin/src/gcode/feature/digipot/M907-M910.cpp @@ -22,7 +22,7 @@ #include "../../../inc/MarlinConfig.h" -#if ANY(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_PWM, HAS_MOTOR_CURRENT_I2C, HAS_MOTOR_CURRENT_DAC) +#if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM || HAS_MOTOR_CURRENT_I2C || HAS_MOTOR_CURRENT_DAC #include "../../gcode.h" @@ -44,12 +44,27 @@ void GcodeSuite::M907() { #if HAS_MOTOR_CURRENT_SPI + if (!parser.seen("BS" LOGICAL_AXES_STRING)) + return M907_report(); + LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper.set_digipot_current(i, parser.value_int()); if (parser.seenval('B')) stepper.set_digipot_current(4, parser.value_int()); if (parser.seenval('S')) LOOP_LE_N(i, 4) stepper.set_digipot_current(i, parser.value_int()); #elif HAS_MOTOR_CURRENT_PWM + if (!parser.seen( + #if ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY) + "XY" + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) + "Z" + #endif + #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) + "E" + #endif + )) return M907_report(); + #if ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY) if (parser.seenval('X') || parser.seenval('Y')) stepper.set_digipot_current(0, parser.value_int()); #endif @@ -82,7 +97,30 @@ void GcodeSuite::M907() { #endif } -#if EITHER(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_DAC) +#if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM + + void GcodeSuite::M907_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_STEPPER_MOTOR_CURRENTS)); + #if HAS_MOTOR_CURRENT_PWM + SERIAL_ECHOLNPAIR_P( // PWM-based has 3 values: + PSTR(" M907 X"), stepper.motor_current_setting[0] // X and Y + , SP_Z_STR, stepper.motor_current_setting[1] // Z + , SP_E_STR, stepper.motor_current_setting[2] // E + ); + #elif HAS_MOTOR_CURRENT_SPI + SERIAL_ECHOPGM(" M907"); // SPI-based has 5 values: + LOOP_LOGICAL_AXES(q) { // X Y Z (I J K) E (map to X Y Z (I J K) E0 by default) + SERIAL_CHAR(' ', axis_codes[q]); + SERIAL_ECHO(stepper.motor_current_setting[q]); + } + SERIAL_CHAR(' ', 'B'); // B (maps to E1 by default) + SERIAL_ECHOLN(stepper.motor_current_setting[4]); + #endif + } + +#endif // HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM + +#if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_DAC /** * M908: Control digital trimpot directly (M908 P S) diff --git a/Marlin/src/gcode/feature/fwretract/M207-M209.cpp b/Marlin/src/gcode/feature/fwretract/M207-M209.cpp index 5793d73f948c..040a09a8e090 100644 --- a/Marlin/src/gcode/feature/fwretract/M207-M209.cpp +++ b/Marlin/src/gcode/feature/fwretract/M207-M209.cpp @@ -29,14 +29,34 @@ /** * M207: Set firmware retraction values + * + * S[+units] retract_length + * W[+units] swap_retract_length (multi-extruder) + * F[units/min] retract_feedrate_mm_s + * Z[units] retract_zraise */ void GcodeSuite::M207() { fwretract.M207(); } +void GcodeSuite::M207_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_RETRACT_S_F_Z)); + fwretract.M207_report(); +} + /** * M208: Set firmware un-retraction values + * + * S[+units] retract_recover_extra (in addition to M207 S*) + * W[+units] swap_retract_recover_extra (multi-extruder) + * F[units/min] retract_recover_feedrate_mm_s + * R[units/min] swap_retract_recover_feedrate_mm_s */ void GcodeSuite::M208() { fwretract.M208(); } +void GcodeSuite::M208_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_RECOVER_S_F)); + fwretract.M208_report(); +} + #if ENABLED(FWRETRACT_AUTORETRACT) /** @@ -47,6 +67,11 @@ void GcodeSuite::M208() { fwretract.M208(); } */ void GcodeSuite::M209() { fwretract.M209(); } + void GcodeSuite::M209_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_AUTO_RETRACT_S)); + fwretract.M209_report(); + } + #endif #endif // FWRETRACT diff --git a/Marlin/src/gcode/feature/network/M552-M554.cpp b/Marlin/src/gcode/feature/network/M552-M554.cpp index 22c718c04228..887e67f3bde0 100644 --- a/Marlin/src/gcode/feature/network/M552-M554.cpp +++ b/Marlin/src/gcode/feature/network/M552-M554.cpp @@ -64,17 +64,7 @@ void ip_report(const uint16_t cmd, PGM_P const post, const IPAddress &ipo) { if (i < 3) SERIAL_CHAR('.'); } SERIAL_ECHOPGM(" ; "); - SERIAL_ECHOPGM_P(post); - SERIAL_EOL(); -} -void M552_report() { - ip_report(552, PSTR("ip address"), Ethernet.linkStatus() == LinkON ? Ethernet.localIP() : ethernet.ip); -} -void M553_report() { - ip_report(553, PSTR("subnet mask"), Ethernet.linkStatus() == LinkON ? Ethernet.subnetMask() : ethernet.subnet); -} -void M554_report() { - ip_report(554, PSTR("gateway"), Ethernet.linkStatus() == LinkON ? Ethernet.gatewayIP() : ethernet.gateway); + SERIAL_ECHOLNPGM_P(post); } /** @@ -107,20 +97,36 @@ void GcodeSuite::M552() { if (nopar || seenP) M552_report(); } +void GcodeSuite::M552_report() { + ip_report(552, PSTR("ip address"), Ethernet.linkStatus() == LinkON ? Ethernet.localIP() : ethernet.ip); +} + /** * M553 Pnnn - Set netmask */ void GcodeSuite::M553() { - if (parser.seenval('P')) ethernet.subnet.fromString(parser.value_string()); - M553_report(); + if (parser.seenval('P')) + ethernet.subnet.fromString(parser.value_string()); + else + M553_report(); +} + +void GcodeSuite::M553_report() { + ip_report(553, PSTR("subnet mask"), Ethernet.linkStatus() == LinkON ? Ethernet.subnetMask() : ethernet.subnet); } /** * M554 Pnnn - Set Gateway */ void GcodeSuite::M554() { - if (parser.seenval('P')) ethernet.gateway.fromString(parser.value_string()); - M554_report(); + if (parser.seenval('P')) + ethernet.gateway.fromString(parser.value_string()); + else + M554_report(); +} + +void GcodeSuite::M554_report() { + ip_report(554, PSTR("gateway"), Ethernet.linkStatus() == LinkON ? Ethernet.gatewayIP() : ethernet.gateway); } #endif // HAS_ETHERNET diff --git a/Marlin/src/gcode/feature/pause/M603.cpp b/Marlin/src/gcode/feature/pause/M603.cpp index 9c3b774bd2b2..e26ab1c7b4c4 100644 --- a/Marlin/src/gcode/feature/pause/M603.cpp +++ b/Marlin/src/gcode/feature/pause/M603.cpp @@ -42,6 +42,8 @@ */ void GcodeSuite::M603() { + if (!parser.seen("TUL")) return M603_report(); + const int8_t target_extruder = get_target_extruder_from_command(); if (target_extruder < 0) return; @@ -62,4 +64,20 @@ void GcodeSuite::M603() { } } +void GcodeSuite::M603_report(const bool forReplay/*=true*/) { + report_heading(forReplay, PSTR(STR_FILAMENT_LOAD_UNLOAD)); + + #if EXTRUDERS == 1 + report_echo_start(forReplay); + SERIAL_ECHOPAIR(" M603 L", LINEAR_UNIT(fc_settings[0].load_length), " U", LINEAR_UNIT(fc_settings[0].unload_length), " ;"); + say_units(); + #else + LOOP_L_N(e, EXTRUDERS) { + report_echo_start(forReplay); + SERIAL_ECHOPAIR(" M603 T", e, " L", LINEAR_UNIT(fc_settings[e].load_length), " U", LINEAR_UNIT(fc_settings[e].unload_length), " ;"); + say_units(); + } + #endif +} + #endif // ADVANCED_PAUSE_FEATURE diff --git a/Marlin/src/gcode/feature/powerloss/M413.cpp b/Marlin/src/gcode/feature/powerloss/M413.cpp index 18aeb507b1cf..b1be80619fc2 100644 --- a/Marlin/src/gcode/feature/powerloss/M413.cpp +++ b/Marlin/src/gcode/feature/powerloss/M413.cpp @@ -40,11 +40,8 @@ void GcodeSuite::M413() { if (parser.seen('S')) recovery.enable(parser.value_bool()); - else { - SERIAL_ECHO_START(); - SERIAL_ECHOPGM("Power-loss recovery "); - serialprintln_onoff(recovery.enabled); - } + else + M413_report(); #if ENABLED(DEBUG_POWER_LOSS_RECOVERY) if (parser.seen("RL")) recovery.load(); @@ -59,4 +56,10 @@ void GcodeSuite::M413() { #endif } +void GcodeSuite::M413_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_POWER_LOSS_RECOVERY)); + SERIAL_ECHOPAIR(" M413 S", AS_DIGIT(recovery.enabled), " ; "); + serialprintln_onoff(recovery.enabled); +} + #endif // POWER_LOSS_RECOVERY diff --git a/Marlin/src/gcode/feature/runout/M412.cpp b/Marlin/src/gcode/feature/runout/M412.cpp index 9a063571326f..56c7f03604ad 100644 --- a/Marlin/src/gcode/feature/runout/M412.cpp +++ b/Marlin/src/gcode/feature/runout/M412.cpp @@ -66,4 +66,16 @@ void GcodeSuite::M412() { } } +void GcodeSuite::M412_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_FILAMENT_RUNOUT_SENSOR)); + SERIAL_ECHOLNPAIR( + " M412 S", runout.enabled + #if HAS_FILAMENT_RUNOUT_DISTANCE + , " D", LINEAR_UNIT(runout.runout_distance()) + #endif + , " ; Sensor " + ); + serialprintln_onoff(runout.enabled); +} + #endif // HAS_FILAMENT_SENSOR diff --git a/Marlin/src/gcode/feature/trinamic/M569.cpp b/Marlin/src/gcode/feature/trinamic/M569.cpp index 9a7f1fbce902..5cadd2d45ea7 100644 --- a/Marlin/src/gcode/feature/trinamic/M569.cpp +++ b/Marlin/src/gcode/feature/trinamic/M569.cpp @@ -138,4 +138,66 @@ void GcodeSuite::M569() { say_stealth_status(); } +void GcodeSuite::M569_report(const bool forReplay/*=true*/) { + report_heading(forReplay, PSTR(STR_DRIVER_STEPPING_MODE)); + + auto say_M569 = [](const bool forReplay, const char * const etc=nullptr, const bool eol=false) { + if (!forReplay) SERIAL_ECHO_START(); + SERIAL_ECHOPGM(" M569 S1"); + if (etc) { + SERIAL_CHAR(' '); + SERIAL_ECHOPGM_P(etc); + } + if (eol) SERIAL_EOL(); + }; + + const bool chop_x = TERN0(X_HAS_STEALTHCHOP, stepperX.get_stored_stealthChop()), + chop_y = TERN0(Y_HAS_STEALTHCHOP, stepperY.get_stored_stealthChop()), + chop_z = TERN0(Z_HAS_STEALTHCHOP, stepperZ.get_stored_stealthChop()), + chop_i = TERN0(I_HAS_STEALTHCHOP, stepperI.get_stored_stealthChop()), + chop_j = TERN0(J_HAS_STEALTHCHOP, stepperJ.get_stored_stealthChop()), + chop_k = TERN0(K_HAS_STEALTHCHOP, stepperK.get_stored_stealthChop()); + + if (chop_x || chop_y || chop_z || chop_i || chop_j || chop_k) { + say_M569(forReplay); + LINEAR_AXIS_CODE( + if (chop_x) SERIAL_ECHOPGM_P(SP_X_STR), + if (chop_y) SERIAL_ECHOPGM_P(SP_Y_STR), + if (chop_z) SERIAL_ECHOPGM_P(SP_Z_STR), + if (chop_i) SERIAL_ECHOPGM_P(SP_I_STR), + if (chop_j) SERIAL_ECHOPGM_P(SP_J_STR), + if (chop_k) SERIAL_ECHOPGM_P(SP_K_STR) + ); + SERIAL_EOL(); + } + + const bool chop_x2 = TERN0(X2_HAS_STEALTHCHOP, stepperX2.get_stored_stealthChop()), + chop_y2 = TERN0(Y2_HAS_STEALTHCHOP, stepperY2.get_stored_stealthChop()), + chop_z2 = TERN0(Z2_HAS_STEALTHCHOP, stepperZ2.get_stored_stealthChop()); + + if (chop_x2 || chop_y2 || chop_z2) { + say_M569(forReplay, PSTR("I1")); + if (chop_x2) SERIAL_ECHOPGM_P(SP_X_STR); + if (chop_y2) SERIAL_ECHOPGM_P(SP_Y_STR); + if (chop_z2) SERIAL_ECHOPGM_P(SP_Z_STR); + SERIAL_EOL(); + } + + if (TERN0(Z3_HAS_STEALTHCHOP, stepperZ3.get_stored_stealthChop())) { say_M569(forReplay, PSTR("I2 Z"), true); } + if (TERN0(Z4_HAS_STEALTHCHOP, stepperZ4.get_stored_stealthChop())) { say_M569(forReplay, PSTR("I3 Z"), true); } + + if (TERN0( I_HAS_STEALTHCHOP, stepperI.get_stored_stealthChop())) { say_M569(forReplay, SP_I_STR, true); } + if (TERN0( J_HAS_STEALTHCHOP, stepperJ.get_stored_stealthChop())) { say_M569(forReplay, SP_J_STR, true); } + if (TERN0( K_HAS_STEALTHCHOP, stepperK.get_stored_stealthChop())) { say_M569(forReplay, SP_K_STR, true); } + + if (TERN0(E0_HAS_STEALTHCHOP, stepperE0.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T0 E"), true); } + if (TERN0(E1_HAS_STEALTHCHOP, stepperE1.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T1 E"), true); } + if (TERN0(E2_HAS_STEALTHCHOP, stepperE2.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T2 E"), true); } + if (TERN0(E3_HAS_STEALTHCHOP, stepperE3.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T3 E"), true); } + if (TERN0(E4_HAS_STEALTHCHOP, stepperE4.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T4 E"), true); } + if (TERN0(E5_HAS_STEALTHCHOP, stepperE5.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T5 E"), true); } + if (TERN0(E6_HAS_STEALTHCHOP, stepperE6.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T6 E"), true); } + if (TERN0(E7_HAS_STEALTHCHOP, stepperE7.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T7 E"), true); } +} + #endif // HAS_STEALTHCHOP diff --git a/Marlin/src/gcode/feature/trinamic/M906.cpp b/Marlin/src/gcode/feature/trinamic/M906.cpp index 9e56e513581d..243cf4656040 100644 --- a/Marlin/src/gcode/feature/trinamic/M906.cpp +++ b/Marlin/src/gcode/feature/trinamic/M906.cpp @@ -198,4 +198,99 @@ void GcodeSuite::M906() { } } +void GcodeSuite::M906_report(const bool forReplay/*=true*/) { + report_heading(forReplay, PSTR(STR_STEPPER_DRIVER_CURRENT)); + + auto say_M906 = [](const bool forReplay) { + report_echo_start(forReplay); + SERIAL_ECHOPGM(" M906"); + }; + + #if AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) + say_M906(forReplay); + #if AXIS_IS_TMC(X) + SERIAL_ECHOPAIR_P(SP_X_STR, stepperX.getMilliamps()); + #endif + #if AXIS_IS_TMC(Y) + SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY.getMilliamps()); + #endif + #if AXIS_IS_TMC(Z) + SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ.getMilliamps()); + #endif + SERIAL_EOL(); + #endif + + #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) + say_M906(forReplay); + SERIAL_ECHOPGM(" I1"); + #if AXIS_IS_TMC(X2) + SERIAL_ECHOPAIR_P(SP_X_STR, stepperX2.getMilliamps()); + #endif + #if AXIS_IS_TMC(Y2) + SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY2.getMilliamps()); + #endif + #if AXIS_IS_TMC(Z2) + SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ2.getMilliamps()); + #endif + SERIAL_EOL(); + #endif + + #if AXIS_IS_TMC(Z3) + say_M906(forReplay); + SERIAL_ECHOLNPAIR(" I2 Z", stepperZ3.getMilliamps()); + #endif + + #if AXIS_IS_TMC(Z4) + say_M906(forReplay); + SERIAL_ECHOLNPAIR(" I3 Z", stepperZ4.getMilliamps()); + #endif + + #if AXIS_IS_TMC(I) + say_M906(forReplay); + SERIAL_ECHOLNPAIR_P(SP_I_STR, stepperI.getMilliamps()); + #endif + #if AXIS_IS_TMC(J) + say_M906(forReplay); + SERIAL_ECHOLNPAIR_P(SP_J_STR, stepperJ.getMilliamps()); + #endif + #if AXIS_IS_TMC(K) + say_M906(forReplay); + SERIAL_ECHOLNPAIR_P(SP_K_STR, stepperK.getMilliamps()); + #endif + + #if AXIS_IS_TMC(E0) + say_M906(forReplay); + SERIAL_ECHOLNPAIR(" T0 E", stepperE0.getMilliamps()); + #endif + #if AXIS_IS_TMC(E1) + say_M906(forReplay); + SERIAL_ECHOLNPAIR(" T1 E", stepperE1.getMilliamps()); + #endif + #if AXIS_IS_TMC(E2) + say_M906(forReplay); + SERIAL_ECHOLNPAIR(" T2 E", stepperE2.getMilliamps()); + #endif + #if AXIS_IS_TMC(E3) + say_M906(forReplay); + SERIAL_ECHOLNPAIR(" T3 E", stepperE3.getMilliamps()); + #endif + #if AXIS_IS_TMC(E4) + say_M906(forReplay); + SERIAL_ECHOLNPAIR(" T4 E", stepperE4.getMilliamps()); + #endif + #if AXIS_IS_TMC(E5) + say_M906(forReplay); + SERIAL_ECHOLNPAIR(" T5 E", stepperE5.getMilliamps()); + #endif + #if AXIS_IS_TMC(E6) + say_M906(forReplay); + SERIAL_ECHOLNPAIR(" T6 E", stepperE6.getMilliamps()); + #endif + #if AXIS_IS_TMC(E7) + say_M906(forReplay); + SERIAL_ECHOLNPAIR(" T7 E", stepperE7.getMilliamps()); + #endif + SERIAL_EOL(); +} + #endif // HAS_TRINAMIC_CONFIG diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index fca16c063025..d711865480d1 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -227,6 +227,7 @@ * M913: Set HYBRID_THRESHOLD speed. */ #if ENABLED(HYBRID_THRESHOLD) + void GcodeSuite::M913() { #define TMC_SAY_PWMTHRS(A,Q) tmc_print_pwmthrs(stepper##Q) #define TMC_SET_PWMTHRS(A,Q) stepper##Q.set_pwm_thrs(value) @@ -308,12 +309,109 @@ TERN_(E7_HAS_STEALTHCHOP, TMC_SAY_PWMTHRS_E(7)); } } + + void GcodeSuite::M913_report(const bool forReplay/*=true*/) { + report_heading(forReplay, PSTR(STR_HYBRID_THRESHOLD)); + + auto say_M913 = [](const bool forReplay) { + report_echo_start(forReplay); + SERIAL_ECHOPGM(" M913"); + }; + + #if X_HAS_STEALTHCHOP || Y_HAS_STEALTHCHOP || Z_HAS_STEALTHCHOP + say_M913(forReplay); + #if X_HAS_STEALTHCHOP + SERIAL_ECHOPAIR_P(SP_X_STR, stepperX.get_pwm_thrs()); + #endif + #if Y_HAS_STEALTHCHOP + SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY.get_pwm_thrs()); + #endif + #if Z_HAS_STEALTHCHOP + SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ.get_pwm_thrs()); + #endif + SERIAL_EOL(); + #endif + + #if X2_HAS_STEALTHCHOP || Y2_HAS_STEALTHCHOP || Z2_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOPGM(" I1"); + #if X2_HAS_STEALTHCHOP + SERIAL_ECHOPAIR_P(SP_X_STR, stepperX2.get_pwm_thrs()); + #endif + #if Y2_HAS_STEALTHCHOP + SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY2.get_pwm_thrs()); + #endif + #if Z2_HAS_STEALTHCHOP + SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ2.get_pwm_thrs()); + #endif + SERIAL_EOL(); + #endif + + #if Z3_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPAIR(" I2 Z", stepperZ3.get_pwm_thrs()); + #endif + + #if Z4_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPAIR(" I3 Z", stepperZ4.get_pwm_thrs()); + #endif + + #if I_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPAIR_P(SP_I_STR, stepperI.get_pwm_thrs()); + #endif + #if J_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPAIR_P(SP_J_STR, stepperJ.get_pwm_thrs()); + #endif + #if K_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPAIR_P(SP_K_STR, stepperK.get_pwm_thrs()); + #endif + + #if E0_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPAIR(" T0 E", stepperE0.get_pwm_thrs()); + #endif + #if E1_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPAIR(" T1 E", stepperE1.get_pwm_thrs()); + #endif + #if E2_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPAIR(" T2 E", stepperE2.get_pwm_thrs()); + #endif + #if E3_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPAIR(" T3 E", stepperE3.get_pwm_thrs()); + #endif + #if E4_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPAIR(" T4 E", stepperE4.get_pwm_thrs()); + #endif + #if E5_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPAIR(" T5 E", stepperE5.get_pwm_thrs()); + #endif + #if E6_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPAIR(" T6 E", stepperE6.get_pwm_thrs()); + #endif + #if E7_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPAIR(" T7 E", stepperE7.get_pwm_thrs()); + #endif + SERIAL_EOL(); + } + #endif // HYBRID_THRESHOLD /** * M914: Set StallGuard sensitivity. */ #if USE_SENSORLESS + void GcodeSuite::M914() { bool report = true; @@ -412,6 +510,68 @@ #endif } } + + void GcodeSuite::M914_report(const bool forReplay/*=true*/) { + report_heading(forReplay, PSTR(STR_STALLGUARD_THRESHOLD)); + + auto say_M914 = [](const bool forReplay) { + report_echo_start(forReplay); + SERIAL_ECHOPGM(" M914"); + }; + + #if X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS + say_M914(forReplay); + #if X_SENSORLESS + SERIAL_ECHOPAIR_P(SP_X_STR, stepperX.homing_threshold()); + #endif + #if Y_SENSORLESS + SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY.homing_threshold()); + #endif + #if Z_SENSORLESS + SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ.homing_threshold()); + #endif + SERIAL_EOL(); + #endif + + #if X2_SENSORLESS || Y2_SENSORLESS || Z2_SENSORLESS + say_M914(forReplay); + SERIAL_ECHOPGM(" I1"); + #if X2_SENSORLESS + SERIAL_ECHOPAIR_P(SP_X_STR, stepperX2.homing_threshold()); + #endif + #if Y2_SENSORLESS + SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY2.homing_threshold()); + #endif + #if Z2_SENSORLESS + SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ2.homing_threshold()); + #endif + SERIAL_EOL(); + #endif + + #if Z3_SENSORLESS + say_M914(forReplay); + SERIAL_ECHOLNPAIR(" I2 Z", stepperZ3.homing_threshold()); + #endif + + #if Z4_SENSORLESS + say_M914(forReplay); + SERIAL_ECHOLNPAIR(" I3 Z", stepperZ4.homing_threshold()); + #endif + + #if I_SENSORLESS + say_M914(forReplay); + SERIAL_ECHOLNPAIR_P(SP_I_STR, stepperI.homing_threshold()); + #endif + #if J_SENSORLESS + say_M914(forReplay); + SERIAL_ECHOLNPAIR_P(SP_J_STR, stepperJ.homing_threshold()); + #endif + #if K_SENSORLESS + say_M914(forReplay); + SERIAL_ECHOLNPAIR_P(SP_K_STR, stepperK.homing_threshold()); + #endif + } + #endif // USE_SENSORLESS #endif // HAS_TRINAMIC_CONFIG diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 94496f2b2576..4c03fd9f85ac 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -102,6 +102,24 @@ uint8_t GcodeSuite::axis_relative = 0 LOGICAL_AXIS_GANG( xyz_pos_t GcodeSuite::coordinate_system[MAX_COORDINATE_SYSTEMS]; #endif +void GcodeSuite::report_echo_start(const bool forReplay) { if (!forReplay) SERIAL_ECHO_START(); } +void GcodeSuite::report_heading(const bool forReplay, PGM_P const pstr, const bool eol/*=true*/) { + if (forReplay) return; + if (pstr) { + SERIAL_ECHO_START(); + SERIAL_ECHOPGM("; "); + SERIAL_ECHOPGM_P(pstr); + } + if (eol) { SERIAL_CHAR(':'); SERIAL_EOL(); } +} + +void GcodeSuite::say_units() { + SERIAL_ECHOLNPGM_P( + TERN_(INCH_MODE_SUPPORT, parser.linear_unit_factor != 1.0 ? PSTR(" (in)") :) + PSTR(" (mm)") + ); +} + /** * Get the target extruder from the T parameter or the active_extruder * Return -1 if the T parameter is out of range @@ -180,7 +198,7 @@ void GcodeSuite::get_destination_from_command() { recovery.save(); #endif - if (parser.linearval('F') > 0) + if (parser.floatval('F') > 0) feedrate_mm_s = parser.value_feedrate(); #if ENABLED(PRINTCOUNTER) diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index ec921052840f..16cee3481db0 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -379,6 +379,14 @@ class GcodeSuite { return ELAPSED(ms, previous_move_ms + stepper_inactive_time); } + static void report_echo_start(const bool forReplay); + static void report_heading(const bool forReplay, PGM_P const pstr, const bool eol=true); + static inline void report_heading_etc(const bool forReplay, PGM_P const pstr, const bool eol=true) { + report_heading(forReplay, pstr, eol); + report_echo_start(forReplay); + } + static void say_units(); + static int8_t get_target_extruder_from_command(); static int8_t get_target_e_stepper_from_command(); static void get_destination_from_command(); @@ -434,6 +442,8 @@ class GcodeSuite { private: + friend class MarlinSettings; + #if ENABLED(MARLIN_DEV_MODE) static void D(const int16_t dcode); #endif @@ -514,6 +524,7 @@ class GcodeSuite { #if ENABLED(Z_STEPPER_AUTO_ALIGN) static void M422(); + static void M422_report(const bool forReplay=true); #endif #if ENABLED(ASSISTED_TRAMMING) @@ -658,6 +669,7 @@ class GcodeSuite { static void M85(); static void M92(); + static void M92_report(const bool forReplay=true, const int8_t e=-1); #if ENABLED(M100_FREE_MEMORY_WATCHER) static void M100(); @@ -737,10 +749,12 @@ class GcodeSuite { #if PREHEAT_COUNT static void M145(); + static void M145_report(const bool forReplay=true); #endif #if ENABLED(TEMPERATURE_UNITS_SUPPORT) static void M149(); + static void M149_report(const bool forReplay=true); #endif #if HAS_COLOR_LEDS @@ -766,37 +780,51 @@ class GcodeSuite { #endif #endif - static void M200(); + #if DISABLED(NO_VOLUMETRICS) + static void M200(); + static void M200_report(const bool forReplay=true); + #endif static void M201(); + static void M201_report(const bool forReplay=true); #if 0 static void M202(); // Not used for Sprinter/grbl gen6 #endif static void M203(); + static void M203_report(const bool forReplay=true); static void M204(); + static void M204_report(const bool forReplay=true); static void M205(); + static void M205_report(const bool forReplay=true); #if HAS_M206_COMMAND static void M206(); + static void M206_report(const bool forReplay=true); #endif #if ENABLED(FWRETRACT) static void M207(); + static void M207_report(const bool forReplay=true); static void M208(); + static void M208_report(const bool forReplay=true); #if ENABLED(FWRETRACT_AUTORETRACT) static void M209(); + static void M209_report(const bool forReplay=true); #endif #endif static void M211(); + static void M211_report(const bool forReplay=true); #if HAS_MULTI_EXTRUDER static void M217(); + static void M217_report(const bool forReplay=true); #endif #if HAS_HOTEND_OFFSET static void M218(); + static void M218_report(const bool forReplay=true); #endif static void M220(); @@ -815,10 +843,12 @@ class GcodeSuite { #if HAS_LCD_CONTRAST static void M250(); + static void M250_report(const bool forReplay=true); #endif #if HAS_LCD_BRIGHTNESS static void M256(); + static void M256_report(const bool forReplay=true); #endif #if ENABLED(EXPERIMENTAL_I2CBUS) @@ -830,6 +860,7 @@ class GcodeSuite { static void M280(); #if ENABLED(EDITABLE_SERVO_ANGLES) static void M281(); + static void M281_report(const bool forReplay=true); #endif #endif @@ -843,6 +874,7 @@ class GcodeSuite { #if ENABLED(PIDTEMP) static void M301(); + static void M301_report(const bool forReplay=true, const int8_t eindex=-1); #endif #if ENABLED(PREVENT_COLD_EXTRUSION) @@ -855,6 +887,7 @@ class GcodeSuite { #if ENABLED(PIDTEMPBED) static void M304(); + static void M304_report(const bool forReplay=true); #endif #if HAS_USER_THERMISTORS @@ -863,6 +896,7 @@ class GcodeSuite { #if ENABLED(PIDTEMPCHAMBER) static void M309(); + static void M309_report(const bool forReplay=true); #endif #if HAS_MICROSTEPS @@ -911,19 +945,23 @@ class GcodeSuite { #if HAS_FILAMENT_SENSOR static void M412(); + static void M412_report(const bool forReplay=true); #endif #if HAS_MULTI_LANGUAGE static void M414(); + static void M414_report(const bool forReplay=true); #endif #if HAS_LEVELING static void M420(); + static void M420_report(const bool forReplay=true); static void M421(); #endif #if ENABLED(BACKLASH_GCODE) static void M425(); + static void M425_report(const bool forReplay=true); #endif #if HAS_M206_COMMAND @@ -968,8 +1006,16 @@ class GcodeSuite { #if HAS_ETHERNET static void M552(); + static void M552_report(); static void M553(); + static void M553_report(); static void M554(); + static void M554_report(); + #endif + + #if HAS_STEALTHCHOP + static void M569(); + static void M569_report(const bool forReplay=true); #endif #if ENABLED(BAUD_RATE_GCODE) @@ -979,6 +1025,7 @@ class GcodeSuite { #if ENABLED(ADVANCED_PAUSE_FEATURE) static void M600(); static void M603(); + static void M603_report(const bool forReplay=true); #endif #if HAS_DUPLICATION_MODE @@ -987,10 +1034,12 @@ class GcodeSuite { #if IS_KINEMATIC static void M665(); + static void M665_report(const bool forReplay=true); #endif - #if ENABLED(DELTA) || HAS_EXTRA_ENDSTOPS + #if EITHER(DELTA, HAS_EXTRA_ENDSTOPS) static void M666(); + static void M666_report(const bool forReplay=true); #endif #if ENABLED(DUET_SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD) @@ -1012,10 +1061,12 @@ class GcodeSuite { #if HAS_BED_PROBE static void M851(); + static void M851_report(const bool forReplay=true); #endif #if ENABLED(SKEW_CORRECTION_GCODE) static void M852(); + static void M852_report(const bool forReplay=true); #endif #if ENABLED(I2C_POSITION_ENCODERS) @@ -1038,23 +1089,24 @@ class GcodeSuite { #if ENABLED(LIN_ADVANCE) static void M900(); + static void M900_report(const bool forReplay=true); #endif #if HAS_TRINAMIC_CONFIG static void M122(); static void M906(); - #if HAS_STEALTHCHOP - static void M569(); - #endif + static void M906_report(const bool forReplay=true); #if ENABLED(MONITOR_DRIVER_STATUS) static void M911(); static void M912(); #endif #if ENABLED(HYBRID_THRESHOLD) static void M913(); + static void M913_report(const bool forReplay=true); #endif #if ENABLED(USE_SENSORLESS) static void M914(); + static void M914_report(const bool forReplay=true); #endif #endif @@ -1066,16 +1118,19 @@ class GcodeSuite { static void M918(); #endif - #if ANY(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_PWM, HAS_MOTOR_CURRENT_I2C, HAS_MOTOR_CURRENT_DAC) + #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM || HAS_MOTOR_CURRENT_I2C || HAS_MOTOR_CURRENT_DAC static void M907(); - #if EITHER(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_DAC) - static void M908(); - #if HAS_MOTOR_CURRENT_DAC - static void M909(); - static void M910(); - #endif + #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM + static void M907_report(const bool forReplay=true); #endif #endif + #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_DAC + static void M908(); + #endif + #if HAS_MOTOR_CURRENT_DAC + static void M909(); + static void M910(); + #endif #if ENABLED(SDSUPPORT) static void M928(); @@ -1102,6 +1157,7 @@ class GcodeSuite { #if ENABLED(POWER_LOSS_RECOVERY) static void M413(); + static void M413_report(const bool forReplay=true); static void M1000(); #endif @@ -1123,6 +1179,7 @@ class GcodeSuite { #if ENABLED(CONTROLLER_FAN_EDITABLE) static void M710(); + static void M710_report(const bool forReplay=true); #endif static void T(const int8_t tool_index); diff --git a/Marlin/src/gcode/geometry/M206_M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp index 51f3e7c14c04..ce142dacdfd1 100644 --- a/Marlin/src/gcode/geometry/M206_M428.cpp +++ b/Marlin/src/gcode/geometry/M206_M428.cpp @@ -30,19 +30,6 @@ #include "../../libs/buzzer.h" #include "../../MarlinCore.h" -void M206_report() { - SERIAL_ECHOLNPAIR_P( - LIST_N(DOUBLE(LINEAR_AXES), - PSTR("M206 X"), home_offset.x, - SP_Y_STR, home_offset.y, - SP_Z_STR, home_offset.z, - SP_I_STR, home_offset.i, - SP_J_STR, home_offset.j, - SP_K_STR, home_offset.k, - ) - ); -} - /** * M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y * @@ -51,6 +38,8 @@ void M206_report() { * *** In the 2.0 release, it will simply be disabled by default. */ void GcodeSuite::M206() { + if (!parser.seen_any()) return M206_report(); + LOOP_LINEAR_AXES(i) if (parser.seen(AXIS_CHAR(i))) set_home_offset((AxisEnum)i, parser.value_linear_units()); @@ -60,10 +49,25 @@ void GcodeSuite::M206() { if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_float()); // Psi #endif - if (!parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", "I", "J", "K"))) - M206_report(); - else - report_current_position(); + report_current_position(); +} + +void GcodeSuite::M206_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_HOME_OFFSET)); + SERIAL_ECHOLNPAIR_P( + #if IS_CARTESIAN + LIST_N(DOUBLE(LINEAR_AXES), + PSTR(" M206 X"), LINEAR_UNIT(home_offset.x), + SP_Y_STR, LINEAR_UNIT(home_offset.y), + SP_Z_STR, LINEAR_UNIT(home_offset.z), + SP_I_STR, LINEAR_UNIT(home_offset.i), + SP_J_STR, LINEAR_UNIT(home_offset.j), + SP_K_STR, LINEAR_UNIT(home_offset.k) + ) + #else + PSTR(" M206 Z"), LINEAR_UNIT(home_offset.z) + #endif + ); } /** diff --git a/Marlin/src/gcode/lcd/M145.cpp b/Marlin/src/gcode/lcd/M145.cpp index d6a57d22157e..cbd752d24572 100644 --- a/Marlin/src/gcode/lcd/M145.cpp +++ b/Marlin/src/gcode/lcd/M145.cpp @@ -60,4 +60,23 @@ void GcodeSuite::M145() { } } +void GcodeSuite::M145_report(const bool forReplay/*=true*/) { + report_heading(forReplay, PSTR(STR_MATERIAL_HEATUP)); + LOOP_L_N(i, PREHEAT_COUNT) { + report_echo_start(forReplay); + SERIAL_ECHOLNPAIR_P( + PSTR(" M145 S"), i + #if HAS_HOTEND + , PSTR(" H"), parser.to_temp_units(ui.material_preset[i].hotend_temp) + #endif + #if HAS_HEATED_BED + , SP_B_STR, parser.to_temp_units(ui.material_preset[i].bed_temp) + #endif + #if HAS_FAN + , PSTR(" F"), ui.material_preset[i].fan_speed + #endif + ); + } +} + #endif // PREHEAT_COUNT diff --git a/Marlin/src/gcode/lcd/M250.cpp b/Marlin/src/gcode/lcd/M250.cpp index f553044d31c0..2b7e3dc994e2 100644 --- a/Marlin/src/gcode/lcd/M250.cpp +++ b/Marlin/src/gcode/lcd/M250.cpp @@ -19,7 +19,6 @@ * along with this program. If not, see . * */ - #include "../../inc/MarlinConfig.h" #if HAS_LCD_CONTRAST @@ -31,8 +30,15 @@ * M250: Read and optionally set the LCD contrast */ void GcodeSuite::M250() { - if (parser.seen('C')) ui.set_contrast(parser.value_int()); - SERIAL_ECHOLNPAIR("LCD Contrast: ", ui.contrast); + if (parser.seenval('C')) + ui.set_contrast(parser.value_int()); + else + M250_report(); +} + +void GcodeSuite::M250_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_LCD_CONTRAST)); + SERIAL_ECHOLNPAIR(" M250 C", ui.contrast); } #endif // HAS_LCD_CONTRAST diff --git a/Marlin/src/gcode/lcd/M256.cpp b/Marlin/src/gcode/lcd/M256.cpp index e292acc4ed44..ff7c59fc9a9b 100644 --- a/Marlin/src/gcode/lcd/M256.cpp +++ b/Marlin/src/gcode/lcd/M256.cpp @@ -30,8 +30,15 @@ * M256: Set the LCD brightness */ void GcodeSuite::M256() { - if (parser.seenval('B')) ui.set_brightness(parser.value_int()); - SERIAL_ECHOLNPAIR("LCD Brightness: ", ui.brightness); + if (parser.seenval('B')) + ui.set_brightness(parser.value_int()); + else + M256_report(); +} + +void GcodeSuite::M256_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_LCD_BRIGHTNESS)); + SERIAL_ECHOLNPAIR(" M256 B", ui.brightness); } #endif // HAS_LCD_BRIGHTNESS diff --git a/Marlin/src/gcode/lcd/M414.cpp b/Marlin/src/gcode/lcd/M414.cpp index 760028a899f2..26ecea2083b4 100644 --- a/Marlin/src/gcode/lcd/M414.cpp +++ b/Marlin/src/gcode/lcd/M414.cpp @@ -38,7 +38,14 @@ void GcodeSuite::M414() { if (parser.seenval('S')) ui.set_language(parser.value_byte()); + else + M414_report(); } +void GcodeSuite::M414_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_UI_LANGUAGE)); + SERIAL_ECHOLNPAIR(" M414 S", ui.language); +} + #endif // HAS_MULTI_LANGUAGE diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index a819de6127f7..f8fb890695f3 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -225,9 +225,7 @@ class GCodeParser { #endif // !FASTER_GCODE_PARSER // Seen any axis parameter - static inline bool seen_axis() { - return seen(LOGICAL_AXIS_GANG("E", "X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR)); - } + static inline bool seen_axis() { return seen(LOGICAL_AXES_STRING); } #if ENABLED(GCODE_QUOTED_STRINGS) static char* unescape_string(char* &src); @@ -350,14 +348,15 @@ class GCodeParser { static inline void set_input_temp_units(const TempUnit units) { input_temp_units = units; } + static inline char temp_units_code() { + return input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C'; + } + static inline PGM_P temp_units_name() { + return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius"); + } + #if HAS_LCD_MENU && DISABLED(DISABLE_M503) - static inline char temp_units_code() { - return input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C'; - } - static inline PGM_P temp_units_name() { - return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius"); - } static inline float to_temp_units(celsius_t c) { switch (input_temp_units) { default: diff --git a/Marlin/src/gcode/probe/M851.cpp b/Marlin/src/gcode/probe/M851.cpp index ee6244932e6d..e7261b5a14be 100644 --- a/Marlin/src/gcode/probe/M851.cpp +++ b/Marlin/src/gcode/probe/M851.cpp @@ -32,19 +32,8 @@ * M851: Set the nozzle-to-probe offsets in current units */ void GcodeSuite::M851() { - - // Show usage with no parameters - if (!parser.seen("XYZ")) { - SERIAL_ECHOLNPAIR_P( - #if HAS_PROBE_XY_OFFSET - PSTR(STR_PROBE_OFFSET " X"), probe.offset_xy.x, SP_Y_STR, probe.offset_xy.y, SP_Z_STR - #else - PSTR(STR_PROBE_OFFSET " X0 Y0 Z") - #endif - , probe.offset.z - ); - return; - } + // No parameters? Show current state. + if (!parser.seen("XYZ")) return M851_report(); // Start with current offsets and modify xyz_pos_t offs = probe.offset; @@ -94,4 +83,20 @@ void GcodeSuite::M851() { if (ok) probe.offset = offs; } +void GcodeSuite::M851_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_Z_PROBE_OFFSET)); + SERIAL_ECHOPAIR_P( + #if HAS_PROBE_XY_OFFSET + PSTR(" M851 X"), LINEAR_UNIT(probe.offset_xy.x), + SP_Y_STR, LINEAR_UNIT(probe.offset_xy.y), + SP_Z_STR + #else + PSTR(" M851 X0 Y0 Z") + #endif + , LINEAR_UNIT(probe.offset.z) + , " ;" + ); + say_units(); +} + #endif // HAS_BED_PROBE diff --git a/Marlin/src/gcode/units/M149.cpp b/Marlin/src/gcode/units/M149.cpp index 5d9f83206980..eeca59088f84 100644 --- a/Marlin/src/gcode/units/M149.cpp +++ b/Marlin/src/gcode/units/M149.cpp @@ -33,6 +33,13 @@ void GcodeSuite::M149() { if (parser.seenval('C')) parser.set_input_temp_units(TEMPUNIT_C); else if (parser.seenval('K')) parser.set_input_temp_units(TEMPUNIT_K); else if (parser.seenval('F')) parser.set_input_temp_units(TEMPUNIT_F); + else M149_report(); +} + +void GcodeSuite::M149_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, PSTR(STR_TEMPERATURE_UNITS)); + SERIAL_ECHOPAIR(" M149 ", AS_CHAR(parser.temp_units_code()), " ; Units in "); + SERIAL_ECHOLNPGM_P(parser.temp_units_name()); } #endif // TEMPERATURE_UNITS_SUPPORT diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 0f4716ed870e..8ca19e436128 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -578,13 +578,13 @@ void _O2 Endstops::report_states() { default: continue; REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) } - SERIAL_ECHOPGM(STR_FILAMENT_RUNOUT_SENSOR); + SERIAL_ECHOPGM(STR_FILAMENT); if (i > 1) SERIAL_CHAR(' ', '0' + i); print_es_state(extDigitalRead(pin) != state); } #undef _CASE_RUNOUT #elif HAS_FILAMENT_SENSOR - print_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE, PSTR(STR_FILAMENT_RUNOUT_SENSOR)); + print_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE, PSTR(STR_FILAMENT)); #endif TERN_(BLTOUCH, bltouch._reset_SW_mode()); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index c24a63ee519f..017b96cc2043 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -133,9 +133,6 @@ #endif #include "../feature/controllerfan.h" -#if ENABLED(CONTROLLER_FAN_EDITABLE) - void M710_report(const bool forReplay=true); -#endif #if ENABLED(CASE_LIGHT_ENABLE) #include "../feature/caselight.h" @@ -167,13 +164,6 @@ #if HAS_ETHERNET void ETH0_report(); void MAC_report(); - void M552_report(); - void M553_report(); - void M554_report(); -#endif - -#if EITHER(DELTA, HAS_EXTRA_ENDSTOPS) - void M666_report(const bool forReplay=true); #endif #define _EN_ITEM(N) , E##N @@ -3012,63 +3002,19 @@ void MarlinSettings::reset() { postprocess(); - DEBUG_ECHO_START(); - DEBUG_ECHOLNPGM("Hardcoded Default Settings Loaded"); + DEBUG_ECHO_MSG("Hardcoded Default Settings Loaded"); TERN_(EXTENSIBLE_UI, ExtUI::onFactoryReset()); } #if DISABLED(DISABLE_M503) - static void config_heading(const bool repl, PGM_P const pstr, const bool eol=true) { - if (!repl) { - SERIAL_ECHO_START(); - SERIAL_ECHOPGM("; "); - SERIAL_ECHOPGM_P(pstr); - if (eol) SERIAL_EOL(); - } - } - - #define CONFIG_ECHO_START() do{ if (!forReplay) SERIAL_ECHO_START(); }while(0) + #define CONFIG_ECHO_START() gcode.report_echo_start(forReplay) #define CONFIG_ECHO_MSG(V...) do{ CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR(V); }while(0) - #define CONFIG_ECHO_HEADING(STR) config_heading(forReplay, PSTR(STR)) - - #if HAS_TRINAMIC_CONFIG - inline void say_M906(const bool forReplay) { CONFIG_ECHO_START(); SERIAL_ECHOPGM(" M906"); } - #if HAS_STEALTHCHOP - void say_M569(const bool forReplay, const char * const etc=nullptr, const bool newLine = false) { - CONFIG_ECHO_START(); - SERIAL_ECHOPGM(" M569 S1"); - if (etc) { - SERIAL_CHAR(' '); - SERIAL_ECHOPGM_P(etc); - } - if (newLine) SERIAL_EOL(); - } - #endif - #if ENABLED(HYBRID_THRESHOLD) - inline void say_M913(const bool forReplay) { CONFIG_ECHO_START(); SERIAL_ECHOPGM(" M913"); } - #endif - #if USE_SENSORLESS - inline void say_M914() { SERIAL_ECHOPGM(" M914"); } - #endif - #endif - - #if ENABLED(ADVANCED_PAUSE_FEATURE) - inline void say_M603(const bool forReplay) { CONFIG_ECHO_START(); SERIAL_ECHOPGM(" M603 "); } - #endif + #define CONFIG_ECHO_MSG_P(V...) do{ CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR_P(V); }while(0) + #define CONFIG_ECHO_HEADING(STR) gcode.report_heading(forReplay, PSTR(STR)) - inline void say_units(const bool colon) { - SERIAL_ECHOPGM_P( - #if ENABLED(INCH_MODE_SUPPORT) - parser.linear_unit_factor != 1.0 ? PSTR(" (in)") : - #endif - PSTR(" (mm)") - ); - if (colon) SERIAL_ECHOLNPGM(":"); - } - - void report_M92(const bool echo=true, const int8_t e=-1); + void M92_report(const bool echo=true, const int8_t e=-1); /** * M503 - Report current settings in RAM @@ -3076,228 +3022,73 @@ void MarlinSettings::reset() { * Unless specifically disabled, M503 is available even without EEPROM */ void MarlinSettings::report(const bool forReplay) { - /** - * Announce current units, in case inches are being displayed - */ - CONFIG_ECHO_START(); + // + // Announce current units, in case inches are being displayed + // + CONFIG_ECHO_HEADING("Linear Units"); #if ENABLED(INCH_MODE_SUPPORT) - SERIAL_ECHOPGM(" G2"); - SERIAL_CHAR(parser.linear_unit_factor == 1.0 ? '1' : '0'); - SERIAL_ECHOPGM(" ;"); - say_units(false); + SERIAL_ECHOPAIR(" G2", AS_DIGIT(parser.linear_unit_factor == 1.0), " ;"); #else - SERIAL_ECHOPGM(" G21 ; Units in mm"); - say_units(false); + SERIAL_ECHOPGM(" G21 ;"); #endif - SERIAL_EOL(); - - #if HAS_LCD_MENU - - // Temperature units - for Ultipanel temperature options - - CONFIG_ECHO_START(); - #if ENABLED(TEMPERATURE_UNITS_SUPPORT) - SERIAL_ECHOPGM(" M149 "); - SERIAL_CHAR(parser.temp_units_code()); - SERIAL_ECHOPGM(" ; Units in "); - SERIAL_ECHOPGM_P(parser.temp_units_name()); - #else - SERIAL_ECHOLNPGM(" M149 C ; Units in Celsius"); - #endif + gcode.say_units(); + // + // M149 Temperature units + // + #if ENABLED(TEMPERATURE_UNITS_SUPPORT) + gcode.M149_report(forReplay); + #else + CONFIG_ECHO_HEADING(STR_TEMPERATURE_UNITS); + CONFIG_ECHO_MSG(" M149 C ; Units in Celsius"); #endif - SERIAL_EOL(); - - #if EXTRUDERS && DISABLED(NO_VOLUMETRICS) - - /** - * Volumetric extrusion M200 - */ - if (!forReplay) { - config_heading(forReplay, PSTR("Filament settings:"), false); - if (parser.volumetric_enabled) - SERIAL_EOL(); - else - SERIAL_ECHOLNPGM(" Disabled"); - } + // + // M200 Volumetric Extrusion + // + IF_DISABLED(NO_VOLUMETRICS, gcode.M200_report(forReplay)); - #if EXTRUDERS == 1 - CONFIG_ECHO_MSG(" M200 S", parser.volumetric_enabled - , " D", LINEAR_UNIT(planner.filament_size[0]) - #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) - , " L", LINEAR_UNIT(planner.volumetric_extruder_limit[0]) - #endif - ); - #else - LOOP_L_N(i, EXTRUDERS) { - CONFIG_ECHO_MSG(" M200 T", i - , " D", LINEAR_UNIT(planner.filament_size[i]) - #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) - , " L", LINEAR_UNIT(planner.volumetric_extruder_limit[i]) - #endif - ); - } - CONFIG_ECHO_MSG(" M200 S", parser.volumetric_enabled); - #endif + // + // M92 Steps per Unit + // + gcode.M92_report(forReplay); - #endif // EXTRUDERS && !NO_VOLUMETRICS - - CONFIG_ECHO_HEADING("Steps per unit:"); - report_M92(!forReplay); - - CONFIG_ECHO_HEADING("Maximum feedrates (units/s):"); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - LIST_N(DOUBLE(LINEAR_AXES), - PSTR(" M203 X"), LINEAR_UNIT(planner.settings.max_feedrate_mm_s[X_AXIS]), - SP_Y_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Y_AXIS]), - SP_Z_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Z_AXIS]), - SP_I_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[I_AXIS]), - SP_J_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[J_AXIS]), - SP_K_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[K_AXIS]) - ) - #if HAS_EXTRUDERS && DISABLED(DISTINCT_E_FACTORS) - , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS]) - #endif - ); - #if ENABLED(DISTINCT_E_FACTORS) - LOOP_L_N(i, E_STEPPERS) { - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - PSTR(" M203 T"), i - , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS_N(i)]) - ); - } - #endif + // + // M203 Maximum feedrates (units/s) + // + gcode.M203_report(forReplay); - CONFIG_ECHO_HEADING("Maximum Acceleration (units/s2):"); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - LIST_N(DOUBLE(LINEAR_AXES), - PSTR(" M201 X"), LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[X_AXIS]), - SP_Y_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Y_AXIS]), - SP_Z_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Z_AXIS]), - SP_I_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[I_AXIS]), - SP_J_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[J_AXIS]), - SP_K_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[K_AXIS]) - ) - #if HAS_EXTRUDERS && DISABLED(DISTINCT_E_FACTORS) - , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_acceleration_mm_per_s2[E_AXIS]) - #endif - ); - #if ENABLED(DISTINCT_E_FACTORS) - LOOP_L_N(i, E_STEPPERS) { - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - PSTR(" M201 T"), i - , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(i)]) - ); - } - #endif + // + // M201 Maximum Acceleration (units/s2) + // + gcode.M201_report(forReplay); - CONFIG_ECHO_HEADING("Acceleration (units/s2): P R T"); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - PSTR(" M204 P"), LINEAR_UNIT(planner.settings.acceleration) - , PSTR(" R"), LINEAR_UNIT(planner.settings.retract_acceleration) - , SP_T_STR, LINEAR_UNIT(planner.settings.travel_acceleration) - ); + // + // M204 Acceleration (units/s2) + // + gcode.M204_report(forReplay); - CONFIG_ECHO_HEADING( - "Advanced: B S T" - TERN_(HAS_JUNCTION_DEVIATION, " J") - #if HAS_CLASSIC_JERK - " X Y Z" - TERN_(HAS_CLASSIC_E_JERK, " E") - #endif - ); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - PSTR(" M205 B"), LINEAR_UNIT(planner.settings.min_segment_time_us) - , PSTR(" S"), LINEAR_UNIT(planner.settings.min_feedrate_mm_s) - , SP_T_STR, LINEAR_UNIT(planner.settings.min_travel_feedrate_mm_s) - #if HAS_JUNCTION_DEVIATION - , PSTR(" J"), LINEAR_UNIT(planner.junction_deviation_mm) - #endif - #if HAS_CLASSIC_JERK - , LIST_N(DOUBLE(LINEAR_AXES), - SP_X_STR, LINEAR_UNIT(planner.max_jerk.x), - SP_Y_STR, LINEAR_UNIT(planner.max_jerk.y), - SP_Z_STR, LINEAR_UNIT(planner.max_jerk.z), - SP_I_STR, LINEAR_UNIT(planner.max_jerk.i), - SP_J_STR, LINEAR_UNIT(planner.max_jerk.j), - SP_K_STR, LINEAR_UNIT(planner.max_jerk.k) - ) - #if HAS_CLASSIC_E_JERK - , SP_E_STR, LINEAR_UNIT(planner.max_jerk.e) - #endif - #endif - ); + // + // M205 "Advanced" Settings + // + gcode.M205_report(forReplay); - #if HAS_M206_COMMAND - CONFIG_ECHO_HEADING("Home offset:"); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - #if IS_CARTESIAN - LIST_N(DOUBLE(LINEAR_AXES), - PSTR(" M206 X"), LINEAR_UNIT(home_offset.x), - SP_Y_STR, LINEAR_UNIT(home_offset.y), - SP_Z_STR, LINEAR_UNIT(home_offset.z), - SP_I_STR, LINEAR_UNIT(home_offset.i), - SP_J_STR, LINEAR_UNIT(home_offset.j), - SP_K_STR, LINEAR_UNIT(home_offset.k) - ) - #else - PSTR(" M206 Z"), LINEAR_UNIT(home_offset.z) - #endif - ); - #endif + // + // M206 Home Offset + // + TERN_(HAS_M206_COMMAND, gcode.M206_report(forReplay)); - #if HAS_HOTEND_OFFSET - CONFIG_ECHO_HEADING("Hotend offsets:"); - CONFIG_ECHO_START(); - LOOP_S_L_N(e, 1, HOTENDS) { - SERIAL_ECHOPAIR_P( - PSTR(" M218 T"), e, - SP_X_STR, LINEAR_UNIT(hotend_offset[e].x), - SP_Y_STR, LINEAR_UNIT(hotend_offset[e].y) - ); - SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(hotend_offset[e].z), 3); - } - #endif + // + // M218 Hotend offsets + // + TERN_(HAS_HOTEND_OFFSET, gcode.M218_report(forReplay)); - /** - * Bed Leveling - */ + // + // Bed Leveling + // #if HAS_LEVELING - #if ENABLED(MESH_BED_LEVELING) - - CONFIG_ECHO_HEADING("Mesh Bed Leveling:"); - - #elif ENABLED(AUTO_BED_LEVELING_UBL) - - config_heading(forReplay, NUL_STR, false); - if (!forReplay) { - ubl.echo_name(); - SERIAL_CHAR(':'); - SERIAL_EOL(); - } - - #elif HAS_ABL_OR_UBL - - CONFIG_ECHO_HEADING("Auto Bed Leveling:"); - - #endif - - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - PSTR(" M420 S"), planner.leveling_active - #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - , SP_Z_STR, LINEAR_UNIT(planner.z_fade_height) - #endif - ); + gcode.M420_report(forReplay); #if ENABLED(MESH_BED_LEVELING) @@ -3318,11 +3109,8 @@ void MarlinSettings::reset() { if (!forReplay) { SERIAL_EOL(); ubl.report_state(); - config_heading(false, PSTR("Active Mesh Slot: "), false); - SERIAL_ECHOLN(ubl.storage_slot); - config_heading(false, PSTR("EEPROM can hold "), false); - SERIAL_ECHO(calc_num_meshes()); - SERIAL_ECHOLNPGM(" meshes.\n"); + SERIAL_ECHO_MSG("Active Mesh Slot ", ubl.storage_slot); + SERIAL_ECHO_MSG("EEPROM can hold ", calc_num_meshes(), " meshes.\n"); } //ubl.report_current_mesh(); // This is too verbose for large meshes. A better (more terse) @@ -3343,602 +3131,150 @@ void MarlinSettings::reset() { #endif // HAS_LEVELING - #if ENABLED(EDITABLE_SERVO_ANGLES) - - CONFIG_ECHO_HEADING("Servo Angles:"); - LOOP_L_N(i, NUM_SERVOS) { - switch (i) { - #if ENABLED(SWITCHING_EXTRUDER) - case SWITCHING_EXTRUDER_SERVO_NR: - #if EXTRUDERS > 3 - case SWITCHING_EXTRUDER_E23_SERVO_NR: - #endif - #elif ENABLED(SWITCHING_NOZZLE) - case SWITCHING_NOZZLE_SERVO_NR: - #elif ENABLED(BLTOUCH) || (HAS_Z_SERVO_PROBE && defined(Z_SERVO_ANGLES)) - case Z_PROBE_SERVO_NR: - #endif - CONFIG_ECHO_MSG(" M281 P", i, " L", servo_angles[i][0], " U", servo_angles[i][1]); - default: break; - } - } - - #endif // EDITABLE_SERVO_ANGLES - - #if HAS_SCARA_OFFSET - - CONFIG_ECHO_HEADING("SCARA settings: S P T"); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - PSTR(" M665 S"), segments_per_second - , SP_P_STR, scara_home_offset.a - , SP_T_STR, scara_home_offset.b - , SP_Z_STR, LINEAR_UNIT(scara_home_offset.z) - ); - - #elif ENABLED(DELTA) - - CONFIG_ECHO_HEADING("Delta settings: L R H S XYZ ABC"); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - PSTR(" M665 L"), LINEAR_UNIT(delta_diagonal_rod) - , PSTR(" R"), LINEAR_UNIT(delta_radius) - , PSTR(" H"), LINEAR_UNIT(delta_height) - , PSTR(" S"), segments_per_second - , SP_X_STR, LINEAR_UNIT(delta_tower_angle_trim.a) - , SP_Y_STR, LINEAR_UNIT(delta_tower_angle_trim.b) - , SP_Z_STR, LINEAR_UNIT(delta_tower_angle_trim.c) - , PSTR(" A"), LINEAR_UNIT(delta_diagonal_rod_trim.a) - , PSTR(" B"), LINEAR_UNIT(delta_diagonal_rod_trim.b) - , PSTR(" C"), LINEAR_UNIT(delta_diagonal_rod_trim.c) - ); + // + // Editable Servo Angles + // + TERN_(EDITABLE_SERVO_ANGLES, gcode.M281_report(forReplay)); - #endif + // + // Delta / SCARA Kinematics + // + TERN_(IS_KINEMATIC, gcode.M665_report(forReplay)); + // + // M666 Endstops Adjustment + // #if EITHER(DELTA, HAS_EXTRA_ENDSTOPS) - M666_report(forReplay); + gcode.M666_report(forReplay); #endif - #if PREHEAT_COUNT - - CONFIG_ECHO_HEADING("Material heatup parameters:"); - LOOP_L_N(i, PREHEAT_COUNT) { - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - PSTR(" M145 S"), i - #if HAS_HOTEND - , PSTR(" H"), parser.to_temp_units(ui.material_preset[i].hotend_temp) - #endif - #if HAS_HEATED_BED - , SP_B_STR, parser.to_temp_units(ui.material_preset[i].bed_temp) - #endif - #if HAS_FAN - , PSTR(" F"), ui.material_preset[i].fan_speed - #endif - ); - } + // + // Z Auto-Align + // + TERN_(Z_STEPPER_AUTO_ALIGN, gcode.M422_report(forReplay)); + // + // LCD Preheat Settings + // + #if PREHEAT_COUNT + gcode.M145_report(forReplay); #endif - #if HAS_PID_HEATING - - CONFIG_ECHO_HEADING("PID settings:"); - - #if ENABLED(PIDTEMP) - HOTEND_LOOP() { - CONFIG_ECHO_START(); - SERIAL_ECHOPAIR_P( - #if ENABLED(PID_PARAMS_PER_HOTEND) - PSTR(" M301 E"), e, - SP_P_STR - #else - PSTR(" M301 P") - #endif - , PID_PARAM(Kp, e) - , PSTR(" I"), unscalePID_i(PID_PARAM(Ki, e)) - , PSTR(" D"), unscalePID_d(PID_PARAM(Kd, e)) - ); - #if ENABLED(PID_EXTRUSION_SCALING) - SERIAL_ECHOPAIR_P(SP_C_STR, PID_PARAM(Kc, e)); - if (e == 0) SERIAL_ECHOPAIR(" L", thermalManager.lpq_len); - #endif - #if ENABLED(PID_FAN_SCALING) - SERIAL_ECHOPAIR(" F", PID_PARAM(Kf, e)); - #endif - SERIAL_EOL(); - } - #endif // PIDTEMP - - #if ENABLED(PIDTEMPBED) - CONFIG_ECHO_MSG( - " M304 P", thermalManager.temp_bed.pid.Kp - , " I", unscalePID_i(thermalManager.temp_bed.pid.Ki) - , " D", unscalePID_d(thermalManager.temp_bed.pid.Kd) - ); - #endif - - #if ENABLED(PIDTEMPCHAMBER) - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR( - " M309 P", thermalManager.temp_chamber.pid.Kp - , " I", unscalePID_i(thermalManager.temp_chamber.pid.Ki) - , " D", unscalePID_d(thermalManager.temp_chamber.pid.Kd) - ); - #endif - - #endif // PIDTEMP || PIDTEMPBED || PIDTEMPCHAMBER + // + // PID + // + TERN_(PIDTEMP, gcode.M301_report(forReplay)); + TERN_(PIDTEMPBED, gcode.M304_report(forReplay)); + TERN_(PIDTEMPCHAMBER, gcode.M309_report(forReplay)); #if HAS_USER_THERMISTORS - CONFIG_ECHO_HEADING("User thermistors:"); LOOP_L_N(i, USER_THERMISTORS) - thermalManager.log_user_thermistor(i, true); + thermalManager.M305_report(i, forReplay); #endif - #if HAS_LCD_CONTRAST - CONFIG_ECHO_HEADING("LCD Contrast:"); - CONFIG_ECHO_MSG(" M250 C", ui.contrast); - #endif + // + // LCD Contrast + // + TERN_(HAS_LCD_CONTRAST, gcode.M250_report(forReplay)); - #if HAS_LCD_BRIGHTNESS - CONFIG_ECHO_HEADING("LCD Brightness:"); - CONFIG_ECHO_MSG(" M256 B", ui.brightness); - #endif + // + // LCD Brightness + // + TERN_(HAS_LCD_BRIGHTNESS, gcode.M256_report(forReplay)); - TERN_(CONTROLLER_FAN_EDITABLE, M710_report(forReplay)); + // + // Controller Fan + // + TERN_(CONTROLLER_FAN_EDITABLE, gcode.M710_report(forReplay)); - #if ENABLED(POWER_LOSS_RECOVERY) - CONFIG_ECHO_HEADING("Power-Loss Recovery:"); - CONFIG_ECHO_MSG(" M413 S", recovery.enabled); - #endif + // + // Power-Loss Recovery + // + TERN_(POWER_LOSS_RECOVERY, gcode.M413_report(forReplay)); + // + // Firmware Retraction + // #if ENABLED(FWRETRACT) - fwretract.M207_report(forReplay); - fwretract.M208_report(forReplay); - TERN_(FWRETRACT_AUTORETRACT, fwretract.M209_report(forReplay)); + gcode.M207_report(forReplay); + gcode.M208_report(forReplay); + TERN_(FWRETRACT_AUTORETRACT, gcode.M209_report(forReplay)); #endif - /** - * Probe Offset - */ - #if HAS_BED_PROBE - config_heading(forReplay, PSTR("Z-Probe Offset"), false); - if (!forReplay) say_units(true); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - #if HAS_PROBE_XY_OFFSET - PSTR(" M851 X"), LINEAR_UNIT(probe.offset_xy.x), - SP_Y_STR, LINEAR_UNIT(probe.offset_xy.y), - SP_Z_STR - #else - PSTR(" M851 X0 Y0 Z") - #endif - , LINEAR_UNIT(probe.offset.z) - ); - #endif + // + // Probe Offset + // + TERN_(HAS_BED_PROBE, gcode.M851_report(forReplay)); - /** - * Bed Skew Correction - */ - #if ENABLED(SKEW_CORRECTION_GCODE) - CONFIG_ECHO_HEADING("Skew Factor: "); - CONFIG_ECHO_START(); - #if ENABLED(SKEW_CORRECTION_FOR_Z) - SERIAL_ECHOPAIR_F(" M852 I", LINEAR_UNIT(planner.skew_factor.xy), 6); - SERIAL_ECHOPAIR_F(" J", LINEAR_UNIT(planner.skew_factor.xz), 6); - SERIAL_ECHOLNPAIR_F(" K", LINEAR_UNIT(planner.skew_factor.yz), 6); - #else - SERIAL_ECHOLNPAIR_F(" M852 S", LINEAR_UNIT(planner.skew_factor.xy), 6); - #endif - #endif + // + // Bed Skew Correction + // + TERN_(SKEW_CORRECTION_GCODE, gcode.M852_report(forReplay)); #if HAS_TRINAMIC_CONFIG + // + // TMC Stepper driver current + // + gcode.M906_report(forReplay); - /** - * TMC stepper driver current - */ - CONFIG_ECHO_HEADING("Stepper driver current:"); - - #if AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) - say_M906(forReplay); - #if AXIS_IS_TMC(X) - SERIAL_ECHOPAIR_P(SP_X_STR, stepperX.getMilliamps()); - #endif - #if AXIS_IS_TMC(Y) - SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY.getMilliamps()); - #endif - #if AXIS_IS_TMC(Z) - SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ.getMilliamps()); - #endif - SERIAL_EOL(); - #endif - - #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) - say_M906(forReplay); - SERIAL_ECHOPGM(" I1"); - #if AXIS_IS_TMC(X2) - SERIAL_ECHOPAIR_P(SP_X_STR, stepperX2.getMilliamps()); - #endif - #if AXIS_IS_TMC(Y2) - SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY2.getMilliamps()); - #endif - #if AXIS_IS_TMC(Z2) - SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ2.getMilliamps()); - #endif - SERIAL_EOL(); - #endif - - #if AXIS_IS_TMC(Z3) - say_M906(forReplay); - SERIAL_ECHOLNPAIR(" I2 Z", stepperZ3.getMilliamps()); - #endif - - #if AXIS_IS_TMC(Z4) - say_M906(forReplay); - SERIAL_ECHOLNPAIR(" I3 Z", stepperZ4.getMilliamps()); - #endif - - #if AXIS_IS_TMC(I) - say_M906(forReplay); - SERIAL_ECHOLNPAIR_P(SP_I_STR, stepperI.getMilliamps()); - #endif - #if AXIS_IS_TMC(J) - say_M906(forReplay); - SERIAL_ECHOLNPAIR_P(SP_J_STR, stepperJ.getMilliamps()); - #endif - #if AXIS_IS_TMC(K) - say_M906(forReplay); - SERIAL_ECHOLNPAIR_P(SP_K_STR, stepperK.getMilliamps()); - #endif - - #if AXIS_IS_TMC(E0) - say_M906(forReplay); - SERIAL_ECHOLNPAIR(" T0 E", stepperE0.getMilliamps()); - #endif - #if AXIS_IS_TMC(E1) - say_M906(forReplay); - SERIAL_ECHOLNPAIR(" T1 E", stepperE1.getMilliamps()); - #endif - #if AXIS_IS_TMC(E2) - say_M906(forReplay); - SERIAL_ECHOLNPAIR(" T2 E", stepperE2.getMilliamps()); - #endif - #if AXIS_IS_TMC(E3) - say_M906(forReplay); - SERIAL_ECHOLNPAIR(" T3 E", stepperE3.getMilliamps()); - #endif - #if AXIS_IS_TMC(E4) - say_M906(forReplay); - SERIAL_ECHOLNPAIR(" T4 E", stepperE4.getMilliamps()); - #endif - #if AXIS_IS_TMC(E5) - say_M906(forReplay); - SERIAL_ECHOLNPAIR(" T5 E", stepperE5.getMilliamps()); - #endif - #if AXIS_IS_TMC(E6) - say_M906(forReplay); - SERIAL_ECHOLNPAIR(" T6 E", stepperE6.getMilliamps()); - #endif - #if AXIS_IS_TMC(E7) - say_M906(forReplay); - SERIAL_ECHOLNPAIR(" T7 E", stepperE7.getMilliamps()); - #endif - SERIAL_EOL(); - - /** - * TMC Hybrid Threshold - */ - #if ENABLED(HYBRID_THRESHOLD) - CONFIG_ECHO_HEADING("Hybrid Threshold:"); - #if X_HAS_STEALTHCHOP || Y_HAS_STEALTHCHOP || Z_HAS_STEALTHCHOP - say_M913(forReplay); - #if X_HAS_STEALTHCHOP - SERIAL_ECHOPAIR_P(SP_X_STR, stepperX.get_pwm_thrs()); - #endif - #if Y_HAS_STEALTHCHOP - SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY.get_pwm_thrs()); - #endif - #if Z_HAS_STEALTHCHOP - SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ.get_pwm_thrs()); - #endif - SERIAL_EOL(); - #endif - - #if X2_HAS_STEALTHCHOP || Y2_HAS_STEALTHCHOP || Z2_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOPGM(" I1"); - #if X2_HAS_STEALTHCHOP - SERIAL_ECHOPAIR_P(SP_X_STR, stepperX2.get_pwm_thrs()); - #endif - #if Y2_HAS_STEALTHCHOP - SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY2.get_pwm_thrs()); - #endif - #if Z2_HAS_STEALTHCHOP - SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ2.get_pwm_thrs()); - #endif - SERIAL_EOL(); - #endif - - #if Z3_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPAIR(" I2 Z", stepperZ3.get_pwm_thrs()); - #endif - - #if Z4_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPAIR(" I3 Z", stepperZ4.get_pwm_thrs()); - #endif - - #if I_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPAIR_P(SP_I_STR, stepperI.get_pwm_thrs()); - #endif - #if J_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPAIR_P(SP_J_STR, stepperJ.get_pwm_thrs()); - #endif - #if K_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPAIR_P(SP_K_STR, stepperK.get_pwm_thrs()); - #endif - - #if E0_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPAIR(" T0 E", stepperE0.get_pwm_thrs()); - #endif - #if E1_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPAIR(" T1 E", stepperE1.get_pwm_thrs()); - #endif - #if E2_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPAIR(" T2 E", stepperE2.get_pwm_thrs()); - #endif - #if E3_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPAIR(" T3 E", stepperE3.get_pwm_thrs()); - #endif - #if E4_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPAIR(" T4 E", stepperE4.get_pwm_thrs()); - #endif - #if E5_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPAIR(" T5 E", stepperE5.get_pwm_thrs()); - #endif - #if E6_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPAIR(" T6 E", stepperE6.get_pwm_thrs()); - #endif - #if E7_HAS_STEALTHCHOP - say_M913(forReplay); - SERIAL_ECHOLNPAIR(" T7 E", stepperE7.get_pwm_thrs()); - #endif - SERIAL_EOL(); - #endif // HYBRID_THRESHOLD - - /** - * TMC Sensorless homing thresholds - */ - #if USE_SENSORLESS - CONFIG_ECHO_HEADING("StallGuard threshold:"); - #if X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS - CONFIG_ECHO_START(); - say_M914(); - #if X_SENSORLESS - SERIAL_ECHOPAIR_P(SP_X_STR, stepperX.homing_threshold()); - #endif - #if Y_SENSORLESS - SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY.homing_threshold()); - #endif - #if Z_SENSORLESS - SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ.homing_threshold()); - #endif - SERIAL_EOL(); - #endif - - #if X2_SENSORLESS || Y2_SENSORLESS || Z2_SENSORLESS - CONFIG_ECHO_START(); - say_M914(); - SERIAL_ECHOPGM(" I1"); - #if X2_SENSORLESS - SERIAL_ECHOPAIR_P(SP_X_STR, stepperX2.homing_threshold()); - #endif - #if Y2_SENSORLESS - SERIAL_ECHOPAIR_P(SP_Y_STR, stepperY2.homing_threshold()); - #endif - #if Z2_SENSORLESS - SERIAL_ECHOPAIR_P(SP_Z_STR, stepperZ2.homing_threshold()); - #endif - SERIAL_EOL(); - #endif - - #if Z3_SENSORLESS - CONFIG_ECHO_START(); - say_M914(); - SERIAL_ECHOLNPAIR(" I2 Z", stepperZ3.homing_threshold()); - #endif - - #if Z4_SENSORLESS - CONFIG_ECHO_START(); - say_M914(); - SERIAL_ECHOLNPAIR(" I3 Z", stepperZ4.homing_threshold()); - #endif - - #if I_SENSORLESS - CONFIG_ECHO_START(); - say_M914(); - SERIAL_ECHOLNPAIR_P(SP_I_STR, stepperI.homing_threshold()); - #endif - #if J_SENSORLESS - CONFIG_ECHO_START(); - say_M914(); - SERIAL_ECHOLNPAIR_P(SP_J_STR, stepperJ.homing_threshold()); - #endif - #if K_SENSORLESS - CONFIG_ECHO_START(); - say_M914(); - SERIAL_ECHOLNPAIR_P(SP_K_STR, stepperK.homing_threshold()); - #endif - - #endif // USE_SENSORLESS - - /** - * TMC stepping mode - */ - #if HAS_STEALTHCHOP - CONFIG_ECHO_HEADING("Driver stepping mode:"); - const bool chop_x = TERN0(X_HAS_STEALTHCHOP, stepperX.get_stored_stealthChop()), - chop_y = TERN0(Y_HAS_STEALTHCHOP, stepperY.get_stored_stealthChop()), - chop_z = TERN0(Z_HAS_STEALTHCHOP, stepperZ.get_stored_stealthChop()), - chop_i = TERN0(I_HAS_STEALTHCHOP, stepperI.get_stored_stealthChop()), - chop_j = TERN0(J_HAS_STEALTHCHOP, stepperJ.get_stored_stealthChop()), - chop_k = TERN0(K_HAS_STEALTHCHOP, stepperK.get_stored_stealthChop()); - - if (chop_x || chop_y || chop_z || chop_i || chop_j || chop_k) { - say_M569(forReplay); - LINEAR_AXIS_CODE( - if (chop_x) SERIAL_ECHOPGM_P(SP_X_STR), - if (chop_y) SERIAL_ECHOPGM_P(SP_Y_STR), - if (chop_z) SERIAL_ECHOPGM_P(SP_Z_STR), - if (chop_i) SERIAL_ECHOPGM_P(SP_I_STR), - if (chop_j) SERIAL_ECHOPGM_P(SP_J_STR), - if (chop_k) SERIAL_ECHOPGM_P(SP_K_STR) - ); - SERIAL_EOL(); - } + // + // TMC Hybrid Threshold + // + TERN_(HYBRID_THRESHOLD, gcode.M913_report(forReplay)); - const bool chop_x2 = TERN0(X2_HAS_STEALTHCHOP, stepperX2.get_stored_stealthChop()), - chop_y2 = TERN0(Y2_HAS_STEALTHCHOP, stepperY2.get_stored_stealthChop()), - chop_z2 = TERN0(Z2_HAS_STEALTHCHOP, stepperZ2.get_stored_stealthChop()); + // + // TMC Sensorless homing thresholds + // + TERN_(USE_SENSORLESS, gcode.M914_report(forReplay)); + #endif - if (chop_x2 || chop_y2 || chop_z2) { - say_M569(forReplay, PSTR("I1")); - if (chop_x2) SERIAL_ECHOPGM_P(SP_X_STR); - if (chop_y2) SERIAL_ECHOPGM_P(SP_Y_STR); - if (chop_z2) SERIAL_ECHOPGM_P(SP_Z_STR); - SERIAL_EOL(); - } + // + // TMC stepping mode + // + TERN_(HAS_STEALTHCHOP, gcode.M569_report(forReplay)); - if (TERN0(Z3_HAS_STEALTHCHOP, stepperZ3.get_stored_stealthChop())) { say_M569(forReplay, PSTR("I2 Z"), true); } - if (TERN0(Z4_HAS_STEALTHCHOP, stepperZ4.get_stored_stealthChop())) { say_M569(forReplay, PSTR("I3 Z"), true); } - - if (TERN0( I_HAS_STEALTHCHOP, stepperI.get_stored_stealthChop())) { say_M569(forReplay, SP_I_STR, true); } - if (TERN0( J_HAS_STEALTHCHOP, stepperJ.get_stored_stealthChop())) { say_M569(forReplay, SP_J_STR, true); } - if (TERN0( K_HAS_STEALTHCHOP, stepperK.get_stored_stealthChop())) { say_M569(forReplay, SP_K_STR, true); } - - if (TERN0(E0_HAS_STEALTHCHOP, stepperE0.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T0 E"), true); } - if (TERN0(E1_HAS_STEALTHCHOP, stepperE1.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T1 E"), true); } - if (TERN0(E2_HAS_STEALTHCHOP, stepperE2.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T2 E"), true); } - if (TERN0(E3_HAS_STEALTHCHOP, stepperE3.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T3 E"), true); } - if (TERN0(E4_HAS_STEALTHCHOP, stepperE4.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T4 E"), true); } - if (TERN0(E5_HAS_STEALTHCHOP, stepperE5.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T5 E"), true); } - if (TERN0(E6_HAS_STEALTHCHOP, stepperE6.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T6 E"), true); } - if (TERN0(E7_HAS_STEALTHCHOP, stepperE7.get_stored_stealthChop())) { say_M569(forReplay, PSTR("T7 E"), true); } - - #endif // HAS_STEALTHCHOP - - #endif // HAS_TRINAMIC_CONFIG - - /** - * Linear Advance - */ - #if ENABLED(LIN_ADVANCE) - CONFIG_ECHO_HEADING("Linear Advance:"); - #if EXTRUDERS < 2 - CONFIG_ECHO_MSG(" M900 K", planner.extruder_advance_K[0]); - #else - LOOP_L_N(i, EXTRUDERS) - CONFIG_ECHO_MSG(" M900 T", i, " K", planner.extruder_advance_K[i]); - #endif - #endif + // + // Linear Advance + // + TERN_(LIN_ADVANCE, gcode.M900_report(forReplay)); - #if EITHER(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_PWM) - CONFIG_ECHO_HEADING("Stepper motor currents:"); - CONFIG_ECHO_START(); - #if HAS_MOTOR_CURRENT_PWM - SERIAL_ECHOLNPAIR_P( // PWM-based has 3 values: - PSTR(" M907 X"), stepper.motor_current_setting[0] // X and Y - , SP_Z_STR, stepper.motor_current_setting[1] // Z - , SP_E_STR, stepper.motor_current_setting[2] // E - ); - #elif HAS_MOTOR_CURRENT_SPI - SERIAL_ECHOPGM(" M907"); // SPI-based has 5 values: - LOOP_LOGICAL_AXES(q) { // X Y Z (I J K) E (map to X Y Z (I J K) E0 by default) - SERIAL_CHAR(' ', axis_codes[q]); - SERIAL_ECHO(stepper.motor_current_setting[q]); - } - SERIAL_CHAR(' ', 'B'); // B (maps to E1 by default) - SERIAL_ECHOLN(stepper.motor_current_setting[4]); - #endif - #elif HAS_MOTOR_CURRENT_I2C // i2c-based has any number of values - // Values sent over i2c are not stored. - // Indexes map directly to drivers, not axes. - #elif HAS_MOTOR_CURRENT_DAC // DAC-based has 4 values, for X Y Z (I J K) E - // Values sent over i2c are not stored. Uses indirect mapping. + // + // Motor Current (SPI or PWM) + // + #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM + gcode.M907_report(forReplay); #endif - /** - * Advanced Pause filament load & unload lengths - */ - #if ENABLED(ADVANCED_PAUSE_FEATURE) - CONFIG_ECHO_HEADING("Filament load/unload lengths:"); - #if EXTRUDERS == 1 - say_M603(forReplay); - SERIAL_ECHOLNPAIR("L", LINEAR_UNIT(fc_settings[0].load_length), " U", LINEAR_UNIT(fc_settings[0].unload_length)); - #else - auto echo_603 = [](const bool f, const uint8_t n) { say_M603(f); SERIAL_ECHOLNPAIR("T", n, " L", LINEAR_UNIT(fc_settings[n].load_length), " U", LINEAR_UNIT(fc_settings[n].unload_length)); }; - LOOP_L_N(i, EXTRUDERS) echo_603(forReplay, i); - #endif - #endif + // + // Advanced Pause filament load & unload lengths + // + TERN_(ADVANCED_PAUSE_FEATURE, gcode.M603_report(forReplay)); - #if HAS_MULTI_EXTRUDER - CONFIG_ECHO_HEADING("Tool-changing:"); - CONFIG_ECHO_START(); - M217_report(true); - #endif + // + // Tool-changing Parameters + // + TERN_(HAS_MULTI_EXTRUDER, gcode.M217_report(forReplay)); - #if ENABLED(BACKLASH_GCODE) - CONFIG_ECHO_HEADING("Backlash compensation:"); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - PSTR(" M425 F"), backlash.get_correction() - , LIST_N(DOUBLE(LINEAR_AXES), - SP_X_STR, LINEAR_UNIT(backlash.distance_mm.x), - SP_Y_STR, LINEAR_UNIT(backlash.distance_mm.y), - SP_Z_STR, LINEAR_UNIT(backlash.distance_mm.z), - SP_I_STR, LINEAR_UNIT(backlash.distance_mm.i), - SP_J_STR, LINEAR_UNIT(backlash.distance_mm.j), - SP_K_STR, LINEAR_UNIT(backlash.distance_mm.k) - ) - #ifdef BACKLASH_SMOOTHING_MM - , PSTR(" S"), LINEAR_UNIT(backlash.smoothing_mm) - #endif - ); - #endif + // + // Backlash Compensation + // + TERN_(BACKLASH_GCODE, gcode.M425_report(forReplay)); - #if HAS_FILAMENT_SENSOR - CONFIG_ECHO_HEADING("Filament runout sensor:"); - CONFIG_ECHO_MSG( - " M412 S", runout.enabled - #if HAS_FILAMENT_RUNOUT_DISTANCE - , " D", LINEAR_UNIT(runout.runout_distance()) - #endif - ); - #endif + // + // Filament Runout Sensor + // + TERN_(HAS_FILAMENT_SENSOR, gcode.M412_report(forReplay)); #if HAS_ETHERNET - CONFIG_ECHO_HEADING("Ethernet:"); - if (!forReplay) { CONFIG_ECHO_START(); ETH0_report(); } + CONFIG_ECHO_HEADING("Ethernet"); + if (!forReplay) ETH0_report(); CONFIG_ECHO_START(); SERIAL_ECHO_SP(2); MAC_report(); - CONFIG_ECHO_START(); SERIAL_ECHO_SP(2); M552_report(); - CONFIG_ECHO_START(); SERIAL_ECHO_SP(2); M553_report(); - CONFIG_ECHO_START(); SERIAL_ECHO_SP(2); M554_report(); + CONFIG_ECHO_START(); SERIAL_ECHO_SP(2); gcode.M552_report(); + CONFIG_ECHO_START(); SERIAL_ECHO_SP(2); gcode.M553_report(); + CONFIG_ECHO_START(); SERIAL_ECHO_SP(2); gcode.M554_report(); #endif - #if HAS_MULTI_LANGUAGE - CONFIG_ECHO_HEADING("UI Language:"); - CONFIG_ECHO_MSG(" M414 S", ui.language); - #endif + TERN_(HAS_MULTI_LANGUAGE, gcode.M414_report(forReplay)); } #endif // !DISABLE_M503 diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 1bb86ed4c7e0..934f734e9cec 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -59,6 +59,10 @@ #include "../feature/host_actions.h" #endif +#if HAS_TEMP_SENSOR + #include "../gcode/gcode.h" +#endif + // MAX TC related macros #define TEMP_SENSOR_IS_MAX(n, M) (ENABLED(TEMP_SENSOR_##n##_IS_MAX##M) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX##M) && REDUNDANT_TEMP_MATCH(SOURCE, E##n))) #define TEMP_SENSOR_IS_ANY_MAX_TC(n) (ENABLED(TEMP_SENSOR_##n##_IS_MAX_TC) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX_TC) && REDUNDANT_TEMP_MATCH(SOURCE, E##n))) @@ -1722,13 +1726,9 @@ void Temperature::manage_heater() { COPY(user_thermistor, default_user_thermistor); } - void Temperature::log_user_thermistor(const uint8_t t_index, const bool eprom/*=false*/) { - - if (eprom) - SERIAL_ECHOPGM(" M305 "); - else - SERIAL_ECHO_START(); - SERIAL_CHAR('P', '0' + t_index); + void Temperature::M305_report(const uint8_t t_index, const bool forReplay/*=true*/) { + gcode.report_heading_etc(forReplay, PSTR(STR_USER_THERMISTORS)); + SERIAL_ECHOPAIR(" M305 P", AS_DIGIT(t_index)); const user_thermistor_t &t = user_thermistor[t_index]; @@ -1794,13 +1794,13 @@ void Temperature::manage_heater() { // Derived from RepRap FiveD extruder::getTemperature() // For hot end temperature measurement. celsius_float_t Temperature::analog_to_celsius_hotend(const int16_t raw, const uint8_t e) { - if (e >= HOTENDS) { - SERIAL_ERROR_START(); - SERIAL_ECHO(e); - SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER_NUM); - kill(); - return 0; - } + if (e >= HOTENDS) { + SERIAL_ERROR_START(); + SERIAL_ECHO(e); + SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER_NUM); + kill(); + return 0; + } switch (e) { case 0: @@ -3490,9 +3490,6 @@ void Temperature::isr() { } #if HAS_TEMP_SENSOR - - #include "../gcode/gcode.h" - /** * Print a single heater state in the form: * Bed: " B:nnn.nn /nnn.nn" diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index c78dfa937217..1675507f8616 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -527,7 +527,7 @@ class Temperature { #if HAS_USER_THERMISTORS static user_thermistor_t user_thermistor[USER_THERMISTORS]; - static void log_user_thermistor(const uint8_t t_index, const bool eprom=false); + static void M305_report(const uint8_t t_index, const bool forReplay=true); static void reset_user_thermistors(); static celsius_float_t user_thermistor_to_deg_c(const uint8_t t_index, const int16_t raw); static inline bool set_pull_up_res(int8_t t_index, float value) {