diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 0de54efa78..f83935698f 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -215,10 +215,6 @@ static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL millis_t lastUpdateMillis; #endif -#if ENABLED(CNC_WORKSPACE_PLANES) - static WorkspacePlane workspace_plane = PLANE_XY; -#endif - /** * *************************************************************************** * ******************************** FUNCTIONS ******************************** @@ -361,10 +357,6 @@ void suicide() { ***************** GCode Handlers ***************** **************************************************/ -#if ENABLED(CNC_WORKSPACE_PLANES) - #include "gcode/geometry/G17-G19.h" -#endif - #if ENABLED(INCH_MODE_SUPPORT) #include "gcode/units/G20_G21.h" #endif diff --git a/Marlin/src/core/enum.h b/Marlin/src/core/enum.h index 9bf3ba856a..9170fd037b 100644 --- a/Marlin/src/core/enum.h +++ b/Marlin/src/core/enum.h @@ -148,12 +148,4 @@ enum LCDViewAction { }; #endif -/** - * Workspace planes only apply to G2/G3 moves - * (and "canned cycles" - not a current feature) - */ -#if ENABLED(CNC_WORKSPACE_PLANES) - enum WorkspacePlane { PLANE_XY, PLANE_ZX, PLANE_YZ }; -#endif - #endif // __ENUM_H__ diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 471152942b..1577defd35 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -48,6 +48,10 @@ bool GcodeSuite::axis_relative_modes[] = AXIS_RELATIVE_MODES; uint8_t GcodeSuite::host_keepalive_interval = DEFAULT_KEEPALIVE_INTERVAL; #endif +#if ENABLED(CNC_WORKSPACE_PLANES) + GcodeSuite::WorkspacePlane GcodeSuite::workspace_plane = PLANE_XY; +#endif + /** * Set target_extruder from the T parameter or the active_extruder * @@ -112,9 +116,6 @@ void GcodeSuite::dwell(millis_t time) { // // Placeholders for non-migrated codes // -extern void gcode_G17(); -extern void gcode_G18(); -extern void gcode_G19(); extern void gcode_G20(); extern void gcode_G21(); extern void gcode_G27(); @@ -318,13 +319,13 @@ void GcodeSuite::process_next_command() { #if ENABLED(CNC_WORKSPACE_PLANES) case 17: // G17: Select Plane XY - gcode_G17(); + G17(); break; case 18: // G18: Select Plane ZX - gcode_G18(); + G18(); break; case 19: // G19: Select Plane YZ - gcode_G19(); + G19(); break; #endif // CNC_WORKSPACE_PLANES diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index eb77b7b553..90c1aabb6e 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -256,6 +256,15 @@ public: static bool axis_relative_modes[]; + #if ENABLED(CNC_WORKSPACE_PLANES) + /** + * Workspace planes only apply to G2/G3 moves + * (and "canned cycles" - not a current feature) + */ + enum WorkspacePlane { PLANE_XY, PLANE_ZX, PLANE_YZ }; + static WorkspacePlane workspace_plane; + #endif + static millis_t previous_cmd_ms; FORCE_INLINE static void refresh_cmd_timeout() { previous_cmd_ms = millis(); } diff --git a/Marlin/src/gcode/geometry/G17-G19.h b/Marlin/src/gcode/geometry/G17-G19.cpp similarity index 58% rename from Marlin/src/gcode/geometry/G17-G19.h rename to Marlin/src/gcode/geometry/G17-G19.cpp index 7bff34fe40..d386e2eed2 100644 --- a/Marlin/src/gcode/geometry/G17-G19.h +++ b/Marlin/src/gcode/geometry/G17-G19.cpp @@ -20,10 +20,25 @@ * */ -void report_workspace_plane() { +#include "../../inc/MarlinConfig.h" + +#if ENABLED(CNC_WORKSPACE_PLANES) + +#include "../gcode.h" + +inline void report_workspace_plane() { SERIAL_ECHO_START(); SERIAL_ECHOPGM("Workspace Plane "); - serialprintPGM(workspace_plane == PLANE_YZ ? PSTR("YZ\n") : workspace_plane == PLANE_ZX ? PSTR("ZX\n") : PSTR("XY\n")); + serialprintPGM( + gcode.workspace_plane == GcodeSuite::PLANE_YZ ? PSTR("YZ\n") + : gcode.workspace_plane == GcodeSuite::PLANE_ZX ? PSTR("ZX\n") + : PSTR("XY\n") + ); +} + +inline void set_workspace_plane(const GcodeSuite::WorkspacePlane plane) { + gcode.workspace_plane = plane; + if (DEBUGGING(INFO)) report_workspace_plane(); } /** @@ -31,6 +46,8 @@ void report_workspace_plane() { * G18: Select Plane ZX * G19: Select Plane YZ */ -void gcode_G17() { workspace_plane = PLANE_XY; } -void gcode_G18() { workspace_plane = PLANE_ZX; } -void gcode_G19() { workspace_plane = PLANE_YZ; } +void GcodeSuite::G17() { set_workspace_plane(PLANE_XY); } +void GcodeSuite::G18() { set_workspace_plane(PLANE_ZX); } +void GcodeSuite::G19() { set_workspace_plane(PLANE_YZ); } + +#endif // CNC_WORKSPACE_PLANES diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index 2986a86a65..44f0f53ba7 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -50,10 +50,10 @@ void plan_arc( ) { #if ENABLED(CNC_WORKSPACE_PLANES) AxisEnum p_axis, q_axis, l_axis; - switch (workspace_plane) { - case PLANE_XY: p_axis = X_AXIS; q_axis = Y_AXIS; l_axis = Z_AXIS; break; - case PLANE_ZX: p_axis = Z_AXIS; q_axis = X_AXIS; l_axis = Y_AXIS; break; - case PLANE_YZ: p_axis = Y_AXIS; q_axis = Z_AXIS; l_axis = X_AXIS; break; + switch (gcode.workspace_plane) { + case GcodeSuite::PLANE_XY: p_axis = X_AXIS; q_axis = Y_AXIS; l_axis = Z_AXIS; break; + case GcodeSuite::PLANE_ZX: p_axis = Z_AXIS; q_axis = X_AXIS; l_axis = Y_AXIS; break; + case GcodeSuite::PLANE_YZ: p_axis = Y_AXIS; q_axis = Z_AXIS; l_axis = X_AXIS; break; } #else constexpr AxisEnum p_axis = X_AXIS, q_axis = Y_AXIS, l_axis = Z_AXIS;