Browse Source

Move M3-M5 to cpp

Scott Lahteine 6 years ago
parent
commit
33e00b6cd6
3 changed files with 18 additions and 19 deletions
  1. 0
    4
      Marlin/src/Marlin.cpp
  2. 13
    4
      Marlin/src/gcode/control/M3-M5.cpp
  3. 5
    11
      Marlin/src/gcode/gcode.cpp

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

@@ -357,10 +357,6 @@ void suicide() {
357 357
  ***************** GCode Handlers *****************
358 358
  **************************************************/
359 359
 
360
-#if ENABLED(SPINDLE_LASER_ENABLE)
361
-  #include "gcode/control/M3-M5.h"
362
-#endif
363
-
364 360
 #include "gcode/control/M17.h"
365 361
 
366 362
 #if ENABLED(ADVANCED_PAUSE_FEATURE)

Marlin/src/gcode/control/M3-M5.h → Marlin/src/gcode/control/M3-M5.cpp View File

@@ -20,6 +20,13 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(SPINDLE_LASER_ENABLE)
26
+
27
+#include "../gcode.h"
28
+#include "../../module/stepper.h"
29
+
23 30
 /**
24 31
  * M3: Spindle Clockwise
25 32
  * M4: Spindle Counter-clockwise
@@ -70,7 +77,7 @@ inline void ocr_val_mode() {
70 77
   analogWrite(SPINDLE_LASER_PWM_PIN, spindle_laser_power);
71 78
 }
72 79
 
73
-void gcode_M3_M4(bool is_M3) {
80
+void GcodeSuite::M3_M4(bool is_M3) {
74 81
 
75 82
   stepper.synchronize();   // wait until previous movement commands (G0/G0/G2/G3) have completed before playing with the spindle
76 83
   #if SPINDLE_DIR_CHANGE
@@ -118,10 +125,12 @@ void gcode_M3_M4(bool is_M3) {
118 125
 }
119 126
 
120 127
 /**
121
-* M5 turn off spindle
122
-*/
123
-void gcode_M5() {
128
+ * M5 turn off spindle
129
+ */
130
+void GcodeSuite::M5() {
124 131
   stepper.synchronize();
125 132
   WRITE(SPINDLE_LASER_ENABLE_PIN, !SPINDLE_LASER_ENABLE_INVERT);
126 133
   delay_for_power_down();
127 134
 }
135
+
136
+#endif // SPINDLE_LASER_ENABLE

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

@@ -116,8 +116,6 @@ void GcodeSuite::dwell(millis_t time) {
116 116
 //
117 117
 // Placeholders for non-migrated codes
118 118
 //
119
-extern void gcode_M3_M4(bool is_M3);
120
-extern void gcode_M5();
121 119
 extern void gcode_M17();
122 120
 extern void gcode_M18_M84();
123 121
 extern void gcode_M20();
@@ -417,16 +415,12 @@ void GcodeSuite::process_next_command() {
417 415
       #endif // ULTIPANEL
418 416
 
419 417
       #if ENABLED(SPINDLE_LASER_ENABLE)
420
-        case 3:
421
-          gcode_M3_M4(true);   // M3: turn spindle/laser on, set laser/spindle power/speed, set rotation direction CW
422
-          break;               // synchronizes with movement commands
423
-        case 4:
424
-          gcode_M3_M4(false);  // M4: turn spindle/laser on, set laser/spindle power/speed, set rotation direction CCW
425
-          break;               // synchronizes with movement commands
426
-        case 5:
427
-          gcode_M5();     // M5 - turn spindle/laser off
428
-          break;          // synchronizes with movement commands
418
+        // These synchronize with movement commands...
419
+        case 3: M3_M4(true ); break;  // M3: turn spindle/laser on, set laser/spindle power/speed, set rotation direction CW
420
+        case 4: M3_M4(false); break;  // M4: turn spindle/laser on, set laser/spindle power/speed, set rotation direction CCW
421
+        case 5: M5(); break;          // M5 - turn spindle/laser off
429 422
       #endif
423
+
430 424
       case 17: // M17: Enable all stepper motors
431 425
         gcode_M17();
432 426
         break;

Loading…
Cancel
Save