Browse Source

Move M80-M81 to cpp

Scott Lahteine 7 years ago
parent
commit
4b9d1b9f26

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

@@ -177,16 +177,6 @@ static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL
177 177
   float z_endstop_adj;
178 178
 #endif
179 179
 
180
-#if HAS_POWER_SWITCH
181
-  bool powersupply_on =
182
-    #if ENABLED(PS_DEFAULT_OFF)
183
-      false
184
-    #else
185
-      true
186
-    #endif
187
-  ;
188
-#endif
189
-
190 180
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
191 181
   static bool filament_ran_out = false;
192 182
 #endif
@@ -369,12 +359,6 @@ bool pin_is_protected(const int8_t pin) {
369 359
   return false;
370 360
 }
371 361
 
372
-#if HAS_POWER_SWITCH
373
-  #include "gcode/control/M80.h"
374
-#endif
375
-
376
-#include "gcode/control/M81.h"
377
-
378 362
 #include "gcode/units/M82_M83.h"
379 363
 
380 364
 #include "gcode/control/M18_M84.h"

+ 0
- 56
Marlin/src/gcode/control/M80.h View File

@@ -1,56 +0,0 @@
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
- * M80   : Turn on the Power Supply
25
- * M80 S : Report the current state and exit
26
- */
27
-void gcode_M80() {
28
-
29
-  // S: Report the current power supply state and exit
30
-  if (parser.seen('S')) {
31
-    serialprintPGM(powersupply_on ? PSTR("PS:1\n") : PSTR("PS:0\n"));
32
-    return;
33
-  }
34
-
35
-  OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); // GND
36
-
37
-  /**
38
-   * If you have a switch on suicide pin, this is useful
39
-   * if you want to start another print with suicide feature after
40
-   * a print without suicide...
41
-   */
42
-  #if HAS_SUICIDE
43
-    OUT_WRITE(SUICIDE_PIN, HIGH);
44
-  #endif
45
-
46
-  #if ENABLED(HAVE_TMC2130)
47
-    delay(100);
48
-    tmc2130_init(); // Settings only stick when the driver has power
49
-  #endif
50
-
51
-  powersupply_on = true;
52
-
53
-  #if ENABLED(ULTIPANEL)
54
-    LCD_MESSAGEPGM(WELCOME_MSG);
55
-  #endif
56
-}

Marlin/src/gcode/control/M81.h → Marlin/src/gcode/control/M80_M81.cpp View File

@@ -20,12 +20,74 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../gcode.h"
24
+#include "../../module/temperature.h"
25
+#include "../../module/stepper.h"
26
+
27
+#include "../../inc/MarlinConfig.h"
28
+
29
+#if ENABLED(ULTIPANEL)
30
+  #include "../../lcd/ultralcd.h"
31
+#endif
32
+
33
+#if HAS_POWER_SWITCH
34
+
35
+  // Could be moved to a feature, but this is all the data
36
+  bool powersupply_on =
37
+    #if ENABLED(PS_DEFAULT_OFF)
38
+      false
39
+    #else
40
+      true
41
+    #endif
42
+  ;
43
+
44
+  #if ENABLED(HAVE_TMC2130)
45
+    #include "../../feature/tmc2130.h"
46
+  #endif
47
+
48
+  /**
49
+   * M80   : Turn on the Power Supply
50
+   * M80 S : Report the current state and exit
51
+   */
52
+  void GcodeSuite::M80() {
53
+
54
+    // S: Report the current power supply state and exit
55
+    if (parser.seen('S')) {
56
+      serialprintPGM(powersupply_on ? PSTR("PS:1\n") : PSTR("PS:0\n"));
57
+      return;
58
+    }
59
+
60
+    OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); // GND
61
+
62
+    /**
63
+     * If you have a switch on suicide pin, this is useful
64
+     * if you want to start another print with suicide feature after
65
+     * a print without suicide...
66
+     */
67
+    #if HAS_SUICIDE
68
+      OUT_WRITE(SUICIDE_PIN, HIGH);
69
+    #endif
70
+
71
+    #if ENABLED(HAVE_TMC2130)
72
+      delay(100);
73
+      tmc2130_init(); // Settings only stick when the driver has power
74
+    #endif
75
+
76
+    powersupply_on = true;
77
+
78
+    #if ENABLED(ULTIPANEL)
79
+      LCD_MESSAGEPGM(WELCOME_MSG);
80
+    #endif
81
+  }
82
+
83
+#endif // HAS_POWER_SWITCH
84
+
23 85
 /**
24 86
  * M81: Turn off Power, including Power Supply, if there is one.
25 87
  *
26 88
  *      This code should ALWAYS be available for EMERGENCY SHUTDOWN!
27 89
  */
28
-void gcode_M81() {
90
+void GcodeSuite::M81() {
29 91
   thermalManager.disable_all_heaters();
30 92
   stepper.finish_and_disable();
31 93
 

+ 3
- 11
Marlin/src/gcode/gcode.cpp View File

@@ -117,8 +117,6 @@ 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_M80();
121
-extern void gcode_M81();
122 120
 extern void gcode_M82();
123 121
 extern void gcode_M83();
124 122
 extern void gcode_M85();
@@ -492,16 +490,10 @@ void GcodeSuite::process_next_command() {
492 490
       #endif // BARICUDA
493 491
 
494 492
       #if HAS_POWER_SWITCH
493
+        case 80: M80(); break;    // M80: Turn on Power Supply
494
+      #endif
495 495
 
496
-        case 80: // M80: Turn on Power Supply
497
-          gcode_M80();
498
-          break;
499
-
500
-      #endif // HAS_POWER_SWITCH
501
-
502
-      case 81: // M81: Turn off Power, including Power Supply, if possible
503
-        gcode_M81();
504
-        break;
496
+      case 81: M81(); break;      // M81: Turn off Power, including Power Supply, if possible
505 497
 
506 498
       case 82: // M82: Set E axis normal mode (same as other axes)
507 499
         gcode_M82();

Loading…
Cancel
Save