Add M207/8/9 reporting (#21335)

This commit is contained in:
Scott Lahteine 2021-03-12 09:25:41 -06:00
parent 7fb04b3656
commit 2480c82d76
5 changed files with 98 additions and 54 deletions

View file

@ -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<length> F<units/m> Z<lift>"); 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<length> F<units/m>"); 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

View file

@ -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;

View file

@ -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

View file

@ -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();
}

View file

@ -3466,30 +3466,11 @@ void MarlinSettings::reset() {
#endif
#if ENABLED(FWRETRACT)
CONFIG_ECHO_HEADING("Retract: S<length> F<units/m> Z<lift>");
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<length> F<units/m>");
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);
fwretract.M207_report(forReplay);
fwretract.M208_report(forReplay);
TERN_(FWRETRACT_AUTORETRACT, fwretract.M209_report(forReplay));
#endif
#endif // FWRETRACT
/**
* Probe Offset
*/