Optimize Power-Loss Recovery (#12440)

This commit is contained in:
Scott Lahteine
2018-11-16 20:47:07 -06:00
committed by GitHub
parent ca21ac6b9b
commit d97e31db4c
23 changed files with 586 additions and 363 deletions

View File

@@ -26,7 +26,6 @@
*/
#include "../sd/cardreader.h"
#include "../core/millis_t.h"
#include "../inc/MarlinConfigPre.h"
#define SAVE_INFO_INTERVAL_MS 0
@@ -37,7 +36,9 @@ typedef struct {
uint8_t valid_head;
// Machine state
float current_position[NUM_AXIS], feedrate;
float current_position[NUM_AXIS];
uint16_t feedrate;
#if HOTENDS > 1
uint8_t active_hotend;
@@ -74,26 +75,45 @@ typedef struct {
millis_t print_job_elapsed;
uint8_t valid_foot;
} job_recovery_info_t;
extern job_recovery_info_t job_recovery_info;
class PrintJobRecovery {
public:
static SdFile file;
static job_recovery_info_t info;
enum JobRecoveryPhase : unsigned char {
JOB_RECOVERY_IDLE,
JOB_RECOVERY_MAYBE,
JOB_RECOVERY_YES,
JOB_RECOVERY_DONE
static void init();
static bool enabled;
static void enable(const bool onoff);
static void changed();
static void check();
static void resume();
static inline bool exists() { return card.jobRecoverFileExists(); }
static inline void open(const bool read) { card.openJobRecoveryFile(read); }
static inline void close() { file.close(); }
static void purge();
static void load();
static void save(const bool force=
#if ENABLED(SAVE_EACH_CMD_MODE)
true
#else
false
#endif
);
static inline bool valid() { return info.valid_head && info.valid_head == info.valid_foot; }
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
static void debug(PGM_P const prefix);
#endif
private:
static void write();
};
extern JobRecoveryPhase job_recovery_phase;
#if HAS_LEVELING
#define APPEND_CMD_COUNT 9
#else
#define APPEND_CMD_COUNT 7
#endif
extern char job_recovery_commands[BUFSIZE + APPEND_CMD_COUNT][MAX_CMD_SIZE];
extern uint8_t job_recovery_commands_count;
void check_print_job_recovery();
void save_job_recovery_info();
extern PrintJobRecovery recovery;