Browse Source

Clean up planner modifier methods

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
parent
commit
7a2cc782b4
  1. 12
      Marlin/src/module/motion.cpp
  2. 6
      Marlin/src/module/planner.cpp
  3. 19
      Marlin/src/module/planner.h

12
Marlin/src/module/motion.cpp

@ -221,11 +221,7 @@ void report_real_position() {
npos.e = planner.get_axis_position_mm(E_AXIS);
#if HAS_POSITION_MODIFIERS
planner.unapply_modifiers(npos
#if HAS_LEVELING
, true
#endif
);
planner.unapply_modifiers(npos, true);
#endif
report_logical_position(npos);
@ -304,11 +300,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
pos.e = planner.get_axis_position_mm(E_AXIS);
#if HAS_POSITION_MODIFIERS
planner.unapply_modifiers(pos
#if HAS_LEVELING
, true
#endif
);
planner.unapply_modifiers(pos, true);
#endif
if (axis == ALL_AXES)

6
Marlin/src/module/planner.cpp

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

19
Marlin/src/module/planner.h

@ -547,6 +547,9 @@ class Planner {
unapply_leveling(raw);
leveling_active = false;
}
#else
FORCE_INLINE static void apply_leveling(xyz_pos_t&) {}
FORCE_INLINE static void unapply_leveling(xyz_pos_t&) {}
#endif
#if ENABLED(FWRETRACT)
@ -557,23 +560,15 @@ class Planner {
#endif
#if HAS_POSITION_MODIFIERS
FORCE_INLINE static void apply_modifiers(xyze_pos_t &pos
#if HAS_LEVELING
, bool leveling = ENABLED(PLANNER_LEVELING)
#endif
) {
FORCE_INLINE static void apply_modifiers(xyze_pos_t &pos, bool leveling=ENABLED(PLANNER_LEVELING)) {
TERN_(SKEW_CORRECTION, skew(pos));
TERN_(HAS_LEVELING, if (leveling) apply_leveling(pos));
if (leveling) apply_leveling(pos);
TERN_(FWRETRACT, apply_retract(pos));
}
FORCE_INLINE static void unapply_modifiers(xyze_pos_t &pos
#if HAS_LEVELING
, bool leveling = ENABLED(PLANNER_LEVELING)
#endif
) {
FORCE_INLINE static void unapply_modifiers(xyze_pos_t &pos, bool leveling=ENABLED(PLANNER_LEVELING)) {
TERN_(FWRETRACT, unapply_retract(pos));
TERN_(HAS_LEVELING, if (leveling) unapply_leveling(pos));
if (leveling) unapply_leveling(pos);
TERN_(SKEW_CORRECTION, unskew(pos));
}
#endif // HAS_POSITION_MODIFIERS

Loading…
Cancel
Save