UBL Cleanup/Bugfix
- Fix bug in ubl_line_to_destination - Improve/fix output of some ubl.h functions
This commit is contained in:
parent
192db2ab1b
commit
4da14b14f4
13
Marlin/ubl.h
13
Marlin/ubl.h
@ -160,7 +160,8 @@
|
|||||||
unified_bed_leveling();
|
unified_bed_leveling();
|
||||||
|
|
||||||
FORCE_INLINE void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
|
FORCE_INLINE void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
|
||||||
int8_t get_cell_index_x(const float &x) {
|
|
||||||
|
int8_t get_cell_index_x(const float &x) {
|
||||||
const int8_t cx = (x - (UBL_MESH_MIN_X)) * (1.0 / (MESH_X_DIST));
|
const int8_t cx = (x - (UBL_MESH_MIN_X)) * (1.0 / (MESH_X_DIST));
|
||||||
return constrain(cx, 0, (GRID_MAX_POINTS_X) - 1); // -1 is appropriate if we want all movement to the X_MAX
|
return constrain(cx, 0, (GRID_MAX_POINTS_X) - 1); // -1 is appropriate if we want all movement to the X_MAX
|
||||||
} // position. But with this defined this way, it is possible
|
} // position. But with this defined this way, it is possible
|
||||||
@ -210,7 +211,8 @@
|
|||||||
*/
|
*/
|
||||||
inline float z_correction_for_x_on_horizontal_mesh_line(const float &lx0, const int x1_i, const int yi) {
|
inline float z_correction_for_x_on_horizontal_mesh_line(const float &lx0, const int x1_i, const int yi) {
|
||||||
if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
|
if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
|
||||||
SERIAL_ECHOPAIR("? in z_correction_for_x_on_horizontal_mesh_line(lx0=", lx0);
|
serialprintPGM( !WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) ? PSTR("x1l_i") : PSTR("yi") );
|
||||||
|
SERIAL_ECHOPAIR(" out of bounds in z_correction_for_x_on_horizontal_mesh_line(lx0=", lx0);
|
||||||
SERIAL_ECHOPAIR(",x1_i=", x1_i);
|
SERIAL_ECHOPAIR(",x1_i=", x1_i);
|
||||||
SERIAL_ECHOPAIR(",yi=", yi);
|
SERIAL_ECHOPAIR(",yi=", yi);
|
||||||
SERIAL_CHAR(')');
|
SERIAL_CHAR(')');
|
||||||
@ -229,9 +231,10 @@
|
|||||||
//
|
//
|
||||||
inline float z_correction_for_y_on_vertical_mesh_line(const float &ly0, const int xi, const int y1_i) {
|
inline float z_correction_for_y_on_vertical_mesh_line(const float &ly0, const int xi, const int y1_i) {
|
||||||
if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) {
|
if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) {
|
||||||
SERIAL_ECHOPAIR("? in get_z_correction_along_vertical_mesh_line_at_specific_x(ly0=", ly0);
|
serialprintPGM( !WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) ? PSTR("xi") : PSTR("yl_i") );
|
||||||
SERIAL_ECHOPAIR(", x1_i=", xi);
|
SERIAL_ECHOPAIR(" out of bounds in z_correction_for_y_on_vertical_mesh_line(ly0=", ly0);
|
||||||
SERIAL_ECHOPAIR(", yi=", y1_i);
|
SERIAL_ECHOPAIR(", xi=", xi);
|
||||||
|
SERIAL_ECHOPAIR(", y1_i=", y1_i);
|
||||||
SERIAL_CHAR(')');
|
SERIAL_CHAR(')');
|
||||||
SERIAL_EOL;
|
SERIAL_EOL;
|
||||||
return NAN;
|
return NAN;
|
||||||
|
@ -231,8 +231,8 @@
|
|||||||
const float m = dy / dx,
|
const float m = dy / dx,
|
||||||
c = start[Y_AXIS] - m * start[X_AXIS];
|
c = start[Y_AXIS] - m * start[X_AXIS];
|
||||||
|
|
||||||
const bool inf_normalized_flag = isinf(e_normalized_dist),
|
const bool inf_normalized_flag = (isinf(e_normalized_dist) != 0),
|
||||||
inf_m_flag = isinf(m);
|
inf_m_flag = (isinf(m) != 0);
|
||||||
/**
|
/**
|
||||||
* This block handles vertical lines. These are lines that stay within the same
|
* This block handles vertical lines. These are lines that stay within the same
|
||||||
* X Cell column. They do not need to be perfectly vertical. They just can
|
* X Cell column. They do not need to be perfectly vertical. They just can
|
||||||
@ -403,9 +403,7 @@
|
|||||||
// as a vertical line move above.)
|
// as a vertical line move above.)
|
||||||
|
|
||||||
if (left_flag == (x > next_mesh_line_x)) { // Check if we hit the Y line first
|
if (left_flag == (x > next_mesh_line_x)) { // Check if we hit the Y line first
|
||||||
//
|
|
||||||
// Yes! Crossing a Y Mesh Line next
|
// Yes! Crossing a Y Mesh Line next
|
||||||
//
|
|
||||||
float z0 = ubl.z_correction_for_x_on_horizontal_mesh_line(x, current_xi - left_flag, current_yi + dyi);
|
float z0 = ubl.z_correction_for_x_on_horizontal_mesh_line(x, current_xi - left_flag, current_yi + dyi);
|
||||||
|
|
||||||
z0 *= ubl.fade_scaling_factor_for_z(end[Z_AXIS]);
|
z0 *= ubl.fade_scaling_factor_for_z(end[Z_AXIS]);
|
||||||
@ -433,9 +431,7 @@
|
|||||||
yi_cnt--;
|
yi_cnt--;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//
|
|
||||||
// Yes! Crossing a X Mesh Line next
|
// Yes! Crossing a X Mesh Line next
|
||||||
//
|
|
||||||
float z0 = ubl.z_correction_for_y_on_vertical_mesh_line(y, current_xi + dxi, current_yi - down_flag);
|
float z0 = ubl.z_correction_for_y_on_vertical_mesh_line(y, current_xi + dxi, current_yi - down_flag);
|
||||||
|
|
||||||
z0 *= ubl.fade_scaling_factor_for_z(end[Z_AXIS]);
|
z0 *= ubl.fade_scaling_factor_for_z(end[Z_AXIS]);
|
||||||
@ -463,6 +459,8 @@
|
|||||||
current_xi += dxi;
|
current_xi += dxi;
|
||||||
xi_cnt--;
|
xi_cnt--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xi_cnt < 0 || yi_cnt < 0) break; // we've gone too far, so exit the loop and move on to FINAL_MOVE
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ubl.g26_debug_flag)
|
if (ubl.g26_debug_flag)
|
||||||
|
Loading…
Reference in New Issue
Block a user