Pass the fade factor to mbl.get_z

This commit is contained in:
Scott Lahteine 2016-12-05 01:54:46 -06:00
parent 85c2b96685
commit 84ff78c1e3
2 changed files with 13 additions and 4 deletions

View file

@ -83,7 +83,11 @@
return z1 + delta_a * delta_z; return z1 + delta_a * delta_z;
} }
float get_z(float x0, float y0) { float get_z(const float &x0, const float &y0
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
, const float &factor
#endif
) const {
int8_t cx = cell_index_x(x0), int8_t cx = cell_index_x(x0),
cy = cell_index_y(y0); cy = cell_index_y(y0);
if (cx < 0 || cy < 0) return z_offset; if (cx < 0 || cy < 0) return z_offset;
@ -96,7 +100,12 @@
float z0 = calc_z0(y0, float z0 = calc_z0(y0,
get_probe_y(cy), z1, get_probe_y(cy), z1,
get_probe_y(cy + 1), z2); get_probe_y(cy + 1), z2);
return z0 + z_offset;
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
return z0 * factor + z_offset;
#else
return z0 + z_offset;
#endif
} }
}; };

View file

@ -559,7 +559,7 @@ void Planner::check_axes_activity() {
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
if (mbl.active()) if (mbl.active())
lz += mbl.get_z(RAW_X_POSITION(lx), RAW_Y_POSITION(ly)) * z_fade_factor; lz += mbl.get_z(RAW_X_POSITION(lx), RAW_Y_POSITION(ly), z_fade_factor);
#elif ABL_PLANAR #elif ABL_PLANAR
@ -595,7 +595,7 @@ void Planner::check_axes_activity() {
if (mbl.active()) { if (mbl.active()) {
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
const float c = mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS])); const float c = mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS]), 1.0);
logical[Z_AXIS] = (z_fade_height * (RAW_Z_POSITION(logical[Z_AXIS]) - c)) / (z_fade_height - c); logical[Z_AXIS] = (z_fade_height * (RAW_Z_POSITION(logical[Z_AXIS]) - c)) / (z_fade_height - c);
#else #else
logical[Z_AXIS] -= mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS])); logical[Z_AXIS] -= mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS]));