1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-29 23:07:42 +00:00

Fix and tweak POWER_LOSS_RECOVERY (#11150)

This commit is contained in:
Scott Lahteine 2018-06-29 22:40:49 -05:00 committed by GitHub
parent 67475374ae
commit 609e7da3f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 30 deletions

View File

@ -897,11 +897,7 @@ void CardReader::printingHasFinished() {
sdprinting = false;
#if ENABLED(POWER_LOSS_RECOVERY)
openJobRecoveryFile(false);
job_recovery_info.valid_head = job_recovery_info.valid_foot = 0;
(void)saveJobRecoveryInfo();
closeJobRecoveryFile();
job_recovery_commands_count = 0;
removeJobRecoveryFile();
#endif
#if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND)
@ -969,10 +965,14 @@ void CardReader::printingHasFinished() {
}
void CardReader::removeJobRecoveryFile() {
if (jobRecoveryFile.remove(&root, job_recovery_file_name))
SERIAL_PROTOCOLLNPGM("Power-loss file deleted.");
else
SERIAL_PROTOCOLLNPGM("Power-loss file delete failed.");
job_recovery_info.valid_head = job_recovery_info.valid_foot = job_recovery_commands_count = 0;
const bool success = jobRecoveryFile.remove(&root, job_recovery_file_name);
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
SERIAL_PROTOCOLPGM("Power-loss file delete");
serialprintPGM(success ? PSTR("d.") : PSTR(" failed."))
#else
UNUSED(success);
#endif
}
#endif // POWER_LOSS_RECOVERY

View File

@ -46,39 +46,45 @@ char job_recovery_commands[BUFSIZE + APPEND_CMD_COUNT][MAX_CMD_SIZE];
// Extern
extern uint8_t commands_in_queue, cmd_queue_index_r;
// Private
static char sd_filename[MAXPATHNAMELENGTH];
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
void debug_print_job_recovery(const bool recovery) {
SERIAL_PROTOCOLPAIR("valid_head:", (int)job_recovery_info.valid_head);
SERIAL_PROTOCOLLNPAIR(" valid_foot:", (int)job_recovery_info.valid_foot);
if (job_recovery_info.valid_head) {
if (job_recovery_info.valid_head == job_recovery_info.valid_foot) {
SERIAL_PROTOCOLPGM("current_position");
LOOP_XYZE(i) SERIAL_PROTOCOLPAIR(": ", job_recovery_info.current_position[i]);
SERIAL_PROTOCOLPGM("current_position: ");
LOOP_XYZE(i) {
SERIAL_PROTOCOL(job_recovery_info.current_position[i]);
if (i < E_AXIS) SERIAL_CHAR(',');
}
SERIAL_EOL();
SERIAL_PROTOCOLLNPAIR("feedrate: ", job_recovery_info.feedrate);
SERIAL_PROTOCOLPGM("target_temperature");
HOTEND_LOOP() SERIAL_PROTOCOLPAIR(": ", job_recovery_info.target_temperature[e]);
SERIAL_PROTOCOLPGM("target_temperature: ");
HOTEND_LOOP() {
SERIAL_PROTOCOL(job_recovery_info.target_temperature[e]);
if (e < HOTENDS - 1) SERIAL_CHAR(',');
}
SERIAL_EOL();
SERIAL_PROTOCOLPGM("fanSpeeds");
for(uint8_t i = 0; i < FAN_COUNT; i++) SERIAL_PROTOCOLPAIR(": ", job_recovery_info.fanSpeeds[i]);
SERIAL_PROTOCOLPGM("fanSpeeds: ");
for (uint8_t i = 0; i < FAN_COUNT; i++) {
SERIAL_PROTOCOL(job_recovery_info.fanSpeeds[i]);
if (i < FAN_COUNT - 1) SERIAL_CHAR(',');
}
SERIAL_EOL();
#if HAS_HEATED_BED
SERIAL_PROTOCOLLNPAIR("target_temperature_bed: ", job_recovery_info.target_temperature_bed);
#endif
#if HAS_LEVELING
SERIAL_PROTOCOLPAIR("leveling: ", int(job_recovery_info.leveling));
SERIAL_PROTOCOLLNPAIR(" fade: ", int(job_recovery_info.fade));
#endif
#if HAS_HEATED_BED
SERIAL_PROTOCOLLNPAIR("target_temperature_bed: ", job_recovery_info.target_temperature_bed);
#endif
SERIAL_PROTOCOLLNPAIR("cmd_queue_index_r: ", job_recovery_info.cmd_queue_index_r);
SERIAL_PROTOCOLLNPAIR("commands_in_queue: ", job_recovery_info.commands_in_queue);
if (recovery)
for (uint8_t i = 0; i < job_recovery_commands_count; i++) SERIAL_PROTOCOLLNPAIR("> ", job_recovery_commands[i]);
else
for (uint8_t i = 0; i < job_recovery_info.commands_in_queue; i++) SERIAL_PROTOCOLLNPAIR("> ", job_recovery_info.command_queue[i]);
SERIAL_PROTOCOLLNPAIR("sd_filename: ", sd_filename);
SERIAL_PROTOCOLLNPAIR("sd_filename: ", job_recovery_info.sd_filename);
SERIAL_PROTOCOLLNPAIR("sdpos: ", job_recovery_info.sdpos);
SERIAL_PROTOCOLLNPAIR("print_job_elapsed: ", job_recovery_info.print_job_elapsed);
}
@ -160,7 +166,7 @@ void do_print_job_recovery() {
debug_print_job_recovery(true);
#endif
card.openFile(sd_filename, true);
card.openFile(job_recovery_info.sd_filename, true);
card.setIndex(job_recovery_info.sdpos);
}
else {
@ -227,7 +233,7 @@ void save_job_recovery_info() {
job_recovery_info.print_job_elapsed = print_job_timer.duration() * 1000UL;
// SD file position
card.getAbsFilename(sd_filename);
card.getAbsFilename(job_recovery_info.sd_filename);
job_recovery_info.sdpos = card.getIndex();
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)

View File

@ -56,7 +56,8 @@ typedef struct {
uint8_t cmd_queue_index_r, commands_in_queue;
char command_queue[BUFSIZE][MAX_CMD_SIZE];
// SD File position
// SD Filename and position
char sd_filename[MAXPATHNAMELENGTH];
uint32_t sdpos;
// Job elapsed time

View File

@ -863,11 +863,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
lcd_return_to_status();
#if ENABLED(POWER_LOSS_RECOVERY)
card.openJobRecoveryFile(false);
job_recovery_info.valid_head = job_recovery_info.valid_foot = 0;
(void)card.saveJobRecoveryInfo();
card.closeJobRecoveryFile();
job_recovery_commands_count = 0;
card.removeJobRecoveryFile();
#endif
}