|
@@ -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
|