浏览代码

Move SD commands to cpp

Scott Lahteine 7 年前
父节点
当前提交
a442c34a1a

+ 0
- 25
Marlin/src/Marlin.cpp 查看文件

@@ -360,33 +360,8 @@ void suicide() {
360 360
  ***************** GCode Handlers *****************
361 361
  **************************************************/
362 362
 
363
-#if ENABLED(SDSUPPORT)
364
-  #include "gcode/sdcard/M20.h"           // M20  - List SD card. (Requires SDSUPPORT)
365
-  #include "gcode/sdcard/M21.h"           // M21  - Init SD card. (Requires SDSUPPORT)
366
-  #include "gcode/sdcard/M22.h"           // M22  - Release SD card. (Requires SDSUPPORT)
367
-  #include "gcode/sdcard/M23.h"           // M23  - Select SD file: "M23 /path/file.gco". (Requires SDSUPPORT)
368
-  #include "gcode/sdcard/M24.h"           // M24  - Start/resume SD print. (Requires SDSUPPORT)
369
-  #include "gcode/sdcard/M25.h"           // M25  - Pause SD print. (Requires SDSUPPORT)
370
-  #include "gcode/sdcard/M26.h"           // M26  - Set SD position in bytes: "M26 S12345". (Requires SDSUPPORT)
371
-  #include "gcode/sdcard/M27.h"           // M27  - Report SD print status. (Requires SDSUPPORT)
372
-  #include "gcode/sdcard/M28.h"           // M28  - Start SD write: "M28 /path/file.gco". (Requires SDSUPPORT)
373
-  #include "gcode/sdcard/M29.h"           // M29  - Stop SD write. (Requires SDSUPPORT)
374
-  #include "gcode/sdcard/M30.h"           // M30  - Delete file from SD: "M30 /path/file.gco"
375
-#endif
376
-
377 363
 #include "gcode/stats/M31.h"              // M31: Get the time since the start of SD Print (or last M109)
378 364
 
379
-#if ENABLED(SDSUPPORT)
380
-  #include "gcode/sdcard/M32.h"
381
-  #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
382
-    #include "gcode/sdcard/M33.h"
383
-  #endif
384
-  #if ENABLED(SDCARD_SORT_ALPHA) && ENABLED(SDSORT_GCODE)
385
-    #include "gcode/sdcard/M34.h"
386
-  #endif
387
-  #include "gcode/sdcard/M928.h"
388
-#endif
389
-
390 365
 /**
391 366
  * Sensitive pin test for M42, M226
392 367
  */

+ 16
- 46
Marlin/src/gcode/gcode.cpp 查看文件

@@ -117,20 +117,7 @@ void GcodeSuite::dwell(millis_t time) {
117 117
 // Placeholders for non-migrated codes
118 118
 //
119 119
 extern void gcode_M18_M84();
120
-extern void gcode_M20();
121
-extern void gcode_M21();
122
-extern void gcode_M22();
123
-extern void gcode_M23();
124
-extern void gcode_M25();
125
-extern void gcode_M26();
126
-extern void gcode_M27();
127
-extern void gcode_M28();
128
-extern void gcode_M29();
129
-extern void gcode_M30();
130 120
 extern void gcode_M31();
131
-extern void gcode_M32();
132
-extern void gcode_M33();
133
-extern void gcode_M34();
134 121
 extern void gcode_M42();
135 122
 extern void gcode_M43();
136 123
 extern void gcode_M48();
@@ -160,7 +147,6 @@ extern void gcode_M118();
160 147
 extern void gcode_M119();
161 148
 extern void gcode_M120();
162 149
 extern void gcode_M121();
163
-extern void gcode_M125();
164 150
 extern void gcode_M126();
165 151
 extern void gcode_M127();
166 152
 extern void gcode_M128();
@@ -225,7 +211,6 @@ extern void gcode_M907();
225 211
 extern void gcode_M908();
226 212
 extern void gcode_M909();
227 213
 extern void gcode_M910();
228
-extern void gcode_M928();
229 214
 extern void gcode_M999();
230 215
 extern void gcode_T(uint8_t tmp_extruder);
231 216
 
@@ -423,43 +408,28 @@ void GcodeSuite::process_next_command() {
423 408
         break;
424 409
 
425 410
       #if ENABLED(SDSUPPORT)
426
-        case 20: // M20: list SD card
427
-          gcode_M20(); break;
428
-        case 21: // M21: init SD card
429
-          gcode_M21(); break;
430
-        case 22: // M22: release SD card
431
-          gcode_M22(); break;
432
-        case 23: // M23: Select file
433
-          gcode_M23(); break;
434
-        case 24: // M24: Start SD print
435
-          M24(); break;
436
-        case 25: // M25: Pause SD print
437
-          gcode_M25(); break;
438
-        case 26: // M26: Set SD index
439
-          gcode_M26(); break;
440
-        case 27: // M27: Get SD status
441
-          gcode_M27(); break;
442
-        case 28: // M28: Start SD write
443
-          gcode_M28(); break;
444
-        case 29: // M29: Stop SD write
445
-          gcode_M29(); break;
446
-        case 30: // M30 <filename> Delete File
447
-          gcode_M30(); break;
448
-        case 32: // M32: Select file and start SD print
449
-          gcode_M32(); break;
411
+        case 20: M20(); break;    // M20: list SD card
412
+        case 21: M21(); break;    // M21: init SD card
413
+        case 22: M22(); break;    // M22: release SD card
414
+        case 23: M23(); break;    // M23: Select file
415
+        case 24: M24(); break;    // M24: Start SD print
416
+        case 25: M25(); break;    // M25: Pause SD print
417
+        case 26: M26(); break;    // M26: Set SD index
418
+        case 27: M27(); break;    // M27: Get SD status
419
+        case 28: M28(); break;    // M28: Start SD write
420
+        case 29: M29(); break;    // M29: Stop SD write
421
+        case 30: M30(); break;    // M30 <filename> Delete File
422
+        case 32: M32(); break;    // M32: Select file and start SD print
450 423
 
451 424
         #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
452
-          case 33: // M33: Get the long full path to a file or folder
453
-            gcode_M33(); break;
425
+          case 33: M33(); break;  // M33: Get the long full path to a file or folder
454 426
         #endif
455 427
 
456 428
         #if ENABLED(SDCARD_SORT_ALPHA) && ENABLED(SDSORT_GCODE)
457
-          case 34: // M34: Set SD card sorting options
458
-            gcode_M34(); break;
459
-        #endif // SDCARD_SORT_ALPHA && SDSORT_GCODE
429
+          case 34: M34(); break;  // M34: Set SD card sorting options
430
+        #endif
460 431
 
461
-        case 928: // M928: Start SD write
462
-          gcode_M928(); break;
432
+        case 928: M928(); break;  // M928: Start SD write
463 433
       #endif // SDSUPPORT
464 434
 
465 435
       case 31: // M31: Report time since the start of SD print or last M109

Marlin/src/gcode/sdcard/M20.h → Marlin/src/gcode/sdcard/M20.cpp 查看文件

@@ -20,11 +20,20 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SDSUPPORT)
26
+
27
+#include "../gcode.h"
28
+#include "../../sd/cardreader.h"
29
+
23 30
 /**
24 31
  * M20: List SD card to serial output
25 32
  */
26
-void gcode_M20() {
33
+void GcodeSuite::M20() {
27 34
   SERIAL_PROTOCOLLNPGM(MSG_BEGIN_FILE_LIST);
28 35
   card.ls();
29 36
   SERIAL_PROTOCOLLNPGM(MSG_END_FILE_LIST);
30 37
 }
38
+
39
+#endif // SDSUPPORT

Marlin/src/gcode/sdcard/M21.h → Marlin/src/gcode/sdcard/M21.cpp 查看文件

@@ -20,7 +20,16 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SDSUPPORT)
26
+
27
+#include "../gcode.h"
28
+#include "../../sd/cardreader.h"
29
+
23 30
 /**
24 31
  * M21: Init SD Card
25 32
  */
26
-void gcode_M21() { card.initsd(); }
33
+void GcodeSuite::M21() { card.initsd(); }
34
+
35
+#endif // SDSUPPORT

Marlin/src/gcode/sdcard/M22.h → Marlin/src/gcode/sdcard/M22.cpp 查看文件

@@ -20,7 +20,16 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SDSUPPORT)
26
+
27
+#include "../gcode.h"
28
+#include "../../sd/cardreader.h"
29
+
23 30
 /**
24 31
  * M22: Release SD Card
25 32
  */
26
-void gcode_M22() { card.release(); }
33
+void GcodeSuite::M22() { card.release(); }
34
+
35
+#endif // SDSUPPORT

Marlin/src/gcode/sdcard/M23.h → Marlin/src/gcode/sdcard/M23.cpp 查看文件

@@ -20,11 +20,20 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SDSUPPORT)
26
+
27
+#include "../gcode.h"
28
+#include "../../sd/cardreader.h"
29
+
23 30
 /**
24 31
  * M23: Open a file
25 32
  */
26
-void gcode_M23() {
33
+void GcodeSuite::M23() {
27 34
   // Simplify3D includes the size, so zero out all spaces (#7227)
28 35
   for (char *fn = parser.string_arg; *fn; ++fn) if (*fn == ' ') *fn = '\0';
29 36
   card.openFile(parser.string_arg, true);
30 37
 }
38
+
39
+#endif // SDSUPPORT

Marlin/src/gcode/sdcard/M25.h → Marlin/src/gcode/sdcard/M25.cpp 查看文件

@@ -20,10 +20,22 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SDSUPPORT)
26
+
27
+#include "../gcode.h"
28
+#include "../../sd/cardreader.h"
29
+#include "../../module/printcounter.h"
30
+
31
+#if ENABLED(PARK_HEAD_ON_PAUSE)
32
+  #include "../queue.h"
33
+#endif
34
+
23 35
 /**
24 36
  * M25: Pause SD Print
25 37
  */
26
-void gcode_M25() {
38
+void GcodeSuite::M25() {
27 39
   card.pauseSDPrint();
28 40
   print_job_timer.pause();
29 41
 
@@ -31,3 +43,5 @@ void gcode_M25() {
31 43
     enqueue_and_echo_commands_P(PSTR("M125")); // Must be enqueued with pauseSDPrint set to be last in the buffer
32 44
   #endif
33 45
 }
46
+
47
+#endif // SDSUPPORT

Marlin/src/gcode/sdcard/M26.h → Marlin/src/gcode/sdcard/M26.cpp 查看文件

@@ -20,10 +20,19 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SDSUPPORT)
26
+
27
+#include "../gcode.h"
28
+#include "../../sd/cardreader.h"
29
+
23 30
 /**
24 31
  * M26: Set SD Card file index
25 32
  */
26
-void gcode_M26() {
33
+void GcodeSuite::M26() {
27 34
   if (card.cardOK && parser.seenval('S'))
28 35
     card.setIndex(parser.value_long());
29 36
 }
37
+
38
+#endif // SDSUPPORT

Marlin/src/gcode/sdcard/M27.h → Marlin/src/gcode/sdcard/M27.cpp 查看文件

@@ -20,7 +20,16 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SDSUPPORT)
26
+
27
+#include "../gcode.h"
28
+#include "../../sd/cardreader.h"
29
+
23 30
 /**
24 31
  * M27: Get SD Card status
25 32
  */
26
-void gcode_M27() { card.getStatus(); }
33
+void GcodeSuite::M27() { card.getStatus(); }
34
+
35
+#endif // SDSUPPORT

Marlin/src/gcode/sdcard/M28.h → Marlin/src/gcode/sdcard/M28.cpp 查看文件

@@ -20,7 +20,16 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SDSUPPORT)
26
+
27
+#include "../gcode.h"
28
+#include "../../sd/cardreader.h"
29
+
23 30
 /**
24 31
  * M28: Start SD Write
25 32
  */
26
-void gcode_M28() { card.openFile(parser.string_arg, false); }
33
+void GcodeSuite::M28() { card.openFile(parser.string_arg, false); }
34
+
35
+#endif // SDSUPPORT

Marlin/src/gcode/sdcard/M29.h → Marlin/src/gcode/sdcard/M29.cpp 查看文件

@@ -20,10 +20,19 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SDSUPPORT)
26
+
27
+#include "../gcode.h"
28
+#include "../../sd/cardreader.h"
29
+
23 30
 /**
24 31
  * M29: Stop SD Write
25 32
  * Processed in write to file routine above
26 33
  */
27
-void gcode_M29() {
34
+void GcodeSuite::M29() {
28 35
   // card.saving = false;
29 36
 }
37
+
38
+#endif // SDSUPPORT

Marlin/src/gcode/sdcard/M30.h → Marlin/src/gcode/sdcard/M30.cpp 查看文件

@@ -20,12 +20,21 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SDSUPPORT)
26
+
27
+#include "../gcode.h"
28
+#include "../../sd/cardreader.h"
29
+
23 30
 /**
24 31
  * M30 <filename>: Delete SD Card file
25 32
  */
26
-void gcode_M30() {
33
+void GcodeSuite::M30() {
27 34
   if (card.cardOK) {
28 35
     card.closefile();
29 36
     card.removeFile(parser.string_arg);
30 37
   }
31 38
 }
39
+
40
+#endif // SDSUPPORT

Marlin/src/gcode/sdcard/M32.h → Marlin/src/gcode/sdcard/M32.cpp 查看文件

@@ -20,10 +20,19 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SDSUPPORT)
26
+
27
+#include "../gcode.h"
28
+#include "../../sd/cardreader.h"
29
+#include "../../module/stepper.h"
30
+#include "../../module/printcounter.h"
31
+
23 32
 /**
24 33
  * M32: Select file and start SD Print
25 34
  */
26
-void gcode_M32() {
35
+void GcodeSuite::M32() {
27 36
   if (IS_SD_PRINTING)
28 37
     stepper.synchronize();
29 38
 
@@ -42,3 +51,5 @@ void gcode_M32() {
42 51
     if (!call_procedure) print_job_timer.start();
43 52
   }
44 53
 }
54
+
55
+#endif // SDSUPPORT

Marlin/src/gcode/sdcard/M33.h → Marlin/src/gcode/sdcard/M33.cpp 查看文件

@@ -20,6 +20,13 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SDSUPPORT) && ENABLED(LONG_FILENAME_HOST_SUPPORT)
26
+
27
+#include "../gcode.h"
28
+#include "../../sd/cardreader.h"
29
+
23 30
 /**
24 31
  * M33: Get the long full path of a file or folder
25 32
  *
@@ -32,6 +39,8 @@
32 39
  * Output:
33 40
  *   /Miscellaneous/Armchair/Armchair.gcode
34 41
  */
35
-void gcode_M33() {
42
+void GcodeSuite::M33() {
36 43
   card.printLongPath(parser.string_arg);
37 44
 }
45
+
46
+#endif // SDSUPPORT && LONG_FILENAME_HOST_SUPPORT

Marlin/src/gcode/sdcard/M34.h → Marlin/src/gcode/sdcard/M34.cpp 查看文件

@@ -20,10 +20,17 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SDSUPPORT) && ENABLED(SDCARD_SORT_ALPHA) && ENABLED(SDSORT_GCODE)
26
+
27
+#include "../gcode.h"
28
+#include "../../sd/cardreader.h"
29
+
23 30
 /**
24 31
  * M34: Set SD Card Sorting Options
25 32
  */
26
-void gcode_M34() {
33
+void GcodeSuite::M34() {
27 34
   if (parser.seen('S')) card.setSortOn(parser.value_bool());
28 35
   if (parser.seenval('F')) {
29 36
     const int v = parser.value_long();
@@ -31,3 +38,5 @@ void gcode_M34() {
31 38
   }
32 39
   //if (parser.seen('R')) card.setSortReverse(parser.value_bool());
33 40
 }
41
+
42
+#endif // SDSUPPORT && SDCARD_SORT_ALPHA && SDSORT_GCODE

Marlin/src/gcode/sdcard/M928.h → Marlin/src/gcode/sdcard/M928.cpp 查看文件

@@ -20,9 +20,18 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SDSUPPORT)
26
+
27
+#include "../gcode.h"
28
+#include "../../sd/cardreader.h"
29
+
23 30
 /**
24 31
  * M928: Start SD Write
25 32
  */
26
-void gcode_M928() {
33
+void GcodeSuite::M928() {
27 34
   card.openLogFile(parser.string_arg);
28 35
 }
36
+
37
+#endif // SDSUPPORT

正在加载...
取消
保存