Browse Source

Cut & Eject: avoid preheat if no filament loaded

and add fullscreen messages for Cut & Eject (messages intentionally reused to save space)
D.R.racer 1 year ago
parent
commit
52a3beb931
2 changed files with 34 additions and 28 deletions
  1. 32 26
      Firmware/mmu2.cpp
  2. 2 2
      Firmware/ultralcd.cpp

+ 32 - 26
Firmware/mmu2.cpp

@@ -440,20 +440,31 @@ bool MMU2::unload() {
     return true;
 }
 
+void FullScreenMsg(const char *pgmS, uint8_t slot){
+    lcd_update_enable(false);
+    lcd_clear();
+    lcd_puts_at_P(0, 1, pgmS);
+    lcd_print(' ');
+    lcd_print(slot + 1);
+}
+
 bool MMU2::cut_filament(uint8_t slot){
     if( ! WaitForMMUReady())
         return false;
 
-    if( FindaDetectsFilament() ){
-        unload();
-    }
+    FullScreenMsg(_T(MSG_CUT_FILAMENT), slot);
+    {
+        if( FindaDetectsFilament() ){
+            unload();
+        }
 
-    ReportingRAII rep(CommandInProgress::CutFilament);
-    for(;;){
-        logic.CutFilament(slot);
-        if( manage_response(false, true) )
-            break;
-        IncrementMMUFails();
+        ReportingRAII rep(CommandInProgress::CutFilament);
+        for(;;){
+            logic.CutFilament(slot);
+            if( manage_response(false, true) )
+                break;
+            IncrementMMUFails();
+        }
     }
     extruder = MMU2_NO_TOOL;
     tool_change_extruder = MMU2_NO_TOOL;
@@ -461,14 +472,6 @@ bool MMU2::cut_filament(uint8_t slot){
     return true;
 }
 
-void FullScreenMsg(const char *pgmS, uint8_t slot){
-    lcd_update_enable(false);
-    lcd_clear();
-    lcd_puts_at_P(0, 1, pgmS);
-    lcd_print(' ');
-    lcd_print(slot + 1);
-}
-
 bool MMU2::loading_test(uint8_t slot){
     FullScreenMsg(_T(MSG_TESTING_FILAMENT), slot);
     tool_change(slot);
@@ -541,16 +544,19 @@ bool MMU2::eject_filament(uint8_t slot, bool recover) {
     if( ! WaitForMMUReady())
         return false;
 
-    if( FindaDetectsFilament() ){
-        unload();
-    }
+    FullScreenMsg(_T(MSG_EJECT_FILAMENT), slot);
+    {
+        if( FindaDetectsFilament() ){
+            unload();
+        }
 
-    ReportingRAII rep(CommandInProgress::EjectFilament);
-    for(;;) {
-        logic.EjectFilament(slot);
-        if( manage_response(false, true) )
-            break;
-        IncrementMMUFails();
+        ReportingRAII rep(CommandInProgress::EjectFilament);
+        for(;;) {
+            logic.EjectFilament(slot);
+            if( manage_response(false, true) )
+                break;
+            IncrementMMUFails();
+        }
     }
     extruder = MMU2_NO_TOOL;
     tool_change_extruder = MMU2_NO_TOOL;

+ 2 - 2
Firmware/ultralcd.cpp

@@ -5071,7 +5071,7 @@ static void mmu_eject_filament(uint8_t filament) {
 }
 
 static void mmu_fil_eject_menu() {
-    if (bFilamentAction) {
+    if (bFilamentAction || (!MMU2::mmu2.FindaDetectsFilament())) {
         MENU_BEGIN();
         MENU_ITEM_BACK_P(_T(MSG_MAIN));
         for (uint8_t i = 0; i < MMU_FILAMENT_COUNT; i++)
@@ -5089,7 +5089,7 @@ static inline void mmu_cut_filament_wrapper(uint8_t index){
 }
 
 static void mmu_cut_filament_menu() {
-    if (bFilamentAction) {
+    if (bFilamentAction || (!MMU2::mmu2.FindaDetectsFilament())) {
         MENU_BEGIN();
         MENU_ITEM_BACK_P(_T(MSG_MAIN));
         for (uint8_t i = 0; i < MMU_FILAMENT_COUNT; i++)