Browse Source

Move set_all_z_lock to Stepper

Scott Lahteine 4 years ago
parent
commit
a1f3d2f3cd
3 changed files with 17 additions and 28 deletions
  1. 2
    23
      Marlin/src/gcode/calibrate/G34_M422.cpp
  2. 4
    4
      Marlin/src/module/motion.cpp
  3. 11
    1
      Marlin/src/module/stepper.h

+ 2
- 23
Marlin/src/gcode/calibrate/G34_M422.cpp View File

@@ -47,17 +47,6 @@
47 47
 #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
48 48
 #include "../../core/debug_out.h"
49 49
 
50
-inline void set_all_z_lock(const bool lock) {
51
-  stepper.set_z_lock(lock);
52
-  stepper.set_z2_lock(lock);
53
-  #if NUM_Z_STEPPER_DRIVERS >= 3
54
-    stepper.set_z3_lock(lock);
55
-    #if NUM_Z_STEPPER_DRIVERS >= 4
56
-      stepper.set_z4_lock(lock);
57
-    #endif
58
-  #endif
59
-}
60
-
61 50
 /**
62 51
  * G34: Z-Stepper automatic alignment
63 52
  *
@@ -318,17 +307,7 @@ void GcodeSuite::G34() {
318 307
         if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " corrected by ", z_align_move);
319 308
 
320 309
         // Lock all steppers except one
321
-        set_all_z_lock(true);
322
-        switch (zstepper) {
323
-          case 0: stepper.set_z_lock(false); break;
324
-          case 1: stepper.set_z2_lock(false); break;
325
-          #if NUM_Z_STEPPER_DRIVERS >= 3
326
-            case 2: stepper.set_z3_lock(false); break;
327
-          #endif
328
-          #if NUM_Z_STEPPER_DRIVERS == 4
329
-            case 3: stepper.set_z4_lock(false); break;
330
-          #endif
331
-        }
310
+        stepper.set_all_z_lock(true, zstepper);
332 311
 
333 312
         #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
334 313
           // Decreasing accuracy was detected so move was inverted.
@@ -342,7 +321,7 @@ void GcodeSuite::G34() {
342 321
       } // for (zstepper)
343 322
 
344 323
       // Back to normal stepper operations
345
-      set_all_z_lock(false);
324
+      stepper.set_all_z_lock(false);
346 325
       stepper.set_separate_multi_axis(false);
347 326
 
348 327
       if (err_break) break;

+ 4
- 4
Marlin/src/module/motion.cpp View File

@@ -1644,9 +1644,9 @@ void homeaxis(const AxisEnum axis) {
1644 1644
 
1645 1645
           const float adj = ABS(endstops.z2_endstop_adj);
1646 1646
           if (adj) {
1647
-            if (pos_dir ? (endstops.z2_endstop_adj > 0) : (endstops.z2_endstop_adj < 0)) stepper.set_z_lock(true); else stepper.set_z2_lock(true);
1647
+            if (pos_dir ? (endstops.z2_endstop_adj > 0) : (endstops.z2_endstop_adj < 0)) stepper.set_z1_lock(true); else stepper.set_z2_lock(true);
1648 1648
             do_homing_move(axis, pos_dir ? -adj : adj);
1649
-            stepper.set_z_lock(false);
1649
+            stepper.set_z1_lock(false);
1650 1650
             stepper.set_z2_lock(false);
1651 1651
           }
1652 1652
 
@@ -1657,7 +1657,7 @@ void homeaxis(const AxisEnum axis) {
1657 1657
           typedef void (*adjustFunc_t)(const bool);
1658 1658
 
1659 1659
           adjustFunc_t lock[] = {
1660
-            stepper.set_z_lock, stepper.set_z2_lock, stepper.set_z3_lock
1660
+            stepper.set_z1_lock, stepper.set_z2_lock, stepper.set_z3_lock
1661 1661
             #if NUM_Z_STEPPER_DRIVERS >= 4
1662 1662
               , stepper.set_z4_lock
1663 1663
             #endif
@@ -1725,7 +1725,7 @@ void homeaxis(const AxisEnum axis) {
1725 1725
             do_homing_move(axis, adj[0] - adj[1]);
1726 1726
           }
1727 1727
 
1728
-          stepper.set_z_lock(false);
1728
+          stepper.set_z1_lock(false);
1729 1729
           stepper.set_z2_lock(false);
1730 1730
           stepper.set_z3_lock(false);
1731 1731
           #if NUM_Z_STEPPER_DRIVERS >= 4

+ 11
- 1
Marlin/src/module/stepper.h View File

@@ -484,7 +484,7 @@ class Stepper {
484 484
       FORCE_INLINE static void set_y2_lock(const bool state) { locked_Y2_motor = state; }
485 485
     #endif
486 486
     #if EITHER(Z_MULTI_ENDSTOPS, Z_STEPPER_AUTO_ALIGN)
487
-      FORCE_INLINE static void set_z_lock(const bool state) { locked_Z_motor = state; }
487
+      FORCE_INLINE static void set_z1_lock(const bool state) { locked_Z_motor = state; }
488 488
       FORCE_INLINE static void set_z2_lock(const bool state) { locked_Z2_motor = state; }
489 489
       #if NUM_Z_STEPPER_DRIVERS >= 3
490 490
         FORCE_INLINE static void set_z3_lock(const bool state) { locked_Z3_motor = state; }
@@ -492,6 +492,16 @@ class Stepper {
492 492
           FORCE_INLINE static void set_z4_lock(const bool state) { locked_Z4_motor = state; }
493 493
         #endif
494 494
       #endif
495
+      static inline void set_all_z_lock(const bool lock, const int8_t except=-1) {
496
+        set_z1_lock(lock ^ (except == 0));
497
+        set_z2_lock(lock ^ (except == 1));
498
+        #if NUM_Z_STEPPER_DRIVERS >= 3
499
+          set_z3_lock(lock ^ (except == 2));
500
+          #if NUM_Z_STEPPER_DRIVERS >= 4
501
+            set_z4_lock(lock ^ (except == 3));
502
+          #endif
503
+        #endif
504
+      }
495 505
     #endif
496 506
 
497 507
     #if ENABLED(BABYSTEPPING)

Loading…
Cancel
Save