Browse Source

ExtUI parity with SPI LCDs (#14172)

InsanityAutomation 6 years ago
parent
commit
f889cc6ea6

+ 3
- 23
Marlin/src/lcd/extensible_ui/ui_api.cpp View File

@@ -831,35 +831,15 @@ namespace ExtUI {
831 831
   }
832 832
 
833 833
   void pausePrint() {
834
-    #if ENABLED(SDSUPPORT)
835
-      card.pauseSDPrint();
836
-      print_job_timer.pause();
837
-      #if ENABLED(PARK_HEAD_ON_PAUSE)
838
-        enqueue_and_echo_commands_P(PSTR("M125"));
839
-      #endif
840
-      ui.set_status_P(PSTR(MSG_PRINT_PAUSED));
841
-    #endif
834
+    ui.pause_print();
842 835
   }
843 836
 
844 837
   void resumePrint() {
845
-    #if ENABLED(SDSUPPORT)
846
-      ui.set_status_P(PSTR(MSG_FILAMENT_CHANGE_RESUME_1));
847
-      #if ENABLED(PARK_HEAD_ON_PAUSE)
848
-        wait_for_heatup = wait_for_user = false;
849
-        enqueue_and_echo_commands_P(PSTR("M24"));
850
-      #else
851
-        card.startFileprint();
852
-        print_job_timer.start();
853
-      #endif
854
-    #endif
838
+    ui.resume_print();
855 839
   }
856 840
 
857 841
   void stopPrint() {
858
-    #if ENABLED(SDSUPPORT)
859
-      wait_for_heatup = wait_for_user = false;
860
-      card.flag.abort_sd_printing = true;
861
-      ui.set_status_P(PSTR(MSG_PRINT_ABORTED));
862
-    #endif
842
+    ui.stop_print();
863 843
   }
864 844
 
865 845
   FileList::FileList() { refresh(); }

+ 3
- 58
Marlin/src/lcd/menu/menu_main.cpp View File

@@ -39,10 +39,6 @@
39 39
   #include "../../feature/power_loss_recovery.h"
40 40
 #endif
41 41
 
42
-#if ENABLED(HOST_ACTION_COMMANDS)
43
-  #include "../../feature/host_actions.h"
44
-#endif
45
-
46 42
 #if HAS_GAMES
47 43
   #include "game/game.h"
48 44
 #endif
@@ -50,61 +46,10 @@
50 46
 #define MACHINE_CAN_STOP (EITHER(SDSUPPORT, HOST_PROMPT_SUPPORT) || defined(ACTION_ON_CANCEL))
51 47
 #define MACHINE_CAN_PAUSE (ANY(SDSUPPORT, HOST_PROMPT_SUPPORT, PARK_HEAD_ON_PAUSE) || defined(ACTION_ON_PAUSE))
52 48
 
53
-#if MACHINE_CAN_PAUSE
54
-
55
-  void lcd_pause_job() {
56
-    ui.synchronize(PSTR(MSG_PAUSE_PRINT));
57
-
58
-    #if ENABLED(POWER_LOSS_RECOVERY)
59
-      if (recovery.enabled) recovery.save(true, false);
60
-    #endif
61
-
62
-    #if ENABLED(HOST_PROMPT_SUPPORT)
63
-      host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume"));
64
-    #endif
65
-
66
-    #if ENABLED(PARK_HEAD_ON_PAUSE)
67
-      lcd_pause_show_message(PAUSE_MESSAGE_PAUSING, PAUSE_MODE_PAUSE_PRINT);  // Show message immediately to let user know about pause in progress
68
-      enqueue_and_echo_commands_P(PSTR("M25 P\nM24"));
69
-    #elif ENABLED(SDSUPPORT)
70
-      enqueue_and_echo_commands_P(PSTR("M25"));
71
-    #elif defined(ACTION_ON_PAUSE)
72
-      host_action_pause();
73
-    #endif
74
-  }
75
-
76
-  void lcd_resume() {
77
-    #if ENABLED(SDSUPPORT)
78
-      if (card.isPaused()) enqueue_and_echo_commands_P(PSTR("M24"));
79
-    #endif
80
-    #ifdef ACTION_ON_RESUME
81
-      host_action_resume();
82
-    #endif
83
-  }
84
-
85
-#endif // MACHINE_CAN_PAUSE
86
-
87 49
 #if MACHINE_CAN_STOP
88
-
89
-  void lcd_abort_job() {
90
-    #if ENABLED(SDSUPPORT)
91
-      wait_for_heatup = wait_for_user = false;
92
-      card.flag.abort_sd_printing = true;
93
-    #endif
94
-    #ifdef ACTION_ON_CANCEL
95
-      host_action_cancel();
96
-    #endif
97
-    #if ENABLED(HOST_PROMPT_SUPPORT)
98
-      host_prompt_open(PROMPT_INFO, PSTR("UI Abort"));
99
-    #endif
100
-    ui.set_status_P(PSTR(MSG_PRINT_ABORTED), -1);
101
-    ui.return_to_status();
102
-  }
103
-
104 50
   void menu_abort_confirm() {
105
-    do_select_screen(PSTR(MSG_BUTTON_STOP), PSTR(MSG_BACK), lcd_abort_job, ui.goto_previous_screen, PSTR(MSG_STOP_PRINT), nullptr, PSTR("?"));
51
+    do_select_screen(PSTR(MSG_BUTTON_STOP), PSTR(MSG_BACK), ui.abort_print, ui.goto_previous_screen, PSTR(MSG_STOP_PRINT), nullptr, PSTR("?"));
106 52
   }
107
-
108 53
 #endif // MACHINE_CAN_STOP
109 54
 
110 55
 #if ENABLED(PRUSA_MMU2)
@@ -160,7 +105,7 @@ void menu_main() {
160 105
 
161 106
   if (busy) {
162 107
     #if MACHINE_CAN_PAUSE
163
-      MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_pause_job);
108
+      MENU_ITEM(function, MSG_PAUSE_PRINT, ui.pause_print);
164 109
     #endif
165 110
     #if MACHINE_CAN_STOP
166 111
       MENU_ITEM(submenu, MSG_STOP_PRINT, menu_abort_confirm);
@@ -204,7 +149,7 @@ void menu_main() {
204 149
           || card.isPaused()
205 150
         #endif
206 151
       );
207
-      if (paused) MENU_ITEM(function, MSG_RESUME_PRINT, lcd_resume);
152
+      if (paused) MENU_ITEM(function, MSG_RESUME_PRINT, ui.resume_print);
208 153
     #endif
209 154
 
210 155
     MENU_ITEM(submenu, MSG_MOTION, menu_motion);

+ 60
- 0
Marlin/src/lcd/ultralcd.cpp View File

@@ -31,6 +31,9 @@
31 31
   #if ENABLED(EXTENSIBLE_UI)
32 32
     #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u)
33 33
   #endif
34
+  #if ENABLED(HOST_ACTION_COMMANDS)
35
+    #include "../feature/host_actions.h"
36
+  #endif
34 37
 #endif
35 38
 
36 39
 #if HAS_SPI_LCD
@@ -1358,6 +1361,63 @@ void MarlinUI::update() {
1358 1361
     set_status_P(msg, -1);
1359 1362
   }
1360 1363
 
1364
+  void MarlinUI::abort_print() {
1365
+    #if ENABLED(SDSUPPORT)
1366
+      wait_for_heatup = wait_for_user = false;
1367
+      card.flag.abort_sd_printing = true;
1368
+    #endif
1369
+    #ifdef ACTION_ON_CANCEL
1370
+      host_action_cancel();
1371
+    #endif
1372
+    #if ENABLED(HOST_PROMPT_SUPPORT)
1373
+      host_prompt_open(PROMPT_INFO, PSTR("UI Abort"));
1374
+    #endif
1375
+    print_job_timer.stop();
1376
+    set_status_P(PSTR(MSG_PRINT_ABORTED));
1377
+    #if HAS_SPI_LCD
1378
+      return_to_status();
1379
+    #endif
1380
+  }
1381
+
1382
+  void MarlinUI::pause_print() {
1383
+    synchronize(PSTR(MSG_PAUSE_PRINT));
1384
+
1385
+    #if ENABLED(POWER_LOSS_RECOVERY)
1386
+      if (recovery.enabled) recovery.save(true, false);
1387
+    #endif
1388
+
1389
+    #if ENABLED(HOST_PROMPT_SUPPORT)
1390
+      host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume"));
1391
+    #endif
1392
+
1393
+    set_status_P(PSTR(MSG_PRINT_PAUSED));
1394
+
1395
+    #if ENABLED(PARK_HEAD_ON_PAUSE)
1396
+      #if HAS_SPI_LCD
1397
+        lcd_pause_show_message(PAUSE_MESSAGE_PAUSING, PAUSE_MODE_PAUSE_PRINT);  // Show message immediately to let user know about pause in progress
1398
+      #endif
1399
+      enqueue_and_echo_commands_P(PSTR("M25 P\nM24"));
1400
+    #elif ENABLED(SDSUPPORT)
1401
+      enqueue_and_echo_commands_P(PSTR("M25"));
1402
+    #elif defined(ACTION_ON_PAUSE)
1403
+      host_action_pause();
1404
+    #endif
1405
+  }
1406
+
1407
+  void MarlinUI::resume_print() {
1408
+    reset_status();
1409
+    #if ENABLED(PARK_HEAD_ON_PAUSE)
1410
+      wait_for_heatup = wait_for_user = false;
1411
+    #endif
1412
+    #if ENABLED(SDSUPPORT)
1413
+      if (card.isPaused()) enqueue_and_echo_commands_P(PSTR("M24"));
1414
+    #endif
1415
+    #ifdef ACTION_ON_RESUME
1416
+      host_action_resume();
1417
+    #endif
1418
+    print_job_timer.start(); // Also called by M24
1419
+  }
1420
+
1361 1421
   #if HAS_PRINT_PROGRESS
1362 1422
     uint8_t MarlinUI::get_progress() {
1363 1423
       #if ENABLED(LCD_SET_PROGRESS_MANUALLY)

+ 4
- 0
Marlin/src/lcd/ultralcd.h View File

@@ -286,6 +286,10 @@ public:
286 286
       static char* status_and_len(uint8_t &len);
287 287
     #endif
288 288
 
289
+    static void abort_print();
290
+    static void pause_print();
291
+    static void resume_print();
292
+    
289 293
     #if HAS_PRINT_PROGRESS
290 294
       #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
291 295
         static uint8_t progress_bar_percent;

Loading…
Cancel
Save