From 7f1fa0d1ff28cea68f5982eafab816b438c2ccdb Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 12 Mar 2021 09:25:41 -0600 Subject: [PATCH] Add M207/8/9 reporting (#21335) --- Marlin/src/feature/fwretract.cpp | 76 +++++++++++++++++++ Marlin/src/feature/fwretract.h | 9 +++ .../src/gcode/feature/fwretract/M207-M209.cpp | 36 ++------- Marlin/src/gcode/geometry/M206_M428.cpp | 4 +- Marlin/src/module/settings.cpp | 27 +------ 5 files changed, 98 insertions(+), 54 deletions(-) diff --git a/Marlin/src/feature/fwretract.cpp b/Marlin/src/feature/fwretract.cpp index 2a71af11d6..4e57ba0150 100644 --- a/Marlin/src/feature/fwretract.cpp +++ b/Marlin/src/feature/fwretract.cpp @@ -36,6 +36,8 @@ FWRetract fwretract; // Single instance - this calls the constructor #include "../module/planner.h" #include "../module/stepper.h" +#include "../gcode/parser.h" + #if ENABLED(RETRACT_SYNC_MIXING) #include "mixing.h" #endif @@ -198,4 +200,78 @@ void FWRetract::retract(const bool retracting //*/ } +//extern const char SP_Z_STR[]; + +/** + * 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 FWRetract::M207() { + if (!parser.seen("FSWZ")) return M207_report(); + if (parser.seen('S')) settings.retract_length = parser.value_axis_units(E_AXIS); + if (parser.seen('F')) settings.retract_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS)); + if (parser.seen('Z')) settings.retract_zraise = parser.value_linear_units(); + if (parser.seen('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(); } + SERIAL_ECHOLNPAIR_P( + PSTR(" M207 S"), LINEAR_UNIT(settings.retract_length) + , PSTR(" W"), LINEAR_UNIT(settings.swap_retract_length) + , PSTR(" F"), LINEAR_UNIT(MMS_TO_MMM(settings.retract_feedrate_mm_s)) + , SP_Z_STR, LINEAR_UNIT(settings.retract_zraise) + ); +} + +/** + * 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 FWRetract::M208() { + if (!parser.seen("FSRW")) return M208_report(); + if (parser.seen('S')) settings.retract_recover_extra = parser.value_axis_units(E_AXIS); + if (parser.seen('F')) settings.retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS)); + if (parser.seen('R')) settings.swap_retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS)); + 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(); } + SERIAL_ECHOLNPAIR( + " M208 S", LINEAR_UNIT(settings.retract_recover_extra) + , " W", LINEAR_UNIT(settings.swap_retract_recover_extra) + , " F", LINEAR_UNIT(MMS_TO_MMM(settings.retract_recover_feedrate_mm_s)) + ); +} + +#if ENABLED(FWRETRACT_AUTORETRACT) + + /** + * M209: Enable automatic retract (M209 S1) + * For slicers that don't support G10/11, reversed extrude-only + * moves will be classified as retraction. + */ + void FWRetract::M209() { + if (!parser.seen('S')) return M209_report(); + if (MIN_AUTORETRACT <= MAX_AUTORETRACT) + 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(); } + SERIAL_ECHOLNPAIR(" M209 S", autoretract_enabled); + } + +#endif // FWRETRACT_AUTORETRACT + + #endif // FWRETRACT diff --git a/Marlin/src/feature/fwretract.h b/Marlin/src/feature/fwretract.h index 134851965d..4fa64ad83b 100644 --- a/Marlin/src/feature/fwretract.h +++ b/Marlin/src/feature/fwretract.h @@ -79,6 +79,15 @@ public: , bool swapping = false #endif ); + + static void M207(); + static void M207_report(const bool forReplay=false); + static void M208(); + static void M208_report(const bool forReplay=false); + #if ENABLED(FWRETRACT_AUTORETRACT) + static void M209(); + static void M209_report(const bool forReplay=false); + #endif }; extern FWRetract fwretract; diff --git a/Marlin/src/gcode/feature/fwretract/M207-M209.cpp b/Marlin/src/gcode/feature/fwretract/M207-M209.cpp index 538f16cde6..5793d73f94 100644 --- a/Marlin/src/gcode/feature/fwretract/M207-M209.cpp +++ b/Marlin/src/gcode/feature/fwretract/M207-M209.cpp @@ -29,46 +29,24 @@ /** * 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() { - if (parser.seen('S')) fwretract.settings.retract_length = parser.value_axis_units(E_AXIS); - if (parser.seen('F')) fwretract.settings.retract_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS)); - if (parser.seen('Z')) fwretract.settings.retract_zraise = parser.value_linear_units(); - if (parser.seen('W')) fwretract.settings.swap_retract_length = parser.value_axis_units(E_AXIS); -} +void GcodeSuite::M207() { fwretract.M207(); } /** * 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() { - if (parser.seen('S')) fwretract.settings.retract_recover_extra = parser.value_axis_units(E_AXIS); - if (parser.seen('F')) fwretract.settings.retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS)); - if (parser.seen('R')) fwretract.settings.swap_retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS)); - if (parser.seen('W')) fwretract.settings.swap_retract_recover_extra = parser.value_axis_units(E_AXIS); -} +void GcodeSuite::M208() { fwretract.M208(); } #if ENABLED(FWRETRACT_AUTORETRACT) /** * M209: Enable automatic retract (M209 S1) - * For slicers that don't support G10/11, reversed extrude-only - * moves will be classified as retraction. + * + * For slicers that don't support G10/11, reversed + * extruder-only moves can be classified as retraction. */ - void GcodeSuite::M209() { - if (MIN_AUTORETRACT <= MAX_AUTORETRACT && parser.seen('S')) - fwretract.enable_autoretract(parser.value_bool()); - } + void GcodeSuite::M209() { fwretract.M209(); } -#endif // FWRETRACT_AUTORETRACT +#endif #endif // FWRETRACT diff --git a/Marlin/src/gcode/geometry/M206_M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp index 2a2cdb16ff..ac2420fcc3 100644 --- a/Marlin/src/gcode/geometry/M206_M428.cpp +++ b/Marlin/src/gcode/geometry/M206_M428.cpp @@ -30,7 +30,7 @@ #include "../../libs/buzzer.h" #include "../../MarlinCore.h" -void m206_report() { +void M206_report() { SERIAL_ECHOLNPAIR_P(PSTR("M206 X"), home_offset.x, SP_Y_STR, home_offset.y, SP_Z_STR, home_offset.z); } @@ -52,7 +52,7 @@ void GcodeSuite::M206() { #endif if (!parser.seen("XYZ")) - m206_report(); + M206_report(); else report_current_position(); } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index c82ed0eb8f..d38ad51934 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -3466,29 +3466,10 @@ void MarlinSettings::reset() { #endif #if ENABLED(FWRETRACT) - - CONFIG_ECHO_HEADING("Retract: S F Z"); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - PSTR(" M207 S"), LINEAR_UNIT(fwretract.settings.retract_length) - , PSTR(" W"), LINEAR_UNIT(fwretract.settings.swap_retract_length) - , PSTR(" F"), LINEAR_UNIT(MMS_TO_MMM(fwretract.settings.retract_feedrate_mm_s)) - , SP_Z_STR, LINEAR_UNIT(fwretract.settings.retract_zraise) - ); - - CONFIG_ECHO_HEADING("Recover: S F"); - CONFIG_ECHO_MSG( - " M208 S", LINEAR_UNIT(fwretract.settings.retract_recover_extra) - , " W", LINEAR_UNIT(fwretract.settings.swap_retract_recover_extra) - , " F", LINEAR_UNIT(MMS_TO_MMM(fwretract.settings.retract_recover_feedrate_mm_s)) - ); - - #if ENABLED(FWRETRACT_AUTORETRACT) - CONFIG_ECHO_HEADING("Auto-Retract: S=0 to disable, 1 to interpret E-only moves as retract/recover"); - CONFIG_ECHO_MSG(" M209 S", fwretract.autoretract_enabled); - #endif - - #endif // FWRETRACT + fwretract.M207_report(forReplay); + fwretract.M208_report(forReplay); + TERN_(FWRETRACT_AUTORETRACT, fwretract.M209_report(forReplay)); + #endif /** * Probe Offset