Fix PLR cancel with ExtUI (#16556)

This commit is contained in:
InsanityAutomation 2020-01-13 21:52:24 -05:00 committed by Scott Lahteine
parent 1457e40208
commit ffd8b595d1
9 changed files with 30 additions and 18 deletions

View File

@ -406,7 +406,7 @@ void startOrResumeJob() {
thermalManager.zero_fan_speeds(); thermalManager.zero_fan_speeds();
wait_for_heatup = false; wait_for_heatup = false;
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
card.removeJobRecoveryFile(); recovery.purge();
#endif #endif
#ifdef EVENT_GCODE_SD_STOP #ifdef EVENT_GCODE_SD_STOP
queue.inject_P(PSTR(EVENT_GCODE_SD_STOP)); queue.inject_P(PSTR(EVENT_GCODE_SD_STOP));

View File

@ -148,14 +148,16 @@ class PrintJobRecovery {
static void enable(const bool onoff); static void enable(const bool onoff);
static void changed(); static void changed();
static void check();
static void resume();
static inline bool exists() { return card.jobRecoverFileExists(); } static inline bool exists() { return card.jobRecoverFileExists(); }
static inline void open(const bool read) { card.openJobRecoveryFile(read); } static inline void open(const bool read) { card.openJobRecoveryFile(read); }
static inline void close() { file.close(); } static inline void close() { file.close(); }
static void check();
static void resume();
static void purge(); static void purge();
static inline void cancel() { purge(); card.autostart_index = 0; }
static void load(); static void load();
static void save(const bool force= static void save(const bool force=
#if ENABLED(SAVE_EACH_CMD_MODE) #if ENABLED(SAVE_EACH_CMD_MODE)

View File

@ -47,6 +47,10 @@ inline void plr_error(PGM_P const prefix) {
#endif #endif
} }
#if HAS_LCD_MENU
void lcd_power_loss_recovery_cancel();
#endif
/** /**
* M1000: Resume from power-loss (undocumented) * M1000: Resume from power-loss (undocumented)
* - With 'S' go to the Resume/Cancel menu * - With 'S' go to the Resume/Cancel menu
@ -64,6 +68,16 @@ void GcodeSuite::M1000() {
SERIAL_ECHO_MSG("Resume requires LCD."); SERIAL_ECHO_MSG("Resume requires LCD.");
#endif #endif
} }
else if (parser.seen('C')) {
#if HAS_LCD_MENU
lcd_power_loss_recovery_cancel();
#else
recovery.cancel();
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onPrintTimerStopped();
#endif
}
else else
recovery.resume(); recovery.resume();
} }

View File

@ -86,6 +86,10 @@ void GcodeSuite::M24() {
*/ */
void GcodeSuite::M25() { void GcodeSuite::M25() {
#if ENABLED(POWER_LOSS_RECOVERY)
if (recovery.enabled) recovery.save(true, false);
#endif
// Set initial pause flag to prevent more commands from landing in the queue while we try to pause // Set initial pause flag to prevent more commands from landing in the queue while we try to pause
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
if (IS_SD_PRINTING()) card.pauseSDPrint(); if (IS_SD_PRINTING()) card.pauseSDPrint();

View File

@ -702,6 +702,7 @@ void DGUSScreenVariableHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, voi
} }
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
void DGUSScreenVariableHandler::HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr) { void DGUSScreenVariableHandler::HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t value = swap16(*(uint16_t*)val_ptr); uint16_t value = swap16(*(uint16_t*)val_ptr);
if (value) { if (value) {
@ -709,11 +710,11 @@ void DGUSScreenVariableHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, voi
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_SDPRINTMANIPULATION); ScreenHandler.GotoScreen(DGUSLCD_SCREEN_SDPRINTMANIPULATION);
} }
else { else {
card.removeJobRecoveryFile(); recovery.cancel();
card.autostart_index = 0;
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_STATUS); ScreenHandler.GotoScreen(DGUSLCD_SCREEN_STATUS);
} }
} }
#endif #endif
void DGUSScreenVariableHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) { void DGUSScreenVariableHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) {

View File

@ -39,8 +39,7 @@ static void lcd_power_loss_recovery_resume() {
} }
void lcd_power_loss_recovery_cancel() { void lcd_power_loss_recovery_cancel() {
card.removeJobRecoveryFile(); recovery.cancel();
card.autostart_index = 0;
ui.return_to_status(); ui.return_to_status();
} }

View File

@ -95,10 +95,6 @@ MarlinUI ui;
#include "../module/planner.h" #include "../module/planner.h"
#include "../module/motion.h" #include "../module/motion.h"
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../feature/power_loss_recovery.h"
#endif
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
#include "../feature/bedlevel/bedlevel.h" #include "../feature/bedlevel/bedlevel.h"
#endif #endif
@ -1519,10 +1515,6 @@ void MarlinUI::update() {
synchronize(GET_TEXT(MSG_PAUSE_PRINT)); synchronize(GET_TEXT(MSG_PAUSE_PRINT));
#endif #endif
#if ENABLED(POWER_LOSS_RECOVERY)
if (recovery.enabled) recovery.save(true, false);
#endif
#if ENABLED(HOST_PROMPT_SUPPORT) #if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume")); host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume"));
#endif #endif

View File

@ -1071,7 +1071,7 @@ void CardReader::printingHasFinished() {
stopSDPrint(); stopSDPrint();
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
removeJobRecoveryFile(); recovery.purge();
#endif #endif
#if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND) #if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND)