Browse Source

PFW-1386 Implement 'U' parameter for M702

Similar to 'L' in M701, this does not apply to the MMU
The U parameter controls how much mm the extruder will unload
Default value is 80mm
Guðni Már Gilbert 2 years ago
parent
commit
20c865c2d4
3 changed files with 13 additions and 19 deletions
  1. 7 5
      Firmware/Marlin_main.cpp
  2. 5 13
      Firmware/ultralcd.cpp
  3. 1 1
      Firmware/ultralcd.h

+ 7 - 5
Firmware/Marlin_main.cpp

@@ -3592,7 +3592,7 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float
     if (MMU2::mmu2.Enabled())
         mmu_M600_unload_filament();
     else
-        unload_filament(true); // unload filament for single material (used also in M702)
+        unload_filament(FILAMENTCHANGE_FINALRETRACT, true); // unload filament for single material (used also in M702)
     st_synchronize();          // finish moves
     {
         FSensorBlockRunout fsBlockRunout;
@@ -8625,7 +8625,10 @@ Sigma_Exit:
     */
     case 702:
     {
-        // TODO: Implement U parameter
+        float unloadLength = FILAMENTCHANGE_FINALRETRACT;
+        if (code_seen('U')) {
+            unloadLength = code_value();
+        }
 
         if (code_seen('Z'))
         {
@@ -8635,11 +8638,10 @@ Sigma_Exit:
             raise_z_above(MIN_Z_FOR_UNLOAD, false);
         }
 
-        if (MMU2::mmu2.Enabled())
-        {
+        if (MMU2::mmu2.Enabled()) {
             MMU2::mmu2.unload();
         } else {
-            unload_filament();
+            unload_filament(unloadLength, false);
         }
     }
     break;

+ 5 - 13
Firmware/ultralcd.cpp

@@ -4107,7 +4107,7 @@ void lcd_wizard(WizState state)
 				lcd_display_message_fullscreen_P(_i("Now I will preheat nozzle for PLA.")); ////MSG_WIZARD_WILL_PREHEAT c=20 r=4
 				wait_preheat();
 				//unload current filament
-				unload_filament(true);
+				unload_filament(FILAMENTCHANGE_FINALRETRACT, true);
 				//load filament
 				lcd_wizard_load();
 				setTargetHotend(0, 0); //we are finished, cooldown nozzle
@@ -5249,7 +5249,7 @@ static void mmu_load_to_bondtech_menu() {
 
 // unload filament for single material printer (used in M702 gcode)
 // @param automatic: If true, unload_filament is part of a unload+load sequence (M600)
-void unload_filament(bool automatic)
+void unload_filament(float unloadLength, bool automatic)
 {
 	custom_message_type = CustomMsg::FilamentLoading;
 	lcd_setstatuspgm(_T(MSG_UNLOADING_FILAMENT));
@@ -5262,17 +5262,9 @@ void unload_filament(bool automatic)
         raise_z_above(MIN_Z_FOR_SWAP);
     }
 
-	//		extr_unload2();
-
-	current_position[E_AXIS] -= 45;
-	plan_buffer_line_curposXYZE(5200 / 60);
-	st_synchronize();
-	current_position[E_AXIS] -= 15;
-	plan_buffer_line_curposXYZE(1000 / 60);
-	st_synchronize();
-	current_position[E_AXIS] -= 20;
-	plan_buffer_line_curposXYZE(1000 / 60);
-	st_synchronize();
+    current_position[E_AXIS] -= unloadLength;
+    plan_buffer_line_curposXYZE(1000 / 60);
+    st_synchronize();
 
 	lcd_display_message_fullscreen_P(_T(MSG_PULL_OUT_FILAMENT));
 

+ 1 - 1
Firmware/ultralcd.h

@@ -191,7 +191,7 @@ extern bool bFilamentAction;
 void mFilamentItem(uint16_t nTemp,uint16_t nTempBed);
 void mFilamentItemForce();
 void lcd_generic_preheat_menu();
-void unload_filament(bool automatic = false);
+void unload_filament(float unloadLength, bool automatic = false);
 
 
 void lcd_wait_for_heater();