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);
|
||||
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);
|
||||
}
|
||||
|
@ -125,13 +134,15 @@ void do_print_job_recovery() {
|
|||
#endif
|
||||
));
|
||||
|
||||
char str_1[16], str_2[16];
|
||||
|
||||
#if HAS_LEVELING
|
||||
// Restore leveling state before G92 sets 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
|
||||
|
||||
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[E_AXIS]
|
||||
#if ENABLED(SAVE_EACH_CMD_MODE)
|
||||
|
@ -156,7 +167,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 {
|
||||
|
@ -223,7 +234,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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -875,11 +875,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
|
||||
}
|
||||
|
||||
|
|
|
@ -937,11 +937,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)
|
||||
|
@ -1016,10 +1012,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
|
||||
|
|
Loading…
Reference in a new issue