From ffd8b595d16dde892e0a48f2afd9b4e79bce47fa Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Mon, 13 Jan 2020 21:52:24 -0500 Subject: [PATCH] Fix PLR cancel with ExtUI (#16556) --- Marlin/src/MarlinCore.cpp | 2 +- Marlin/src/feature/power_loss_recovery.h | 8 +++++--- Marlin/src/gcode/feature/powerloss/M1000.cpp | 14 ++++++++++++++ Marlin/src/gcode/sdcard/M24_M25.cpp | 4 ++++ .../src/lcd/extensible_ui/lib/dgus/DGUSDisplay.cpp | 5 +++-- Marlin/src/lcd/menu/menu_job_recovery.cpp | 3 +-- Marlin/src/lcd/ultralcd.cpp | 8 -------- Marlin/src/sd/cardreader.cpp | 2 +- platformio.ini | 2 +- 9 files changed, 30 insertions(+), 18 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 55e1f033a..b7d26ca4e 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -406,7 +406,7 @@ void startOrResumeJob() { thermalManager.zero_fan_speeds(); wait_for_heatup = false; #if ENABLED(POWER_LOSS_RECOVERY) - card.removeJobRecoveryFile(); + recovery.purge(); #endif #ifdef EVENT_GCODE_SD_STOP queue.inject_P(PSTR(EVENT_GCODE_SD_STOP)); diff --git a/Marlin/src/feature/power_loss_recovery.h b/Marlin/src/feature/power_loss_recovery.h index 771fce44d..24e24e9e2 100644 --- a/Marlin/src/feature/power_loss_recovery.h +++ b/Marlin/src/feature/power_loss_recovery.h @@ -148,14 +148,16 @@ class PrintJobRecovery { static void enable(const bool onoff); static void changed(); - static void check(); - static void resume(); - static inline bool exists() { return card.jobRecoverFileExists(); } static inline void open(const bool read) { card.openJobRecoveryFile(read); } static inline void close() { file.close(); } + static void check(); + static void resume(); static void purge(); + + static inline void cancel() { purge(); card.autostart_index = 0; } + static void load(); static void save(const bool force= #if ENABLED(SAVE_EACH_CMD_MODE) diff --git a/Marlin/src/gcode/feature/powerloss/M1000.cpp b/Marlin/src/gcode/feature/powerloss/M1000.cpp index 8462dbe81..b85dc84c4 100644 --- a/Marlin/src/gcode/feature/powerloss/M1000.cpp +++ b/Marlin/src/gcode/feature/powerloss/M1000.cpp @@ -47,6 +47,10 @@ inline void plr_error(PGM_P const prefix) { #endif } +#if HAS_LCD_MENU + void lcd_power_loss_recovery_cancel(); +#endif + /** * M1000: Resume from power-loss (undocumented) * - With 'S' go to the Resume/Cancel menu @@ -64,6 +68,16 @@ void GcodeSuite::M1000() { SERIAL_ECHO_MSG("Resume requires LCD."); #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 recovery.resume(); } diff --git a/Marlin/src/gcode/sdcard/M24_M25.cpp b/Marlin/src/gcode/sdcard/M24_M25.cpp index 046df659c..d68031c0c 100644 --- a/Marlin/src/gcode/sdcard/M24_M25.cpp +++ b/Marlin/src/gcode/sdcard/M24_M25.cpp @@ -86,6 +86,10 @@ void GcodeSuite::M24() { */ 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 #if ENABLED(SDSUPPORT) if (IS_SD_PRINTING()) card.pauseSDPrint(); diff --git a/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplay.cpp b/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplay.cpp index d8e2a5bdb..0807ca9a9 100644 --- a/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplay.cpp @@ -702,6 +702,7 @@ void DGUSScreenVariableHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, voi } #if ENABLED(POWER_LOSS_RECOVERY) + void DGUSScreenVariableHandler::HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr) { uint16_t value = swap16(*(uint16_t*)val_ptr); if (value) { @@ -709,11 +710,11 @@ void DGUSScreenVariableHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, voi ScreenHandler.GotoScreen(DGUSLCD_SCREEN_SDPRINTMANIPULATION); } else { - card.removeJobRecoveryFile(); - card.autostart_index = 0; + recovery.cancel(); ScreenHandler.GotoScreen(DGUSLCD_SCREEN_STATUS); } } + #endif void DGUSScreenVariableHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) { diff --git a/Marlin/src/lcd/menu/menu_job_recovery.cpp b/Marlin/src/lcd/menu/menu_job_recovery.cpp index a85b4934e..1ac69aff7 100644 --- a/Marlin/src/lcd/menu/menu_job_recovery.cpp +++ b/Marlin/src/lcd/menu/menu_job_recovery.cpp @@ -39,8 +39,7 @@ static void lcd_power_loss_recovery_resume() { } void lcd_power_loss_recovery_cancel() { - card.removeJobRecoveryFile(); - card.autostart_index = 0; + recovery.cancel(); ui.return_to_status(); } diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index edd14dcf1..380b18a07 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -95,10 +95,6 @@ MarlinUI ui; #include "../module/planner.h" #include "../module/motion.h" -#if ENABLED(POWER_LOSS_RECOVERY) - #include "../feature/power_loss_recovery.h" -#endif - #if ENABLED(AUTO_BED_LEVELING_UBL) #include "../feature/bedlevel/bedlevel.h" #endif @@ -1519,10 +1515,6 @@ void MarlinUI::update() { synchronize(GET_TEXT(MSG_PAUSE_PRINT)); #endif - #if ENABLED(POWER_LOSS_RECOVERY) - if (recovery.enabled) recovery.save(true, false); - #endif - #if ENABLED(HOST_PROMPT_SUPPORT) host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume")); #endif diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 38354fe92..ec75206bd 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -1071,7 +1071,7 @@ void CardReader::printingHasFinished() { stopSDPrint(); #if ENABLED(POWER_LOSS_RECOVERY) - removeJobRecoveryFile(); + recovery.purge(); #endif #if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND) diff --git a/platformio.ini b/platformio.ini index cc5061473..f3d24799a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -437,7 +437,7 @@ src_filter = ${common.default_src_filter} + # # Geeetech GTM32 (STM32F103VET6) -# +# [env:STM32F103VE_GTM32] platform = ststm32 board = genericSTM32F103VE