From 8eb29f91e62d4d68185dbd842921b3a47430cad6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 17 Mar 2017 21:35:31 -0500 Subject: [PATCH 1/6] Patch filament change options and beep code --- Marlin/Configuration_adv.h | 8 +++---- Marlin/Marlin_main.cpp | 24 ++++++++++++------- .../Cartesio/Configuration_adv.h | 8 +++---- .../Felix/Configuration_adv.h | 8 +++---- .../Hephestos/Configuration_adv.h | 8 +++---- .../Hephestos_2/Configuration_adv.h | 8 +++---- .../K8200/Configuration_adv.h | 8 +++---- .../K8400/Configuration_adv.h | 8 +++---- .../RigidBot/Configuration_adv.h | 8 +++---- .../SCARA/Configuration_adv.h | 8 +++---- .../TAZ4/Configuration_adv.h | 8 +++---- .../WITBOX/Configuration_adv.h | 8 +++---- .../flsun_kossel_mini/Configuration_adv.h | 8 +++---- .../delta/generic/Configuration_adv.h | 8 +++---- .../delta/kossel_mini/Configuration_adv.h | 8 +++---- .../delta/kossel_pro/Configuration_adv.h | 8 +++---- .../delta/kossel_xl/Configuration_adv.h | 8 +++---- .../makibox/Configuration_adv.h | 8 +++---- .../tvrrug/Round2/Configuration_adv.h | 8 +++---- 19 files changed, 87 insertions(+), 81 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index af217e50d2..6f319c9d74 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -762,10 +762,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 83717a339e..dae8ed38ca 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -7217,10 +7217,12 @@ inline void gcode_M503() { #if ENABLED(FILAMENT_CHANGE_FEATURE) - millis_t next_buzz = 0; - unsigned long int runout_beep = 0; + void filament_change_beep(const bool init=false) { + static millis_t next_buzz = 0; + static uint16_t runout_beep = 0; + + if (init) next_buzz = runout_beep = 0; - void filament_change_beep() { const millis_t ms = millis(); if (ELAPSED(ms, next_buzz)) { if (runout_beep <= FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS + 5) { // Only beep as long as we're supposed to @@ -7334,20 +7336,22 @@ inline void gcode_M503() { disable_e3(); delay(100); - millis_t nozzle_timeout = millis() + FILAMENT_CHANGE_NOZZLE_TIMEOUT * 1000L; + millis_t nozzle_timeout = millis() + (millis_t)(FILAMENT_CHANGE_NOZZLE_TIMEOUT) * 1000L; bool nozzle_timed_out = false; float temps[4]; // Wait for filament insert by user and press button lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT); + #if HAS_BUZZER + filament_change_beep(true); + #endif + idle(); - wait_for_user = true; // LCD click or M108 will clear this - next_buzz = 0; - runout_beep = 0; HOTEND_LOOP() temps[e] = thermalManager.target_temperature[e]; // Save nozzle temps + wait_for_user = true; // LCD click or M108 will clear this while (wait_for_user) { millis_t current_ms = millis(); if (nozzle_timed_out) @@ -7389,9 +7393,11 @@ inline void gcode_M503() { if (nozzle_timed_out) lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT); + #if HAS_BUZZER + filament_change_beep(true); + #endif + wait_for_user = true; // LCD click or M108 will clear this - next_buzz = 0; - runout_beep = 0; while (wait_for_user && nozzle_timed_out) { #if HAS_BUZZER filament_change_beep(); diff --git a/Marlin/example_configurations/Cartesio/Configuration_adv.h b/Marlin/example_configurations/Cartesio/Configuration_adv.h index 5d8b55f495..4eb8ab689c 100644 --- a/Marlin/example_configurations/Cartesio/Configuration_adv.h +++ b/Marlin/example_configurations/Cartesio/Configuration_adv.h @@ -752,10 +752,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index 27116092dc..1dc28d57c3 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -752,10 +752,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index b5e1d2832b..659ea5a2ce 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -752,10 +752,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h index a8899ab838..314890125f 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h @@ -735,10 +735,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index f85d1009da..8e0f5a718e 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -765,10 +765,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/K8400/Configuration_adv.h b/Marlin/example_configurations/K8400/Configuration_adv.h index fc293e3451..a0d9eafcd1 100644 --- a/Marlin/example_configurations/K8400/Configuration_adv.h +++ b/Marlin/example_configurations/K8400/Configuration_adv.h @@ -752,10 +752,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/RigidBot/Configuration_adv.h b/Marlin/example_configurations/RigidBot/Configuration_adv.h index 4751b30fd2..08fb726d10 100644 --- a/Marlin/example_configurations/RigidBot/Configuration_adv.h +++ b/Marlin/example_configurations/RigidBot/Configuration_adv.h @@ -752,10 +752,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index 67dc5630a0..90a5dcacb0 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -752,10 +752,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/TAZ4/Configuration_adv.h b/Marlin/example_configurations/TAZ4/Configuration_adv.h index b347b3d7dd..6c8c853941 100644 --- a/Marlin/example_configurations/TAZ4/Configuration_adv.h +++ b/Marlin/example_configurations/TAZ4/Configuration_adv.h @@ -760,10 +760,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index b5e1d2832b..659ea5a2ce 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -752,10 +752,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/delta/flsun_kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/flsun_kossel_mini/Configuration_adv.h index f1f703aa39..a787973995 100644 --- a/Marlin/example_configurations/delta/flsun_kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/flsun_kossel_mini/Configuration_adv.h @@ -757,10 +757,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index 4e09826315..9d74ba09fa 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -754,10 +754,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index 4e09826315..9d74ba09fa 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -754,10 +754,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h index 2b32809a82..bdddf75fad 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h @@ -759,10 +759,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h index 3fa66b4cc8..a76a670a42 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h @@ -754,10 +754,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 84e65c0ed9..e17f293678 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -752,10 +752,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index ab80eca718..4535f0651f 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -752,10 +752,10 @@ // 0 to disable for manual extrusion // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend, // or until outcoming filament color is not clear for filament color change - #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45L // Turn off nozzle if user doesn't change filament within this time limit in seconds - #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5L // Number of alert beeps before printer goes quiet - #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change - // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + #define FILAMENT_CHANGE_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds + #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet + #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change + // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. #endif // @section tmc From 4c7f14752a9cd5c69c1493ef1e28b932e44b5232 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 17 Mar 2017 21:12:19 -0500 Subject: [PATCH 2/6] Add disable_e_steppers function --- Marlin/Marlin.h | 1 + Marlin/Marlin_main.cpp | 29 +++++++++++------------------ Marlin/planner.cpp | 7 +------ 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index e77fc46158..8694398177 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -223,6 +223,7 @@ void manage_inactivity(bool ignore_stepper_queue = false); #define _AXIS(AXIS) AXIS ##_AXIS void enable_all_steppers(); +void disable_e_steppers(); void disable_all_steppers(); void FlushSerialRequestResend(); diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index dae8ed38ca..a5ce315a46 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -5918,12 +5918,7 @@ inline void gcode_M18_M84() { if (code_seen('Y')) disable_y(); if (code_seen('Z')) disable_z(); #if ((E0_ENABLE_PIN != X_ENABLE_PIN) && (E1_ENABLE_PIN != Y_ENABLE_PIN)) // Only enable on boards that have seperate ENABLE_PINS - if (code_seen('E')) { - disable_e0(); - disable_e1(); - disable_e2(); - disable_e3(); - } + if (code_seen('E')) disable_e_steppers(); #endif } } @@ -7330,10 +7325,7 @@ inline void gcode_M503() { // Synchronize steppers and then disable extruders steppers for manual filament changing stepper.synchronize(); - disable_e0(); - disable_e1(); - disable_e2(); - disable_e3(); + disable_e_steppers(); delay(100); millis_t nozzle_timeout = millis() + (millis_t)(FILAMENT_CHANGE_NOZZLE_TIMEOUT) * 1000L; @@ -10123,16 +10115,20 @@ void enable_all_steppers() { enable_e3(); } -void disable_all_steppers() { - disable_x(); - disable_y(); - disable_z(); +void disable_e_steppers() { disable_e0(); disable_e1(); disable_e2(); disable_e3(); } +void disable_all_steppers() { + disable_x(); + disable_y(); + disable_z(); + disable_e_steppers(); +} + #if ENABLED(AUTOMATIC_CURRENT_CONTROL) void automatic_current_control(const TMC2130Stepper &st) { @@ -10240,10 +10236,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { disable_z(); #endif #if ENABLED(DISABLE_INACTIVE_E) - disable_e0(); - disable_e1(); - disable_e2(); - disable_e3(); + disable_e_steppers(); #endif } diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 7ccf4795bc..c5d0fe4cb2 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -450,12 +450,7 @@ void Planner::check_axes_activity() { if (!axis_active[Z_AXIS]) disable_z(); #endif #if ENABLED(DISABLE_E) - if (!axis_active[E_AXIS]) { - disable_e0(); - disable_e1(); - disable_e2(); - disable_e3(); - } + if (!axis_active[E_AXIS]) disable_e_steppers(); #endif #if FAN_COUNT > 0 From 4cf51157b3e7e2e0bd648c8e6cad0dcf7d1341d6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 17 Mar 2017 21:14:05 -0500 Subject: [PATCH 3/6] Use XYZE rather than NUM_AXIS --- Marlin/Marlin_main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index a5ce315a46..c88f4b6393 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -448,7 +448,7 @@ volatile bool wait_for_heatup = true; const char errormagic[] PROGMEM = "Error:"; const char echomagic[] PROGMEM = "echo:"; -const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'}; +const char axis_codes[XYZE] = {'X', 'Y', 'Z', 'E'}; // Number of characters read in the current line of serial input static int serial_count = 0; @@ -690,7 +690,7 @@ void get_cartesian_from_steppers(); void set_current_from_steppers_for_axis(const AxisEnum axis); #if ENABLED(ARC_SUPPORT) - void plan_arc(float target[NUM_AXIS], float* offset, uint8_t clockwise); + void plan_arc(float target[XYZE], float* offset, uint8_t clockwise); #endif #if ENABLED(BEZIER_CURVE_SUPPORT) @@ -1333,7 +1333,7 @@ bool get_target_extruder_from_command(int code) { static float inactive_extruder_x_pos = X2_MAX_POS; // used in mode 0 & 1 static bool active_extruder_parked = false; // used in mode 1 & 2 - static float raised_parked_position[NUM_AXIS]; // used in mode 1 + static float raised_parked_position[XYZE]; // used in mode 1 static millis_t delayed_move_time = 0; // used in mode 1 static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2 static float duplicate_extruder_temp_offset = 0; // used in mode 2 @@ -7581,7 +7581,7 @@ inline void gcode_M503() { * Report driver currents when no axis specified */ inline void gcode_M906() { - uint16_t values[NUM_AXIS]; + uint16_t values[XYZE]; LOOP_XYZE(i) values[i] = code_seen(axis_codes[i]) ? code_value_int() : 0; @@ -9499,7 +9499,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) { * This calls planner.buffer_line several times, adding * small incremental moves for DELTA or SCARA. */ - inline bool prepare_kinematic_move_to(float ltarget[NUM_AXIS]) { + inline bool prepare_kinematic_move_to(float ltarget[XYZE]) { // Get the top feedrate of the move in the XY plane float _feedrate_mm_s = MMS_SCALED(feedrate_mm_s); @@ -9511,7 +9511,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) { } // Get the cartesian distances moved in XYZE - float difference[NUM_AXIS]; + float difference[XYZE]; LOOP_XYZE(i) difference[i] = ltarget[i] - current_position[i]; // Get the linear distance in XYZ @@ -9736,7 +9736,7 @@ void prepare_move_to_destination() { * options for G2/G3 arc generation. In future these options may be GCode tunable. */ void plan_arc( - float logical[NUM_AXIS], // Destination position + float logical[XYZE], // Destination position float* offset, // Center of rotation relative to current_position uint8_t clockwise // Clockwise? ) { From 26473cab6ddcfed1a491d73de7f80ee725f803e1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 17 Mar 2017 21:24:33 -0500 Subject: [PATCH 4/6] Add PARK_HEAD_ON_PAUSE feature --- Marlin/Configuration_adv.h | 1 + Marlin/SanityCheck.h | 3 ++- Marlin/example_configurations/Cartesio/Configuration_adv.h | 1 + Marlin/example_configurations/Felix/Configuration_adv.h | 1 + Marlin/example_configurations/Hephestos/Configuration_adv.h | 1 + Marlin/example_configurations/Hephestos_2/Configuration_adv.h | 1 + Marlin/example_configurations/K8200/Configuration_adv.h | 1 + Marlin/example_configurations/K8400/Configuration_adv.h | 1 + Marlin/example_configurations/RigidBot/Configuration_adv.h | 1 + Marlin/example_configurations/SCARA/Configuration_adv.h | 1 + Marlin/example_configurations/TAZ4/Configuration_adv.h | 1 + Marlin/example_configurations/WITBOX/Configuration_adv.h | 1 + .../delta/flsun_kossel_mini/Configuration_adv.h | 1 + .../example_configurations/delta/generic/Configuration_adv.h | 1 + .../delta/kossel_mini/Configuration_adv.h | 1 + .../delta/kossel_pro/Configuration_adv.h | 1 + .../example_configurations/delta/kossel_xl/Configuration_adv.h | 1 + Marlin/example_configurations/makibox/Configuration_adv.h | 1 + .../example_configurations/tvrrug/Round2/Configuration_adv.h | 1 + 19 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 6f319c9d74..57209236ac 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -766,6 +766,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index 8958743e74..23666d8f75 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -280,6 +280,8 @@ #error "FILAMENT_CHANGE_FEATURE currently requires an LCD controller." #elif ENABLED(EXTRUDER_RUNOUT_PREVENT) #error "EXTRUDER_RUNOUT_PREVENT is incompatible with FILAMENT_CHANGE_FEATURE." + #elif ENABLED(PARK_HEAD_ON_PAUSE) && DISABLED(SDSUPPORT) && DISABLED(ULTIPANEL) && DISABLED(EMERGENCY_PARSER) + #error "PARK_HEAD_ON_PAUSE requires SDSUPPORT, EMERGENCY_PARSER, or an LCD controller." #endif #endif @@ -936,7 +938,6 @@ static_assert(1 >= 0 #endif #endif - /** * Make sure only one display is enabled * diff --git a/Marlin/example_configurations/Cartesio/Configuration_adv.h b/Marlin/example_configurations/Cartesio/Configuration_adv.h index 4eb8ab689c..c3e90d78fb 100644 --- a/Marlin/example_configurations/Cartesio/Configuration_adv.h +++ b/Marlin/example_configurations/Cartesio/Configuration_adv.h @@ -756,6 +756,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index 1dc28d57c3..749573c8a4 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -756,6 +756,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index 659ea5a2ce..7d8d8a469c 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -756,6 +756,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h index 314890125f..1b86b47736 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h @@ -739,6 +739,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index 8e0f5a718e..a8bf205645 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -769,6 +769,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/K8400/Configuration_adv.h b/Marlin/example_configurations/K8400/Configuration_adv.h index a0d9eafcd1..feeb1dee97 100644 --- a/Marlin/example_configurations/K8400/Configuration_adv.h +++ b/Marlin/example_configurations/K8400/Configuration_adv.h @@ -756,6 +756,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/RigidBot/Configuration_adv.h b/Marlin/example_configurations/RigidBot/Configuration_adv.h index 08fb726d10..f13eb5e608 100644 --- a/Marlin/example_configurations/RigidBot/Configuration_adv.h +++ b/Marlin/example_configurations/RigidBot/Configuration_adv.h @@ -756,6 +756,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index 90a5dcacb0..21eed190cf 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -756,6 +756,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/TAZ4/Configuration_adv.h b/Marlin/example_configurations/TAZ4/Configuration_adv.h index 6c8c853941..f257b7f0a7 100644 --- a/Marlin/example_configurations/TAZ4/Configuration_adv.h +++ b/Marlin/example_configurations/TAZ4/Configuration_adv.h @@ -764,6 +764,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index 659ea5a2ce..7d8d8a469c 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -756,6 +756,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/delta/flsun_kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/flsun_kossel_mini/Configuration_adv.h index a787973995..816708620a 100644 --- a/Marlin/example_configurations/delta/flsun_kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/flsun_kossel_mini/Configuration_adv.h @@ -761,6 +761,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index 9d74ba09fa..ad8d1ec8db 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -758,6 +758,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index 9d74ba09fa..ad8d1ec8db 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -758,6 +758,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h index bdddf75fad..4ea6e9637a 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h @@ -763,6 +763,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h index a76a670a42..7651a35e27 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h @@ -758,6 +758,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index e17f293678..a3c7c764ec 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -756,6 +756,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index 4535f0651f..db2b5f85b8 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -756,6 +756,7 @@ #define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet #define FILAMENT_CHANGE_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME. + //#define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume #endif // @section tmc From ff0dd162b79905291eed7d9944216875bb801562 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 19 Mar 2017 04:26:22 -0500 Subject: [PATCH 5/6] PARK_HEAD_ON_PAUSE implementation --- Marlin/Marlin_main.cpp | 186 +++++++++++++++++++++++++++++++++++++---- Marlin/ultralcd.cpp | 13 ++- 2 files changed, 179 insertions(+), 20 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index c88f4b6393..7d5cf729ab 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -122,6 +122,7 @@ * M119 - Report endstops status. * M120 - Enable endstops detection. * M121 - Disable endstops detection. + * M125 - Save current position and move to filament change position. (Requires PARK_HEAD_ON_PAUSE) * M126 - Solenoid Air Valve Open. (Requires BARICUDA) * M127 - Solenoid Air Valve Closed. (Requires BARICUDA) * M128 - EtoP Open. (Requires BARICUDA) @@ -150,7 +151,7 @@ * M208 - Set Recover (unretract) Additional (!) Length: S and Feedrate: F. (Requires FWRETRACT) * M209 - Turn Automatic Retract Detection on/off: S<0|1> (For slicers that don't support G10/11). (Requires FWRETRACT) Every normal extrude-only move will be classified as retract depending on the direction. - * M211 - Enable, Disable, and/or Report software endstops: S<0|1> + * M211 - Enable, Disable, and/or Report software endstops: S<0|1> (Requires MIN_SOFTWARE_ENDSTOPS or MAX_SOFTWARE_ENDSTOPS) * M218 - Set a tool offset: "M218 T X Y". (Requires 2 or more extruders) * M220 - Set Feedrate Percentage: "M220 S" (i.e., "FR" on the LCD) * M221 - Set Flow Percentage: "M221 S" @@ -199,13 +200,11 @@ * M350 - Set microstepping mode. (Requires digital microstepping pins.) * M351 - Toggle MS1 MS2 pins directly. (Requires digital microstepping pins.) * - * ************ SCARA Specific - This can change to suit future G-code regulations * M360 - SCARA calibration: Move to cal-position ThetaA (0 deg calibration) * M361 - SCARA calibration: Move to cal-position ThetaB (90 deg calibration - steps per degree) * M362 - SCARA calibration: Move to cal-position PsiA (0 deg calibration) * M363 - SCARA calibration: Move to cal-position PsiB (90 deg calibration - steps per degree) * M364 - SCARA calibration: Move to cal-position PSIC (90 deg to Theta calibration position) - * ************* SCARA End *************** * * ************ Custom codes - This can change to suit future G-code regulations * M100 - Watch Free Memory (For Debugging). (Requires M100_FREE_MEMORY_WATCHER) @@ -4667,6 +4666,45 @@ inline void gcode_M17() { enable_all_steppers(); } +#if IS_KINEMATIC + #define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder) +#else + #define RUNPLAN(RATE_MM_S) line_to_destination(RATE_MM_S) +#endif + +#if ENABLED(PARK_HEAD_ON_PAUSE) + float resume_position[XYZE]; + bool move_away_flag = false; + + inline void move_back_on_resume() { + if (!move_away_flag) return; + move_away_flag = false; + + // Set extruder to saved position + destination[E_AXIS] = current_position[E_AXIS] = resume_position[E_AXIS]; + planner.set_e_position_mm(current_position[E_AXIS]); + + #if IS_KINEMATIC + // Move XYZ to starting position + planner.buffer_line_kinematic(lastpos, FILAMENT_CHANGE_XY_FEEDRATE, active_extruder); + #else + // Move XY to starting position, then Z + destination[X_AXIS] = resume_position[X_AXIS]; + destination[Y_AXIS] = resume_position[Y_AXIS]; + RUNPLAN(FILAMENT_CHANGE_XY_FEEDRATE); + destination[Z_AXIS] = resume_position[Z_AXIS]; + RUNPLAN(FILAMENT_CHANGE_Z_FEEDRATE); + #endif + stepper.synchronize(); + + #if ENABLED(FILAMENT_RUNOUT_SENSOR) + filament_ran_out = false; + #endif + set_current_to_destination(); + } + +#endif // PARK_HEAD_ON_PAUSE + #if ENABLED(SDSUPPORT) /** @@ -4694,9 +4732,13 @@ inline void gcode_M17() { inline void gcode_M23() { card.openFile(current_command_args, true); } /** - * M24: Start SD Print + * M24: Start or Resume SD Print */ inline void gcode_M24() { + #if ENABLED(PARK_HEAD_ON_PAUSE) + move_back_on_resume(); + #endif + card.startFileprint(); print_job_timer.start(); } @@ -4704,7 +4746,14 @@ inline void gcode_M17() { /** * M25: Pause SD Print */ - inline void gcode_M25() { card.pauseSDPrint(); } + inline void gcode_M25() { + card.pauseSDPrint(); + print_job_timer.pause(); + + #if ENABLED(PARK_HEAD_ON_PAUSE) + enqueue_and_echo_commands_P(PSTR("M125")); // Must be enqueued with pauseSDPrint set to be last in the buffer + #endif + } /** * M26: Set SD Card file index @@ -6084,6 +6133,111 @@ inline void gcode_M120() { endstops.enable_globally(true); } */ inline void gcode_M121() { endstops.enable_globally(false); } +#if ENABLED(PARK_HEAD_ON_PAUSE) + + /** + * M125: Store current position and move to filament change position. + * Called on pause (by M25) to prevent material leaking onto the + * object. On resume (M24) the head will be moved back and the + * print will resume. + * + * If Marlin is compiled without SD Card support, M125 can be + * used directly to pause the print and move to park position, + * resuming with a button click or M108. + * + * L = override retract length + * X = override X + * Y = override Y + * Z = override Z raise + */ + inline void gcode_M125() { + if (move_away_flag) return; // already paused + + const bool job_running = print_job_timer.isRunning(); + + // there are blocks after this one, or sd printing + move_away_flag = job_running || planner.blocks_queued() + #if ENABLED(SDSUPPORT) + || card.sdprinting + #endif + ; + + if (!move_away_flag) return; // nothing to pause + + // M125 can be used to pause a print too + #if ENABLED(SDSUPPORT) + card.pauseSDPrint(); + #endif + print_job_timer.pause(); + + // Save current position + COPY(resume_position, current_position); + + set_destination_to_current(); + + // Initial retract before move to filament change position + destination[E_AXIS] += code_seen('L') ? code_value_axis_units(E_AXIS) : 0 + #if defined(FILAMENT_CHANGE_RETRACT_LENGTH) && FILAMENT_CHANGE_RETRACT_LENGTH > 0 + - (FILAMENT_CHANGE_RETRACT_LENGTH) + #endif + ; + RUNPLAN(FILAMENT_CHANGE_RETRACT_FEEDRATE); + + // Lift Z axis + const float z_lift = code_seen('Z') ? code_value_axis_units(Z_AXIS) : + #if defined(FILAMENT_CHANGE_Z_ADD) && FILAMENT_CHANGE_Z_ADD > 0 + FILAMENT_CHANGE_Z_ADD + #else + 0 + #endif + ; + if (z_lift > 0) { + destination[Z_AXIS] += z_lift; + NOMORE(destination[Z_AXIS], Z_MAX_POS); + RUNPLAN(FILAMENT_CHANGE_Z_FEEDRATE); + } + + // Move XY axes to filament change position or given position + destination[X_AXIS] = code_seen('X') ? code_value_axis_units(X_AXIS) : 0 + #ifdef FILAMENT_CHANGE_X_POS + + FILAMENT_CHANGE_X_POS + #endif + ; + destination[Y_AXIS] = code_seen('Y') ? code_value_axis_units(Y_AXIS) : 0 + #ifdef FILAMENT_CHANGE_Y_POS + + FILAMENT_CHANGE_Y_POS + #endif + ; + + #if HOTENDS > 1 && DISABLED(DUAL_X_CARRIAGE) + if (active_extruder > 0) { + if (!code_seen('X')) destination[X_AXIS] += hotend_offset[X_AXIS][active_extruder]; + if (!code_seen('Y')) destination[Y_AXIS] += hotend_offset[Y_AXIS][active_extruder]; + } + #endif + + clamp_to_software_endstops(destination); + RUNPLAN(FILAMENT_CHANGE_XY_FEEDRATE); + set_current_to_destination(); + stepper.synchronize(); + disable_e_steppers(); + + #if DISABLED(SDSUPPORT) + // Wait for lcd click or M108 + wait_for_user = true; + KEEPALIVE_STATE(PAUSED_FOR_USER); + while (wait_for_user) idle(); + KEEPALIVE_STATE(IN_HANDLER); + + // Return to print position and continue + move_back_on_resume(); + if (job_running) print_job_timer.start(); + move_away_flag = false; + #endif + } + +#endif // PARK_HEAD_ON_PAUSE + #if ENABLED(BLINKM) || ENABLED(RGB_LED) void set_led_color(const uint8_t r, const uint8_t g, const uint8_t b) { @@ -7253,25 +7407,18 @@ inline void gcode_M503() { busy_doing_M600 = true; // Stepper Motors can't timeout when this is set // Pause the print job timer - bool job_running = print_job_timer.isRunning(); + const bool job_running = print_job_timer.isRunning(); + print_job_timer.pause(); // Show initial message and wait for synchronize steppers lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INIT); stepper.synchronize(); - float lastpos[NUM_AXIS]; - // Save current position of all axes - LOOP_XYZE(i) - lastpos[i] = destination[i] = current_position[i]; - - // Define runplan for move axes - #if IS_KINEMATIC - #define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder); - #else - #define RUNPLAN(RATE_MM_S) line_to_destination(RATE_MM_S); - #endif + float lastpos[XYZE]; + COPY(lastpos, current_position); + set_destination_to_current(); // Initial retract before move to filament change position destination[E_AXIS] += code_seen('E') ? code_value_axis_units(E_AXIS) : 0 @@ -8555,6 +8702,11 @@ void process_next_command() { break; #endif // FAN_COUNT > 0 + #if ENABLED(PARK_HEAD_ON_PAUSE) + case 125: // M125: Store current position and move to filament change position + gcode_M125(); break; + #endif + #if ENABLED(BARICUDA) // PWM for HEATER_1_PIN #if HAS_HEATER_1 diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 4ce684ddf2..7b04d28059 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -615,11 +615,18 @@ void kill_screen(const char* lcd_msg) { void lcd_sdcard_pause() { card.pauseSDPrint(); print_job_timer.pause(); + #if ENABLED(PARK_HEAD_ON_PAUSE) + enqueue_and_echo_commands_P(PSTR("M125")) + #endif } void lcd_sdcard_resume() { - card.startFileprint(); - print_job_timer.start(); + #if ENABLED(PARK_HEAD_ON_PAUSE) + enqueue_and_echo_commands_P(PSTR("M24")) + #else + card.startFileprint(); + print_job_timer.start(); + #endif } void lcd_sdcard_stop() { @@ -634,7 +641,7 @@ void kill_screen(const char* lcd_msg) { lcd_setstatus(MSG_PRINT_ABORTED, true); } - #endif //SDSUPPORT + #endif // SDSUPPORT #if ENABLED(MENU_ITEM_CASE_LIGHT) From 786fe2ba2ae0a3beba25b2f6a06eaa11c71782b2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 19 Mar 2017 18:34:58 -0500 Subject: [PATCH 6/6] Include PARK_HEAD_ON_PAUSE in Travis testing --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a2c766f580..9935453f08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -201,11 +201,11 @@ script: - opt_set MOTHERBOARD BOARD_MINIRAMBO - build_marlin # - # Test FILAMENT_CHANGE_FEATURE and LCD_INFO_MENU + # Test FILAMENT_CHANGE_FEATURE, PARK_HEAD_ON_PAUSE, and LCD_INFO_MENU # - restore_configs - opt_enable ULTIMAKERCONTROLLER - - opt_enable_adv FILAMENT_CHANGE_FEATURE LCD_INFO_MENU + - opt_enable_adv FILAMENT_CHANGE_FEATURE PARK_HEAD_ON_PAUSE LCD_INFO_MENU - build_marlin # # Enable filament sensor