|
@@ -30,250 +30,326 @@
|
30
|
30
|
#include <avr/io.h>
|
31
|
31
|
#include <math.h>
|
32
|
32
|
|
33
|
|
- extern float destination[XYZE];
|
34
|
|
-
|
35
|
33
|
#if AVR_AT90USB1286_FAMILY // Teensyduino & Printrboard IDE extensions have compile errors without this
|
36
|
34
|
inline void set_current_from_destination() { COPY(current_position, destination); }
|
37
|
35
|
#else
|
38
|
36
|
extern void set_current_from_destination();
|
39
|
37
|
#endif
|
40
|
38
|
|
41
|
|
- static void debug_echo_axis(const AxisEnum axis) {
|
42
|
|
- if (current_position[axis] == destination[axis])
|
43
|
|
- SERIAL_ECHOPGM("-------------");
|
44
|
|
- else
|
45
|
|
- SERIAL_ECHO_F(destination[X_AXIS], 6);
|
46
|
|
- }
|
47
|
|
-
|
48
|
|
- void debug_current_and_destination(const char *title) {
|
49
|
|
-
|
50
|
|
- // if the title message starts with a '!' it is so important, we are going to
|
51
|
|
- // ignore the status of the g26_debug_flag
|
52
|
|
- if (*title != '!' && !g26_debug_flag) return;
|
53
|
|
-
|
54
|
|
- const float de = destination[E_AXIS] - current_position[E_AXIS];
|
55
|
|
-
|
56
|
|
- if (de == 0.0) return; // Printing moves only
|
57
|
|
-
|
58
|
|
- const float dx = destination[X_AXIS] - current_position[X_AXIS],
|
59
|
|
- dy = destination[Y_AXIS] - current_position[Y_AXIS],
|
60
|
|
- xy_dist = HYPOT(dx, dy);
|
61
|
|
-
|
62
|
|
- if (xy_dist == 0.0) return;
|
63
|
|
-
|
64
|
|
- SERIAL_ECHOPGM(" fpmm=");
|
65
|
|
- const float fpmm = de / xy_dist;
|
66
|
|
- SERIAL_ECHO_F(fpmm, 6);
|
67
|
|
-
|
68
|
|
- SERIAL_ECHOPGM(" current=( ");
|
69
|
|
- SERIAL_ECHO_F(current_position[X_AXIS], 6);
|
70
|
|
- SERIAL_ECHOPGM(", ");
|
71
|
|
- SERIAL_ECHO_F(current_position[Y_AXIS], 6);
|
72
|
|
- SERIAL_ECHOPGM(", ");
|
73
|
|
- SERIAL_ECHO_F(current_position[Z_AXIS], 6);
|
74
|
|
- SERIAL_ECHOPGM(", ");
|
75
|
|
- SERIAL_ECHO_F(current_position[E_AXIS], 6);
|
76
|
|
- SERIAL_ECHOPGM(" ) destination=( ");
|
77
|
|
- debug_echo_axis(X_AXIS);
|
78
|
|
- SERIAL_ECHOPGM(", ");
|
79
|
|
- debug_echo_axis(Y_AXIS);
|
80
|
|
- SERIAL_ECHOPGM(", ");
|
81
|
|
- debug_echo_axis(Z_AXIS);
|
82
|
|
- SERIAL_ECHOPGM(", ");
|
83
|
|
- debug_echo_axis(E_AXIS);
|
84
|
|
- SERIAL_ECHOPGM(" ) ");
|
85
|
|
- SERIAL_ECHO(title);
|
86
|
|
- SERIAL_EOL();
|
87
|
|
-
|
88
|
|
- }
|
89
|
|
-
|
90
|
|
- void unified_bed_leveling::line_to_destination_cartesian(const float &feed_rate, uint8_t extruder) {
|
91
|
|
- /**
|
92
|
|
- * Much of the nozzle movement will be within the same cell. So we will do as little computation
|
93
|
|
- * as possible to determine if this is the case. If this move is within the same cell, we will
|
94
|
|
- * just do the required Z-Height correction, call the Planner's buffer_line() routine, and leave
|
95
|
|
- */
|
96
|
|
- const float start[XYZE] = {
|
97
|
|
- current_position[X_AXIS],
|
98
|
|
- current_position[Y_AXIS],
|
99
|
|
- current_position[Z_AXIS],
|
100
|
|
- current_position[E_AXIS]
|
101
|
|
- },
|
102
|
|
- end[XYZE] = {
|
103
|
|
- destination[X_AXIS],
|
104
|
|
- destination[Y_AXIS],
|
105
|
|
- destination[Z_AXIS],
|
106
|
|
- destination[E_AXIS]
|
107
|
|
- };
|
108
|
|
-
|
109
|
|
- const int cell_start_xi = get_cell_index_x(start[X_AXIS]),
|
110
|
|
- cell_start_yi = get_cell_index_y(start[Y_AXIS]),
|
111
|
|
- cell_dest_xi = get_cell_index_x(end[X_AXIS]),
|
112
|
|
- cell_dest_yi = get_cell_index_y(end[Y_AXIS]);
|
113
|
|
-
|
114
|
|
- if (g26_debug_flag) {
|
115
|
|
- SERIAL_ECHOPAIR(" ubl.line_to_destination(xe=", end[X_AXIS]);
|
116
|
|
- SERIAL_ECHOPAIR(", ye=", end[Y_AXIS]);
|
117
|
|
- SERIAL_ECHOPAIR(", ze=", end[Z_AXIS]);
|
118
|
|
- SERIAL_ECHOPAIR(", ee=", end[E_AXIS]);
|
119
|
|
- SERIAL_CHAR(')');
|
120
|
|
- SERIAL_EOL();
|
121
|
|
- debug_current_and_destination(PSTR("Start of ubl.line_to_destination()"));
|
122
|
|
- }
|
|
39
|
+ #if !UBL_SEGMENTED
|
123
|
40
|
|
124
|
|
- if (cell_start_xi == cell_dest_xi && cell_start_yi == cell_dest_yi) { // if the whole move is within the same cell,
|
|
41
|
+ void unified_bed_leveling::line_to_destination_cartesian(const float &feed_rate, const uint8_t extruder) {
|
125
|
42
|
/**
|
126
|
|
- * we don't need to break up the move
|
127
|
|
- *
|
128
|
|
- * If we are moving off the print bed, we are going to allow the move at this level.
|
129
|
|
- * But we detect it and isolate it. For now, we just pass along the request.
|
|
43
|
+ * Much of the nozzle movement will be within the same cell. So we will do as little computation
|
|
44
|
+ * as possible to determine if this is the case. If this move is within the same cell, we will
|
|
45
|
+ * just do the required Z-Height correction, call the Planner's buffer_line() routine, and leave
|
130
|
46
|
*/
|
|
47
|
+ #if ENABLED(SKEW_CORRECTION)
|
|
48
|
+ // For skew correction just adjust the destination point and we're done
|
|
49
|
+ float start[XYZE] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS] },
|
|
50
|
+ end[XYZE] = { destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS] };
|
|
51
|
+ planner.skew(start[X_AXIS], start[Y_AXIS], start[Z_AXIS]);
|
|
52
|
+ planner.skew(end[X_AXIS], end[Y_AXIS], end[Z_AXIS]);
|
|
53
|
+ #else
|
|
54
|
+ const float (&start)[XYZE] = current_position,
|
|
55
|
+ (&end)[XYZE] = destination;
|
|
56
|
+ #endif
|
131
|
57
|
|
132
|
|
- if (!WITHIN(cell_dest_xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(cell_dest_yi, 0, GRID_MAX_POINTS_Y - 1)) {
|
|
58
|
+ const int cell_start_xi = get_cell_index_x(start[X_AXIS]),
|
|
59
|
+ cell_start_yi = get_cell_index_y(start[Y_AXIS]),
|
|
60
|
+ cell_dest_xi = get_cell_index_x(end[X_AXIS]),
|
|
61
|
+ cell_dest_yi = get_cell_index_y(end[Y_AXIS]);
|
|
62
|
+
|
|
63
|
+ if (g26_debug_flag) {
|
|
64
|
+ SERIAL_ECHOPAIR(" ubl.line_to_destination_cartesian(xe=", destination[X_AXIS]);
|
|
65
|
+ SERIAL_ECHOPAIR(", ye=", destination[Y_AXIS]);
|
|
66
|
+ SERIAL_ECHOPAIR(", ze=", destination[Z_AXIS]);
|
|
67
|
+ SERIAL_ECHOPAIR(", ee=", destination[E_AXIS]);
|
|
68
|
+ SERIAL_CHAR(')');
|
|
69
|
+ SERIAL_EOL();
|
|
70
|
+ debug_current_and_destination(PSTR("Start of ubl.line_to_destination_cartesian()"));
|
|
71
|
+ }
|
133
|
72
|
|
134
|
|
- // Note: There is no Z Correction in this case. We are off the grid and don't know what
|
135
|
|
- // a reasonable correction would be.
|
|
73
|
+ if (cell_start_xi == cell_dest_xi && cell_start_yi == cell_dest_yi) { // if the whole move is within the same cell,
|
|
74
|
+ /**
|
|
75
|
+ * we don't need to break up the move
|
|
76
|
+ *
|
|
77
|
+ * If we are moving off the print bed, we are going to allow the move at this level.
|
|
78
|
+ * But we detect it and isolate it. For now, we just pass along the request.
|
|
79
|
+ */
|
136
|
80
|
|
137
|
|
- planner._buffer_line(end[X_AXIS], end[Y_AXIS], end[Z_AXIS], end[E_AXIS], feed_rate, extruder);
|
138
|
|
- set_current_from_destination();
|
|
81
|
+ if (!WITHIN(cell_dest_xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(cell_dest_yi, 0, GRID_MAX_POINTS_Y - 1)) {
|
|
82
|
+
|
|
83
|
+ // Note: There is no Z Correction in this case. We are off the grid and don't know what
|
|
84
|
+ // a reasonable correction would be.
|
|
85
|
+
|
|
86
|
+ planner.buffer_segment(end[X_AXIS], end[Y_AXIS], end[Z_AXIS], end[E_AXIS], feed_rate, extruder);
|
|
87
|
+ set_current_from_destination();
|
|
88
|
+
|
|
89
|
+ if (g26_debug_flag)
|
|
90
|
+ debug_current_and_destination(PSTR("out of bounds in ubl.line_to_destination_cartesian()"));
|
|
91
|
+
|
|
92
|
+ return;
|
|
93
|
+ }
|
|
94
|
+
|
|
95
|
+ FINAL_MOVE:
|
|
96
|
+
|
|
97
|
+ /**
|
|
98
|
+ * Optimize some floating point operations here. We could call float get_z_correction(float x0, float y0) to
|
|
99
|
+ * generate the correction for us. But we can lighten the load on the CPU by doing a modified version of the function.
|
|
100
|
+ * We are going to only calculate the amount we are from the first mesh line towards the second mesh line once.
|
|
101
|
+ * We will use this fraction in both of the original two Z Height calculations for the bi-linear interpolation. And,
|
|
102
|
+ * instead of doing a generic divide of the distance, we know the distance is MESH_X_DIST so we can use the preprocessor
|
|
103
|
+ * to create a 1-over number for us. That will allow us to do a floating point multiply instead of a floating point divide.
|
|
104
|
+ */
|
|
105
|
+
|
|
106
|
+ const float xratio = (end[X_AXIS] - mesh_index_to_xpos(cell_dest_xi)) * (1.0 / (MESH_X_DIST));
|
|
107
|
+
|
|
108
|
+ float z1 = z_values[cell_dest_xi ][cell_dest_yi ] + xratio *
|
|
109
|
+ (z_values[cell_dest_xi + 1][cell_dest_yi ] - z_values[cell_dest_xi][cell_dest_yi ]),
|
|
110
|
+ z2 = z_values[cell_dest_xi ][cell_dest_yi + 1] + xratio *
|
|
111
|
+ (z_values[cell_dest_xi + 1][cell_dest_yi + 1] - z_values[cell_dest_xi][cell_dest_yi + 1]);
|
|
112
|
+
|
|
113
|
+ if (cell_dest_xi >= GRID_MAX_POINTS_X - 1) z1 = z2 = 0.0;
|
|
114
|
+
|
|
115
|
+ // we are done with the fractional X distance into the cell. Now with the two Z-Heights we have calculated, we
|
|
116
|
+ // are going to apply the Y-Distance into the cell to interpolate the final Z correction.
|
|
117
|
+
|
|
118
|
+ const float yratio = (end[Y_AXIS] - mesh_index_to_ypos(cell_dest_yi)) * (1.0 / (MESH_Y_DIST));
|
|
119
|
+ float z0 = cell_dest_yi < GRID_MAX_POINTS_Y - 1 ? (z1 + (z2 - z1) * yratio) * planner.fade_scaling_factor_for_z(end[Z_AXIS]) : 0.0;
|
|
120
|
+
|
|
121
|
+ /**
|
|
122
|
+ * If part of the Mesh is undefined, it will show up as NAN
|
|
123
|
+ * in z_values[][] and propagate through the
|
|
124
|
+ * calculations. If our correction is NAN, we throw it out
|
|
125
|
+ * because part of the Mesh is undefined and we don't have the
|
|
126
|
+ * information we need to complete the height correction.
|
|
127
|
+ */
|
|
128
|
+ if (isnan(z0)) z0 = 0.0;
|
|
129
|
+
|
|
130
|
+ planner.buffer_segment(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + z0, end[E_AXIS], feed_rate, extruder);
|
139
|
131
|
|
140
|
132
|
if (g26_debug_flag)
|
141
|
|
- debug_current_and_destination(PSTR("out of bounds in ubl.line_to_destination()"));
|
|
133
|
+ debug_current_and_destination(PSTR("FINAL_MOVE in ubl.line_to_destination_cartesian()"));
|
142
|
134
|
|
|
135
|
+ set_current_from_destination();
|
143
|
136
|
return;
|
144
|
137
|
}
|
145
|
138
|
|
146
|
|
- FINAL_MOVE:
|
|
139
|
+ /**
|
|
140
|
+ * If we get here, we are processing a move that crosses at least one Mesh Line. We will check
|
|
141
|
+ * for the simple case of just crossing X or just crossing Y Mesh Lines after we get all the details
|
|
142
|
+ * of the move figured out. We can process the easy case of just crossing an X or Y Mesh Line with less
|
|
143
|
+ * computation and in fact most lines are of this nature. We will check for that in the following
|
|
144
|
+ * blocks of code:
|
|
145
|
+ */
|
|
146
|
+
|
|
147
|
+ const float dx = end[X_AXIS] - start[X_AXIS],
|
|
148
|
+ dy = end[Y_AXIS] - start[Y_AXIS];
|
|
149
|
+
|
|
150
|
+ const int left_flag = dx < 0.0 ? 1 : 0,
|
|
151
|
+ down_flag = dy < 0.0 ? 1 : 0;
|
|
152
|
+
|
|
153
|
+ const float adx = left_flag ? -dx : dx,
|
|
154
|
+ ady = down_flag ? -dy : dy;
|
|
155
|
+
|
|
156
|
+ const int dxi = cell_start_xi == cell_dest_xi ? 0 : left_flag ? -1 : 1,
|
|
157
|
+ dyi = cell_start_yi == cell_dest_yi ? 0 : down_flag ? -1 : 1;
|
147
|
158
|
|
148
|
159
|
/**
|
149
|
|
- * Optimize some floating point operations here. We could call float get_z_correction(float x0, float y0) to
|
150
|
|
- * generate the correction for us. But we can lighten the load on the CPU by doing a modified version of the function.
|
151
|
|
- * We are going to only calculate the amount we are from the first mesh line towards the second mesh line once.
|
152
|
|
- * We will use this fraction in both of the original two Z Height calculations for the bi-linear interpolation. And,
|
153
|
|
- * instead of doing a generic divide of the distance, we know the distance is MESH_X_DIST so we can use the preprocessor
|
154
|
|
- * to create a 1-over number for us. That will allow us to do a floating point multiply instead of a floating point divide.
|
|
160
|
+ * Compute the scaling factor for the extruder for each partial move.
|
|
161
|
+ * We need to watch out for zero length moves because it will cause us to
|
|
162
|
+ * have an infinate scaling factor. We are stuck doing a floating point
|
|
163
|
+ * divide to get our scaling factor, but after that, we just multiply by this
|
|
164
|
+ * number. We also pick our scaling factor based on whether the X or Y
|
|
165
|
+ * component is larger. We use the biggest of the two to preserve precision.
|
155
|
166
|
*/
|
156
|
167
|
|
157
|
|
- const float xratio = (end[X_AXIS] - mesh_index_to_xpos(cell_dest_xi)) * (1.0 / (MESH_X_DIST));
|
|
168
|
+ const bool use_x_dist = adx > ady;
|
158
|
169
|
|
159
|
|
- float z1 = z_values[cell_dest_xi ][cell_dest_yi ] + xratio *
|
160
|
|
- (z_values[cell_dest_xi + 1][cell_dest_yi ] - z_values[cell_dest_xi][cell_dest_yi ]),
|
161
|
|
- z2 = z_values[cell_dest_xi ][cell_dest_yi + 1] + xratio *
|
162
|
|
- (z_values[cell_dest_xi + 1][cell_dest_yi + 1] - z_values[cell_dest_xi][cell_dest_yi + 1]);
|
|
170
|
+ float on_axis_distance = use_x_dist ? dx : dy,
|
|
171
|
+ e_position = end[E_AXIS] - start[E_AXIS],
|
|
172
|
+ z_position = end[Z_AXIS] - start[Z_AXIS];
|
163
|
173
|
|
164
|
|
- if (cell_dest_xi >= GRID_MAX_POINTS_X - 1) z1 = z2 = 0.0;
|
|
174
|
+ const float e_normalized_dist = e_position / on_axis_distance,
|
|
175
|
+ z_normalized_dist = z_position / on_axis_distance;
|
165
|
176
|
|
166
|
|
- // we are done with the fractional X distance into the cell. Now with the two Z-Heights we have calculated, we
|
167
|
|
- // are going to apply the Y-Distance into the cell to interpolate the final Z correction.
|
|
177
|
+ int current_xi = cell_start_xi,
|
|
178
|
+ current_yi = cell_start_yi;
|
168
|
179
|
|
169
|
|
- const float yratio = (end[Y_AXIS] - mesh_index_to_ypos(cell_dest_yi)) * (1.0 / (MESH_Y_DIST));
|
170
|
|
- float z0 = cell_dest_yi < GRID_MAX_POINTS_Y - 1 ? (z1 + (z2 - z1) * yratio) * planner.fade_scaling_factor_for_z(end[Z_AXIS]) : 0.0;
|
|
180
|
+ const float m = dy / dx,
|
|
181
|
+ c = start[Y_AXIS] - m * start[X_AXIS];
|
171
|
182
|
|
|
183
|
+ const bool inf_normalized_flag = (isinf(e_normalized_dist) != 0),
|
|
184
|
+ inf_m_flag = (isinf(m) != 0);
|
172
|
185
|
/**
|
173
|
|
- * If part of the Mesh is undefined, it will show up as NAN
|
174
|
|
- * in z_values[][] and propagate through the
|
175
|
|
- * calculations. If our correction is NAN, we throw it out
|
176
|
|
- * because part of the Mesh is undefined and we don't have the
|
177
|
|
- * information we need to complete the height correction.
|
|
186
|
+ * This block handles vertical lines. These are lines that stay within the same
|
|
187
|
+ * X Cell column. They do not need to be perfectly vertical. They just can
|
|
188
|
+ * not cross into another X Cell column.
|
178
|
189
|
*/
|
179
|
|
- if (isnan(z0)) z0 = 0.0;
|
180
|
|
-
|
181
|
|
- planner._buffer_line(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + z0, end[E_AXIS], feed_rate, extruder);
|
|
190
|
+ if (dxi == 0) { // Check for a vertical line
|
|
191
|
+ current_yi += down_flag; // Line is heading down, we just want to go to the bottom
|
|
192
|
+ while (current_yi != cell_dest_yi + down_flag) {
|
|
193
|
+ current_yi += dyi;
|
|
194
|
+ const float next_mesh_line_y = mesh_index_to_ypos(current_yi);
|
|
195
|
+
|
|
196
|
+ /**
|
|
197
|
+ * if the slope of the line is infinite, we won't do the calculations
|
|
198
|
+ * else, we know the next X is the same so we can recover and continue!
|
|
199
|
+ * Calculate X at the next Y mesh line
|
|
200
|
+ */
|
|
201
|
+ const float rx = inf_m_flag ? start[X_AXIS] : (next_mesh_line_y - c) / m;
|
|
202
|
+
|
|
203
|
+ float z0 = z_correction_for_x_on_horizontal_mesh_line(rx, current_xi, current_yi)
|
|
204
|
+ * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
|
|
205
|
+
|
|
206
|
+ /**
|
|
207
|
+ * If part of the Mesh is undefined, it will show up as NAN
|
|
208
|
+ * in z_values[][] and propagate through the
|
|
209
|
+ * calculations. If our correction is NAN, we throw it out
|
|
210
|
+ * because part of the Mesh is undefined and we don't have the
|
|
211
|
+ * information we need to complete the height correction.
|
|
212
|
+ */
|
|
213
|
+ if (isnan(z0)) z0 = 0.0;
|
|
214
|
+
|
|
215
|
+ const float ry = mesh_index_to_ypos(current_yi);
|
|
216
|
+
|
|
217
|
+ /**
|
|
218
|
+ * Without this check, it is possible for the algorithm to generate a zero length move in the case
|
|
219
|
+ * where the line is heading down and it is starting right on a Mesh Line boundary. For how often that
|
|
220
|
+ * happens, it might be best to remove the check and always 'schedule' the move because
|
|
221
|
+ * the planner.buffer_segment() routine will filter it if that happens.
|
|
222
|
+ */
|
|
223
|
+ if (ry != start[Y_AXIS]) {
|
|
224
|
+ if (!inf_normalized_flag) {
|
|
225
|
+ on_axis_distance = use_x_dist ? rx - start[X_AXIS] : ry - start[Y_AXIS];
|
|
226
|
+ e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
|
|
227
|
+ z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
|
|
228
|
+ }
|
|
229
|
+ else {
|
|
230
|
+ e_position = end[E_AXIS];
|
|
231
|
+ z_position = end[Z_AXIS];
|
|
232
|
+ }
|
182
|
233
|
|
183
|
|
- if (g26_debug_flag)
|
184
|
|
- debug_current_and_destination(PSTR("FINAL_MOVE in ubl.line_to_destination()"));
|
|
234
|
+ planner.buffer_segment(rx, ry, z_position + z0, e_position, feed_rate, extruder);
|
|
235
|
+ } //else printf("FIRST MOVE PRUNED ");
|
|
236
|
+ }
|
185
|
237
|
|
186
|
|
- set_current_from_destination();
|
187
|
|
- return;
|
188
|
|
- }
|
|
238
|
+ if (g26_debug_flag)
|
|
239
|
+ debug_current_and_destination(PSTR("vertical move done in ubl.line_to_destination_cartesian()"));
|
189
|
240
|
|
190
|
|
- /**
|
191
|
|
- * If we get here, we are processing a move that crosses at least one Mesh Line. We will check
|
192
|
|
- * for the simple case of just crossing X or just crossing Y Mesh Lines after we get all the details
|
193
|
|
- * of the move figured out. We can process the easy case of just crossing an X or Y Mesh Line with less
|
194
|
|
- * computation and in fact most lines are of this nature. We will check for that in the following
|
195
|
|
- * blocks of code:
|
196
|
|
- */
|
|
241
|
+ //
|
|
242
|
+ // Check if we are at the final destination. Usually, we won't be, but if it is on a Y Mesh Line, we are done.
|
|
243
|
+ //
|
|
244
|
+ if (current_position[X_AXIS] != end[X_AXIS] || current_position[Y_AXIS] != end[Y_AXIS])
|
|
245
|
+ goto FINAL_MOVE;
|
197
|
246
|
|
198
|
|
- const float dx = end[X_AXIS] - start[X_AXIS],
|
199
|
|
- dy = end[Y_AXIS] - start[Y_AXIS];
|
|
247
|
+ set_current_from_destination();
|
|
248
|
+ return;
|
|
249
|
+ }
|
200
|
250
|
|
201
|
|
- const int left_flag = dx < 0.0 ? 1 : 0,
|
202
|
|
- down_flag = dy < 0.0 ? 1 : 0;
|
|
251
|
+ /**
|
|
252
|
+ *
|
|
253
|
+ * This block handles horizontal lines. These are lines that stay within the same
|
|
254
|
+ * Y Cell row. They do not need to be perfectly horizontal. They just can
|
|
255
|
+ * not cross into another Y Cell row.
|
|
256
|
+ *
|
|
257
|
+ */
|
203
|
258
|
|
204
|
|
- const float adx = left_flag ? -dx : dx,
|
205
|
|
- ady = down_flag ? -dy : dy;
|
|
259
|
+ if (dyi == 0) { // Check for a horizontal line
|
|
260
|
+ current_xi += left_flag; // Line is heading left, we just want to go to the left
|
|
261
|
+ // edge of this cell for the first move.
|
|
262
|
+ while (current_xi != cell_dest_xi + left_flag) {
|
|
263
|
+ current_xi += dxi;
|
|
264
|
+ const float next_mesh_line_x = mesh_index_to_xpos(current_xi),
|
|
265
|
+ ry = m * next_mesh_line_x + c; // Calculate Y at the next X mesh line
|
|
266
|
+
|
|
267
|
+ float z0 = z_correction_for_y_on_vertical_mesh_line(ry, current_xi, current_yi)
|
|
268
|
+ * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
|
|
269
|
+
|
|
270
|
+ /**
|
|
271
|
+ * If part of the Mesh is undefined, it will show up as NAN
|
|
272
|
+ * in z_values[][] and propagate through the
|
|
273
|
+ * calculations. If our correction is NAN, we throw it out
|
|
274
|
+ * because part of the Mesh is undefined and we don't have the
|
|
275
|
+ * information we need to complete the height correction.
|
|
276
|
+ */
|
|
277
|
+ if (isnan(z0)) z0 = 0.0;
|
|
278
|
+
|
|
279
|
+ const float rx = mesh_index_to_xpos(current_xi);
|
|
280
|
+
|
|
281
|
+ /**
|
|
282
|
+ * Without this check, it is possible for the algorithm to generate a zero length move in the case
|
|
283
|
+ * where the line is heading left and it is starting right on a Mesh Line boundary. For how often
|
|
284
|
+ * that happens, it might be best to remove the check and always 'schedule' the move because
|
|
285
|
+ * the planner.buffer_segment() routine will filter it if that happens.
|
|
286
|
+ */
|
|
287
|
+ if (rx != start[X_AXIS]) {
|
|
288
|
+ if (!inf_normalized_flag) {
|
|
289
|
+ on_axis_distance = use_x_dist ? rx - start[X_AXIS] : ry - start[Y_AXIS];
|
|
290
|
+ e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist; // is based on X or Y because this is a horizontal move
|
|
291
|
+ z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
|
|
292
|
+ }
|
|
293
|
+ else {
|
|
294
|
+ e_position = end[E_AXIS];
|
|
295
|
+ z_position = end[Z_AXIS];
|
|
296
|
+ }
|
206
|
297
|
|
207
|
|
- const int dxi = cell_start_xi == cell_dest_xi ? 0 : left_flag ? -1 : 1,
|
208
|
|
- dyi = cell_start_yi == cell_dest_yi ? 0 : down_flag ? -1 : 1;
|
|
298
|
+ planner.buffer_segment(rx, ry, z_position + z0, e_position, feed_rate, extruder);
|
|
299
|
+ } //else printf("FIRST MOVE PRUNED ");
|
|
300
|
+ }
|
209
|
301
|
|
210
|
|
- /**
|
211
|
|
- * Compute the scaling factor for the extruder for each partial move.
|
212
|
|
- * We need to watch out for zero length moves because it will cause us to
|
213
|
|
- * have an infinate scaling factor. We are stuck doing a floating point
|
214
|
|
- * divide to get our scaling factor, but after that, we just multiply by this
|
215
|
|
- * number. We also pick our scaling factor based on whether the X or Y
|
216
|
|
- * component is larger. We use the biggest of the two to preserve precision.
|
217
|
|
- */
|
|
302
|
+ if (g26_debug_flag)
|
|
303
|
+ debug_current_and_destination(PSTR("horizontal move done in ubl.line_to_destination_cartesian()"));
|
218
|
304
|
|
219
|
|
- const bool use_x_dist = adx > ady;
|
|
305
|
+ if (current_position[X_AXIS] != end[X_AXIS] || current_position[Y_AXIS] != end[Y_AXIS])
|
|
306
|
+ goto FINAL_MOVE;
|
220
|
307
|
|
221
|
|
- float on_axis_distance = use_x_dist ? dx : dy,
|
222
|
|
- e_position = end[E_AXIS] - start[E_AXIS],
|
223
|
|
- z_position = end[Z_AXIS] - start[Z_AXIS];
|
|
308
|
+ set_current_from_destination();
|
|
309
|
+ return;
|
|
310
|
+ }
|
224
|
311
|
|
225
|
|
- const float e_normalized_dist = e_position / on_axis_distance,
|
226
|
|
- z_normalized_dist = z_position / on_axis_distance;
|
|
312
|
+ /**
|
|
313
|
+ *
|
|
314
|
+ * This block handles the generic case of a line crossing both X and Y Mesh lines.
|
|
315
|
+ *
|
|
316
|
+ */
|
227
|
317
|
|
228
|
|
- int current_xi = cell_start_xi,
|
229
|
|
- current_yi = cell_start_yi;
|
|
318
|
+ int xi_cnt = cell_start_xi - cell_dest_xi,
|
|
319
|
+ yi_cnt = cell_start_yi - cell_dest_yi;
|
230
|
320
|
|
231
|
|
- const float m = dy / dx,
|
232
|
|
- c = start[Y_AXIS] - m * start[X_AXIS];
|
|
321
|
+ if (xi_cnt < 0) xi_cnt = -xi_cnt;
|
|
322
|
+ if (yi_cnt < 0) yi_cnt = -yi_cnt;
|
233
|
323
|
|
234
|
|
- const bool inf_normalized_flag = (isinf(e_normalized_dist) != 0),
|
235
|
|
- inf_m_flag = (isinf(m) != 0);
|
236
|
|
- /**
|
237
|
|
- * This block handles vertical lines. These are lines that stay within the same
|
238
|
|
- * X Cell column. They do not need to be perfectly vertical. They just can
|
239
|
|
- * not cross into another X Cell column.
|
240
|
|
- */
|
241
|
|
- if (dxi == 0) { // Check for a vertical line
|
242
|
|
- current_yi += down_flag; // Line is heading down, we just want to go to the bottom
|
243
|
|
- while (current_yi != cell_dest_yi + down_flag) {
|
244
|
|
- current_yi += dyi;
|
245
|
|
- const float next_mesh_line_y = mesh_index_to_ypos(current_yi);
|
|
324
|
+ current_xi += left_flag;
|
|
325
|
+ current_yi += down_flag;
|
246
|
326
|
|
247
|
|
- /**
|
248
|
|
- * if the slope of the line is infinite, we won't do the calculations
|
249
|
|
- * else, we know the next X is the same so we can recover and continue!
|
250
|
|
- * Calculate X at the next Y mesh line
|
251
|
|
- */
|
252
|
|
- const float rx = inf_m_flag ? start[X_AXIS] : (next_mesh_line_y - c) / m;
|
|
327
|
+ while (xi_cnt > 0 || yi_cnt > 0) {
|
253
|
328
|
|
254
|
|
- float z0 = z_correction_for_x_on_horizontal_mesh_line(rx, current_xi, current_yi)
|
255
|
|
- * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
|
|
329
|
+ const float next_mesh_line_x = mesh_index_to_xpos(current_xi + dxi),
|
|
330
|
+ next_mesh_line_y = mesh_index_to_ypos(current_yi + dyi),
|
|
331
|
+ ry = m * next_mesh_line_x + c, // Calculate Y at the next X mesh line
|
|
332
|
+ rx = (next_mesh_line_y - c) / m; // Calculate X at the next Y mesh line
|
|
333
|
+ // (No need to worry about m being zero.
|
|
334
|
+ // If that was the case, it was already detected
|
|
335
|
+ // as a vertical line move above.)
|
256
|
336
|
|
257
|
|
- /**
|
258
|
|
- * If part of the Mesh is undefined, it will show up as NAN
|
259
|
|
- * in z_values[][] and propagate through the
|
260
|
|
- * calculations. If our correction is NAN, we throw it out
|
261
|
|
- * because part of the Mesh is undefined and we don't have the
|
262
|
|
- * information we need to complete the height correction.
|
263
|
|
- */
|
264
|
|
- if (isnan(z0)) z0 = 0.0;
|
|
337
|
+ if (left_flag == (rx > next_mesh_line_x)) { // Check if we hit the Y line first
|
|
338
|
+ // Yes! Crossing a Y Mesh Line next
|
|
339
|
+ float z0 = z_correction_for_x_on_horizontal_mesh_line(rx, current_xi - left_flag, current_yi + dyi)
|
|
340
|
+ * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
|
265
|
341
|
|
266
|
|
- const float ry = mesh_index_to_ypos(current_yi);
|
|
342
|
+ /**
|
|
343
|
+ * If part of the Mesh is undefined, it will show up as NAN
|
|
344
|
+ * in z_values[][] and propagate through the
|
|
345
|
+ * calculations. If our correction is NAN, we throw it out
|
|
346
|
+ * because part of the Mesh is undefined and we don't have the
|
|
347
|
+ * information we need to complete the height correction.
|
|
348
|
+ */
|
|
349
|
+ if (isnan(z0)) z0 = 0.0;
|
267
|
350
|
|
268
|
|
- /**
|
269
|
|
- * Without this check, it is possible for the algorithm to generate a zero length move in the case
|
270
|
|
- * where the line is heading down and it is starting right on a Mesh Line boundary. For how often that
|
271
|
|
- * happens, it might be best to remove the check and always 'schedule' the move because
|
272
|
|
- * the planner._buffer_line() routine will filter it if that happens.
|
273
|
|
- */
|
274
|
|
- if (ry != start[Y_AXIS]) {
|
275
|
351
|
if (!inf_normalized_flag) {
|
276
|
|
- on_axis_distance = use_x_dist ? rx - start[X_AXIS] : ry - start[Y_AXIS];
|
|
352
|
+ on_axis_distance = use_x_dist ? rx - start[X_AXIS] : next_mesh_line_y - start[Y_AXIS];
|
277
|
353
|
e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
|
278
|
354
|
z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
|
279
|
355
|
}
|
|
@@ -281,64 +357,27 @@
|
281
|
357
|
e_position = end[E_AXIS];
|
282
|
358
|
z_position = end[Z_AXIS];
|
283
|
359
|
}
|
|
360
|
+ planner.buffer_segment(rx, next_mesh_line_y, z_position + z0, e_position, feed_rate, extruder);
|
|
361
|
+ current_yi += dyi;
|
|
362
|
+ yi_cnt--;
|
|
363
|
+ }
|
|
364
|
+ else {
|
|
365
|
+ // Yes! Crossing a X Mesh Line next
|
|
366
|
+ float z0 = z_correction_for_y_on_vertical_mesh_line(ry, current_xi + dxi, current_yi - down_flag)
|
|
367
|
+ * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
|
|
368
|
+
|
|
369
|
+ /**
|
|
370
|
+ * If part of the Mesh is undefined, it will show up as NAN
|
|
371
|
+ * in z_values[][] and propagate through the
|
|
372
|
+ * calculations. If our correction is NAN, we throw it out
|
|
373
|
+ * because part of the Mesh is undefined and we don't have the
|
|
374
|
+ * information we need to complete the height correction.
|
|
375
|
+ */
|
|
376
|
+ if (isnan(z0)) z0 = 0.0;
|
284
|
377
|
|
285
|
|
- planner._buffer_line(rx, ry, z_position + z0, e_position, feed_rate, extruder);
|
286
|
|
- } //else printf("FIRST MOVE PRUNED ");
|
287
|
|
- }
|
288
|
|
-
|
289
|
|
- if (g26_debug_flag)
|
290
|
|
- debug_current_and_destination(PSTR("vertical move done in ubl.line_to_destination()"));
|
291
|
|
-
|
292
|
|
- //
|
293
|
|
- // Check if we are at the final destination. Usually, we won't be, but if it is on a Y Mesh Line, we are done.
|
294
|
|
- //
|
295
|
|
- if (current_position[X_AXIS] != end[X_AXIS] || current_position[Y_AXIS] != end[Y_AXIS])
|
296
|
|
- goto FINAL_MOVE;
|
297
|
|
-
|
298
|
|
- set_current_from_destination();
|
299
|
|
- return;
|
300
|
|
- }
|
301
|
|
-
|
302
|
|
- /**
|
303
|
|
- *
|
304
|
|
- * This block handles horizontal lines. These are lines that stay within the same
|
305
|
|
- * Y Cell row. They do not need to be perfectly horizontal. They just can
|
306
|
|
- * not cross into another Y Cell row.
|
307
|
|
- *
|
308
|
|
- */
|
309
|
|
-
|
310
|
|
- if (dyi == 0) { // Check for a horizontal line
|
311
|
|
- current_xi += left_flag; // Line is heading left, we just want to go to the left
|
312
|
|
- // edge of this cell for the first move.
|
313
|
|
- while (current_xi != cell_dest_xi + left_flag) {
|
314
|
|
- current_xi += dxi;
|
315
|
|
- const float next_mesh_line_x = mesh_index_to_xpos(current_xi),
|
316
|
|
- ry = m * next_mesh_line_x + c; // Calculate Y at the next X mesh line
|
317
|
|
-
|
318
|
|
- float z0 = z_correction_for_y_on_vertical_mesh_line(ry, current_xi, current_yi)
|
319
|
|
- * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
|
320
|
|
-
|
321
|
|
- /**
|
322
|
|
- * If part of the Mesh is undefined, it will show up as NAN
|
323
|
|
- * in z_values[][] and propagate through the
|
324
|
|
- * calculations. If our correction is NAN, we throw it out
|
325
|
|
- * because part of the Mesh is undefined and we don't have the
|
326
|
|
- * information we need to complete the height correction.
|
327
|
|
- */
|
328
|
|
- if (isnan(z0)) z0 = 0.0;
|
329
|
|
-
|
330
|
|
- const float rx = mesh_index_to_xpos(current_xi);
|
331
|
|
-
|
332
|
|
- /**
|
333
|
|
- * Without this check, it is possible for the algorithm to generate a zero length move in the case
|
334
|
|
- * where the line is heading left and it is starting right on a Mesh Line boundary. For how often
|
335
|
|
- * that happens, it might be best to remove the check and always 'schedule' the move because
|
336
|
|
- * the planner._buffer_line() routine will filter it if that happens.
|
337
|
|
- */
|
338
|
|
- if (rx != start[X_AXIS]) {
|
339
|
378
|
if (!inf_normalized_flag) {
|
340
|
|
- on_axis_distance = use_x_dist ? rx - start[X_AXIS] : ry - start[Y_AXIS];
|
341
|
|
- e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist; // is based on X or Y because this is a horizontal move
|
|
379
|
+ on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : ry - start[Y_AXIS];
|
|
380
|
+ e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
|
342
|
381
|
z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
|
343
|
382
|
}
|
344
|
383
|
else {
|
|
@@ -346,136 +385,38 @@
|
346
|
385
|
z_position = end[Z_AXIS];
|
347
|
386
|
}
|
348
|
387
|
|
349
|
|
- planner._buffer_line(rx, ry, z_position + z0, e_position, feed_rate, extruder);
|
350
|
|
- } //else printf("FIRST MOVE PRUNED ");
|
|
388
|
+ planner.buffer_segment(next_mesh_line_x, ry, z_position + z0, e_position, feed_rate, extruder);
|
|
389
|
+ current_xi += dxi;
|
|
390
|
+ xi_cnt--;
|
|
391
|
+ }
|
|
392
|
+
|
|
393
|
+ if (xi_cnt < 0 || yi_cnt < 0) break; // we've gone too far, so exit the loop and move on to FINAL_MOVE
|
351
|
394
|
}
|
352
|
395
|
|
353
|
396
|
if (g26_debug_flag)
|
354
|
|
- debug_current_and_destination(PSTR("horizontal move done in ubl.line_to_destination()"));
|
|
397
|
+ debug_current_and_destination(PSTR("generic move done in ubl.line_to_destination_cartesian()"));
|
355
|
398
|
|
356
|
399
|
if (current_position[X_AXIS] != end[X_AXIS] || current_position[Y_AXIS] != end[Y_AXIS])
|
357
|
400
|
goto FINAL_MOVE;
|
358
|
401
|
|
359
|
402
|
set_current_from_destination();
|
360
|
|
- return;
|
361
|
|
- }
|
362
|
|
-
|
363
|
|
- /**
|
364
|
|
- *
|
365
|
|
- * This block handles the generic case of a line crossing both X and Y Mesh lines.
|
366
|
|
- *
|
367
|
|
- */
|
368
|
|
-
|
369
|
|
- int xi_cnt = cell_start_xi - cell_dest_xi,
|
370
|
|
- yi_cnt = cell_start_yi - cell_dest_yi;
|
371
|
|
-
|
372
|
|
- if (xi_cnt < 0) xi_cnt = -xi_cnt;
|
373
|
|
- if (yi_cnt < 0) yi_cnt = -yi_cnt;
|
374
|
|
-
|
375
|
|
- current_xi += left_flag;
|
376
|
|
- current_yi += down_flag;
|
377
|
|
-
|
378
|
|
- while (xi_cnt > 0 || yi_cnt > 0) {
|
379
|
|
-
|
380
|
|
- const float next_mesh_line_x = mesh_index_to_xpos(current_xi + dxi),
|
381
|
|
- next_mesh_line_y = mesh_index_to_ypos(current_yi + dyi),
|
382
|
|
- ry = m * next_mesh_line_x + c, // Calculate Y at the next X mesh line
|
383
|
|
- rx = (next_mesh_line_y - c) / m; // Calculate X at the next Y mesh line
|
384
|
|
- // (No need to worry about m being zero.
|
385
|
|
- // If that was the case, it was already detected
|
386
|
|
- // as a vertical line move above.)
|
387
|
|
-
|
388
|
|
- if (left_flag == (rx > next_mesh_line_x)) { // Check if we hit the Y line first
|
389
|
|
- // Yes! Crossing a Y Mesh Line next
|
390
|
|
- float z0 = z_correction_for_x_on_horizontal_mesh_line(rx, current_xi - left_flag, current_yi + dyi)
|
391
|
|
- * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
|
392
|
|
-
|
393
|
|
- /**
|
394
|
|
- * If part of the Mesh is undefined, it will show up as NAN
|
395
|
|
- * in z_values[][] and propagate through the
|
396
|
|
- * calculations. If our correction is NAN, we throw it out
|
397
|
|
- * because part of the Mesh is undefined and we don't have the
|
398
|
|
- * information we need to complete the height correction.
|
399
|
|
- */
|
400
|
|
- if (isnan(z0)) z0 = 0.0;
|
401
|
|
-
|
402
|
|
- if (!inf_normalized_flag) {
|
403
|
|
- on_axis_distance = use_x_dist ? rx - start[X_AXIS] : next_mesh_line_y - start[Y_AXIS];
|
404
|
|
- e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
|
405
|
|
- z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
|
406
|
|
- }
|
407
|
|
- else {
|
408
|
|
- e_position = end[E_AXIS];
|
409
|
|
- z_position = end[Z_AXIS];
|
410
|
|
- }
|
411
|
|
- planner._buffer_line(rx, next_mesh_line_y, z_position + z0, e_position, feed_rate, extruder);
|
412
|
|
- current_yi += dyi;
|
413
|
|
- yi_cnt--;
|
414
|
|
- }
|
415
|
|
- else {
|
416
|
|
- // Yes! Crossing a X Mesh Line next
|
417
|
|
- float z0 = z_correction_for_y_on_vertical_mesh_line(ry, current_xi + dxi, current_yi - down_flag)
|
418
|
|
- * planner.fade_scaling_factor_for_z(end[Z_AXIS]);
|
419
|
|
-
|
420
|
|
- /**
|
421
|
|
- * If part of the Mesh is undefined, it will show up as NAN
|
422
|
|
- * in z_values[][] and propagate through the
|
423
|
|
- * calculations. If our correction is NAN, we throw it out
|
424
|
|
- * because part of the Mesh is undefined and we don't have the
|
425
|
|
- * information we need to complete the height correction.
|
426
|
|
- */
|
427
|
|
- if (isnan(z0)) z0 = 0.0;
|
428
|
|
-
|
429
|
|
- if (!inf_normalized_flag) {
|
430
|
|
- on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : ry - start[Y_AXIS];
|
431
|
|
- e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
|
432
|
|
- z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
|
433
|
|
- }
|
434
|
|
- else {
|
435
|
|
- e_position = end[E_AXIS];
|
436
|
|
- z_position = end[Z_AXIS];
|
437
|
|
- }
|
438
|
|
-
|
439
|
|
- planner._buffer_line(next_mesh_line_x, ry, z_position + z0, e_position, feed_rate, extruder);
|
440
|
|
- current_xi += dxi;
|
441
|
|
- xi_cnt--;
|
442
|
|
- }
|
443
|
|
-
|
444
|
|
- if (xi_cnt < 0 || yi_cnt < 0) break; // we've gone too far, so exit the loop and move on to FINAL_MOVE
|
445
|
403
|
}
|
446
|
404
|
|
447
|
|
- if (g26_debug_flag)
|
448
|
|
- debug_current_and_destination(PSTR("generic move done in ubl.line_to_destination()"));
|
449
|
|
-
|
450
|
|
- if (current_position[X_AXIS] != end[X_AXIS] || current_position[Y_AXIS] != end[Y_AXIS])
|
451
|
|
- goto FINAL_MOVE;
|
452
|
|
-
|
453
|
|
- set_current_from_destination();
|
454
|
|
- }
|
455
|
|
-
|
456
|
|
- #if UBL_DELTA
|
457
|
|
-
|
458
|
|
- // macro to inline copy exactly 4 floats, don't rely on sizeof operator
|
459
|
|
- #define COPY_XYZE( target, source ) { \
|
460
|
|
- target[X_AXIS] = source[X_AXIS]; \
|
461
|
|
- target[Y_AXIS] = source[Y_AXIS]; \
|
462
|
|
- target[Z_AXIS] = source[Z_AXIS]; \
|
463
|
|
- target[E_AXIS] = source[E_AXIS]; \
|
464
|
|
- }
|
|
405
|
+ #else // UBL_SEGMENTED
|
465
|
406
|
|
466
|
407
|
#if IS_SCARA // scale the feed rate from mm/s to degrees/s
|
467
|
408
|
static float scara_feed_factor, scara_oldA, scara_oldB;
|
468
|
409
|
#endif
|
469
|
410
|
|
470
|
411
|
// We don't want additional apply_leveling() performed by regular buffer_line or buffer_line_kinematic,
|
471
|
|
- // so we call _buffer_line directly here. Per-segmented leveling and kinematics performed first.
|
|
412
|
+ // so we call buffer_segment directly here. Per-segmented leveling and kinematics performed first.
|
472
|
413
|
|
473
|
|
- inline void _O2 ubl_buffer_segment_raw(const float raw[XYZE], const float &fr) {
|
|
414
|
+ inline void _O2 ubl_buffer_segment_raw(const float (&raw)[XYZE], const float &fr) {
|
474
|
415
|
|
475
|
416
|
#if ENABLED(DELTA) // apply delta inverse_kinematics
|
476
|
417
|
|
477
|
418
|
DELTA_RAW_IK();
|
478
|
|
- planner._buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS], fr, active_extruder);
|
|
419
|
+ planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS], fr, active_extruder);
|
479
|
420
|
|
480
|
421
|
#elif IS_SCARA // apply scara inverse_kinematics (should be changed to save raw->logical->raw)
|
481
|
422
|
|
|
@@ -488,11 +429,11 @@
|
488
|
429
|
scara_oldB = delta[B_AXIS];
|
489
|
430
|
float s_feedrate = max(adiff, bdiff) * scara_feed_factor;
|
490
|
431
|
|
491
|
|
- planner._buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS], s_feedrate, active_extruder);
|
|
432
|
+ planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS], s_feedrate, active_extruder);
|
492
|
433
|
|
493
|
434
|
#else // CARTESIAN
|
494
|
435
|
|
495
|
|
- planner._buffer_line(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS], raw[E_AXIS], fr, active_extruder);
|
|
436
|
+ planner.buffer_segment(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS], raw[E_AXIS], fr, active_extruder);
|
496
|
437
|
|
497
|
438
|
#endif
|
498
|
439
|
}
|
|
@@ -511,15 +452,23 @@
|
511
|
452
|
|
512
|
453
|
/**
|
513
|
454
|
* Prepare a segmented linear move for DELTA/SCARA/CARTESIAN with UBL and FADE semantics.
|
514
|
|
- * This calls planner._buffer_line multiple times for small incremental moves.
|
|
455
|
+ * This calls planner.buffer_segment multiple times for small incremental moves.
|
515
|
456
|
* Returns true if did NOT move, false if moved (requires current_position update).
|
516
|
457
|
*/
|
517
|
458
|
|
518
|
|
- bool _O2 unified_bed_leveling::prepare_segmented_line_to(const float rtarget[XYZE], const float &feedrate) {
|
|
459
|
+ bool _O2 unified_bed_leveling::prepare_segmented_line_to(const float (&in_target)[XYZE], const float &feedrate) {
|
519
|
460
|
|
520
|
|
- if (!position_is_reachable(rtarget[X_AXIS], rtarget[Y_AXIS])) // fail if moving outside reachable boundary
|
|
461
|
+ if (!position_is_reachable(in_target[X_AXIS], in_target[Y_AXIS])) // fail if moving outside reachable boundary
|
521
|
462
|
return true; // did not move, so current_position still accurate
|
522
|
463
|
|
|
464
|
+ #if ENABLED(SKEW_CORRECTION)
|
|
465
|
+ // For skew correction just adjust the destination point and we're done
|
|
466
|
+ float rtarget[XYZE] = { in_target[X_AXIS], in_target[Y_AXIS], in_target[Z_AXIS], in_target[E_AXIS] };
|
|
467
|
+ planner.skew(rtarget[X_AXIS], rtarget[Y_AXIS], rtarget[Z_AXIS]);
|
|
468
|
+ #else
|
|
469
|
+ const float (&rtarget)[XYZE] = in_target;
|
|
470
|
+ #endif
|
|
471
|
+
|
523
|
472
|
const float total[XYZE] = {
|
524
|
473
|
rtarget[X_AXIS] - current_position[X_AXIS],
|
525
|
474
|
rtarget[Y_AXIS] - current_position[Y_AXIS],
|
|
@@ -564,6 +513,10 @@
|
564
|
513
|
current_position[E_AXIS]
|
565
|
514
|
};
|
566
|
515
|
|
|
516
|
+ #if ENABLED(SKEW_CORRECTION)
|
|
517
|
+ planner.skew(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS]);
|
|
518
|
+ #endif
|
|
519
|
+
|
567
|
520
|
// Only compute leveling per segment if ubl active and target below z_fade_height.
|
568
|
521
|
if (!planner.leveling_active || !planner.leveling_active_at_z(rtarget[Z_AXIS])) { // no mesh leveling
|
569
|
522
|
while (--segments) {
|
|
@@ -670,6 +623,6 @@
|
670
|
623
|
} // cell loop
|
671
|
624
|
}
|
672
|
625
|
|
673
|
|
- #endif // UBL_DELTA
|
|
626
|
+ #endif // UBL_SEGMENTED
|
674
|
627
|
|
675
|
628
|
#endif // AUTO_BED_LEVELING_UBL
|