Browse Source

Add probe option to position_is_reachable

Scott Lahteine 8 years ago
parent
commit
b800eb0fed
1 changed files with 26 additions and 12 deletions
  1. 26
    12
      Marlin/Marlin_main.cpp

+ 26
- 12
Marlin/Marlin_main.cpp View File

@@ -2486,28 +2486,36 @@ void unknown_command_error() {
2486 2486
 
2487 2487
 #endif //HOST_KEEPALIVE_FEATURE
2488 2488
 
2489
-bool position_is_reachable(float target[XYZ]) {
2489
+bool position_is_reachable(float target[XYZ]
2490
+  #if HAS_BED_PROBE
2491
+    , bool by_probe=false
2492
+  #endif
2493
+) {
2490 2494
   float dx = RAW_X_POSITION(target[X_AXIS]),
2491 2495
         dy = RAW_Y_POSITION(target[Y_AXIS]),
2492 2496
         dz = RAW_Z_POSITION(target[Z_AXIS]);
2493 2497
 
2494
-  bool good;
2498
+  #if HAS_BED_PROBE
2499
+    if (by_probe) {
2500
+      dx -= X_PROBE_OFFSET_FROM_EXTRUDER;
2501
+      dy -= Y_PROBE_OFFSET_FROM_EXTRUDER;
2502
+    }
2503
+  #endif
2504
+
2495 2505
   #if IS_SCARA
2496 2506
     #if MIDDLE_DEAD_ZONE_R > 0
2497 2507
       const float R2 = HYPOT2(dx - SCARA_OFFSET_X, dy - SCARA_OFFSET_Y);
2498
-      good = (R2 >= sq(float(MIDDLE_DEAD_ZONE_R))) && (R2 <= sq(L1 + L2));
2508
+      return R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) && R2 <= sq(L1 + L2);
2499 2509
     #else
2500
-      good = HYPOT2(dx - SCARA_OFFSET_X, dy - SCARA_OFFSET_Y) <= sq(L1 + L2);
2510
+      return HYPOT2(dx - SCARA_OFFSET_X, dy - SCARA_OFFSET_Y) <= sq(L1 + L2);
2501 2511
     #endif
2502 2512
   #elif ENABLED(DELTA)
2503
-    good = HYPOT2(dx, dy) <= sq(DELTA_PRINTABLE_RADIUS);
2513
+    return HYPOT2(dx, dy) <= sq(DELTA_PRINTABLE_RADIUS);
2504 2514
   #else
2505
-    good = true;
2515
+    return dx >= X_MIN_POS - 0.0001 && dx <= X_MAX_POS + 0.0001
2516
+        && dy >= Y_MIN_POS - 0.0001 && dy <= Y_MAX_POS + 0.0001
2517
+        && dz >= Z_MIN_POS - 0.0001 && dz <= Z_MAX_POS + 0.0001;
2506 2518
   #endif
2507
-
2508
-  return good && dx >= X_MIN_POS - 0.0001 && dx <= X_MAX_POS + 0.0001
2509
-              && dy >= Y_MIN_POS - 0.0001 && dy <= Y_MAX_POS + 0.0001
2510
-              && dz >= Z_MIN_POS - 0.0001 && dz <= Z_MAX_POS + 0.0001;
2511 2519
 }
2512 2520
 
2513 2521
 /**************************************************
@@ -2896,7 +2904,13 @@ inline void gcode_G4() {
2896 2904
       if (DEBUGGING(LEVELING)) DEBUG_POS("Z_SAFE_HOMING", destination);
2897 2905
     #endif
2898 2906
 
2899
-    if (position_is_reachable(destination)) {
2907
+    if (position_is_reachable(
2908
+          destination
2909
+          #if HAS_BED_PROBE
2910
+            , true
2911
+          #endif
2912
+        )
2913
+    ) {
2900 2914
       do_blocking_move_to_xy(destination[X_AXIS], destination[Y_AXIS]);
2901 2915
       HOMEAXIS(Z);
2902 2916
     }
@@ -4245,7 +4259,7 @@ inline void gcode_M42() {
4245 4259
       }
4246 4260
     #else
4247 4261
       float pos[XYZ] = { X_probe_location, Y_probe_location, 0 };
4248
-      if (!position_is_reachable(pos)) {
4262
+      if (!position_is_reachable(pos, true)) {
4249 4263
         SERIAL_PROTOCOLLNPGM("? (X,Y) location outside of probeable radius.");
4250 4264
         return;
4251 4265
       }

Loading…
Cancel
Save