Fix and tweak POWER_LOSS_RECOVERY (#11151)
This commit is contained in:
parent
0fff79c24b
commit
fbf1c9b496
|
@ -53,30 +53,39 @@ static char sd_filename[MAXPATHNAMELENGTH];
|
||||||
SERIAL_PROTOCOLLNPAIR(" valid_foot:", (int)job_recovery_info.valid_foot);
|
SERIAL_PROTOCOLLNPAIR(" valid_foot:", (int)job_recovery_info.valid_foot);
|
||||||
if (job_recovery_info.valid_head) {
|
if (job_recovery_info.valid_head) {
|
||||||
if (job_recovery_info.valid_head == job_recovery_info.valid_foot) {
|
if (job_recovery_info.valid_head == job_recovery_info.valid_foot) {
|
||||||
SERIAL_PROTOCOLPGM("current_position");
|
SERIAL_PROTOCOLPGM("current_position: ");
|
||||||
LOOP_XYZE(i) SERIAL_PROTOCOLPAIR(": ", job_recovery_info.current_position[i]);
|
LOOP_XYZE(i) {
|
||||||
|
SERIAL_PROTOCOL(job_recovery_info.current_position[i]);
|
||||||
|
if (i < E_AXIS) SERIAL_CHAR(',');
|
||||||
|
}
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
SERIAL_PROTOCOLLNPAIR("feedrate: ", job_recovery_info.feedrate);
|
SERIAL_PROTOCOLLNPAIR("feedrate: ", job_recovery_info.feedrate);
|
||||||
SERIAL_PROTOCOLPGM("target_temperature");
|
SERIAL_PROTOCOLPGM("target_temperature: ");
|
||||||
HOTEND_LOOP() SERIAL_PROTOCOLPAIR(": ", job_recovery_info.target_temperature[e]);
|
HOTEND_LOOP() {
|
||||||
|
SERIAL_PROTOCOL(job_recovery_info.target_temperature[e]);
|
||||||
|
if (e < HOTENDS - 1) SERIAL_CHAR(',');
|
||||||
|
}
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
SERIAL_PROTOCOLPGM("fanSpeeds");
|
SERIAL_PROTOCOLPGM("fanSpeeds: ");
|
||||||
for(uint8_t i = 0; i < FAN_COUNT; i++) SERIAL_PROTOCOLPAIR(": ", job_recovery_info.fanSpeeds[i]);
|
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();
|
SERIAL_EOL();
|
||||||
|
#if HAS_HEATED_BED
|
||||||
|
SERIAL_PROTOCOLLNPAIR("target_temperature_bed: ", job_recovery_info.target_temperature_bed);
|
||||||
|
#endif
|
||||||
#if HAS_LEVELING
|
#if HAS_LEVELING
|
||||||
SERIAL_PROTOCOLPAIR("leveling: ", int(job_recovery_info.leveling));
|
SERIAL_PROTOCOLPAIR("leveling: ", int(job_recovery_info.leveling));
|
||||||
SERIAL_PROTOCOLLNPAIR(" fade: ", int(job_recovery_info.fade));
|
SERIAL_PROTOCOLLNPAIR(" fade: ", int(job_recovery_info.fade));
|
||||||
#endif
|
#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("cmd_queue_index_r: ", job_recovery_info.cmd_queue_index_r);
|
||||||
SERIAL_PROTOCOLLNPAIR("commands_in_queue: ", job_recovery_info.commands_in_queue);
|
SERIAL_PROTOCOLLNPAIR("commands_in_queue: ", job_recovery_info.commands_in_queue);
|
||||||
if (recovery)
|
if (recovery)
|
||||||
for (uint8_t i = 0; i < job_recovery_commands_count; i++) SERIAL_PROTOCOLLNPAIR("> ", job_recovery_commands[i]);
|
for (uint8_t i = 0; i < job_recovery_commands_count; i++) SERIAL_PROTOCOLLNPAIR("> ", job_recovery_commands[i]);
|
||||||
else
|
else
|
||||||
for (uint8_t i = 0; i < job_recovery_info.commands_in_queue; i++) SERIAL_PROTOCOLLNPAIR("> ", job_recovery_info.command_queue[i]);
|
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("sdpos: ", job_recovery_info.sdpos);
|
||||||
SERIAL_PROTOCOLLNPAIR("print_job_elapsed: ", job_recovery_info.print_job_elapsed);
|
SERIAL_PROTOCOLLNPAIR("print_job_elapsed: ", job_recovery_info.print_job_elapsed);
|
||||||
}
|
}
|
||||||
|
@ -125,13 +134,15 @@ void do_print_job_recovery() {
|
||||||
#endif
|
#endif
|
||||||
));
|
));
|
||||||
|
|
||||||
|
char str_1[16], str_2[16];
|
||||||
|
|
||||||
#if HAS_LEVELING
|
#if HAS_LEVELING
|
||||||
// Restore leveling state before G92 sets Z
|
// Restore leveling state before G92 sets Z
|
||||||
// This ensures the steppers correspond to the native Z
|
// This ensures the steppers correspond to the native Z
|
||||||
sprintf_P(job_recovery_commands[ind++], PSTR("M420 S%i Z%s"), int(job_recovery_info.leveling), job_recovery_info.fade);
|
dtostrf(job_recovery_info.fade, 1, 1, str_1);
|
||||||
|
sprintf_P(job_recovery_commands[ind++], PSTR("M420 S%i Z%s"), int(job_recovery_info.leveling), str_1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char str_1[16], str_2[16];
|
|
||||||
dtostrf(job_recovery_info.current_position[Z_AXIS] + 2, 1, 3, str_1);
|
dtostrf(job_recovery_info.current_position[Z_AXIS] + 2, 1, 3, str_1);
|
||||||
dtostrf(job_recovery_info.current_position[E_AXIS]
|
dtostrf(job_recovery_info.current_position[E_AXIS]
|
||||||
#if ENABLED(SAVE_EACH_CMD_MODE)
|
#if ENABLED(SAVE_EACH_CMD_MODE)
|
||||||
|
@ -156,7 +167,7 @@ void do_print_job_recovery() {
|
||||||
debug_print_job_recovery(true);
|
debug_print_job_recovery(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
card.openFile(sd_filename, true);
|
card.openFile(job_recovery_info.sd_filename, true);
|
||||||
card.setIndex(job_recovery_info.sdpos);
|
card.setIndex(job_recovery_info.sdpos);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -223,7 +234,7 @@ void save_job_recovery_info() {
|
||||||
job_recovery_info.print_job_elapsed = print_job_timer.duration() * 1000UL;
|
job_recovery_info.print_job_elapsed = print_job_timer.duration() * 1000UL;
|
||||||
|
|
||||||
// SD file position
|
// SD file position
|
||||||
card.getAbsFilename(sd_filename);
|
card.getAbsFilename(job_recovery_info.sd_filename);
|
||||||
job_recovery_info.sdpos = card.getIndex();
|
job_recovery_info.sdpos = card.getIndex();
|
||||||
|
|
||||||
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
|
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
|
||||||
|
|
|
@ -56,7 +56,8 @@ typedef struct {
|
||||||
uint8_t cmd_queue_index_r, commands_in_queue;
|
uint8_t cmd_queue_index_r, commands_in_queue;
|
||||||
char command_queue[BUFSIZE][MAX_CMD_SIZE];
|
char command_queue[BUFSIZE][MAX_CMD_SIZE];
|
||||||
|
|
||||||
// SD File position
|
// SD Filename and position
|
||||||
|
char sd_filename[MAXPATHNAMELENGTH];
|
||||||
uint32_t sdpos;
|
uint32_t sdpos;
|
||||||
|
|
||||||
// Job elapsed time
|
// Job elapsed time
|
||||||
|
|
|
@ -875,11 +875,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
||||||
lcd_return_to_status();
|
lcd_return_to_status();
|
||||||
|
|
||||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||||
card.openJobRecoveryFile(false);
|
card.removeJobRecoveryFile();
|
||||||
job_recovery_info.valid_head = job_recovery_info.valid_foot = 0;
|
|
||||||
(void)card.saveJobRecoveryInfo();
|
|
||||||
card.closeJobRecoveryFile();
|
|
||||||
job_recovery_commands_count = 0;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -937,11 +937,7 @@ void CardReader::printingHasFinished() {
|
||||||
sdprinting = false;
|
sdprinting = false;
|
||||||
|
|
||||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||||
openJobRecoveryFile(false);
|
removeJobRecoveryFile();
|
||||||
job_recovery_info.valid_head = job_recovery_info.valid_foot = 0;
|
|
||||||
(void)saveJobRecoveryInfo();
|
|
||||||
closeJobRecoveryFile();
|
|
||||||
job_recovery_commands_count = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND)
|
#if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND)
|
||||||
|
@ -1016,10 +1012,14 @@ void CardReader::printingHasFinished() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardReader::removeJobRecoveryFile() {
|
void CardReader::removeJobRecoveryFile() {
|
||||||
if (jobRecoveryFile.remove(&root, job_recovery_file_name))
|
job_recovery_info.valid_head = job_recovery_info.valid_foot = job_recovery_commands_count = 0;
|
||||||
SERIAL_PROTOCOLLNPGM("Power-loss file deleted.");
|
const bool success = jobRecoveryFile.remove(&root, job_recovery_file_name);
|
||||||
else
|
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
|
||||||
SERIAL_PROTOCOLLNPGM("Power-loss file delete failed.");
|
SERIAL_PROTOCOLPGM("Power-loss file delete");
|
||||||
|
serialprintPGM(success ? PSTR("d.") : PSTR(" failed."))
|
||||||
|
#else
|
||||||
|
UNUSED(success);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // POWER_LOSS_RECOVERY
|
#endif // POWER_LOSS_RECOVERY
|
||||||
|
|
Loading…
Reference in a new issue