Browse Source

Fix G2/G3 workspace plane parameters (#15475)

Scott Lahteine 5 years ago
parent
commit
e84389c976
No account linked to committer's email address
1 changed files with 26 additions and 14 deletions
  1. 26
    14
      Marlin/src/gcode/motion/G2_G3.cpp

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

@@ -59,8 +59,8 @@ void plan_arc(
59 59
     switch (gcode.workspace_plane) {
60 60
       default:
61 61
       case GcodeSuite::PLANE_XY: p_axis = X_AXIS; q_axis = Y_AXIS; l_axis = Z_AXIS; break;
62
-      case GcodeSuite::PLANE_ZX: p_axis = Z_AXIS; q_axis = X_AXIS; l_axis = Y_AXIS; break;
63 62
       case GcodeSuite::PLANE_YZ: p_axis = Y_AXIS; q_axis = Z_AXIS; l_axis = X_AXIS; break;
63
+      case GcodeSuite::PLANE_ZX: p_axis = Z_AXIS; q_axis = X_AXIS; l_axis = Y_AXIS; break;
64 64
     }
65 65
   #else
66 66
     constexpr AxisEnum p_axis = X_AXIS, q_axis = Y_AXIS, l_axis = Z_AXIS;
@@ -242,19 +242,20 @@ void plan_arc(
242 242
  * G2: Clockwise Arc
243 243
  * G3: Counterclockwise Arc
244 244
  *
245
- * This command has two forms: IJ-form and R-form.
245
+ * This command has two forms: IJ-form (JK, KI) and R-form.
246 246
  *
247
- *  - I specifies an X offset. J specifies a Y offset.
248
- *    At least one of the IJ parameters is required.
249
- *    X and Y can be omitted to do a complete circle.
250
- *    The given XY is not error-checked. The arc ends
251
- *     based on the angle of the destination.
252
- *    Mixing I or J with R will throw an error.
247
+ *  - Depending on the current Workspace Plane orientation,
248
+ *    use parameters IJ/JK/KI to specify the XY/YZ/ZX offsets.
249
+ *    At least one of the IJ/JK/KI parameters is required.
250
+ *    XY/YZ/ZX can be omitted to do a complete circle.
251
+ *    The given XY/YZ/ZX is not error-checked. The arc ends
252
+ *    based on the angle of the destination.
253
+ *    Mixing IJ/JK/KI with R will throw an error.
253 254
  *
254
- *  - R specifies the radius. X or Y is required.
255
- *    Omitting both X and Y will throw an error.
256
- *    X or Y must differ from the current XY.
257
- *    Mixing R with I or J will throw an error.
255
+ *  - R specifies the radius. X or Y (Y or Z / Z or X) is required.
256
+ *    Omitting both XY/YZ/ZX will throw an error.
257
+ *    XY/YZ/ZX must differ from the current XY/YZ/ZX.
258
+ *    Mixing R with IJ/JK/KI will throw an error.
258 259
  *
259 260
  *  - P specifies the number of full circles to do
260 261
  *    before the specified arc move.
@@ -294,8 +295,19 @@ void GcodeSuite::G2_G3(const bool clockwise) {
294 295
       }
295 296
     }
296 297
     else {
297
-      if (parser.seenval('I')) arc_offset.a = parser.value_linear_units();
298
-      if (parser.seenval('J')) arc_offset.b = parser.value_linear_units();
298
+      #if ENABLED(CNC_WORKSPACE_PLANES)
299
+        char achar, bchar;
300
+        switch (gcode.workspace_plane) {
301
+          default:
302
+          case GcodeSuite::PLANE_XY: achar = 'I'; bchar = 'J'; break;
303
+          case GcodeSuite::PLANE_YZ: achar = 'J'; bchar = 'K'; break;
304
+          case GcodeSuite::PLANE_ZX: achar = 'K'; bchar = 'I'; break;
305
+        }
306
+      #else
307
+        constexpr char achar = 'I', bchar = 'J';
308
+      #endif
309
+      if (parser.seenval(achar)) arc_offset.a = parser.value_linear_units();
310
+      if (parser.seenval(bchar)) arc_offset.b = parser.value_linear_units();
299 311
     }
300 312
 
301 313
     if (arc_offset) {

Loading…
Cancel
Save