Clean up planner modifier methods

This commit is contained in:
Scott Lahteine 2020-05-05 03:09:40 -05:00
parent 852a8d6685
commit 7a2cc782b4
3 changed files with 10 additions and 27 deletions

View file

@ -221,11 +221,7 @@ void report_real_position() {
npos.e = planner.get_axis_position_mm(E_AXIS); npos.e = planner.get_axis_position_mm(E_AXIS);
#if HAS_POSITION_MODIFIERS #if HAS_POSITION_MODIFIERS
planner.unapply_modifiers(npos planner.unapply_modifiers(npos, true);
#if HAS_LEVELING
, true
#endif
);
#endif #endif
report_logical_position(npos); 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); pos.e = planner.get_axis_position_mm(E_AXIS);
#if HAS_POSITION_MODIFIERS #if HAS_POSITION_MODIFIERS
planner.unapply_modifiers(pos planner.unapply_modifiers(pos, true);
#if HAS_LEVELING
, true
#endif
);
#endif #endif
if (axis == ALL_AXES) if (axis == ALL_AXES)

View file

@ -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) { 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 }; xyze_pos_t machine = { rx, ry, rz, e };
#if HAS_POSITION_MODIFIERS #if HAS_POSITION_MODIFIERS
apply_modifiers(machine apply_modifiers(machine, true);
#if HAS_LEVELING
, true
#endif
);
#endif #endif
#if IS_KINEMATIC #if IS_KINEMATIC
position_cart.set(rx, ry, rz, e); position_cart.set(rx, ry, rz, e);

View file

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