Browse Source

Move M380_M381 to cpp, solenoid feature

Scott Lahteine 8 years ago
parent
commit
4a220a8b79

+ 0
- 4
Marlin/src/Marlin.cpp View File

@@ -352,10 +352,6 @@ bool pin_is_protected(const int8_t pin) {
352 352
   return false;
353 353
 }
354 354
 
355
-#if ENABLED(EXT_SOLENOID)
356
-  #include "gcode/control/M380_M381.h"
357
-#endif
358
-
359 355
 #include "gcode/control/M400.h"
360 356
 
361 357
 #if HAS_BED_PROBE

Marlin/src/gcode/control/M380_M381.h → Marlin/src/feature/solenoid.cpp View File

@@ -20,9 +20,15 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../inc/MarlinConfig.h"
24
+
23 25
 #if ENABLED(EXT_SOLENOID)
24 26
 
25
-void enable_solenoid(const uint8_t num) {
27
+#include "solenoid.h"
28
+
29
+#include "../module/motion.h" // for active_extruder
30
+
31
+inline void enable_solenoid(const uint8_t num) {
26 32
   switch (num) {
27 33
     case 0:
28 34
       OUT_WRITE(SOL0_PIN, HIGH);
@@ -72,22 +78,4 @@ void disable_all_solenoids() {
72 78
   #endif
73 79
 }
74 80
 
75
-/**
76
- * M380: Enable solenoid on the active extruder
77
- */
78
-void gcode_M380() {
79
-
80
-  enable_solenoid_on_active_extruder();
81
-
82
-}
83
-
84
-/**
85
- * M381: Disable all solenoids
86
- */
87
-void gcode_M381() {
88
-
89
-  disable_all_solenoids();
90
-
91
-}
92
-
93 81
 #endif // EXT_SOLENOID

+ 29
- 0
Marlin/src/feature/solenoid.h View File

@@ -0,0 +1,29 @@
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
+#ifndef __SOLENOID_H__
24
+#define __SOLENOID_H__
25
+
26
+void enable_solenoid_on_active_extruder();
27
+void disable_all_solenoids();
28
+
29
+#endif // __SOLENOID_H__

+ 40
- 0
Marlin/src/gcode/control/M380_M381.cpp View File

@@ -0,0 +1,40 @@
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
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(EXT_SOLENOID)
26
+
27
+#include "../gcode.h"
28
+#include "../../feature/solenoid.h"
29
+
30
+/**
31
+ * M380: Enable solenoid on the active extruder
32
+ */
33
+void GcodeSuite::M380() { enable_solenoid_on_active_extruder(); }
34
+
35
+/**
36
+ * M381: Disable all solenoids
37
+ */
38
+void GcodeSuite::M381() { disable_all_solenoids(); }
39
+
40
+#endif // EXT_SOLENOID

+ 2
- 8
Marlin/src/gcode/gcode.cpp View File

@@ -122,8 +122,6 @@ extern void gcode_M165();
122 122
 extern void gcode_M350();
123 123
 extern void gcode_M351();
124 124
 extern void gcode_M355();
125
-extern void gcode_M380();
126
-extern void gcode_M381();
127 125
 extern void gcode_M400();
128 126
 extern void gcode_M401();
129 127
 extern void gcode_M402();
@@ -597,12 +595,8 @@ void GcodeSuite::process_next_command() {
597 595
       #endif
598 596
 
599 597
       #if ENABLED(EXT_SOLENOID)
600
-        case 380: // M380: Activate solenoid on active extruder
601
-          gcode_M380();
602
-          break;
603
-        case 381: // M381: Disable all solenoids
604
-          gcode_M381();
605
-          break;
598
+        case 380: M380(); break;  // M380: Activate solenoid on active extruder
599
+        case 381: M381(); break;  // M381: Disable all solenoids
606 600
       #endif
607 601
 
608 602
       case 400: // M400: Finish all moves

+ 4
- 0
Marlin/src/module/tool_change.cpp View File

@@ -34,6 +34,10 @@
34 34
   #include "../gcode/gcode.h" // for dwell()
35 35
 #endif
36 36
 
37
+#if ENABLED(EXT_SOLENOID) && !ENABLED(PARKING_EXTRUDER)
38
+  #include "../feature/solenoid.h"
39
+#endif
40
+
37 41
 #if ENABLED(SWITCHING_EXTRUDER)
38 42
 
39 43
   #if EXTRUDERS > 3

Loading…
Cancel
Save