|
@@ -31,8 +31,6 @@
|
31
|
31
|
|
32
|
32
|
mesh_bed_leveling mbl;
|
33
|
33
|
|
34
|
|
- bool mesh_bed_leveling::has_mesh;
|
35
|
|
-
|
36
|
34
|
float mesh_bed_leveling::z_offset,
|
37
|
35
|
mesh_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
|
38
|
36
|
mesh_bed_leveling::index_to_xpos[GRID_MAX_POINTS_X],
|
|
@@ -47,7 +45,6 @@
|
47
|
45
|
}
|
48
|
46
|
|
49
|
47
|
void mesh_bed_leveling::reset() {
|
50
|
|
- has_mesh = false;
|
51
|
48
|
z_offset = 0;
|
52
|
49
|
ZERO(z_values);
|
53
|
50
|
}
|
|
@@ -58,12 +55,12 @@
|
58
|
55
|
* Prepare a mesh-leveled linear move in a Cartesian setup,
|
59
|
56
|
* splitting the move where it crosses mesh borders.
|
60
|
57
|
*/
|
61
|
|
- void mesh_line_to_destination(const float fr_mm_s, uint8_t x_splits, uint8_t y_splits) {
|
|
58
|
+ void mesh_bed_leveling::line_to_destination(const float fr_mm_s, uint8_t x_splits, uint8_t y_splits) {
|
62
|
59
|
// Get current and destination cells for this line
|
63
|
|
- int cx1 = mbl.cell_index_x(current_position[X_AXIS]),
|
64
|
|
- cy1 = mbl.cell_index_y(current_position[Y_AXIS]),
|
65
|
|
- cx2 = mbl.cell_index_x(destination[X_AXIS]),
|
66
|
|
- cy2 = mbl.cell_index_y(destination[Y_AXIS]);
|
|
60
|
+ int cx1 = cell_index_x(current_position[X_AXIS]),
|
|
61
|
+ cy1 = cell_index_y(current_position[Y_AXIS]),
|
|
62
|
+ cx2 = cell_index_x(destination[X_AXIS]),
|
|
63
|
+ cy2 = cell_index_y(destination[Y_AXIS]);
|
67
|
64
|
NOMORE(cx1, GRID_MAX_POINTS_X - 2);
|
68
|
65
|
NOMORE(cy1, GRID_MAX_POINTS_Y - 2);
|
69
|
66
|
NOMORE(cx2, GRID_MAX_POINTS_X - 2);
|
|
@@ -71,7 +68,7 @@
|
71
|
68
|
|
72
|
69
|
// Start and end in the same cell? No split needed.
|
73
|
70
|
if (cx1 == cx2 && cy1 == cy2) {
|
74
|
|
- buffer_line_to_destination(fr_mm_s);
|
|
71
|
+ line_to_destination(fr_mm_s);
|
75
|
72
|
set_current_from_destination();
|
76
|
73
|
return;
|
77
|
74
|
}
|
|
@@ -87,7 +84,7 @@
|
87
|
84
|
// Split on the X grid line
|
88
|
85
|
CBI(x_splits, gcx);
|
89
|
86
|
COPY(end, destination);
|
90
|
|
- destination[X_AXIS] = mbl.index_to_xpos[gcx];
|
|
87
|
+ destination[X_AXIS] = index_to_xpos[gcx];
|
91
|
88
|
normalized_dist = (destination[X_AXIS] - current_position[X_AXIS]) / (end[X_AXIS] - current_position[X_AXIS]);
|
92
|
89
|
destination[Y_AXIS] = MBL_SEGMENT_END(Y);
|
93
|
90
|
}
|
|
@@ -96,14 +93,14 @@
|
96
|
93
|
// Split on the Y grid line
|
97
|
94
|
CBI(y_splits, gcy);
|
98
|
95
|
COPY(end, destination);
|
99
|
|
- destination[Y_AXIS] = mbl.index_to_ypos[gcy];
|
|
96
|
+ destination[Y_AXIS] = index_to_ypos[gcy];
|
100
|
97
|
normalized_dist = (destination[Y_AXIS] - current_position[Y_AXIS]) / (end[Y_AXIS] - current_position[Y_AXIS]);
|
101
|
98
|
destination[X_AXIS] = MBL_SEGMENT_END(X);
|
102
|
99
|
}
|
103
|
100
|
else {
|
104
|
101
|
// Must already have been split on these border(s)
|
105
|
102
|
// This should be a rare case.
|
106
|
|
- buffer_line_to_destination(fr_mm_s);
|
|
103
|
+ line_to_destination(fr_mm_s);
|
107
|
104
|
set_current_from_destination();
|
108
|
105
|
return;
|
109
|
106
|
}
|
|
@@ -112,21 +109,21 @@
|
112
|
109
|
destination[E_AXIS] = MBL_SEGMENT_END(E);
|
113
|
110
|
|
114
|
111
|
// Do the split and look for more borders
|
115
|
|
- mesh_line_to_destination(fr_mm_s, x_splits, y_splits);
|
|
112
|
+ line_to_destination(fr_mm_s, x_splits, y_splits);
|
116
|
113
|
|
117
|
114
|
// Restore destination from stack
|
118
|
115
|
COPY(destination, end);
|
119
|
|
- mesh_line_to_destination(fr_mm_s, x_splits, y_splits);
|
|
116
|
+ line_to_destination(fr_mm_s, x_splits, y_splits);
|
120
|
117
|
}
|
121
|
118
|
|
122
|
119
|
#endif // IS_CARTESIAN && !SEGMENT_LEVELED_MOVES
|
123
|
120
|
|
124
|
|
- void mbl_mesh_report() {
|
|
121
|
+ void mesh_bed_leveling::report_mesh() {
|
125
|
122
|
SERIAL_PROTOCOLLNPGM("Num X,Y: " STRINGIFY(GRID_MAX_POINTS_X) "," STRINGIFY(GRID_MAX_POINTS_Y));
|
126
|
|
- SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(mbl.z_offset, 5);
|
|
123
|
+ SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(z_offset, 5);
|
127
|
124
|
SERIAL_PROTOCOLLNPGM("\nMeasured points:");
|
128
|
125
|
print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 5,
|
129
|
|
- [](const uint8_t ix, const uint8_t iy) { return mbl.z_values[ix][iy]; }
|
|
126
|
+ [](const uint8_t ix, const uint8_t iy) { return z_values[ix][iy]; }
|
130
|
127
|
);
|
131
|
128
|
}
|
132
|
129
|
|