Browse Source

Fix bug in CardReader::stopSDPrint

If the SD print is paused, it cannot be stopped
Scott Lahteine 8 years ago
parent
commit
61932b859e
2 changed files with 7 additions and 15 deletions
  1. 6
    14
      Marlin/cardreader.cpp
  2. 1
    1
      Marlin/cardreader.h

+ 6
- 14
Marlin/cardreader.cpp View File

276
 }
276
 }
277
 
277
 
278
 void CardReader::startFileprint() {
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
 void CardReader::stopSDPrint() {
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
 void CardReader::openLogFile(char* name) {
287
 void CardReader::openLogFile(char* name) {
340
      SERIAL_ECHOPGM("Now doing file: ");
333
      SERIAL_ECHOPGM("Now doing file: ");
341
      SERIAL_ECHOLN(name);
334
      SERIAL_ECHOLN(name);
342
     }
335
     }
343
-    file.close();
344
   }
336
   }
345
   else { //opening fresh file
337
   else { //opening fresh file
346
     file_subcall_ctr = 0; //resetting procedure depth in case user cancels print while in procedure
338
     file_subcall_ctr = 0; //resetting procedure depth in case user cancels print while in procedure
348
     SERIAL_ECHOPGM("Now fresh file: ");
340
     SERIAL_ECHOPGM("Now fresh file: ");
349
     SERIAL_ECHOLN(name);
341
     SERIAL_ECHOLN(name);
350
   }
342
   }
351
-  sdprinting = false;
343
+
344
+  stopSDPrint();
352
 
345
 
353
   SdFile myDir;
346
   SdFile myDir;
354
   curDir = &root;
347
   curDir = &root;
425
 void CardReader::removeFile(char* name) {
418
 void CardReader::removeFile(char* name) {
426
   if (!cardOK) return;
419
   if (!cardOK) return;
427
 
420
 
428
-  file.close();
429
-  sdprinting = false;
421
+  stopSDPrint();
430
 
422
 
431
   SdFile myDir;
423
   SdFile myDir;
432
   curDir = &root;
424
   curDir = &root;

+ 1
- 1
Marlin/cardreader.h View File

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

Loading…
Cancel
Save