Browse Source

Variable tool change purge (#14618)

pull/1/head
InsanityAutomation 6 years ago
committed by Scott Lahteine
parent
commit
ce02c6cee2
  1. 19
      Marlin/src/gcode/config/M217.cpp
  2. 9
      Marlin/src/lcd/language/language_en.h
  3. 10
      Marlin/src/lcd/menu/menu_configuration.cpp
  4. 3
      Marlin/src/module/configuration_store.cpp
  5. 9
      Marlin/src/module/tool_change.cpp
  6. 2
      Marlin/src/module/tool_change.h

19
Marlin/src/gcode/config/M217.cpp

@ -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"
if (parser.seenval('S')) { const float v = parser.value_linear_units(); toolchange_settings.swap_length = constrain(v, 0, 500); }
#define SPR_PARAM "SPRE"
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();

9
Marlin/src/lcd/language/language_en.h

@ -868,13 +868,16 @@
#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")
#define MSG_TOOL_CHANGE _UxGT("Tool Change")
#endif
#ifndef MSG_TOOL_CHANGE_ZLIFT
#define MSG_TOOL_CHANGE_ZLIFT _UxGT("Z Raise")
#define MSG_TOOL_CHANGE_ZLIFT _UxGT("Z Raise")
#endif
#ifndef MSG_SINGLENOZZLE_PRIME_SPD
#define MSG_SINGLENOZZLE_PRIME_SPD _UxGT("Prime Speed")

10
Marlin/src/lcd/menu/menu_configuration.cpp

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

3
Marlin/src/module/configuration_store.cpp

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

9
Marlin/src/module/tool_change.cpp

@ -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
planner.set_e_position_mm((destination[E_AXIS] = current_position[E_AXIS] = current_position[E_AXIS] - (TOOLCHANGE_FIL_EXTRA_PRIME)));
}
#endif

2
Marlin/src/module/tool_change.h

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

Loading…
Cancel
Save