Browse Source

Move G17-G19 to cpp

Scott Lahteine 7 years ago
parent
commit
9b4aa5ea8b

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

215
   millis_t lastUpdateMillis;
215
   millis_t lastUpdateMillis;
216
 #endif
216
 #endif
217
 
217
 
218
-#if ENABLED(CNC_WORKSPACE_PLANES)
219
-  static WorkspacePlane workspace_plane = PLANE_XY;
220
-#endif
221
-
222
 /**
218
 /**
223
  * ***************************************************************************
219
  * ***************************************************************************
224
  * ******************************** FUNCTIONS ********************************
220
  * ******************************** FUNCTIONS ********************************
361
  ***************** GCode Handlers *****************
357
  ***************** GCode Handlers *****************
362
  **************************************************/
358
  **************************************************/
363
 
359
 
364
-#if ENABLED(CNC_WORKSPACE_PLANES)
365
-  #include "gcode/geometry/G17-G19.h"
366
-#endif
367
-
368
 #if ENABLED(INCH_MODE_SUPPORT)
360
 #if ENABLED(INCH_MODE_SUPPORT)
369
   #include "gcode/units/G20_G21.h"
361
   #include "gcode/units/G20_G21.h"
370
 #endif
362
 #endif

+ 0
- 8
Marlin/src/core/enum.h View File

148
   };
148
   };
149
 #endif
149
 #endif
150
 
150
 
151
-/**
152
- * Workspace planes only apply to G2/G3 moves
153
- * (and "canned cycles" - not a current feature)
154
- */
155
-#if ENABLED(CNC_WORKSPACE_PLANES)
156
-  enum WorkspacePlane { PLANE_XY, PLANE_ZX, PLANE_YZ };
157
-#endif
158
-
159
 #endif // __ENUM_H__
151
 #endif // __ENUM_H__

+ 7
- 6
Marlin/src/gcode/gcode.cpp View File

48
   uint8_t GcodeSuite::host_keepalive_interval = DEFAULT_KEEPALIVE_INTERVAL;
48
   uint8_t GcodeSuite::host_keepalive_interval = DEFAULT_KEEPALIVE_INTERVAL;
49
 #endif
49
 #endif
50
 
50
 
51
+#if ENABLED(CNC_WORKSPACE_PLANES)
52
+  GcodeSuite::WorkspacePlane GcodeSuite::workspace_plane = PLANE_XY;
53
+#endif
54
+
51
 /**
55
 /**
52
  * Set target_extruder from the T parameter or the active_extruder
56
  * Set target_extruder from the T parameter or the active_extruder
53
  *
57
  *
112
 //
116
 //
113
 // Placeholders for non-migrated codes
117
 // Placeholders for non-migrated codes
114
 //
118
 //
115
-extern void gcode_G17();
116
-extern void gcode_G18();
117
-extern void gcode_G19();
118
 extern void gcode_G20();
119
 extern void gcode_G20();
119
 extern void gcode_G21();
120
 extern void gcode_G21();
120
 extern void gcode_G27();
121
 extern void gcode_G27();
318
 
319
 
319
       #if ENABLED(CNC_WORKSPACE_PLANES)
320
       #if ENABLED(CNC_WORKSPACE_PLANES)
320
         case 17: // G17: Select Plane XY
321
         case 17: // G17: Select Plane XY
321
-          gcode_G17();
322
+          G17();
322
           break;
323
           break;
323
         case 18: // G18: Select Plane ZX
324
         case 18: // G18: Select Plane ZX
324
-          gcode_G18();
325
+          G18();
325
           break;
326
           break;
326
         case 19: // G19: Select Plane YZ
327
         case 19: // G19: Select Plane YZ
327
-          gcode_G19();
328
+          G19();
328
           break;
329
           break;
329
       #endif // CNC_WORKSPACE_PLANES
330
       #endif // CNC_WORKSPACE_PLANES
330
 
331
 

+ 9
- 0
Marlin/src/gcode/gcode.h View File

256
 
256
 
257
   static bool axis_relative_modes[];
257
   static bool axis_relative_modes[];
258
 
258
 
259
+  #if ENABLED(CNC_WORKSPACE_PLANES)
260
+    /**
261
+     * Workspace planes only apply to G2/G3 moves
262
+     * (and "canned cycles" - not a current feature)
263
+     */
264
+    enum WorkspacePlane { PLANE_XY, PLANE_ZX, PLANE_YZ };
265
+    static WorkspacePlane workspace_plane;
266
+  #endif
267
+
259
   static millis_t previous_cmd_ms;
268
   static millis_t previous_cmd_ms;
260
   FORCE_INLINE static void refresh_cmd_timeout() { previous_cmd_ms = millis(); }
269
   FORCE_INLINE static void refresh_cmd_timeout() { previous_cmd_ms = millis(); }
261
 
270
 

Marlin/src/gcode/geometry/G17-G19.h → Marlin/src/gcode/geometry/G17-G19.cpp View File

20
  *
20
  *
21
  */
21
  */
22
 
22
 
23
-void report_workspace_plane() {
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(CNC_WORKSPACE_PLANES)
26
+
27
+#include "../gcode.h"
28
+
29
+inline void report_workspace_plane() {
24
   SERIAL_ECHO_START();
30
   SERIAL_ECHO_START();
25
   SERIAL_ECHOPGM("Workspace Plane ");
31
   SERIAL_ECHOPGM("Workspace Plane ");
26
-  serialprintPGM(workspace_plane == PLANE_YZ ? PSTR("YZ\n") : workspace_plane == PLANE_ZX ? PSTR("ZX\n") : PSTR("XY\n"));
32
+  serialprintPGM(
33
+      gcode.workspace_plane == GcodeSuite::PLANE_YZ ? PSTR("YZ\n")
34
+    : gcode.workspace_plane == GcodeSuite::PLANE_ZX ? PSTR("ZX\n")
35
+                                                    : PSTR("XY\n")
36
+  );
37
+}
38
+
39
+inline void set_workspace_plane(const GcodeSuite::WorkspacePlane plane) {
40
+  gcode.workspace_plane = plane;
41
+  if (DEBUGGING(INFO)) report_workspace_plane();
27
 }
42
 }
28
 
43
 
29
 /**
44
 /**
31
  * G18: Select Plane ZX
46
  * G18: Select Plane ZX
32
  * G19: Select Plane YZ
47
  * G19: Select Plane YZ
33
  */
48
  */
34
-void gcode_G17() { workspace_plane = PLANE_XY; }
35
-void gcode_G18() { workspace_plane = PLANE_ZX; }
36
-void gcode_G19() { workspace_plane = PLANE_YZ; }
49
+void GcodeSuite::G17() { set_workspace_plane(PLANE_XY); }
50
+void GcodeSuite::G18() { set_workspace_plane(PLANE_ZX); }
51
+void GcodeSuite::G19() { set_workspace_plane(PLANE_YZ); }
52
+
53
+#endif // CNC_WORKSPACE_PLANES

+ 4
- 4
Marlin/src/gcode/motion/G2_G3.cpp View File

50
 ) {
50
 ) {
51
   #if ENABLED(CNC_WORKSPACE_PLANES)
51
   #if ENABLED(CNC_WORKSPACE_PLANES)
52
     AxisEnum p_axis, q_axis, l_axis;
52
     AxisEnum p_axis, q_axis, l_axis;
53
-    switch (workspace_plane) {
54
-      case PLANE_XY: p_axis = X_AXIS; q_axis = Y_AXIS; l_axis = Z_AXIS; break;
55
-      case PLANE_ZX: p_axis = Z_AXIS; q_axis = X_AXIS; l_axis = Y_AXIS; break;
56
-      case PLANE_YZ: p_axis = Y_AXIS; q_axis = Z_AXIS; l_axis = X_AXIS; break;
53
+    switch (gcode.workspace_plane) {
54
+      case GcodeSuite::PLANE_XY: p_axis = X_AXIS; q_axis = Y_AXIS; l_axis = Z_AXIS; break;
55
+      case GcodeSuite::PLANE_ZX: p_axis = Z_AXIS; q_axis = X_AXIS; l_axis = Y_AXIS; break;
56
+      case GcodeSuite::PLANE_YZ: p_axis = Y_AXIS; q_axis = Z_AXIS; l_axis = X_AXIS; break;
57
     }
57
     }
58
   #else
58
   #else
59
     constexpr AxisEnum p_axis = X_AXIS, q_axis = Y_AXIS, l_axis = Z_AXIS;
59
     constexpr AxisEnum p_axis = X_AXIS, q_axis = Y_AXIS, l_axis = Z_AXIS;

Loading…
Cancel
Save