1 |
ron |
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 |
* power_loss_recovery.h - Resume an SD print after power-loss
|
|
|
25 |
*/
|
|
|
26 |
|
|
|
27 |
#ifndef _POWER_LOSS_RECOVERY_H_
|
|
|
28 |
#define _POWER_LOSS_RECOVERY_H_
|
|
|
29 |
|
|
|
30 |
#include "cardreader.h"
|
|
|
31 |
#include "types.h"
|
|
|
32 |
#include "MarlinConfig.h"
|
|
|
33 |
|
|
|
34 |
#define SAVE_INFO_INTERVAL_MS 0
|
|
|
35 |
//#define SAVE_EACH_CMD_MODE
|
|
|
36 |
//#define DEBUG_POWER_LOSS_RECOVERY
|
|
|
37 |
|
|
|
38 |
typedef struct {
|
|
|
39 |
uint8_t valid_head;
|
|
|
40 |
|
|
|
41 |
// Machine state
|
|
|
42 |
float current_position[NUM_AXIS], feedrate;
|
|
|
43 |
|
|
|
44 |
#if HOTENDS > 1
|
|
|
45 |
uint8_t active_hotend;
|
|
|
46 |
#endif
|
|
|
47 |
|
|
|
48 |
int16_t target_temperature[HOTENDS];
|
|
|
49 |
|
|
|
50 |
#if HAS_HEATED_BED
|
|
|
51 |
int16_t target_temperature_bed;
|
|
|
52 |
#endif
|
|
|
53 |
|
|
|
54 |
#if FAN_COUNT
|
|
|
55 |
int16_t fanSpeeds[FAN_COUNT];
|
|
|
56 |
#endif
|
|
|
57 |
|
|
|
58 |
#if HAS_LEVELING
|
|
|
59 |
bool leveling;
|
|
|
60 |
float fade;
|
|
|
61 |
#endif
|
|
|
62 |
|
|
|
63 |
// Command queue
|
|
|
64 |
uint8_t cmd_queue_index_r, commands_in_queue;
|
|
|
65 |
char command_queue[BUFSIZE][MAX_CMD_SIZE];
|
|
|
66 |
|
|
|
67 |
// SD Filename and position
|
|
|
68 |
char sd_filename[MAXPATHNAMELENGTH];
|
|
|
69 |
uint32_t sdpos;
|
|
|
70 |
|
|
|
71 |
// Job elapsed time
|
|
|
72 |
millis_t print_job_elapsed;
|
|
|
73 |
|
|
|
74 |
uint8_t valid_foot;
|
|
|
75 |
} job_recovery_info_t;
|
|
|
76 |
|
|
|
77 |
extern job_recovery_info_t job_recovery_info;
|
|
|
78 |
|
|
|
79 |
enum JobRecoveryPhase : unsigned char {
|
|
|
80 |
JOB_RECOVERY_IDLE,
|
|
|
81 |
JOB_RECOVERY_MAYBE,
|
|
|
82 |
JOB_RECOVERY_YES,
|
|
|
83 |
JOB_RECOVERY_DONE
|
|
|
84 |
};
|
|
|
85 |
extern JobRecoveryPhase job_recovery_phase;
|
|
|
86 |
|
|
|
87 |
#if HAS_LEVELING
|
|
|
88 |
#define APPEND_CMD_COUNT 9
|
|
|
89 |
#else
|
|
|
90 |
#define APPEND_CMD_COUNT 7
|
|
|
91 |
#endif
|
|
|
92 |
|
|
|
93 |
extern char job_recovery_commands[BUFSIZE + APPEND_CMD_COUNT][MAX_CMD_SIZE];
|
|
|
94 |
extern uint8_t job_recovery_commands_count;
|
|
|
95 |
|
|
|
96 |
void check_print_job_recovery();
|
|
|
97 |
void save_job_recovery_info();
|
|
|
98 |
|
|
|
99 |
#endif // _POWER_LOSS_RECOVERY_H_
|