Browse Source

Standardize active/paused functions

Scott Lahteine 4 years ago
parent
commit
72d791a736

+ 14
- 0
Marlin/src/Marlin.cpp View File

@@ -427,6 +427,20 @@ void disable_all_steppers() {
427 427
 #endif
428 428
 
429 429
 /**
430
+ * Printing is active when the print job timer is running
431
+ */
432
+bool printingIsActive() {
433
+  return print_job_timer.isRunning() || IS_SD_PRINTING();
434
+}
435
+
436
+/**
437
+ * Printing is paused according to SD or host indicators
438
+ */
439
+bool printingIsPaused() {
440
+  return print_job_timer.isPaused() || IS_SD_PAUSED();
441
+}
442
+
443
+/**
430 444
  * Manage several activities:
431 445
  *  - Check for Filament Runout
432 446
  *  - Keep the command buffer full

+ 3
- 0
Marlin/src/Marlin.h View File

@@ -331,6 +331,9 @@ extern bool Running;
331 331
 inline bool IsRunning() { return  Running; }
332 332
 inline bool IsStopped() { return !Running; }
333 333
 
334
+bool printingIsActive();
335
+bool printingIsPaused();
336
+
334 337
 extern bool wait_for_heatup;
335 338
 
336 339
 #if HAS_RESUME_CONTINUE

+ 2
- 2
Marlin/src/feature/pause.cpp View File

@@ -381,7 +381,7 @@ bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
381 381
  * - Park the nozzle at the given position
382 382
  * - Call unload_filament (if a length was specified)
383 383
  *
384
- * Returns 'true' if pause was completed, 'false' for abort
384
+ * Return 'true' if pause was completed, 'false' for abort
385 385
  */
386 386
 uint8_t did_pause_print = 0;
387 387
 
@@ -603,7 +603,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
603 603
 /**
604 604
  * Resume or Start print procedure
605 605
  *
606
- * - Abort if not paused
606
+ * - If not paused, do nothing and return
607 607
  * - Reset heater idle timers
608 608
  * - Load filament if specified, but only if:
609 609
  *   - a nozzle timed out, or

+ 1
- 1
Marlin/src/feature/runout.h View File

@@ -98,7 +98,7 @@ class TFilamentMonitor : public FilamentMonitorBase {
98 98
 
99 99
     // Give the response a chance to update its counter.
100 100
     static inline void run() {
101
-      if (enabled && !filament_ran_out && (IS_SD_PRINTING() || print_job_timer.isRunning()
101
+      if (enabled && !filament_ran_out && (printingIsActive()
102 102
         #if ENABLED(ADVANCED_PAUSE_FEATURE)
103 103
           || did_pause_print
104 104
         #endif

+ 4
- 2
Marlin/src/lcd/menu/menu.cpp View File

@@ -30,7 +30,7 @@
30 30
 #include "../../module/motion.h"
31 31
 #include "../../module/printcounter.h"
32 32
 #include "../../gcode/queue.h"
33
-#include "../../sd/cardreader.h"
33
+
34 34
 #if HAS_BUZZER
35 35
   #include "../../libs/buzzer.h"
36 36
 #endif
@@ -206,8 +206,10 @@ void MenuItem_bool::action(PGM_P pstr, bool *ptr, screenFunc_t callback) {
206 206
   void _lcd_set_z_fade_height() { set_z_fade_height(lcd_z_fade_height); }
207 207
 #endif
208 208
 
209
+#include "../../Marlin.h"
210
+
209 211
 bool printer_busy() {
210
-  return planner.movesplanned() || IS_SD_PRINTING() || print_job_timer.isRunning();
212
+  return planner.movesplanned() || printingIsActive();
211 213
 }
212 214
 
213 215
 /**

+ 2
- 7
Marlin/src/lcd/menu/menu_main.cpp View File

@@ -99,7 +99,7 @@ void menu_main() {
99 99
   START_MENU();
100 100
   BACK_ITEM(MSG_WATCH);
101 101
 
102
-  const bool busy = IS_SD_PRINTING() || print_job_timer.isRunning()
102
+  const bool busy = printingIsActive()
103 103
     #if ENABLED(SDSUPPORT)
104 104
       , card_detected = card.isMounted()
105 105
       , card_open = card_detected && card.isFileOpen()
@@ -147,12 +147,7 @@ void menu_main() {
147 147
     #endif // !HAS_ENCODER_WHEEL && SDSUPPORT
148 148
 
149 149
     #if MACHINE_CAN_PAUSE
150
-      const bool paused = (print_job_timer.isPaused()
151
-        #if ENABLED(SDSUPPORT)
152
-          || card.isPaused()
153
-        #endif
154
-      );
155
-      if (paused) ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print);
150
+      if (printingIsPaused()) ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print);
156 151
     #endif
157 152
 
158 153
     SUBMENU(MSG_MOTION, menu_motion);

+ 6
- 7
Marlin/src/lcd/ultralcd.cpp View File

@@ -1427,11 +1427,12 @@ void MarlinUI::update() {
1427 1427
 
1428 1428
   #include "../module/printcounter.h"
1429 1429
 
1430
+  static const char print_paused[] PROGMEM = MSG_PRINT_PAUSED;
1431
+
1430 1432
   /**
1431 1433
    * Reset the status message
1432 1434
    */
1433 1435
   void MarlinUI::reset_status() {
1434
-    static const char paused[] PROGMEM = MSG_PRINT_PAUSED;
1435 1436
     static const char printing[] PROGMEM = MSG_PRINTING;
1436 1437
     static const char welcome[] PROGMEM = WELCOME_MSG;
1437 1438
     #if SERVICE_INTERVAL_1 > 0
@@ -1444,8 +1445,8 @@ void MarlinUI::update() {
1444 1445
       static const char service3[] PROGMEM = { "> " SERVICE_NAME_3 "!" };
1445 1446
     #endif
1446 1447
     PGM_P msg;
1447
-    if (!IS_SD_PRINTING() && print_job_timer.isPaused())
1448
-      msg = paused;
1448
+    if (printingIsPaused())
1449
+      msg = print_paused;
1449 1450
     #if ENABLED(SDSUPPORT)
1450 1451
       else if (IS_SD_PRINTING())
1451 1452
         return set_status(card.longest_filename(), true);
@@ -1508,7 +1509,7 @@ void MarlinUI::update() {
1508 1509
       host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume"));
1509 1510
     #endif
1510 1511
 
1511
-    set_status_P(PSTR(MSG_PRINT_PAUSED));
1512
+    set_status_P(print_paused); // MSG_PRINT_PAUSED
1512 1513
 
1513 1514
     #if ENABLED(PARK_HEAD_ON_PAUSE)
1514 1515
       #if HAS_SPI_LCD
@@ -1527,9 +1528,7 @@ void MarlinUI::update() {
1527 1528
     #if ENABLED(PARK_HEAD_ON_PAUSE)
1528 1529
       wait_for_heatup = wait_for_user = false;
1529 1530
     #endif
1530
-    #if ENABLED(SDSUPPORT)
1531
-      if (card.isPaused()) queue.inject_P(PSTR("M24"));
1532
-    #endif
1531
+    if (IS_SD_PAUSED()) queue.inject_P(PSTR("M24"));
1533 1532
     #ifdef ACTION_ON_RESUME
1534 1533
       host_action_resume();
1535 1534
     #endif

+ 2
- 0
Marlin/src/sd/cardreader.h View File

@@ -282,6 +282,7 @@ private:
282 282
 #endif
283 283
 
284 284
 #define IS_SD_PRINTING()  card.flag.sdprinting
285
+#define IS_SD_PAUSED()    card.isPaused()
285 286
 #define IS_SD_FILE_OPEN() card.isFileOpen()
286 287
 
287 288
 extern CardReader card;
@@ -289,6 +290,7 @@ extern CardReader card;
289 290
 #else // !SDSUPPORT
290 291
 
291 292
 #define IS_SD_PRINTING()  false
293
+#define IS_SD_PAUSED()    false
292 294
 #define IS_SD_FILE_OPEN() false
293 295
 
294 296
 #endif // !SDSUPPORT

Loading…
Cancel
Save