Browse Source

Fix PLR cancel with ExtUI (#16556)

InsanityAutomation 4 years ago
parent
commit
ffd8b595d1

+ 1
- 1
Marlin/src/MarlinCore.cpp View File

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

+ 5
- 3
Marlin/src/feature/power_loss_recovery.h View File

@@ -148,14 +148,16 @@ class PrintJobRecovery {
148 148
     static void enable(const bool onoff);
149 149
     static void changed();
150 150
 
151
-    static void check();
152
-    static void resume();
153
-
154 151
     static inline bool exists() { return card.jobRecoverFileExists(); }
155 152
     static inline void open(const bool read) { card.openJobRecoveryFile(read); }
156 153
     static inline void close() { file.close(); }
157 154
 
155
+    static void check();
156
+    static void resume();
158 157
     static void purge();
158
+
159
+    static inline void cancel() { purge(); card.autostart_index = 0; }
160
+
159 161
     static void load();
160 162
     static void save(const bool force=
161 163
       #if ENABLED(SAVE_EACH_CMD_MODE)

+ 14
- 0
Marlin/src/gcode/feature/powerloss/M1000.cpp View File

@@ -47,6 +47,10 @@ inline void plr_error(PGM_P const prefix) {
47 47
   #endif
48 48
 }
49 49
 
50
+#if HAS_LCD_MENU
51
+  void lcd_power_loss_recovery_cancel();
52
+#endif
53
+
50 54
 /**
51 55
  * M1000: Resume from power-loss (undocumented)
52 56
  *   - With 'S' go to the Resume/Cancel menu
@@ -64,6 +68,16 @@ void GcodeSuite::M1000() {
64 68
         SERIAL_ECHO_MSG("Resume requires LCD.");
65 69
       #endif
66 70
     }
71
+    else if (parser.seen('C')) {
72
+      #if HAS_LCD_MENU
73
+        lcd_power_loss_recovery_cancel();
74
+      #else
75
+        recovery.cancel();
76
+      #endif
77
+      #if ENABLED(EXTENSIBLE_UI)
78
+        ExtUI::onPrintTimerStopped();
79
+      #endif
80
+    }
67 81
     else
68 82
       recovery.resume();
69 83
   }

+ 4
- 0
Marlin/src/gcode/sdcard/M24_M25.cpp View File

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

+ 3
- 2
Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplay.cpp View File

@@ -702,6 +702,7 @@ void DGUSScreenVariableHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, voi
702 702
 }
703 703
 
704 704
 #if ENABLED(POWER_LOSS_RECOVERY)
705
+
705 706
   void DGUSScreenVariableHandler::HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr) {
706 707
     uint16_t value = swap16(*(uint16_t*)val_ptr);
707 708
     if (value) {
@@ -709,11 +710,11 @@ void DGUSScreenVariableHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, voi
709 710
       ScreenHandler.GotoScreen(DGUSLCD_SCREEN_SDPRINTMANIPULATION);
710 711
     }
711 712
     else {
712
-      card.removeJobRecoveryFile();
713
-      card.autostart_index = 0;
713
+      recovery.cancel();
714 714
       ScreenHandler.GotoScreen(DGUSLCD_SCREEN_STATUS);
715 715
     }
716 716
   }
717
+
717 718
 #endif
718 719
 
719 720
 void DGUSScreenVariableHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) {

+ 1
- 2
Marlin/src/lcd/menu/menu_job_recovery.cpp View File

@@ -39,8 +39,7 @@ static void lcd_power_loss_recovery_resume() {
39 39
 }
40 40
 
41 41
 void lcd_power_loss_recovery_cancel() {
42
-  card.removeJobRecoveryFile();
43
-  card.autostart_index = 0;
42
+  recovery.cancel();
44 43
   ui.return_to_status();
45 44
 }
46 45
 

+ 0
- 8
Marlin/src/lcd/ultralcd.cpp View File

@@ -95,10 +95,6 @@ MarlinUI ui;
95 95
 #include "../module/planner.h"
96 96
 #include "../module/motion.h"
97 97
 
98
-#if ENABLED(POWER_LOSS_RECOVERY)
99
-  #include "../feature/power_loss_recovery.h"
100
-#endif
101
-
102 98
 #if ENABLED(AUTO_BED_LEVELING_UBL)
103 99
   #include "../feature/bedlevel/bedlevel.h"
104 100
 #endif
@@ -1519,10 +1515,6 @@ void MarlinUI::update() {
1519 1515
       synchronize(GET_TEXT(MSG_PAUSE_PRINT));
1520 1516
     #endif
1521 1517
 
1522
-    #if ENABLED(POWER_LOSS_RECOVERY)
1523
-      if (recovery.enabled) recovery.save(true, false);
1524
-    #endif
1525
-
1526 1518
     #if ENABLED(HOST_PROMPT_SUPPORT)
1527 1519
       host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume"));
1528 1520
     #endif

+ 1
- 1
Marlin/src/sd/cardreader.cpp View File

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

+ 1
- 1
platformio.ini View File

@@ -437,7 +437,7 @@ src_filter    = ${common.default_src_filter} +<src/HAL/HAL_STM32>
437 437
 
438 438
 #
439 439
 # Geeetech GTM32 (STM32F103VET6)
440
-#  
440
+#
441 441
 [env:STM32F103VE_GTM32]
442 442
 platform        = ststm32
443 443
 board           = genericSTM32F103VE

Loading…
Cancel
Save