Use planner.leveling_active for all leveling systems

This commit is contained in:
Scott Lahteine
2017-10-13 17:21:25 -05:00
parent 32c607ffe2
commit 3e3911fb81
21 changed files with 143 additions and 180 deletions

View File

@@ -51,7 +51,7 @@
void unified_bed_leveling::report_state() {
echo_name();
SERIAL_PROTOCOLPGM(" System v" UBL_VERSION " ");
if (!state.active) SERIAL_PROTOCOLPGM("in");
if (!planner.leveling_active) SERIAL_PROTOCOLPGM("in");
SERIAL_PROTOCOLLNPGM("active.");
safe_delay(50);
}
@@ -93,7 +93,7 @@
set_bed_leveling_enabled(false);
state.storage_slot = -1;
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
planner.z_fade_height = 10.0;
planner.set_z_fade_height(10.0);
#endif
ZERO(z_values);
last_specified_z = -999.9;

View File

@@ -1170,7 +1170,7 @@
return;
}
ubl_state_at_invocation = state.active;
ubl_state_at_invocation = planner.leveling_active;
set_bed_leveling_enabled(false);
}

View File

@@ -257,9 +257,8 @@
*/
const float x = inf_m_flag ? start[X_AXIS] : (next_mesh_line_y - c) / m;
float z0 = z_correction_for_x_on_horizontal_mesh_line(x, current_xi, current_yi);
z0 *= planner.fade_scaling_factor_for_z(end[Z_AXIS]);
float z0 = z_correction_for_x_on_horizontal_mesh_line(x, current_xi, current_yi)
* planner.fade_scaling_factor_for_z(end[Z_AXIS]);
/**
* If part of the Mesh is undefined, it will show up as NAN
@@ -322,9 +321,8 @@
const float next_mesh_line_x = LOGICAL_X_POSITION(mesh_index_to_xpos(current_xi)),
y = m * next_mesh_line_x + c; // Calculate Y at the next X mesh line
float z0 = z_correction_for_y_on_vertical_mesh_line(y, current_xi, current_yi);
z0 *= planner.fade_scaling_factor_for_z(end[Z_AXIS]);
float z0 = z_correction_for_y_on_vertical_mesh_line(y, current_xi, current_yi)
* planner.fade_scaling_factor_for_z(end[Z_AXIS]);
/**
* If part of the Mesh is undefined, it will show up as NAN
@@ -395,9 +393,8 @@
if (left_flag == (x > next_mesh_line_x)) { // Check if we hit the Y line first
// Yes! Crossing a Y Mesh Line next
float z0 = z_correction_for_x_on_horizontal_mesh_line(x, current_xi - left_flag, current_yi + dyi);
z0 *= planner.fade_scaling_factor_for_z(end[Z_AXIS]);
float z0 = z_correction_for_x_on_horizontal_mesh_line(x, current_xi - left_flag, current_yi + dyi)
* planner.fade_scaling_factor_for_z(end[Z_AXIS]);
/**
* If part of the Mesh is undefined, it will show up as NAN
@@ -423,9 +420,8 @@
}
else {
// Yes! Crossing a X Mesh Line next
float z0 = z_correction_for_y_on_vertical_mesh_line(y, current_xi + dxi, current_yi - down_flag);
z0 *= planner.fade_scaling_factor_for_z(end[Z_AXIS]);
float z0 = z_correction_for_y_on_vertical_mesh_line(y, current_xi + dxi, current_yi - down_flag)
* planner.fade_scaling_factor_for_z(end[Z_AXIS]);
/**
* If part of the Mesh is undefined, it will show up as NAN
@@ -580,17 +576,9 @@
seg_rz = RAW_Z_POSITION(current_position[Z_AXIS]),
seg_le = current_position[E_AXIS];
const bool above_fade_height = (
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
planner.z_fade_height != 0 && planner.z_fade_height < RAW_Z_POSITION(ltarget[Z_AXIS])
#else
false
#endif
);
// Only compute leveling per segment if ubl active and target below z_fade_height.
if (!state.active || above_fade_height) { // no mesh leveling
if (!planner.leveling_active || !planner.leveling_active_at_z(ltarget[Z_AXIS])) { // no mesh leveling
do {
@@ -648,7 +636,7 @@
z_x0y1 = z_values[cell_xi ][cell_yi+1], // z at lower right corner
z_x1y1 = z_values[cell_xi+1][cell_yi+1]; // z at upper right corner
if (isnan(z_x0y0)) z_x0y0 = 0; // ideally activating state.active (G29 A)
if (isnan(z_x0y0)) z_x0y0 = 0; // ideally activating planner.leveling_active (G29 A)
if (isnan(z_x1y0)) z_x1y0 = 0; // should refuse if any invalid mesh points
if (isnan(z_x0y1)) z_x0y1 = 0; // in order to avoid isnan tests per cell,
if (isnan(z_x1y1)) z_x1y1 = 0; // thus guessing zero for undefined points