Browse Source

Clean up planner modifier methods

Scott Lahteine 5 years ago
parent
commit
7a2cc782b4
3 changed files with 10 additions and 27 deletions
  1. 2
    10
      Marlin/src/module/motion.cpp
  2. 1
    5
      Marlin/src/module/planner.cpp
  3. 7
    12
      Marlin/src/module/planner.h

+ 2
- 10
Marlin/src/module/motion.cpp View File

@@ -221,11 +221,7 @@ void report_real_position() {
221 221
   npos.e = planner.get_axis_position_mm(E_AXIS);
222 222
 
223 223
   #if HAS_POSITION_MODIFIERS
224
-    planner.unapply_modifiers(npos
225
-      #if HAS_LEVELING
226
-        , true
227
-      #endif
228
-    );
224
+    planner.unapply_modifiers(npos, true);
229 225
   #endif
230 226
 
231 227
   report_logical_position(npos);
@@ -304,11 +300,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
304 300
   pos.e = planner.get_axis_position_mm(E_AXIS);
305 301
 
306 302
   #if HAS_POSITION_MODIFIERS
307
-    planner.unapply_modifiers(pos
308
-      #if HAS_LEVELING
309
-        , true
310
-      #endif
311
-    );
303
+    planner.unapply_modifiers(pos, true);
312 304
   #endif
313 305
 
314 306
   if (axis == ALL_AXES)

+ 1
- 5
Marlin/src/module/planner.cpp View File

@@ -2742,11 +2742,7 @@ void Planner::set_machine_position_mm(const float &a, const float &b, const floa
2742 2742
 void Planner::set_position_mm(const float &rx, const float &ry, const float &rz, const float &e) {
2743 2743
   xyze_pos_t machine = { rx, ry, rz, e };
2744 2744
   #if HAS_POSITION_MODIFIERS
2745
-    apply_modifiers(machine
2746
-      #if HAS_LEVELING
2747
-        , true
2748
-      #endif
2749
-    );
2745
+    apply_modifiers(machine, true);
2750 2746
   #endif
2751 2747
   #if IS_KINEMATIC
2752 2748
     position_cart.set(rx, ry, rz, e);

+ 7
- 12
Marlin/src/module/planner.h View File

@@ -547,6 +547,9 @@ class Planner {
547 547
         unapply_leveling(raw);
548 548
         leveling_active = false;
549 549
       }
550
+    #else
551
+      FORCE_INLINE static void apply_leveling(xyz_pos_t&) {}
552
+      FORCE_INLINE static void unapply_leveling(xyz_pos_t&) {}
550 553
     #endif
551 554
 
552 555
     #if ENABLED(FWRETRACT)
@@ -557,23 +560,15 @@ class Planner {
557 560
     #endif
558 561
 
559 562
     #if HAS_POSITION_MODIFIERS
560
-      FORCE_INLINE static void apply_modifiers(xyze_pos_t &pos
561
-        #if HAS_LEVELING
562
-          , bool leveling = ENABLED(PLANNER_LEVELING)
563
-        #endif
564
-      ) {
563
+      FORCE_INLINE static void apply_modifiers(xyze_pos_t &pos, bool leveling=ENABLED(PLANNER_LEVELING)) {
565 564
         TERN_(SKEW_CORRECTION, skew(pos));
566
-        TERN_(HAS_LEVELING, if (leveling) apply_leveling(pos));
565
+        if (leveling) apply_leveling(pos);
567 566
         TERN_(FWRETRACT, apply_retract(pos));
568 567
       }
569 568
 
570
-      FORCE_INLINE static void unapply_modifiers(xyze_pos_t &pos
571
-        #if HAS_LEVELING
572
-          , bool leveling = ENABLED(PLANNER_LEVELING)
573
-        #endif
574
-      ) {
569
+      FORCE_INLINE static void unapply_modifiers(xyze_pos_t &pos, bool leveling=ENABLED(PLANNER_LEVELING)) {
575 570
         TERN_(FWRETRACT, unapply_retract(pos));
576
-        TERN_(HAS_LEVELING, if (leveling) unapply_leveling(pos));
571
+        if (leveling) unapply_leveling(pos);
577 572
         TERN_(SKEW_CORRECTION, unskew(pos));
578 573
       }
579 574
     #endif // HAS_POSITION_MODIFIERS

Loading…
Cancel
Save