Quellcode durchsuchen

Update criteria for PAUSE/RESUME/STOP menu items (#13294)

Scott Lahteine vor 6 Jahren
Ursprung
Commit
4771e372a1
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden
1 geänderte Dateien mit 67 neuen und 52 gelöschten Zeilen
  1. 67
    52
      Marlin/src/lcd/menu/menu_main.cpp

+ 67
- 52
Marlin/src/lcd/menu/menu_main.cpp Datei anzeigen

@@ -46,56 +46,67 @@
46 46
   #include "../../feature/host_actions.h"
47 47
 #endif
48 48
 
49
-void lcd_pause() {
50
-  #if ENABLED(POWER_LOSS_RECOVERY)
51
-    if (recovery.enabled) recovery.save(true, false);
52
-  #endif
49
+#define MACHINE_CAN_STOP (ENABLED(SDSUPPORT) || ENABLED(HOST_PROMPT_SUPPORT) || defined(ACTION_ON_CANCEL))
50
+#define MACHINE_CAN_PAUSE (ENABLED(SDSUPPORT) || ENABLED(HOST_PROMPT_SUPPORT) || ENABLED(PARK_HEAD_ON_PAUSE) || defined(ACTION_ON_PAUSE))
53 51
 
54
-  #if ENABLED(HOST_PROMPT_SUPPORT)
55
-    host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume"));
56
-  #endif
52
+#if MACHINE_CAN_PAUSE
57 53
 
58
-  #if ENABLED(PARK_HEAD_ON_PAUSE)
59
-    lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT, ADVANCED_PAUSE_MODE_PAUSE_PRINT);  // Show message immediately to let user know about pause in progress
60
-    enqueue_and_echo_commands_P(PSTR("M25 P\nM24"));
61
-  #elif ENABLED(SDSUPPORT)
62
-    enqueue_and_echo_commands_P(PSTR("M25"));
63
-  #elif defined(ACTION_ON_PAUSE)
64
-    host_action_pause();
65
-  #endif
66
-  planner.synchronize();
67
-}
54
+  void lcd_pause_job() {
55
+    #if ENABLED(POWER_LOSS_RECOVERY)
56
+      if (recovery.enabled) recovery.save(true, false);
57
+    #endif
68 58
 
69
-void lcd_resume() {
70
-  #if ENABLED(SDSUPPORT)
71
-    if (card.isPaused()) enqueue_and_echo_commands_P(PSTR("M24"));
72
-  #endif
73
-  #ifdef ACTION_ON_RESUME
74
-    host_action_resume();
75
-  #endif
76
-}
59
+    #if ENABLED(HOST_PROMPT_SUPPORT)
60
+      host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume"));
61
+    #endif
77 62
 
78
-void lcd_stop() {
79
-  #if ENABLED(SDSUPPORT)
80
-    wait_for_heatup = wait_for_user = false;
81
-    card.flag.abort_sd_printing = true;
82
-  #endif
83
-  #ifdef ACTION_ON_CANCEL
84
-    host_action_cancel();
85
-  #endif
86
-  #if ENABLED(HOST_PROMPT_SUPPORT)
87
-    host_prompt_open(PROMPT_INFO, PSTR("UI Abort"));
88
-  #endif
89
-  ui.set_status_P(PSTR(MSG_PRINT_ABORTED), -1);
90
-  ui.return_to_status();
91
-}
63
+    #if ENABLED(PARK_HEAD_ON_PAUSE)
64
+      lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT, ADVANCED_PAUSE_MODE_PAUSE_PRINT);  // Show message immediately to let user know about pause in progress
65
+      enqueue_and_echo_commands_P(PSTR("M25 P\nM24"));
66
+    #elif ENABLED(SDSUPPORT)
67
+      enqueue_and_echo_commands_P(PSTR("M25"));
68
+    #elif defined(ACTION_ON_PAUSE)
69
+      host_action_pause();
70
+    #endif
71
+    planner.synchronize();
72
+  }
92 73
 
93
-void menu_abort_confirm() {
94
-  START_MENU();
95
-  MENU_BACK(MSG_MAIN);
96
-  MENU_ITEM(function, MSG_STOP_PRINT, lcd_stop);
97
-  END_MENU();
98
-}
74
+  void lcd_resume() {
75
+    #if ENABLED(SDSUPPORT)
76
+      if (card.isPaused()) enqueue_and_echo_commands_P(PSTR("M24"));
77
+    #endif
78
+    #ifdef ACTION_ON_RESUME
79
+      host_action_resume();
80
+    #endif
81
+  }
82
+
83
+#endif // MACHINE_CAN_PAUSE
84
+
85
+#if MACHINE_CAN_STOP
86
+
87
+  void lcd_abort_job() {
88
+    #if ENABLED(SDSUPPORT)
89
+      wait_for_heatup = wait_for_user = false;
90
+      card.flag.abort_sd_printing = true;
91
+    #endif
92
+    #ifdef ACTION_ON_CANCEL
93
+      host_action_cancel();
94
+    #endif
95
+    #if ENABLED(HOST_PROMPT_SUPPORT)
96
+      host_prompt_open(PROMPT_INFO, PSTR("UI Abort"));
97
+    #endif
98
+    ui.set_status_P(PSTR(MSG_PRINT_ABORTED), -1);
99
+    ui.return_to_status();
100
+  }
101
+
102
+  void menu_abort_confirm() {
103
+    START_MENU();
104
+    MENU_BACK(MSG_MAIN);
105
+    MENU_ITEM(function, MSG_STOP_PRINT, lcd_abort_job);
106
+    END_MENU();
107
+  }
108
+
109
+#endif // MACHINE_CAN_STOP
99 110
 
100 111
 #if ENABLED(PRUSA_MMU2)
101 112
   #include "../../lcd/menu/menu_mmu2.h"
@@ -139,8 +150,10 @@ void menu_main() {
139 150
   ;
140 151
 
141 152
   if (busy) {
142
-    MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_pause);
143
-    #if ENABLED(SDSUPPORT) || defined(ACTION_ON_CANCEL)
153
+    #if MACHINE_CAN_PAUSE
154
+      MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_pause_job);
155
+    #endif
156
+    #if MACHINE_CAN_STOP
144 157
       MENU_ITEM(submenu, MSG_STOP_PRINT, menu_abort_confirm);
145 158
     #endif
146 159
     MENU_ITEM(submenu, MSG_TUNE, menu_tune);
@@ -170,11 +183,13 @@ void menu_main() {
170 183
       }
171 184
     #endif // !HAS_ENCODER_WHEEL && SDSUPPORT
172 185
 
173
-    #if ENABLED(SDSUPPORT) || ENABLED(HOST_ACTION_COMMANDS)
174
-      #if DISABLED(HOST_ACTION_COMMANDS)
175
-        if (card_open && card.isPaused())
176
-      #endif
177
-          MENU_ITEM(function, MSG_RESUME_PRINT, lcd_resume);
186
+    #if MACHINE_CAN_PAUSE
187
+      const bool paused = (print_job_timer.isPaused()
188
+        #if ENABLED(SDSUPPORT)
189
+          || card.isPaused()
190
+        #endif
191
+      );
192
+      if (paused) MENU_ITEM(function, MSG_RESUME_PRINT, lcd_resume);
178 193
     #endif
179 194
 
180 195
     MENU_ITEM(submenu, MSG_MOTION, menu_motion);

Laden…
Abbrechen
Speichern