Przeglądaj źródła

Improve menu pause / resume (#12876)

InsanityAutomation 6 lat temu
rodzic
commit
a403d9a50c

+ 5
- 5
Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp Wyświetl plik

19
 }
19
 }
20
 
20
 
21
 Ctrl_status sd_mmc_spi_test_unit_ready(void) {
21
 Ctrl_status sd_mmc_spi_test_unit_ready(void) {
22
-  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.flag.cardOK)
22
+  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
23
     return CTRL_NO_PRESENT;
23
     return CTRL_NO_PRESENT;
24
   return CTRL_GOOD;
24
   return CTRL_GOOD;
25
 }
25
 }
27
 // NOTE: This function is defined as returning the address of the last block
27
 // NOTE: This function is defined as returning the address of the last block
28
 // in the card, which is cardSize() - 1
28
 // in the card, which is cardSize() - 1
29
 Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) {
29
 Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) {
30
-  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.flag.cardOK)
30
+  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
31
     return CTRL_NO_PRESENT;
31
     return CTRL_NO_PRESENT;
32
   *nb_sector = card.getSd2Card().cardSize() - 1;
32
   *nb_sector = card.getSd2Card().cardSize() - 1;
33
   return CTRL_GOOD;
33
   return CTRL_GOOD;
42
 }
42
 }
43
 
43
 
44
 bool sd_mmc_spi_removal(void) {
44
 bool sd_mmc_spi_removal(void) {
45
-  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.flag.cardOK)
45
+  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
46
     return true;
46
     return true;
47
   return false;
47
   return false;
48
 }
48
 }
61
 // #define DEBUG_MMC
61
 // #define DEBUG_MMC
62
 
62
 
63
 Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
63
 Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) {
64
-  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.flag.cardOK)
64
+  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
65
     return CTRL_NO_PRESENT;
65
     return CTRL_NO_PRESENT;
66
 
66
 
67
   #ifdef DEBUG_MMC
67
   #ifdef DEBUG_MMC
95
 }
95
 }
96
 
96
 
97
 Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) {
97
 Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) {
98
-  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.flag.cardOK)
98
+  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
99
     return CTRL_NO_PRESENT;
99
     return CTRL_NO_PRESENT;
100
 
100
 
101
   #ifdef DEBUG_MMC
101
   #ifdef DEBUG_MMC

+ 1
- 1
Marlin/src/HAL/HAL_LPC1768/main.cpp Wyświetl plik

106
     // the disk if Marlin has it mounted. Unfortuately there is currently no way
106
     // the disk if Marlin has it mounted. Unfortuately there is currently no way
107
     // to unmount the disk from the LCD menu.
107
     // to unmount the disk from the LCD menu.
108
     // if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
108
     // if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
109
-    if (card.flag.cardOK)
109
+    if (card.isDetected())
110
       MSC_Aquire_Lock();
110
       MSC_Aquire_Lock();
111
     else
111
     else
112
       MSC_Release_Lock();
112
       MSC_Release_Lock();

+ 2
- 2
Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp Wyświetl plik

41
 char eeprom_filename[] = "eeprom.dat";
41
 char eeprom_filename[] = "eeprom.dat";
42
 
42
 
43
 bool PersistentStore::access_start() {
43
 bool PersistentStore::access_start() {
44
-  if (!card.flag.cardOK) return false;
44
+  if (!card.isDetected()) return false;
45
   int16_t bytes_read = 0;
45
   int16_t bytes_read = 0;
46
   constexpr char eeprom_zero = 0xFF;
46
   constexpr char eeprom_zero = 0xFF;
47
   card.openFile(eeprom_filename, true);
47
   card.openFile(eeprom_filename, true);
54
 }
54
 }
55
 
55
 
56
 bool PersistentStore::access_finish() {
56
 bool PersistentStore::access_finish() {
57
-  if (!card.flag.cardOK) return false;
57
+  if (!card.isDetected()) return false;
58
   card.openFile(eeprom_filename, true);
58
   card.openFile(eeprom_filename, true);
59
   int16_t bytes_written = card.write(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
59
   int16_t bytes_written = card.write(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
60
   card.closefile();
60
   card.closefile();

+ 2
- 2
Marlin/src/feature/power_loss_recovery.cpp Wyświetl plik

84
  */
84
  */
85
 void PrintJobRecovery::check() {
85
 void PrintJobRecovery::check() {
86
   if (enabled) {
86
   if (enabled) {
87
-    if (!card.flag.cardOK) card.initsd();
88
-    if (card.flag.cardOK) {
87
+    if (!card.isDetected()) card.initsd();
88
+    if (card.isDetected()) {
89
       load();
89
       load();
90
       if (!valid()) return purge();
90
       if (!valid()) return purge();
91
       enqueue_and_echo_commands_P(PSTR("M1000 S"));
91
       enqueue_and_echo_commands_P(PSTR("M1000 S"));

+ 25
- 10
Marlin/src/gcode/sdcard/M20-M30_M32-M34_M524_M928.cpp Wyświetl plik

85
  * M24: Start or Resume SD Print
85
  * M24: Start or Resume SD Print
86
  */
86
  */
87
 void GcodeSuite::M24() {
87
 void GcodeSuite::M24() {
88
-  #if ENABLED(PARK_HEAD_ON_PAUSE)
89
-    resume_print();
90
-  #endif
91
 
88
 
92
   #if ENABLED(POWER_LOSS_RECOVERY)
89
   #if ENABLED(POWER_LOSS_RECOVERY)
93
     if (parser.seenval('S')) card.setIndex(parser.value_long());
90
     if (parser.seenval('S')) card.setIndex(parser.value_long());
94
     if (parser.seenval('T')) print_job_timer.resume(parser.value_long());
91
     if (parser.seenval('T')) print_job_timer.resume(parser.value_long());
95
   #endif
92
   #endif
96
 
93
 
97
-  card.startFileprint();
98
-  print_job_timer.start();
99
-  ui.reset_status();
94
+  #if ENABLED(PARK_HEAD_ON_PAUSE)
95
+    resume_print();
96
+  #else
97
+    if (card.isFileOpen()) {
98
+      card.startFileprint();
99
+      print_job_timer.start();
100
+    }
101
+
102
+    ui.reset_status();
103
+    
104
+    #ifdef ACTION_ON_RESUME
105
+      SERIAL_ECHOLNPGM("//action:" ACTION_ON_RESUME);
106
+    #endif
107
+  #endif
100
 }
108
 }
101
 
109
 
102
 /**
110
 /**
106
   #if ENABLED(PARK_HEAD_ON_PAUSE)
114
   #if ENABLED(PARK_HEAD_ON_PAUSE)
107
     M125();
115
     M125();
108
   #else
116
   #else
109
-    card.pauseSDPrint();
117
+    #if ENABLED(SDSUPPORT)
118
+      if (IS_SD_PRINTING()) card.pauseSDPrint();
119
+    #endif
120
+
110
     print_job_timer.pause();
121
     print_job_timer.pause();
111
     ui.reset_status();
122
     ui.reset_status();
123
+
124
+    #ifdef ACTION_ON_PAUSE
125
+      SERIAL_ECHOLNPGM("//action:" ACTION_ON_PAUSE);
126
+    #endif
112
   #endif
127
   #endif
113
 }
128
 }
114
 
129
 
116
  * M26: Set SD Card file index
131
  * M26: Set SD Card file index
117
  */
132
  */
118
 void GcodeSuite::M26() {
133
 void GcodeSuite::M26() {
119
-  if (card.flag.cardOK && parser.seenval('S'))
134
+  if (card.isDetected() && parser.seenval('S'))
120
     card.setIndex(parser.value_long());
135
     card.setIndex(parser.value_long());
121
 }
136
 }
122
 
137
 
207
  * M30 <filename>: Delete SD Card file
222
  * M30 <filename>: Delete SD Card file
208
  */
223
  */
209
 void GcodeSuite::M30() {
224
 void GcodeSuite::M30() {
210
-  if (card.flag.cardOK) {
225
+  if (card.isDetected()) {
211
     card.closefile();
226
     card.closefile();
212
     card.removeFile(parser.string_arg);
227
     card.removeFile(parser.string_arg);
213
   }
228
   }
226
 void GcodeSuite::M32() {
241
 void GcodeSuite::M32() {
227
   if (IS_SD_PRINTING()) planner.synchronize();
242
   if (IS_SD_PRINTING()) planner.synchronize();
228
 
243
 
229
-  if (card.flag.cardOK) {
244
+  if (card.isDetected()) {
230
     const bool call_procedure = parser.boolval('P');
245
     const bool call_procedure = parser.boolval('P');
231
 
246
 
232
     card.openFile(parser.string_arg, true, call_procedure);
247
     card.openFile(parser.string_arg, true, call_procedure);

+ 4
- 4
Marlin/src/lcd/extensible_ui/ui_api.cpp Wyświetl plik

578
   }
578
   }
579
 
579
 
580
   bool isPrintingFromMedia() {
580
   bool isPrintingFromMedia() {
581
-    return IFSD(card.flag.cardOK && card.isFileOpen(), false);
581
+    return IFSD(card.isFileOpen(), false);
582
   }
582
   }
583
 
583
 
584
   bool isPrinting() {
584
   bool isPrinting() {
586
   }
586
   }
587
 
587
 
588
   bool isMediaInserted() {
588
   bool isMediaInserted() {
589
-    return IFSD(IS_SD_INSERTED() && card.flag.cardOK, false);
589
+    return IFSD(IS_SD_INSERTED() && card.isDetected(), false);
590
   }
590
   }
591
 
591
 
592
   void pausePrint() {
592
   void pausePrint() {
703
       last_sd_status = sd_status;
703
       last_sd_status = sd_status;
704
       if (sd_status) {
704
       if (sd_status) {
705
         card.initsd();
705
         card.initsd();
706
-        if (card.flag.cardOK)
706
+        if (card.isDetected())
707
           ExtUI::onMediaInserted();
707
           ExtUI::onMediaInserted();
708
         else
708
         else
709
           ExtUI::onMediaError();
709
           ExtUI::onMediaError();
710
       }
710
       }
711
       else {
711
       else {
712
-        const bool ok = card.flag.cardOK;
712
+        const bool ok = card.isDetected();
713
         card.release();
713
         card.release();
714
         if (ok) ExtUI::onMediaRemoved();
714
         if (ok) ExtUI::onMediaRemoved();
715
       }
715
       }

+ 1
- 1
Marlin/src/lcd/malyanlcd.cpp Wyświetl plik

330
 
330
 
331
     case 'L': {
331
     case 'L': {
332
       #if ENABLED(SDSUPPORT)
332
       #if ENABLED(SDSUPPORT)
333
-        if (!card.flag.cardOK) card.initsd();
333
+        if (!card.isDetected()) card.initsd();
334
 
334
 
335
         // A more efficient way to do this would be to
335
         // A more efficient way to do this would be to
336
         // implement a callback in the ls_SerialPrint code, but
336
         // implement a callback in the ls_SerialPrint code, but

+ 48
- 46
Marlin/src/lcd/menu/menu_main.cpp Wyświetl plik

30
 
30
 
31
 #include "menu.h"
31
 #include "menu.h"
32
 #include "../../module/temperature.h"
32
 #include "../../module/temperature.h"
33
+#include "../../gcode/queue.h"
34
+#include "../../module/printcounter.h"
33
 
35
 
34
-#if ENABLED(SDSUPPORT)
35
-
36
-  #include "../../sd/cardreader.h"
37
-  #include "../../gcode/queue.h"
38
-  #include "../../module/printcounter.h"
36
+#if ENABLED(POWER_LOSS_RECOVERY)
37
+  #include "../../feature/power_loss_recovery.h"
38
+#endif
39
 
39
 
40
+void lcd_pause() {
40
   #if ENABLED(POWER_LOSS_RECOVERY)
41
   #if ENABLED(POWER_LOSS_RECOVERY)
41
-    #include "../../feature/power_loss_recovery.h"
42
+    if (recovery.enabled) recovery.save(true, false);
42
   #endif
43
   #endif
43
 
44
 
44
-  void lcd_sdcard_pause() {
45
-    #if ENABLED(POWER_LOSS_RECOVERY)
46
-      if (recovery.enabled) recovery.save(true, false);
47
-    #endif
45
+  #if ENABLED(PARK_HEAD_ON_PAUSE)
46
+    pause_print(PAUSE_PARK_RETRACT_LENGTH, NOZZLE_PARK_POINT, 0, true);
47
+  #elif ENABLED(SDSUPPORT)
48
     enqueue_and_echo_commands_P(PSTR("M25"));
48
     enqueue_and_echo_commands_P(PSTR("M25"));
49
-  }
49
+  #elif defined(ACTION_ON_PAUSE)
50
+    SERIAL_ECHOLNPGM("//action:" ACTION_ON_PAUSE);
51
+  #endif
52
+}
50
 
53
 
51
-  void lcd_sdcard_resume() {
52
-    #if ENABLED(PARK_HEAD_ON_PAUSE)
53
-      enqueue_and_echo_commands_P(PSTR("M24"));
54
-    #else
55
-      card.startFileprint();
56
-      print_job_timer.start();
57
-      ui.reset_status();
58
-    #endif
59
-  }
54
+void lcd_resume() {
55
+  #if ENABLED(SDSUPPORT)
56
+    if (card.isPaused()) enqueue_and_echo_commands_P(PSTR("M24"));
57
+  #elif ENABLED(ACTION_ON_RESUME)
58
+    SERIAL_ECHOLNPGM("//action:" ACTION_ON_RESUME);
59
+  #endif
60
+}
61
+
62
+#if ENABLED(SDSUPPORT)
63
+
64
+  #include "../../sd/cardreader.h"
60
 
65
 
61
   void lcd_sdcard_stop() {
66
   void lcd_sdcard_stop() {
62
     wait_for_heatup = wait_for_user = false;
67
     wait_for_heatup = wait_for_user = false;
88
   START_MENU();
93
   START_MENU();
89
   MENU_BACK(MSG_WATCH);
94
   MENU_BACK(MSG_WATCH);
90
 
95
 
91
-  #if ENABLED(SDSUPPORT)
92
-    if (card.flag.cardOK) {
93
-      if (card.isFileOpen()) {
94
-        if (IS_SD_PRINTING())
95
-          MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause);
96
-        else
97
-          MENU_ITEM(function, MSG_RESUME_PRINT, lcd_sdcard_resume);
98
-
99
-        MENU_ITEM(submenu, MSG_STOP_PRINT, menu_sdcard_abort_confirm);
100
-      }
101
-      else {
102
-        MENU_ITEM(submenu, MSG_CARD_MENU, menu_sdcard);
103
-        #if !PIN_EXISTS(SD_DETECT)
104
-          MENU_ITEM(gcode, MSG_CHANGE_SDCARD, PSTR("M21"));  // SD-card changed by user
105
-        #endif
106
-      }
107
-    }
108
-    else {
109
-      MENU_ITEM(function, MSG_NO_CARD, NULL);
110
-      #if !PIN_EXISTS(SD_DETECT)
111
-        MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
112
-      #endif
113
-    }
114
-  #endif // SDSUPPORT
115
-
116
   const bool busy = printer_busy();
96
   const bool busy = printer_busy();
117
-  if (busy)
97
+
98
+  if (busy) {
99
+    MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_pause);
118
     MENU_ITEM(submenu, MSG_TUNE, menu_tune);
100
     MENU_ITEM(submenu, MSG_TUNE, menu_tune);
101
+  }
119
   else {
102
   else {
103
+    MENU_ITEM(function, MSG_RESUME_PRINT, lcd_resume);
104
+    #if ENABLED(SDSUPPORT)
105
+      if (card.isFileOpen())
106
+        MENU_ITEM(submenu, MSG_STOP_PRINT, menu_sdcard_abort_confirm);
107
+    #endif
120
     MENU_ITEM(submenu, MSG_MOTION, menu_motion);
108
     MENU_ITEM(submenu, MSG_MOTION, menu_motion);
121
     MENU_ITEM(submenu, MSG_TEMPERATURE, menu_temperature);
109
     MENU_ITEM(submenu, MSG_TEMPERATURE, menu_temperature);
122
   }
110
   }
164
       MENU_ITEM(function, MSG_AUTOSTART, card.beginautostart);
152
       MENU_ITEM(function, MSG_AUTOSTART, card.beginautostart);
165
   #endif
153
   #endif
166
 
154
 
155
+#if ENABLED(SDSUPPORT)
156
+    if (card.isDetected() && !card.isFileOpen()) {
157
+      MENU_ITEM(submenu, MSG_CARD_MENU, menu_sdcard);
158
+      #if !PIN_EXISTS(SD_DETECT)
159
+        MENU_ITEM(gcode, MSG_CHANGE_SDCARD, PSTR("M21"));  // SD-card changed by user
160
+      #endif
161
+    }
162
+    else {
163
+      MENU_ITEM(function, MSG_NO_CARD, NULL);
164
+      #if !PIN_EXISTS(SD_DETECT)
165
+        MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
166
+      #endif
167
+    }
168
+  #endif
167
   END_MENU();
169
   END_MENU();
168
 }
170
 }
169
 
171
 

+ 1
- 1
Marlin/src/lcd/menu/menu_sdcard.cpp Wyświetl plik

111
       MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
111
       MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
112
     #endif
112
     #endif
113
   }
113
   }
114
-  else if (card.flag.cardOK)
114
+  else if (card.isDetected())
115
     MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
115
     MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
116
 
116
 
117
   if (ui.should_draw()) for (uint16_t i = 0; i < fileCnt; i++) {
117
   if (ui.should_draw()) for (uint16_t i = 0; i < fileCnt; i++) {

+ 11
- 11
Marlin/src/sd/cardreader.cpp Wyświetl plik

124
       //sort_reverse = false;
124
       //sort_reverse = false;
125
     #endif
125
     #endif
126
   #endif
126
   #endif
127
-  flag.sdprinting = flag.cardOK = flag.saving = flag.logging = false;
127
+  flag.sdprinting = flag.detected = flag.saving = flag.logging = false;
128
   filesize = sdpos = 0;
128
   filesize = sdpos = 0;
129
   file_subcall_ctr = 0;
129
   file_subcall_ctr = 0;
130
 
130
 
360
 }
360
 }
361
 
361
 
362
 void CardReader::initsd() {
362
 void CardReader::initsd() {
363
-  flag.cardOK = false;
363
+  flag.detected = false;
364
   if (root.isOpen()) root.close();
364
   if (root.isOpen()) root.close();
365
 
365
 
366
   #ifndef SPI_SPEED
366
   #ifndef SPI_SPEED
380
   else if (!root.openRoot(&volume))
380
   else if (!root.openRoot(&volume))
381
     SERIAL_ERROR_MSG(MSG_SD_OPENROOT_FAIL);
381
     SERIAL_ERROR_MSG(MSG_SD_OPENROOT_FAIL);
382
   else {
382
   else {
383
-    flag.cardOK = true;
383
+    flag.detected = true;
384
     SERIAL_ECHO_MSG(MSG_SD_CARD_OK);
384
     SERIAL_ECHO_MSG(MSG_SD_CARD_OK);
385
   }
385
   }
386
   setroot();
386
   setroot();
390
 
390
 
391
 void CardReader::release() {
391
 void CardReader::release() {
392
   stopSDPrint();
392
   stopSDPrint();
393
-  flag.cardOK = false;
393
+  flag.detected = false;
394
 }
394
 }
395
 
395
 
396
 void CardReader::openAndPrintFile(const char *name) {
396
 void CardReader::openAndPrintFile(const char *name) {
402
 }
402
 }
403
 
403
 
404
 void CardReader::startFileprint() {
404
 void CardReader::startFileprint() {
405
-  if (flag.cardOK) {
405
+  if (isDetected()) {
406
     flag.sdprinting = true;
406
     flag.sdprinting = true;
407
     #if SD_RESORT
407
     #if SD_RESORT
408
       flush_presort();
408
       flush_presort();
452
 
452
 
453
 void CardReader::openFile(char * const path, const bool read, const bool subcall/*=false*/) {
453
 void CardReader::openFile(char * const path, const bool read, const bool subcall/*=false*/) {
454
 
454
 
455
-  if (!flag.cardOK) return;
455
+  if (!isDetected()) return;
456
 
456
 
457
   uint8_t doing = 0;
457
   uint8_t doing = 0;
458
   if (isFileOpen()) {                     // Replacing current file or doing a subroutine
458
   if (isFileOpen()) {                     // Replacing current file or doing a subroutine
535
 }
535
 }
536
 
536
 
537
 void CardReader::removeFile(const char * const name) {
537
 void CardReader::removeFile(const char * const name) {
538
-  if (!flag.cardOK) return;
538
+  if (!isDetected()) return;
539
 
539
 
540
   //stopSDPrint();
540
   //stopSDPrint();
541
 
541
 
561
     const int8_t port/*= -1*/
561
     const int8_t port/*= -1*/
562
   #endif
562
   #endif
563
 ) {
563
 ) {
564
-  if (flag.cardOK && flag.sdprinting) {
564
+  if (isPrinting()) {
565
     SERIAL_ECHOPGM_P(port, MSG_SD_PRINTING_BYTE);
565
     SERIAL_ECHOPGM_P(port, MSG_SD_PRINTING_BYTE);
566
     SERIAL_ECHO_P(port, sdpos);
566
     SERIAL_ECHO_P(port, sdpos);
567
     SERIAL_CHAR_P(port, '/');
567
     SERIAL_CHAR_P(port, '/');
600
 
600
 
601
   if (autostart_index < 0 || flag.sdprinting) return;
601
   if (autostart_index < 0 || flag.sdprinting) return;
602
 
602
 
603
-  if (!flag.cardOK) initsd();
603
+  if (!isDetected()) initsd();
604
 
604
 
605
-  if (flag.cardOK
605
+  if (isDetected()
606
     #if ENABLED(POWER_LOSS_RECOVERY)
606
     #if ENABLED(POWER_LOSS_RECOVERY)
607
       && !recovery.valid() // Don't run auto#.g when a resume file exists
607
       && !recovery.valid() // Don't run auto#.g when a resume file exists
608
     #endif
608
     #endif
1065
   }
1065
   }
1066
 
1066
 
1067
   void CardReader::openJobRecoveryFile(const bool read) {
1067
   void CardReader::openJobRecoveryFile(const bool read) {
1068
-    if (!flag.cardOK) return;
1068
+    if (!isDetected()) return;
1069
     if (recovery.file.isOpen()) return;
1069
     if (recovery.file.isOpen()) return;
1070
     if (!recovery.file.open(&root, job_recovery_file_name, read ? O_READ : O_CREAT | O_WRITE | O_TRUNC | O_SYNC)) {
1070
     if (!recovery.file.open(&root, job_recovery_file_name, read ? O_READ : O_CREAT | O_WRITE | O_TRUNC | O_SYNC)) {
1071
       SERIAL_ECHOPAIR(MSG_SD_OPEN_FILE_FAIL, job_recovery_file_name);
1071
       SERIAL_ECHOPAIR(MSG_SD_OPEN_FILE_FAIL, job_recovery_file_name);

+ 5
- 2
Marlin/src/sd/cardreader.h Wyświetl plik

39
   bool saving:1,
39
   bool saving:1,
40
        logging:1,
40
        logging:1,
41
        sdprinting:1,
41
        sdprinting:1,
42
-       cardOK:1,
42
+       detected:1,
43
        filenameIsDir:1,
43
        filenameIsDir:1,
44
        abort_sd_printing:1
44
        abort_sd_printing:1
45
        #if ENABLED(FAST_FILE_TRANSFER)
45
        #if ENABLED(FAST_FILE_TRANSFER)
127
   #endif
127
   #endif
128
 
128
 
129
   static inline void pauseSDPrint() { flag.sdprinting = false; }
129
   static inline void pauseSDPrint() { flag.sdprinting = false; }
130
-  static inline bool isFileOpen() { return file.isOpen(); }
130
+  static inline bool isDetected() { return flag.detected; }
131
+  static inline bool isFileOpen() { return isDetected() && file.isOpen(); }
132
+  static inline bool isPaused() { return isFileOpen() && !flag.sdprinting; }
133
+  static inline bool isPrinting() { return flag.sdprinting; }
131
   static inline bool eof() { return sdpos >= filesize; }
134
   static inline bool eof() { return sdpos >= filesize; }
132
   static inline int16_t get() { sdpos = file.curPosition(); return (int16_t)file.read(); }
135
   static inline int16_t get() { sdpos = file.curPosition(); return (int16_t)file.read(); }
133
   static inline void setIndex(const uint32_t index) { sdpos = index; file.seekSet(index); }
136
   static inline void setIndex(const uint32_t index) { sdpos = index; file.seekSet(index); }

Ładowanie…
Anuluj
Zapisz