Преглед на файлове

Consolidate pause, apply to M125, M600, M24

Scott Lahteine преди 7 години
родител
ревизия
be0e4a4ad0

+ 3
- 13
Marlin/src/Marlin.cpp Целия файл

@@ -125,6 +125,9 @@
125 125
   #include "feature/tmc2130.h"
126 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 132
 bool Running = true;
130 133
 
@@ -357,11 +360,6 @@ void suicide() {
357 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 363
 #if ENABLED(SDSUPPORT)
366 364
   #include "gcode/sdcard/M20.h"           // M20  - List SD card. (Requires SDSUPPORT)
367 365
   #include "gcode/sdcard/M21.h"           // M21  - Init SD card. (Requires SDSUPPORT)
@@ -508,10 +506,6 @@ static bool pin_is_protected(const int8_t pin) {
508 506
 
509 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 509
 #if HAS_COLOR_LEDS
516 510
   #include "gcode/feature/leds/M150.h"
517 511
 #endif
@@ -612,10 +606,6 @@ void quickstop_stepper() {
612 606
   #include "gcode/config/M540.h"
613 607
 #endif
614 608
 
615
-#if ENABLED(ADVANCED_PAUSE_FEATURE)
616
-  #include "gcode/feature/pause/M600.h"
617
-#endif
618
-
619 609
 #if ENABLED(MK2_MULTIPLEXER)
620 610
   #include "gcode/feature/snmm/M702.h"
621 611
 #endif

Marlin/src/gcode/feature/pause/common.h → Marlin/src/feature/pause.cpp Целия файл

@@ -21,21 +21,34 @@
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 42
 #endif
35 43
 
44
+#include "../libs/buzzer.h"
45
+
46
+// private:
47
+
36 48
 static float resume_position[XYZE];
37
-static bool move_away_flag = false;
49
+
38 50
 #if ENABLED(SDSUPPORT)
51
+  #include "../sd/cardreader.h"
39 52
   static bool sd_print_paused = false;
40 53
 #endif
41 54
 
@@ -74,8 +87,18 @@ static void ensure_safe_temperature() {
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 103
   if (move_away_flag) return false; // already paused
81 104
 
@@ -172,7 +195,7 @@ static bool pause_print(const float &retract, const float &z_lift, const float &
172 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 199
   bool nozzle_timed_out = false;
177 200
 
178 201
   // Wait for filament insert by user and press button
@@ -226,7 +249,7 @@ static void wait_for_filament_reload(const int8_t max_beep_count = 0) {
226 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 253
   bool nozzle_timed_out = false;
231 254
 
232 255
   if (!move_away_flag) return;
@@ -332,4 +355,4 @@ static void resume_print(const float &load_length = 0, const float &initial_extr
332 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 Целия файл

@@ -0,0 +1,41 @@
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,7 +20,13 @@
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 32
  * M125: Store current position and move to filament change position.
@@ -37,7 +43,7 @@
37 43
  *    Y = override Y
38 44
  *    Z = override Z raise
39 45
  */
40
-void gcode_M125() {
46
+void GcodeSuite::M125() {
41 47
 
42 48
   // Initial retract before move to filament change position
43 49
   const float retract = parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0
@@ -87,3 +93,5 @@ void gcode_M125() {
87 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,7 +20,16 @@
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 35
  * M600: Pause for filament change
@@ -36,7 +45,7 @@
36 45
  *  Default values are used for omitted arguments.
37 46
  *
38 47
  */
39
-void gcode_M600() {
48
+void GcodeSuite::M600() {
40 49
 
41 50
   #if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
42 51
     // Don't allow filament change without homing first
@@ -101,3 +110,5 @@ void gcode_M600() {
101 110
   // Resume the print job timer if it was running
102 111
   if (job_running) print_job_timer.start();
103 112
 }
113
+
114
+#endif // ADVANCED_PAUSE_FEATURE

+ 3
- 5
Marlin/src/gcode/gcode.cpp Целия файл

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

Marlin/src/gcode/sdcard/M24.h → Marlin/src/gcode/sdcard/M24.cpp Целия файл

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

Loading…
Отказ
Запис