瀏覽代碼

Consolidate pause, apply to M125, M600, M24

Scott Lahteine 7 年之前
父節點
當前提交
be0e4a4ad0

+ 3
- 13
Marlin/src/Marlin.cpp 查看文件

125
   #include "feature/tmc2130.h"
125
   #include "feature/tmc2130.h"
126
 #endif
126
 #endif
127
 
127
 
128
+#if ENABLED(ADVANCED_PAUSE_FEATURE) && ENABLED(PAUSE_PARK_NO_STEPPER_TIMEOUT)
129
+  #include "feature/pause.h"
130
+#endif
128
 
131
 
129
 bool Running = true;
132
 bool Running = true;
130
 
133
 
357
  ***************** GCode Handlers *****************
360
  ***************** GCode Handlers *****************
358
  **************************************************/
361
  **************************************************/
359
 
362
 
360
-#if ENABLED(ADVANCED_PAUSE_FEATURE)
361
-  // For M125, M600, M24
362
-  #include "gcode/feature/pause/common.h"
363
-#endif
364
-
365
 #if ENABLED(SDSUPPORT)
363
 #if ENABLED(SDSUPPORT)
366
   #include "gcode/sdcard/M20.h"           // M20  - List SD card. (Requires SDSUPPORT)
364
   #include "gcode/sdcard/M20.h"           // M20  - List SD card. (Requires SDSUPPORT)
367
   #include "gcode/sdcard/M21.h"           // M21  - Init SD card. (Requires SDSUPPORT)
365
   #include "gcode/sdcard/M21.h"           // M21  - Init SD card. (Requires SDSUPPORT)
508
 
506
 
509
 #include "gcode/control/M120_M121.h"
507
 #include "gcode/control/M120_M121.h"
510
 
508
 
511
-#if ENABLED(PARK_HEAD_ON_PAUSE)
512
-  #include "gcode/feature/pause/M125.h"
513
-#endif
514
-
515
 #if HAS_COLOR_LEDS
509
 #if HAS_COLOR_LEDS
516
   #include "gcode/feature/leds/M150.h"
510
   #include "gcode/feature/leds/M150.h"
517
 #endif
511
 #endif
612
   #include "gcode/config/M540.h"
606
   #include "gcode/config/M540.h"
613
 #endif
607
 #endif
614
 
608
 
615
-#if ENABLED(ADVANCED_PAUSE_FEATURE)
616
-  #include "gcode/feature/pause/M600.h"
617
-#endif
618
-
619
 #if ENABLED(MK2_MULTIPLEXER)
609
 #if ENABLED(MK2_MULTIPLEXER)
620
   #include "gcode/feature/snmm/M702.h"
610
   #include "gcode/feature/snmm/M702.h"
621
 #endif
611
 #endif

Marlin/src/gcode/feature/pause/common.h → Marlin/src/feature/pause.cpp 查看文件

21
  */
21
  */
22
 
22
 
23
 /**
23
 /**
24
- * feature/pause/common.h - Merge this with its G-codes in the refactor
24
+ * feature/pause.cpp - Pause feature support functions
25
+ * This may be combined with related G-codes if features are consolidated.
25
  */
26
  */
26
 
27
 
27
-#ifndef PAUSE_COMMON_H
28
-#define PAUSE_COMMON_H
28
+#include "../inc/MarlinConfig.h"
29
 
29
 
30
-#if IS_KINEMATIC
31
-  #define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder)
32
-#else
33
-  #define RUNPLAN(RATE_MM_S) line_to_destination(RATE_MM_S)
30
+#if ENABLED(ADVANCED_PAUSE_FEATURE) || ENABLED(PARK_HEAD_ON_PAUSE)
31
+
32
+#include "../Marlin.h"
33
+#include "../gcode/gcode.h"
34
+#include "../module/motion.h"
35
+#include "../module/planner.h"
36
+#include "../module/stepper.h"
37
+#include "../module/printcounter.h"
38
+#include "../module/temperature.h"
39
+
40
+#if ENABLED(ULTIPANEL)
41
+  #include "../lcd/ultralcd.h"
34
 #endif
42
 #endif
35
 
43
 
44
+#include "../libs/buzzer.h"
45
+
46
+// private:
47
+
36
 static float resume_position[XYZE];
48
 static float resume_position[XYZE];
37
-static bool move_away_flag = false;
49
+
38
 #if ENABLED(SDSUPPORT)
50
 #if ENABLED(SDSUPPORT)
51
+  #include "../sd/cardreader.h"
39
   static bool sd_print_paused = false;
52
   static bool sd_print_paused = false;
40
 #endif
53
 #endif
41
 
54
 
74
   }
87
   }
75
 }
88
 }
76
 
89
 
77
-static bool pause_print(const float &retract, const float &z_lift, const float &x_pos, const float &y_pos,
78
-                        const float &unload_length = 0 , const int8_t max_beep_count = 0, const bool show_lcd = false
90
+// public:
91
+
92
+bool move_away_flag = false;
93
+
94
+#if IS_KINEMATIC
95
+  #define RUNPLAN(RATE_MM_S) planner.buffer_line_kinematic(destination, RATE_MM_S, active_extruder)
96
+#else
97
+  #define RUNPLAN(RATE_MM_S) line_to_destination(RATE_MM_S)
98
+#endif
99
+
100
+bool pause_print(const float &retract, const float &z_lift, const float &x_pos, const float &y_pos,
101
+                        const float &unload_length/*=0*/ , const int8_t max_beep_count/*=0*/, const bool show_lcd/*=false*/
79
 ) {
102
 ) {
80
   if (move_away_flag) return false; // already paused
103
   if (move_away_flag) return false; // already paused
81
 
104
 
172
   return true;
195
   return true;
173
 }
196
 }
174
 
197
 
175
-static void wait_for_filament_reload(const int8_t max_beep_count = 0) {
198
+void wait_for_filament_reload(const int8_t max_beep_count/*=0*/) {
176
   bool nozzle_timed_out = false;
199
   bool nozzle_timed_out = false;
177
 
200
 
178
   // Wait for filament insert by user and press button
201
   // Wait for filament insert by user and press button
226
   KEEPALIVE_STATE(IN_HANDLER);
249
   KEEPALIVE_STATE(IN_HANDLER);
227
 }
250
 }
228
 
251
 
229
-static void resume_print(const float &load_length = 0, const float &initial_extrude_length = 0, const int8_t max_beep_count = 0) {
252
+void resume_print(const float &load_length/*=0*/, const float &initial_extrude_length/*=0*/, const int8_t max_beep_count/*=0*/) {
230
   bool nozzle_timed_out = false;
253
   bool nozzle_timed_out = false;
231
 
254
 
232
   if (!move_away_flag) return;
255
   if (!move_away_flag) return;
332
   move_away_flag = false;
355
   move_away_flag = false;
333
 }
356
 }
334
 
357
 
335
-#endif // PAUSE_COMMON_H
358
+#endif // ADVANCED_PAUSE_FEATURE || PARK_HEAD_ON_PAUSE

+ 41
- 0
Marlin/src/feature/pause.h 查看文件

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * feature/pause.h - Pause feature support functions
25
+ * This may be combined with related G-codes if features are consolidated.
26
+ */
27
+
28
+#ifndef _PAUSE_H_
29
+#define _PAUSE_H_
30
+
31
+extern bool move_away_flag;
32
+
33
+bool pause_print(const float &retract, const float &z_lift, const float &x_pos, const float &y_pos,
34
+                        const float &unload_length=0 , const int8_t max_beep_count=0, const bool show_lcd=false
35
+);
36
+
37
+void wait_for_filament_reload(const int8_t max_beep_count=0);
38
+
39
+void resume_print(const float &load_length=0, const float &initial_extrude_length=0, const int8_t max_beep_count=0);
40
+
41
+#endif // _PAUSE_H_

Marlin/src/gcode/feature/pause/M125.h → Marlin/src/gcode/feature/pause/M125.cpp 查看文件

20
  *
20
  *
21
  */
21
  */
22
 
22
 
23
-#include "common.h"
23
+#include "../../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(PARK_HEAD_ON_PAUSE)
26
+
27
+#include "../../gcode.h"
28
+#include "../../parser.h"
29
+#include "../../../feature/pause.h"
24
 
30
 
25
 /**
31
 /**
26
  * M125: Store current position and move to filament change position.
32
  * M125: Store current position and move to filament change position.
37
  *    Y = override Y
43
  *    Y = override Y
38
  *    Z = override Z raise
44
  *    Z = override Z raise
39
  */
45
  */
40
-void gcode_M125() {
46
+void GcodeSuite::M125() {
41
 
47
 
42
   // Initial retract before move to filament change position
48
   // Initial retract before move to filament change position
43
   const float retract = parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0
49
   const float retract = parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0
87
     #endif
93
     #endif
88
   }
94
   }
89
 }
95
 }
96
+
97
+#endif // PARK_HEAD_ON_PAUSE

Marlin/src/gcode/feature/pause/M600.h → Marlin/src/gcode/feature/pause/M600.cpp 查看文件

20
  *
20
  *
21
  */
21
  */
22
 
22
 
23
-#include "common.h"
23
+#include "../../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(ADVANCED_PAUSE_FEATURE)
26
+
27
+#include "../../../feature/pause.h"
28
+
29
+#include "../../gcode.h"
30
+#include "../../parser.h"
31
+
32
+#include "../../../module/printcounter.h"
24
 
33
 
25
 /**
34
 /**
26
  * M600: Pause for filament change
35
  * M600: Pause for filament change
36
  *  Default values are used for omitted arguments.
45
  *  Default values are used for omitted arguments.
37
  *
46
  *
38
  */
47
  */
39
-void gcode_M600() {
48
+void GcodeSuite::M600() {
40
 
49
 
41
   #if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
50
   #if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
42
     // Don't allow filament change without homing first
51
     // Don't allow filament change without homing first
101
   // Resume the print job timer if it was running
110
   // Resume the print job timer if it was running
102
   if (job_running) print_job_timer.start();
111
   if (job_running) print_job_timer.start();
103
 }
112
 }
113
+
114
+#endif // ADVANCED_PAUSE_FEATURE

+ 3
- 5
Marlin/src/gcode/gcode.cpp 查看文件

121
 extern void gcode_M21();
121
 extern void gcode_M21();
122
 extern void gcode_M22();
122
 extern void gcode_M22();
123
 extern void gcode_M23();
123
 extern void gcode_M23();
124
-extern void gcode_M24();
125
 extern void gcode_M25();
124
 extern void gcode_M25();
126
 extern void gcode_M26();
125
 extern void gcode_M26();
127
 extern void gcode_M27();
126
 extern void gcode_M27();
212
 extern void gcode_M502();
211
 extern void gcode_M502();
213
 extern void gcode_M503();
212
 extern void gcode_M503();
214
 extern void gcode_M540();
213
 extern void gcode_M540();
215
-extern void gcode_M600();
216
 extern void gcode_M605();
214
 extern void gcode_M605();
217
 extern void gcode_M665();
215
 extern void gcode_M665();
218
 extern void gcode_M666();
216
 extern void gcode_M666();
434
         case 23: // M23: Select file
432
         case 23: // M23: Select file
435
           gcode_M23(); break;
433
           gcode_M23(); break;
436
         case 24: // M24: Start SD print
434
         case 24: // M24: Start SD print
437
-          gcode_M24(); break;
435
+          M24(); break;
438
         case 25: // M25: Pause SD print
436
         case 25: // M25: Pause SD print
439
           gcode_M25(); break;
437
           gcode_M25(); break;
440
         case 26: // M26: Set SD index
438
         case 26: // M26: Set SD index
570
 
568
 
571
       #if ENABLED(PARK_HEAD_ON_PAUSE)
569
       #if ENABLED(PARK_HEAD_ON_PAUSE)
572
         case 125: // M125: Store current position and move to filament change position
570
         case 125: // M125: Store current position and move to filament change position
573
-          gcode_M125(); break;
571
+          M125(); break;
574
       #endif
572
       #endif
575
 
573
 
576
       #if ENABLED(BARICUDA)
574
       #if ENABLED(BARICUDA)
911
 
909
 
912
       #if ENABLED(ADVANCED_PAUSE_FEATURE)
910
       #if ENABLED(ADVANCED_PAUSE_FEATURE)
913
         case 600: // M600: Pause for filament change
911
         case 600: // M600: Pause for filament change
914
-          gcode_M600();
912
+          M600();
915
           break;
913
           break;
916
       #endif // ADVANCED_PAUSE_FEATURE
914
       #endif // ADVANCED_PAUSE_FEATURE
917
 
915
 

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

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
+
23
 #if ENABLED(PARK_HEAD_ON_PAUSE)
31
 #if ENABLED(PARK_HEAD_ON_PAUSE)
24
-  #include "../feature/pause/common.h"
32
+  #include "../../feature/pause.h"
25
 #endif
33
 #endif
26
 
34
 
27
 /**
35
 /**
28
  * M24: Start or Resume SD Print
36
  * M24: Start or Resume SD Print
29
  */
37
  */
30
-void gcode_M24() {
38
+void GcodeSuite::M24() {
31
   #if ENABLED(PARK_HEAD_ON_PAUSE)
39
   #if ENABLED(PARK_HEAD_ON_PAUSE)
32
     resume_print();
40
     resume_print();
33
   #endif
41
   #endif
35
   card.startFileprint();
43
   card.startFileprint();
36
   print_job_timer.start();
44
   print_job_timer.start();
37
 }
45
 }
46
+
47
+#endif // SDSUPPORT

Loading…
取消
儲存