Merge pull request #10479 from thinkyhead/bf2_creality_power_loss_resume
[2.0.x] Creality3D Power-Loss Recovery
This commit is contained in:
@ -302,7 +302,7 @@ void process_lcd_s_command(const char* command) {
|
||||
|
||||
case 'H':
|
||||
// Home all axis
|
||||
enqueue_and_echo_command("G28", false);
|
||||
enqueue_and_echo_commands_P(PSTR("G28"));
|
||||
break;
|
||||
|
||||
case 'L': {
|
||||
|
@ -43,6 +43,10 @@
|
||||
#include "../feature/pause.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
#include "../feature/power_loss_recovery.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(PRINTCOUNTER) && ENABLED(LCD_INFO_MENU)
|
||||
#include "../libs/duration_t.h"
|
||||
#endif
|
||||
@ -862,10 +866,70 @@ void kill_screen(const char* lcd_msg) {
|
||||
abort_sd_printing = true;
|
||||
lcd_setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1);
|
||||
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;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // SDSUPPORT
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
|
||||
static void lcd_sdcard_recover_job() {
|
||||
char cmd[20];
|
||||
|
||||
// Return to status now
|
||||
lcd_return_to_status();
|
||||
|
||||
// Turn leveling off and home
|
||||
enqueue_and_echo_commands_P(PSTR("M420 S0\nG28"
|
||||
#if !IS_KINEMATIC
|
||||
" X Y"
|
||||
#endif
|
||||
));
|
||||
|
||||
// Restore the bed temperature
|
||||
sprintf_P(cmd, PSTR("M190 S%i"), job_recovery_info.target_temperature_bed);
|
||||
enqueue_and_echo_command(cmd);
|
||||
|
||||
// Restore all hotend temperatures
|
||||
HOTEND_LOOP() {
|
||||
sprintf_P(cmd, PSTR("M109 S%i"), job_recovery_info.target_temperature[e]);
|
||||
enqueue_and_echo_command(cmd);
|
||||
}
|
||||
|
||||
// Restore print cooling fan speeds
|
||||
for (uint8_t i = 0; i < FAN_COUNT; i++) {
|
||||
sprintf_P(cmd, PSTR("M106 P%i S%i"), i, job_recovery_info.fanSpeeds[i]);
|
||||
enqueue_and_echo_command(cmd);
|
||||
}
|
||||
|
||||
// Start draining the job recovery command queue
|
||||
job_recovery_phase = JOB_RECOVERY_YES;
|
||||
|
||||
// Resume the print job timer
|
||||
if (job_recovery_info.print_job_elapsed)
|
||||
print_job_timer.resume(job_recovery_info.print_job_elapsed);
|
||||
|
||||
// Start getting commands from SD
|
||||
card.startFileprint();
|
||||
}
|
||||
|
||||
static void lcd_job_recovery_menu() {
|
||||
defer_return_to_status = true;
|
||||
START_MENU();
|
||||
MENU_ITEM(function, MSG_RESUME_PRINT, lcd_sdcard_recover_job);
|
||||
MENU_ITEM(function, MSG_STOP_PRINT, lcd_sdcard_stop);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // POWER_LOSS_RECOVERY
|
||||
|
||||
#if ENABLED(MENU_ITEM_CASE_LIGHT)
|
||||
|
||||
#include "../feature/caselight.h"
|
||||
@ -5067,6 +5131,13 @@ void lcd_update() {
|
||||
|
||||
#endif // SDSUPPORT && SD_DETECT_PIN
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
if (job_recovery_commands_count && job_recovery_phase == JOB_RECOVERY_IDLE) {
|
||||
lcd_goto_screen(lcd_job_recovery_menu);
|
||||
job_recovery_phase = JOB_RECOVERY_MAYBE; // Waiting for a response
|
||||
}
|
||||
#endif
|
||||
|
||||
const millis_t ms = millis();
|
||||
if (ELAPSED(ms, next_lcd_update_ms)
|
||||
#if ENABLED(DOGLCD)
|
||||
|
Reference in New Issue
Block a user