From eb02f8c71921b09d9f1044f43c1e57e588d9fe7c Mon Sep 17 00:00:00 2001 From: studiodyne Date: Thu, 26 Oct 2017 23:33:19 +0200 Subject: [PATCH 1/4] Improve FWRETRACT logic, add common sense --- Marlin/src/feature/fwretract.cpp | 61 ++++++++++++--------------- Marlin/src/lcd/language/language_en.h | 5 ++- Marlin/src/lcd/language/language_fr.h | 1 + Marlin/src/lcd/ultralcd.cpp | 3 ++ 4 files changed, 36 insertions(+), 34 deletions(-) diff --git a/Marlin/src/feature/fwretract.cpp b/Marlin/src/feature/fwretract.cpp index a6093205f3..708b52ec71 100644 --- a/Marlin/src/feature/fwretract.cpp +++ b/Marlin/src/feature/fwretract.cpp @@ -94,13 +94,16 @@ void FWRetract::retract(const bool retracting #endif ) { - static float hop_height, // Remember where the Z height started - hop_amount = 0.0; // Total amount lifted, for use in recover + static float hop_amount = 0.0; // Total amount lifted, for use in recover - // Simply never allow two retracts or recovers in a row + // Prevent two retracts or recovers in a row if (retracted[active_extruder] == retracting) return; + // Prevent two swap-retract or recovers in a row #if EXTRUDERS > 1 + // Allow G10 S1 only after G10 + if (swapping && retracted_swap[active_extruder] == retracting) return; + // G11 priority to recover the long retract if activated if (!retracting) swapping = retracted_swap[active_extruder]; #else const bool swapping = false; @@ -121,64 +124,56 @@ void FWRetract::retract(const bool retracting //*/ const bool has_zhop = retract_zlift > 0.01; // Is there a hop set? - const float old_feedrate_mm_s = feedrate_mm_s; - const int16_t old_flow = planner.flow_percentage[active_extruder]; - - // Don't apply flow multiplication to retract/recover - planner.flow_percentage[active_extruder] = 100; // The current position will be the destination for E and Z moves set_destination_from_current(); - stepper.synchronize(); // Wait for buffered moves to complete - if (retracting) { - // Remember the Z height since G-code may include its own Z-hop - // For best results turn off Z hop if G-code already includes it - hop_height = destination[Z_AXIS]; + const float renormalize = 100.0 / planner.flow_percentage[active_extruder] / planner.volumetric_multiplier[active_extruder]; + if (retracting) { // Retract by moving from a faux E position back to the current E position feedrate_mm_s = retract_feedrate_mm_s; - current_position[E_AXIS] += (swapping ? swap_retract_length : retract_length) / planner.volumetric_multiplier[active_extruder]; + current_position[E_AXIS] += (swapping ? swap_retract_length : retract_length) * renormalize; sync_plan_position_e(); prepare_move_to_destination(); // Is a Z hop set, and has the hop not yet been done? - if (has_zhop) { - hop_amount += retract_zlift; // Carriage is raised for retraction hop - current_position[Z_AXIS] -= retract_zlift; // Pretend current pos is lower. Next move raises Z. - SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position - prepare_move_to_destination(); // Raise up to the old current pos + // No double zlifting + // Feedrate to the max + if (has_zhop && !hop_amount) { + hop_amount += retract_zlift; // Carriage is raised for retraction hop + feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Z feedrate to max + current_position[Z_AXIS] -= retract_zlift; // Pretend current pos is lower. Next move raises Z. + SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position + prepare_move_to_destination(); // Raise up to the old current pos } } else { // If a hop was done and Z hasn't changed, undo the Z hop - if (hop_amount && NEAR(hop_height, destination[Z_AXIS])) { - current_position[Z_AXIS] += hop_amount; // Pretend current pos is higher. Next move lowers Z. - SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position - prepare_move_to_destination(); // Lower to the old current pos - hop_amount = 0.0; + if (hop_amount) { + current_position[Z_AXIS] -= retract_zlift; // Pretend current pos is lower. Next move raises Z. + SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position + feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Z feedrate to max + prepare_move_to_destination(); // Raise up to the old current pos + hop_amount = 0.0; // Clear hop } // A retract multiplier has been added here to get faster swap recovery feedrate_mm_s = swapping ? swap_retract_recover_feedrate_mm_s : retract_recover_feedrate_mm_s; const float move_e = swapping ? swap_retract_length + swap_retract_recover_length : retract_length + retract_recover_length; - current_position[E_AXIS] -= move_e / planner.volumetric_multiplier[active_extruder]; + current_position[E_AXIS] -= move_e * renormalize; sync_plan_position_e(); - prepare_move_to_destination(); // Recover E } - // Restore flow and feedrate - planner.flow_percentage[active_extruder] = old_flow; - feedrate_mm_s = old_feedrate_mm_s; + feedrate_mm_s = old_feedrate_mm_s; // Restore original feedrate - // The active extruder is now retracted or recovered - retracted[active_extruder] = retracting; + retracted[active_extruder] = retracting; // Active extruder now retracted / recovered - // If swap retract/recover then update the retracted_swap flag too + // If swap retract/recover update the retracted_swap flag too #if EXTRUDERS > 1 if (swapping) retracted_swap[active_extruder] = retracting; #endif @@ -197,6 +192,6 @@ void FWRetract::retract(const bool retracting SERIAL_ECHOLNPAIR("hop_amount ", hop_amount); //*/ -} // retract() +} #endif // FWRETRACT diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 3713433530..9c3b0b7711 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -615,7 +615,10 @@ #define MSG_CONTROL_RETRACT_RECOVER_SWAP _UxGT("S UnRet mm") #endif #ifndef MSG_CONTROL_RETRACT_RECOVERF - #define MSG_CONTROL_RETRACT_RECOVERF _UxGT("UnRet V") + #define MSG_CONTROL_RETRACT_RECOVERF _UxGT("UnRet V") +#endif +#ifndef MSG_CONTROL_RETRACT_RECOVER_SWAPF + #define MSG_CONTROL_RETRACT_RECOVER_SWAPF _UxGT("S UnRet V") #endif #ifndef MSG_AUTORETRACT #define MSG_AUTORETRACT _UxGT("AutoRetr.") diff --git a/Marlin/src/lcd/language/language_fr.h b/Marlin/src/lcd/language/language_fr.h index b98fc38643..fda68334a5 100644 --- a/Marlin/src/lcd/language/language_fr.h +++ b/Marlin/src/lcd/language/language_fr.h @@ -222,6 +222,7 @@ #define MSG_CONTROL_RETRACT_RECOVER _UxGT("UnRet mm") #define MSG_CONTROL_RETRACT_RECOVER_SWAP _UxGT("Ech. UnRet mm") #define MSG_CONTROL_RETRACT_RECOVERF _UxGT("UnRet V") +#define MSG_CONTROL_RETRACT_RECOVER_SWAPF _UxGT("Ech. Retr. V") #define MSG_AUTORETRACT _UxGT("Retract. Auto.") #define MSG_FILAMENTCHANGE _UxGT("Changer filament") #define MSG_INIT_SDCARD _UxGT("Init. la carte SD") diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index ca036563a0..d9669c06a5 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -3716,6 +3716,9 @@ void kill_screen(const char* lcd_msg) { MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER_SWAP, &fwretract.swap_retract_recover_length, -100, 100); #endif MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &fwretract.retract_recover_feedrate_mm_s, 1, 999); + #if EXTRUDERS > 1 + MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVER_SWAPF, &fwretract.swap_retract_recover_feedrate_mm_s, 1, 999); + #endif END_MENU(); } From 0ceec1f1669c6b678d8df7095a8170e5bfd312d3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 26 Oct 2017 22:19:23 -0500 Subject: [PATCH 2/4] Fix leveling_active_at_z warning --- Marlin/src/module/planner.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 36f4e4e9a0..1e157bbdf2 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -308,7 +308,7 @@ class Planner { return 1.0; } - FORCE_INLINE static bool leveling_active_at_z(const float &lz) { return true; } + FORCE_INLINE static bool leveling_active_at_z(const float &lz) { UNUSED(lz); return true; } #endif From daeff5a11a25a58adb3e61a8cb75deb9a06ff011 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 26 Oct 2017 22:47:07 -0500 Subject: [PATCH 3/4] Tweak neopixel self-test --- Marlin/src/feature/leds/neopixel.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index 778170ba65..ae06e9b009 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -45,13 +45,13 @@ void setup_neopixel() { pixels.show(); // initialize to all off #if ENABLED(NEOPIXEL_STARTUP_TEST) - delay(2000); + safe_delay(1000); set_neopixel_color(pixels.Color(255, 0, 0, 0)); // red - delay(2000); + safe_delay(1000); set_neopixel_color(pixels.Color(0, 255, 0, 0)); // green - delay(2000); + safe_delay(1000); set_neopixel_color(pixels.Color(0, 0, 255, 0)); // blue - delay(2000); + safe_delay(1000); #endif set_neopixel_color(pixels.Color(NEO_WHITE)); // white } From 33f379fe88e0068082cbafdedad4a7f5bb82f387 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 26 Oct 2017 22:49:04 -0500 Subject: [PATCH 4/4] Add some Polish language Thanks @SCiunczyk --- Marlin/src/lcd/language/language_pl-DOGM.h | 1 + Marlin/src/lcd/language/language_pl-HD44780.h | 1 + 2 files changed, 2 insertions(+) diff --git a/Marlin/src/lcd/language/language_pl-DOGM.h b/Marlin/src/lcd/language/language_pl-DOGM.h index 5329536b4b..e712185c61 100644 --- a/Marlin/src/lcd/language/language_pl-DOGM.h +++ b/Marlin/src/lcd/language/language_pl-DOGM.h @@ -43,6 +43,7 @@ #define MSG_LEVEL_BED_WAITING _UxGT("Kliknij by rozp.") #define MSG_LEVEL_BED_NEXT_POINT _UxGT("Następny punkt") #define MSG_LEVEL_BED_DONE _UxGT("Wypoziomowano!") +#define MSG_USER_MENU _UxGT("Własne Polecenia") #define MSG_SET_HOME_OFFSETS _UxGT("Ust. poz. zer.") #define MSG_HOME_OFFSETS_APPLIED _UxGT("Poz. zerowa ust.") #define MSG_SET_ORIGIN _UxGT("Ustaw punkt zero") diff --git a/Marlin/src/lcd/language/language_pl-HD44780.h b/Marlin/src/lcd/language/language_pl-HD44780.h index aee679f8db..67ecaac6c0 100644 --- a/Marlin/src/lcd/language/language_pl-HD44780.h +++ b/Marlin/src/lcd/language/language_pl-HD44780.h @@ -43,6 +43,7 @@ #define MSG_LEVEL_BED_WAITING _UxGT("Kliknij by rozp.") #define MSG_LEVEL_BED_NEXT_POINT _UxGT("Nastepny punkt") #define MSG_LEVEL_BED_DONE _UxGT("Wypoziomowano!") +#define MSG_USER_MENU _UxGT("Wlasne Polecenia") #define MSG_SET_HOME_OFFSETS _UxGT("Ust. poz. zer.") #define MSG_HOME_OFFSETS_APPLIED _UxGT("Poz. zerowa ust.") #define MSG_SET_ORIGIN _UxGT("Ustaw punkt zero")