Fix and tweak POWER_LOSS_RECOVERY (#11151)

This commit is contained in:
Scott Lahteine
2018-06-29 22:41:02 -05:00
committed by GitHub
parent 0fff79c24b
commit fbf1c9b496
4 changed files with 37 additions and 29 deletions

View File

@ -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)

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