Selaa lähdekoodia

Fix bug in CardReader::stopSDPrint

If the SD print is paused, it cannot be stopped
Scott Lahteine 8 vuotta sitten
vanhempi
commit
61932b859e
2 muutettua tiedostoa jossa 7 lisäystä ja 15 poistoa
  1. 6
    14
      Marlin/cardreader.cpp
  2. 1
    1
      Marlin/cardreader.h

+ 6
- 14
Marlin/cardreader.cpp Näytä tiedosto

@@ -276,19 +276,12 @@ void CardReader::openAndPrintFile(const char *name) {
276 276
 }
277 277
 
278 278
 void CardReader::startFileprint() {
279
-  if (cardOK)
280
-    sdprinting = true;
281
-}
282
-
283
-void CardReader::pauseSDPrint() {
284
-  if (sdprinting) sdprinting = false;
279
+  if (cardOK) sdprinting = true;
285 280
 }
286 281
 
287 282
 void CardReader::stopSDPrint() {
288
-  if (sdprinting) {
289
-    sdprinting = false;
290
-    file.close();
291
-  }
283
+  sdprinting = false;
284
+  if (isFileOpen()) file.close();
292 285
 }
293 286
 
294 287
 void CardReader::openLogFile(char* name) {
@@ -340,7 +333,6 @@ void CardReader::openFile(char* name, bool read, bool push_current/*=false*/) {
340 333
      SERIAL_ECHOPGM("Now doing file: ");
341 334
      SERIAL_ECHOLN(name);
342 335
     }
343
-    file.close();
344 336
   }
345 337
   else { //opening fresh file
346 338
     file_subcall_ctr = 0; //resetting procedure depth in case user cancels print while in procedure
@@ -348,7 +340,8 @@ void CardReader::openFile(char* name, bool read, bool push_current/*=false*/) {
348 340
     SERIAL_ECHOPGM("Now fresh file: ");
349 341
     SERIAL_ECHOLN(name);
350 342
   }
351
-  sdprinting = false;
343
+
344
+  stopSDPrint();
352 345
 
353 346
   SdFile myDir;
354 347
   curDir = &root;
@@ -425,8 +418,7 @@ void CardReader::openFile(char* name, bool read, bool push_current/*=false*/) {
425 418
 void CardReader::removeFile(char* name) {
426 419
   if (!cardOK) return;
427 420
 
428
-  file.close();
429
-  sdprinting = false;
421
+  stopSDPrint();
430 422
 
431 423
   SdFile myDir;
432 424
   curDir = &root;

+ 1
- 1
Marlin/cardreader.h Näytä tiedosto

@@ -51,7 +51,6 @@ public:
51 51
   void release();
52 52
   void openAndPrintFile(const char *name);
53 53
   void startFileprint();
54
-  void pauseSDPrint();
55 54
   void stopSDPrint();
56 55
   void getStatus();
57 56
   void printingHasFinished();
@@ -70,6 +69,7 @@ public:
70 69
   void updir();
71 70
   void setroot();
72 71
 
72
+  FORCE_INLINE void pauseSDPrint() { sdprinting = false; }
73 73
   FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
74 74
   FORCE_INLINE bool eof() { return sdpos >= filesize; }
75 75
   FORCE_INLINE int16_t get() { sdpos = file.curPosition(); return (int16_t)file.read(); }

Loading…
Peruuta
Tallenna