Variable tool change purge (#14618)

This commit is contained in:
InsanityAutomation 2019-07-14 12:40:58 -04:00 committed by Scott Lahteine
parent cbe4bf2ba8
commit ce02c6cee2
6 changed files with 36 additions and 14 deletions

View file

@ -32,6 +32,7 @@ void M217_report(const bool eeprom=false) {
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
serialprintPGM(eeprom ? PSTR(" M217") : PSTR("Toolchange:"));
SERIAL_ECHOPAIR(" S", LINEAR_UNIT(toolchange_settings.swap_length));
SERIAL_ECHOPAIR(" E", LINEAR_UNIT(toolchange_settings.extra_prime));
SERIAL_ECHOPAIR(" P", LINEAR_UNIT(toolchange_settings.prime_speed));
SERIAL_ECHOPAIR(" R", LINEAR_UNIT(toolchange_settings.retract_speed));
@ -54,6 +55,7 @@ void M217_report(const bool eeprom=false) {
* M217 - Set SINGLENOZZLE toolchange parameters
*
* S[linear] Swap length
* E[linear] Purge length
* P[linear/m] Prime speed
* R[linear/m] Retract speed
* X[linear] Park X (Requires TOOLCHANGE_PARK)
@ -68,18 +70,29 @@ void GcodeSuite::M217() {
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
#undef SPR_PARAM
#define SPR_PARAM "SPR"
#define SPR_PARAM "SPRE"
if (parser.seenval('S')) { const float v = parser.value_linear_units(); toolchange_settings.swap_length = constrain(v, 0, 500); }
static constexpr float max_extrude =
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
EXTRUDE_MAXLENGTH
#else
500
#endif
;
if (parser.seenval('S')) { const float v = parser.value_linear_units(); toolchange_settings.swap_length = constrain(v, 0, max_extrude); }
if (parser.seenval('E')) { const float v = parser.value_linear_units(); toolchange_settings.extra_prime = constrain(v, 0, max_extrude); }
if (parser.seenval('P')) { const int16_t v = parser.value_linear_units(); toolchange_settings.prime_speed = constrain(v, 10, 5400); }
if (parser.seenval('R')) { const int16_t v = parser.value_linear_units(); toolchange_settings.retract_speed = constrain(v, 10, 5400); }
#endif
#if ENABLED(TOOLCHANGE_PARK)
#undef XY_PARAM
#define XY_PARAM "XY"
if (parser.seenval('X')) { toolchange_settings.change_point.x = parser.value_linear_units(); }
if (parser.seenval('Y')) { toolchange_settings.change_point.y = parser.value_linear_units(); }
#endif
if (parser.seenval('Z')) { toolchange_settings.z_raise = parser.value_linear_units(); }
if (!parser.seen(SPR_PARAM XY_PARAM "Z")) M217_report();

View file

@ -868,7 +868,10 @@
#define MSG_AUTORETRACT _UxGT("AutoRetr.")
#endif
#ifndef MSG_FILAMENT_SWAP_LENGTH
#define MSG_FILAMENT_SWAP_LENGTH _UxGT("Retract Distance")
#define MSG_FILAMENT_SWAP_LENGTH _UxGT("Swap Length")
#endif
#ifndef MSG_FILAMENT_PURGE_LENGTH
#define MSG_FILAMENT_PURGE_LENGTH _UxGT("Purge Length")
#endif
#ifndef MSG_TOOL_CHANGE
#define MSG_TOOL_CHANGE _UxGT("Tool Change")

View file

@ -109,7 +109,15 @@ static void lcd_factory_settings() {
START_MENU();
MENU_BACK(MSG_CONFIGURATION);
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
MENU_ITEM_EDIT(float3, MSG_FILAMENT_SWAP_LENGTH, &toolchange_settings.swap_length, 0, 200);
static constexpr float max_extrude =
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
EXTRUDE_MAXLENGTH
#else
500
#endif
;
MENU_ITEM_EDIT(float3, MSG_FILAMENT_SWAP_LENGTH, &toolchange_settings.swap_length, 0, max_extrude);
MENU_ITEM_EDIT(float3, MSG_FILAMENT_PURGE_LENGTH, &toolchange_settings.extra_prime, 0, max_extrude);
MENU_MULTIPLIER_ITEM_EDIT(int4, MSG_SINGLENOZZLE_RETRACT_SPD, &toolchange_settings.retract_speed, 10, 5400);
MENU_MULTIPLIER_ITEM_EDIT(int4, MSG_SINGLENOZZLE_PRIME_SPD, &toolchange_settings.prime_speed, 10, 5400);
#endif

View file

@ -37,7 +37,7 @@
*/
// Change EEPROM version if the structure changes
#define EEPROM_VERSION "V67"
#define EEPROM_VERSION "V68"
#define EEPROM_OFFSET 100
// Check the integrity of data offsets.
@ -2290,6 +2290,7 @@ void MarlinSettings::reset() {
#if EXTRUDERS > 1
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
toolchange_settings.swap_length = TOOLCHANGE_FIL_SWAP_LENGTH;
toolchange_settings.extra_prime = TOOLCHANGE_FIL_EXTRA_PRIME;
toolchange_settings.prime_speed = TOOLCHANGE_FIL_SWAP_PRIME_SPEED;
toolchange_settings.retract_speed = TOOLCHANGE_FIL_SWAP_RETRACT_SPEED;
#endif

View file

@ -993,16 +993,13 @@ void tool_change(const uint8_t tmp_extruder, bool no_move/*=false*/) {
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
if (should_swap && !too_cold) {
#if ENABLED(ADVANCED_PAUSE_FEATURE)
do_pause_e_move(toolchange_settings.swap_length + TOOLCHANGE_FIL_EXTRA_PRIME, MMM_TO_MMS(toolchange_settings.prime_speed));
do_pause_e_move(toolchange_settings.swap_length + toolchange_settings.extra_prime, MMM_TO_MMS(toolchange_settings.prime_speed));
#else
current_position[E_AXIS] += (toolchange_settings.swap_length + TOOLCHANGE_FIL_EXTRA_PRIME) / planner.e_factor[tmp_extruder];
current_position[E_AXIS] += (toolchange_settings.swap_length + toolchange_settings.extra_prime) / planner.e_factor[tmp_extruder];
planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.prime_speed), tmp_extruder);
#endif
planner.synchronize();
#if TOOLCHANGE_FIL_EXTRA_PRIME
planner.set_e_position_mm((destination[E_AXIS] = current_position[E_AXIS] = current_position[E_AXIS] - (TOOLCHANGE_FIL_EXTRA_PRIME)));
#endif
}
#endif

View file

@ -27,7 +27,7 @@
typedef struct {
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
float swap_length;
float swap_length, extra_prime;
int16_t prime_speed, retract_speed;
#endif
#if ENABLED(TOOLCHANGE_PARK)