Browse Source

Add checking

Brian 7 years ago
parent
commit
e09b4ce4a5
1 changed files with 13 additions and 2 deletions
  1. 13
    2
      Marlin/Marlin_main.cpp

+ 13
- 2
Marlin/Marlin_main.cpp View File

51
  * G3  - CCW ARC
51
  * G3  - CCW ARC
52
  * G4  - Dwell S<seconds> or P<milliseconds>
52
  * G4  - Dwell S<seconds> or P<milliseconds>
53
  * G5  - Cubic B-spline with XYZE destination and IJPQ offsets
53
  * G5  - Cubic B-spline with XYZE destination and IJPQ offsets
54
+ * G7  - Coordinated move between UBL mesh points (I & J)
54
  * G10 - Retract filament according to settings of M207
55
  * G10 - Retract filament according to settings of M207
55
  * G11 - Retract recover filament according to settings of M208
56
  * G11 - Retract recover filament according to settings of M208
56
  * G12 - Clean tool
57
  * G12 - Clean tool
3405
   #endif
3406
   #endif
3406
 ) {
3407
 ) {
3407
   if (IsRunning()) {
3408
   if (IsRunning()) {
3408
-    destination[X_AXIS] = code_seen('I') ? pgm_read_float(&ubl.mesh_index_to_xpos[code_has_value() ? code_value_int() : 0]) : current_position[X_AXIS];
3409
-    destination[Y_AXIS] = code_seen('J') ? pgm_read_float(&ubl.mesh_index_to_ypos[code_has_value() ? code_value_int() : 0]) : current_position[Y_AXIS];
3409
+    const bool hasI = code_seen('I');
3410
+    const int8_t ix = code_has_value() ? code_value_int() : 0;
3411
+    const bool hasJ = code_seen('J');
3412
+    const int8_t iy = code_has_value() ? code_value_int() : 0;
3413
+
3414
+    if ((hasI && !WITHIN(ix, 0, GRID_MAX_POINTS_X - 1)) || (hasJ && !WITHIN(iy, 0, GRID_MAX_POINTS_Y - 1))) {
3415
+      SERIAL_ECHOLNPGM(MSG_ERR_MESH_XY);
3416
+      return;
3417
+    }
3418
+
3419
+    destination[X_AXIS] = hasI ? pgm_read_float(&ubl.mesh_index_to_xpos[ix]) : current_position[X_AXIS];
3420
+    destination[Y_AXIS] = hasJ ? pgm_read_float(&ubl.mesh_index_to_ypos[iy]) : current_position[Y_AXIS];
3410
     destination[Z_AXIS] = current_position[Z_AXIS]; //todo: perhaps add Z-move support?
3421
     destination[Z_AXIS] = current_position[Z_AXIS]; //todo: perhaps add Z-move support?
3411
     destination[E_AXIS] = current_position[E_AXIS];
3422
     destination[E_AXIS] = current_position[E_AXIS];
3412
 
3423
 

Loading…
Cancel
Save