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
   npos.e = planner.get_axis_position_mm(E_AXIS);
221
   npos.e = planner.get_axis_position_mm(E_AXIS);
222
 
222
 
223
   #if HAS_POSITION_MODIFIERS
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
   #endif
225
   #endif
230
 
226
 
231
   report_logical_position(npos);
227
   report_logical_position(npos);
304
   pos.e = planner.get_axis_position_mm(E_AXIS);
300
   pos.e = planner.get_axis_position_mm(E_AXIS);
305
 
301
 
306
   #if HAS_POSITION_MODIFIERS
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
   #endif
304
   #endif
313
 
305
 
314
   if (axis == ALL_AXES)
306
   if (axis == ALL_AXES)

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

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

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

547
         unapply_leveling(raw);
547
         unapply_leveling(raw);
548
         leveling_active = false;
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
     #endif
553
     #endif
551
 
554
 
552
     #if ENABLED(FWRETRACT)
555
     #if ENABLED(FWRETRACT)
557
     #endif
560
     #endif
558
 
561
 
559
     #if HAS_POSITION_MODIFIERS
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
         TERN_(SKEW_CORRECTION, skew(pos));
564
         TERN_(SKEW_CORRECTION, skew(pos));
566
-        TERN_(HAS_LEVELING, if (leveling) apply_leveling(pos));
565
+        if (leveling) apply_leveling(pos);
567
         TERN_(FWRETRACT, apply_retract(pos));
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
         TERN_(FWRETRACT, unapply_retract(pos));
570
         TERN_(FWRETRACT, unapply_retract(pos));
576
-        TERN_(HAS_LEVELING, if (leveling) unapply_leveling(pos));
571
+        if (leveling) unapply_leveling(pos);
577
         TERN_(SKEW_CORRECTION, unskew(pos));
572
         TERN_(SKEW_CORRECTION, unskew(pos));
578
       }
573
       }
579
     #endif // HAS_POSITION_MODIFIERS
574
     #endif // HAS_POSITION_MODIFIERS

Loading…
Cancel
Save