Browse Source

Move Job Recovery Menu to its own file

Scott Lahteine 6 years ago
parent
commit
9cd5471202

+ 1
- 5
Marlin/src/feature/power_loss_recovery.h View File

@@ -19,14 +19,12 @@
19 19
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 20
  *
21 21
  */
22
+#pragma once
22 23
 
23 24
 /**
24 25
  * power_loss_recovery.h - Resume an SD print after power-loss
25 26
  */
26 27
 
27
-#ifndef _POWER_LOSS_RECOVERY_H_
28
-#define _POWER_LOSS_RECOVERY_H_
29
-
30 28
 #include "../sd/cardreader.h"
31 29
 #include "../core/millis_t.h"
32 30
 #include "../inc/MarlinConfigPre.h"
@@ -99,5 +97,3 @@ extern uint8_t job_recovery_commands_count;
99 97
 
100 98
 void check_print_job_recovery();
101 99
 void save_job_recovery_info();
102
-
103
-#endif // _POWER_LOSS_RECOVERY_H_

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

@@ -27,7 +27,6 @@
27 27
 #include "menu.h"
28 28
 
29 29
 #include "../ultralcd.h"
30
-#include "../../sd/cardreader.h"
31 30
 #include "../../module/planner.h"
32 31
 #include "../../module/motion.h"
33 32
 #include "../../module/probe.h"
@@ -40,16 +39,12 @@
40 39
 
41 40
 #include <stdarg.h>
42 41
 
43
-#if ENABLED(ADVANCED_PAUSE_FEATURE)
44
-  #include "../../feature/pause.h"
45
-#endif
46
-
47
-#if ENABLED(POWER_LOSS_RECOVERY)
48
-  #include "../../feature/power_loss_recovery.h"
42
+#if ENABLED(SDSUPPORT)
43
+  #include "../../sd/cardreader.h"
49 44
 #endif
50 45
 
51
-#if ENABLED(PRINTCOUNTER) && ENABLED(LCD_INFO_MENU)
52
-  #include "../../libs/duration_t.h"
46
+#if ENABLED(ADVANCED_PAUSE_FEATURE)
47
+  #include "../../feature/pause.h"
53 48
 #endif
54 49
 
55 50
 #if HAS_LEVELING
@@ -405,80 +400,6 @@ void line_to_z(const float &z) {
405 400
   line_to_current_z();
406 401
 }
407 402
 
408
-#if ENABLED(POWER_LOSS_RECOVERY)
409
-
410
-  static void lcd_power_loss_recovery_resume() {
411
-    char cmd[20];
412
-
413
-    // Return to status now
414
-    lcd_return_to_status();
415
-
416
-    // Turn leveling off and home
417
-    enqueue_and_echo_commands_P(PSTR("M420 S0\nG28 R0"
418
-      #if ENABLED(MARLIN_DEV_MODE)
419
-        " S"
420
-      #elif !IS_KINEMATIC
421
-        " X Y"
422
-      #endif
423
-    ));
424
-
425
-    #if HAS_HEATED_BED
426
-      const int16_t bt = job_recovery_info.target_temperature_bed;
427
-      if (bt) {
428
-        // Restore the bed temperature
429
-        sprintf_P(cmd, PSTR("M190 S%i"), bt);
430
-        enqueue_and_echo_command(cmd);
431
-      }
432
-    #endif
433
-
434
-    // Restore all hotend temperatures
435
-    HOTEND_LOOP() {
436
-      const int16_t et = job_recovery_info.target_temperature[e];
437
-      if (et) {
438
-        #if HOTENDS > 1
439
-          sprintf_P(cmd, PSTR("T%i"), e);
440
-          enqueue_and_echo_command(cmd);
441
-        #endif
442
-        sprintf_P(cmd, PSTR("M109 S%i"), et);
443
-        enqueue_and_echo_command(cmd);
444
-      }
445
-    }
446
-
447
-    #if HOTENDS > 1
448
-      sprintf_P(cmd, PSTR("T%i"), job_recovery_info.active_hotend);
449
-      enqueue_and_echo_command(cmd);
450
-    #endif
451
-
452
-    // Restore print cooling fan speeds
453
-    for (uint8_t i = 0; i < FAN_COUNT; i++) {
454
-      uint8_t f = job_recovery_info.fan_speed[i];
455
-      if (f) {
456
-        sprintf_P(cmd, PSTR("M106 P%i S%i"), i, f);
457
-        enqueue_and_echo_command(cmd);
458
-      }
459
-    }
460
-
461
-    // Start draining the job recovery command queue
462
-    job_recovery_phase = JOB_RECOVERY_YES;
463
-  }
464
-
465
-  static void lcd_power_loss_recovery_cancel() {
466
-    card.removeJobRecoveryFile();
467
-    card.autostart_index = 0;
468
-    lcd_return_to_status();
469
-  }
470
-
471
-  void menu_job_recovery() {
472
-    defer_return_to_status = true;
473
-    START_MENU();
474
-    STATIC_ITEM(MSG_POWER_LOSS_RECOVERY);
475
-    MENU_ITEM(function, MSG_RESUME_PRINT, lcd_power_loss_recovery_resume);
476
-    MENU_ITEM(function, MSG_STOP_PRINT, lcd_power_loss_recovery_cancel);
477
-    END_MENU();
478
-  }
479
-
480
-#endif // POWER_LOSS_RECOVERY
481
-
482 403
 #if ENABLED(CUSTOM_USER_MENUS)
483 404
 
484 405
   #ifdef USER_SCRIPT_DONE

+ 106
- 0
Marlin/src/lcd/menu/menu_job_recovery.cpp View File

@@ -0,0 +1,106 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+//
24
+// Job Recovery Menu
25
+//
26
+
27
+#include "../../inc/MarlinConfigPre.h"
28
+
29
+#if HAS_LCD_MENU && ENABLED(POWER_LOSS_RECOVERY)
30
+
31
+#include "menu.h"
32
+#include "../../gcode/queue.h"
33
+#include "../../sd/cardreader.h"
34
+#include "../../feature/power_loss_recovery.h"
35
+
36
+static void lcd_power_loss_recovery_resume() {
37
+  char cmd[20];
38
+
39
+  // Return to status now
40
+  lcd_return_to_status();
41
+
42
+  // Turn leveling off and home
43
+  enqueue_and_echo_commands_P(PSTR("M420 S0\nG28 R0"
44
+    #if ENABLED(MARLIN_DEV_MODE)
45
+      " S"
46
+    #elif !IS_KINEMATIC
47
+      " X Y"
48
+    #endif
49
+  ));
50
+
51
+  #if HAS_HEATED_BED
52
+    const int16_t bt = job_recovery_info.target_temperature_bed;
53
+    if (bt) {
54
+      // Restore the bed temperature
55
+      sprintf_P(cmd, PSTR("M190 S%i"), bt);
56
+      enqueue_and_echo_command(cmd);
57
+    }
58
+  #endif
59
+
60
+  // Restore all hotend temperatures
61
+  HOTEND_LOOP() {
62
+    const int16_t et = job_recovery_info.target_temperature[e];
63
+    if (et) {
64
+      #if HOTENDS > 1
65
+        sprintf_P(cmd, PSTR("T%i"), e);
66
+        enqueue_and_echo_command(cmd);
67
+      #endif
68
+      sprintf_P(cmd, PSTR("M109 S%i"), et);
69
+      enqueue_and_echo_command(cmd);
70
+    }
71
+  }
72
+
73
+  #if HOTENDS > 1
74
+    sprintf_P(cmd, PSTR("T%i"), job_recovery_info.active_hotend);
75
+    enqueue_and_echo_command(cmd);
76
+  #endif
77
+
78
+  // Restore print cooling fan speeds
79
+  for (uint8_t i = 0; i < FAN_COUNT; i++) {
80
+    uint8_t f = job_recovery_info.fan_speed[i];
81
+    if (f) {
82
+      sprintf_P(cmd, PSTR("M106 P%i S%i"), i, f);
83
+      enqueue_and_echo_command(cmd);
84
+    }
85
+  }
86
+
87
+  // Start draining the job recovery command queue
88
+  job_recovery_phase = JOB_RECOVERY_YES;
89
+}
90
+
91
+static void lcd_power_loss_recovery_cancel() {
92
+  card.removeJobRecoveryFile();
93
+  card.autostart_index = 0;
94
+  lcd_return_to_status();
95
+}
96
+
97
+void menu_job_recovery() {
98
+  defer_return_to_status = true;
99
+  START_MENU();
100
+  STATIC_ITEM(MSG_POWER_LOSS_RECOVERY);
101
+  MENU_ITEM(function, MSG_RESUME_PRINT, lcd_power_loss_recovery_resume);
102
+  MENU_ITEM(function, MSG_STOP_PRINT, lcd_power_loss_recovery_cancel);
103
+  END_MENU();
104
+}
105
+
106
+#endif // HAS_LCD_MENU && POWER_LOSS_RECOVERY

Loading…
Cancel
Save