Operate in Native Machine Space
This commit is contained in:
@ -202,7 +202,7 @@ class Planner {
|
||||
static uint32_t cutoff_long;
|
||||
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
static float last_raw_lz;
|
||||
static float last_fade_z;
|
||||
#endif
|
||||
|
||||
#if ENABLED(DISABLE_INACTIVE_EXTRUDER)
|
||||
@ -275,21 +275,20 @@ class Planner {
|
||||
* Returns 1.0 if planner.z_fade_height is 0.0.
|
||||
* Returns 0.0 if Z is past the specified 'Fade Height'.
|
||||
*/
|
||||
inline static float fade_scaling_factor_for_z(const float &lz) {
|
||||
inline static float fade_scaling_factor_for_z(const float &rz) {
|
||||
static float z_fade_factor = 1.0;
|
||||
if (z_fade_height) {
|
||||
const float raw_lz = RAW_Z_POSITION(lz);
|
||||
if (raw_lz >= z_fade_height) return 0.0;
|
||||
if (last_raw_lz != raw_lz) {
|
||||
last_raw_lz = raw_lz;
|
||||
z_fade_factor = 1.0 - raw_lz * inverse_z_fade_height;
|
||||
if (rz >= z_fade_height) return 0.0;
|
||||
if (last_fade_z != rz) {
|
||||
last_fade_z = rz;
|
||||
z_fade_factor = 1.0 - rz * inverse_z_fade_height;
|
||||
}
|
||||
return z_fade_factor;
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
FORCE_INLINE static void force_fade_recalc() { last_raw_lz = -999.999; }
|
||||
FORCE_INLINE static void force_fade_recalc() { last_fade_z = -999.999; }
|
||||
|
||||
FORCE_INLINE static void set_z_fade_height(const float &zfh) {
|
||||
z_fade_height = zfh > 0 ? zfh : 0;
|
||||
@ -297,40 +296,40 @@ class Planner {
|
||||
force_fade_recalc();
|
||||
}
|
||||
|
||||
FORCE_INLINE static bool leveling_active_at_z(const float &lz) {
|
||||
return !z_fade_height || RAW_Z_POSITION(lz) < z_fade_height;
|
||||
FORCE_INLINE static bool leveling_active_at_z(const float &rz) {
|
||||
return !z_fade_height || rz < z_fade_height;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
FORCE_INLINE static float fade_scaling_factor_for_z(const float &lz) {
|
||||
UNUSED(lz);
|
||||
FORCE_INLINE static float fade_scaling_factor_for_z(const float &rz) {
|
||||
UNUSED(rz);
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
FORCE_INLINE static bool leveling_active_at_z(const float &lz) { UNUSED(lz); return true; }
|
||||
FORCE_INLINE static bool leveling_active_at_z(const float &rz) { UNUSED(rz); return true; }
|
||||
|
||||
#endif
|
||||
|
||||
#if PLANNER_LEVELING
|
||||
|
||||
#define ARG_X float lx
|
||||
#define ARG_Y float ly
|
||||
#define ARG_Z float lz
|
||||
#define ARG_X float rx
|
||||
#define ARG_Y float ry
|
||||
#define ARG_Z float rz
|
||||
|
||||
/**
|
||||
* Apply leveling to transform a cartesian position
|
||||
* as it will be given to the planner and steppers.
|
||||
*/
|
||||
static void apply_leveling(float &lx, float &ly, float &lz);
|
||||
static void apply_leveling(float logical[XYZ]) { apply_leveling(logical[X_AXIS], logical[Y_AXIS], logical[Z_AXIS]); }
|
||||
static void unapply_leveling(float logical[XYZ]);
|
||||
static void apply_leveling(float &rx, float &ry, float &rz);
|
||||
static void apply_leveling(float raw[XYZ]) { apply_leveling(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS]); }
|
||||
static void unapply_leveling(float raw[XYZ]);
|
||||
|
||||
#else
|
||||
|
||||
#define ARG_X const float &lx
|
||||
#define ARG_Y const float &ly
|
||||
#define ARG_Z const float &lz
|
||||
#define ARG_X const float &rx
|
||||
#define ARG_Y const float &ry
|
||||
#define ARG_Z const float &rz
|
||||
|
||||
#endif
|
||||
|
||||
@ -357,15 +356,15 @@ class Planner {
|
||||
* Kinematic machines should call buffer_line_kinematic (for leveled moves).
|
||||
* (Cartesians may also call buffer_line_kinematic.)
|
||||
*
|
||||
* lx,ly,lz,e - target position in mm or degrees
|
||||
* rx,ry,rz,e - target position in mm or degrees
|
||||
* fr_mm_s - (target) speed of the move (mm/s)
|
||||
* extruder - target extruder
|
||||
*/
|
||||
static FORCE_INLINE void buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, const float &fr_mm_s, const uint8_t extruder) {
|
||||
#if PLANNER_LEVELING && IS_CARTESIAN
|
||||
apply_leveling(lx, ly, lz);
|
||||
apply_leveling(rx, ry, rz);
|
||||
#endif
|
||||
_buffer_line(lx, ly, lz, e, fr_mm_s, extruder);
|
||||
_buffer_line(rx, ry, rz, e, fr_mm_s, extruder);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -373,22 +372,22 @@ class Planner {
|
||||
* The target is cartesian, it's translated to delta/scara if
|
||||
* needed.
|
||||
*
|
||||
* ltarget - x,y,z,e CARTESIAN target in mm
|
||||
* rtarget - x,y,z,e CARTESIAN target in mm
|
||||
* fr_mm_s - (target) speed of the move (mm/s)
|
||||
* extruder - target extruder
|
||||
*/
|
||||
static FORCE_INLINE void buffer_line_kinematic(const float ltarget[XYZE], const float &fr_mm_s, const uint8_t extruder) {
|
||||
static FORCE_INLINE void buffer_line_kinematic(const float rtarget[XYZE], const float &fr_mm_s, const uint8_t extruder) {
|
||||
#if PLANNER_LEVELING
|
||||
float lpos[XYZ] = { ltarget[X_AXIS], ltarget[Y_AXIS], ltarget[Z_AXIS] };
|
||||
float lpos[XYZ] = { rtarget[X_AXIS], rtarget[Y_AXIS], rtarget[Z_AXIS] };
|
||||
apply_leveling(lpos);
|
||||
#else
|
||||
const float * const lpos = ltarget;
|
||||
const float * const lpos = rtarget;
|
||||
#endif
|
||||
#if IS_KINEMATIC
|
||||
inverse_kinematics(lpos);
|
||||
_buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], ltarget[E_AXIS], fr_mm_s, extruder);
|
||||
_buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], rtarget[E_AXIS], fr_mm_s, extruder);
|
||||
#else
|
||||
_buffer_line(lpos[X_AXIS], lpos[Y_AXIS], lpos[Z_AXIS], ltarget[E_AXIS], fr_mm_s, extruder);
|
||||
_buffer_line(lpos[X_AXIS], lpos[Y_AXIS], lpos[Z_AXIS], rtarget[E_AXIS], fr_mm_s, extruder);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -403,9 +402,9 @@ class Planner {
|
||||
*/
|
||||
static FORCE_INLINE void set_position_mm(ARG_X, ARG_Y, ARG_Z, const float &e) {
|
||||
#if PLANNER_LEVELING && IS_CARTESIAN
|
||||
apply_leveling(lx, ly, lz);
|
||||
apply_leveling(rx, ry, rz);
|
||||
#endif
|
||||
_set_position_mm(lx, ly, lz, e);
|
||||
_set_position_mm(rx, ry, rz, e);
|
||||
}
|
||||
static void set_position_mm_kinematic(const float position[NUM_AXIS]);
|
||||
static void set_position_mm(const AxisEnum axis, const float &v);
|
||||
|
Reference in New Issue
Block a user