Browse Source

Standardize active/paused functions

Scott Lahteine 5 years ago
parent
commit
72d791a736

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

427
 #endif
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
  * Manage several activities:
444
  * Manage several activities:
431
  *  - Check for Filament Runout
445
  *  - Check for Filament Runout
432
  *  - Keep the command buffer full
446
  *  - Keep the command buffer full

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

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

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

381
  * - Park the nozzle at the given position
381
  * - Park the nozzle at the given position
382
  * - Call unload_filament (if a length was specified)
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
 uint8_t did_pause_print = 0;
386
 uint8_t did_pause_print = 0;
387
 
387
 
603
 /**
603
 /**
604
  * Resume or Start print procedure
604
  * Resume or Start print procedure
605
  *
605
  *
606
- * - Abort if not paused
606
+ * - If not paused, do nothing and return
607
  * - Reset heater idle timers
607
  * - Reset heater idle timers
608
  * - Load filament if specified, but only if:
608
  * - Load filament if specified, but only if:
609
  *   - a nozzle timed out, or
609
  *   - a nozzle timed out, or

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

98
 
98
 
99
     // Give the response a chance to update its counter.
99
     // Give the response a chance to update its counter.
100
     static inline void run() {
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
         #if ENABLED(ADVANCED_PAUSE_FEATURE)
102
         #if ENABLED(ADVANCED_PAUSE_FEATURE)
103
           || did_pause_print
103
           || did_pause_print
104
         #endif
104
         #endif

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

30
 #include "../../module/motion.h"
30
 #include "../../module/motion.h"
31
 #include "../../module/printcounter.h"
31
 #include "../../module/printcounter.h"
32
 #include "../../gcode/queue.h"
32
 #include "../../gcode/queue.h"
33
-#include "../../sd/cardreader.h"
33
+
34
 #if HAS_BUZZER
34
 #if HAS_BUZZER
35
   #include "../../libs/buzzer.h"
35
   #include "../../libs/buzzer.h"
36
 #endif
36
 #endif
206
   void _lcd_set_z_fade_height() { set_z_fade_height(lcd_z_fade_height); }
206
   void _lcd_set_z_fade_height() { set_z_fade_height(lcd_z_fade_height); }
207
 #endif
207
 #endif
208
 
208
 
209
+#include "../../Marlin.h"
210
+
209
 bool printer_busy() {
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
   START_MENU();
99
   START_MENU();
100
   BACK_ITEM(MSG_WATCH);
100
   BACK_ITEM(MSG_WATCH);
101
 
101
 
102
-  const bool busy = IS_SD_PRINTING() || print_job_timer.isRunning()
102
+  const bool busy = printingIsActive()
103
     #if ENABLED(SDSUPPORT)
103
     #if ENABLED(SDSUPPORT)
104
       , card_detected = card.isMounted()
104
       , card_detected = card.isMounted()
105
       , card_open = card_detected && card.isFileOpen()
105
       , card_open = card_detected && card.isFileOpen()
147
     #endif // !HAS_ENCODER_WHEEL && SDSUPPORT
147
     #endif // !HAS_ENCODER_WHEEL && SDSUPPORT
148
 
148
 
149
     #if MACHINE_CAN_PAUSE
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
     #endif
151
     #endif
157
 
152
 
158
     SUBMENU(MSG_MOTION, menu_motion);
153
     SUBMENU(MSG_MOTION, menu_motion);

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

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

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

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

Loading…
Cancel
Save