|
@@ -41,6 +41,10 @@
|
41
|
41
|
|
42
|
42
|
#define SERVO_LEVELING defined(ENABLE_AUTO_BED_LEVELING) && PROBE_SERVO_DEACTIVATION_DELAY > 0
|
43
|
43
|
|
|
44
|
+#if defined(MESH_BED_LEVELING)
|
|
45
|
+ #include "mesh_bed_leveling.h"
|
|
46
|
+#endif // MESH_BED_LEVELING
|
|
47
|
+
|
44
|
48
|
#include "ultralcd.h"
|
45
|
49
|
#include "planner.h"
|
46
|
50
|
#include "stepper.h"
|
|
@@ -4987,6 +4991,65 @@ void calculate_delta(float cartesian[3])
|
4987
|
4991
|
}
|
4988
|
4992
|
#endif
|
4989
|
4993
|
|
|
4994
|
+#if defined(MESH_BED_LEVELING)
|
|
4995
|
+#if !defined(MIN)
|
|
4996
|
+#define MIN(_v1, _v2) (((_v1) < (_v2)) ? (_v1) : (_v2))
|
|
4997
|
+#endif // ! MIN
|
|
4998
|
+// This function is used to split lines on mesh borders so each segment is only part of one mesh area
|
|
4999
|
+void mesh_plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder, uint8_t x_splits=0xff, uint8_t y_splits=0xff)
|
|
5000
|
+{
|
|
5001
|
+ int pix = mbl.select_x_index(current_position[X_AXIS]);
|
|
5002
|
+ int piy = mbl.select_y_index(current_position[Y_AXIS]);
|
|
5003
|
+ int ix = mbl.select_x_index(x);
|
|
5004
|
+ int iy = mbl.select_y_index(y);
|
|
5005
|
+ pix = MIN(pix, MESH_NUM_X_POINTS-2);
|
|
5006
|
+ piy = MIN(piy, MESH_NUM_Y_POINTS-2);
|
|
5007
|
+ ix = MIN(ix, MESH_NUM_X_POINTS-2);
|
|
5008
|
+ iy = MIN(iy, MESH_NUM_Y_POINTS-2);
|
|
5009
|
+ if (ix > pix && (x_splits)&(1<<ix)) {
|
|
5010
|
+ float nx = mbl.get_x(ix);
|
|
5011
|
+ float normalized_dist = (nx - current_position[X_AXIS])/(x - current_position[X_AXIS]);
|
|
5012
|
+ float ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
|
|
5013
|
+ float ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
|
|
5014
|
+ x_splits ^= 1 << ix;
|
|
5015
|
+ mesh_plan_buffer_line(nx, ny, z, ne, feed_rate, extruder, x_splits, y_splits);
|
|
5016
|
+ mesh_plan_buffer_line(x, y, z, e, feed_rate, extruder, x_splits, y_splits);
|
|
5017
|
+ return;
|
|
5018
|
+ } else if (ix < pix && (x_splits)&(1<<pix)) {
|
|
5019
|
+ float nx = mbl.get_x(pix);
|
|
5020
|
+ float normalized_dist = (nx - current_position[X_AXIS])/(x - current_position[X_AXIS]);
|
|
5021
|
+ float ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
|
|
5022
|
+ float ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
|
|
5023
|
+ x_splits ^= 1 << pix;
|
|
5024
|
+ mesh_plan_buffer_line(nx, ny, z, ne, feed_rate, extruder, x_splits, y_splits);
|
|
5025
|
+ mesh_plan_buffer_line(x, y, z, e, feed_rate, extruder, x_splits, y_splits);
|
|
5026
|
+ return;
|
|
5027
|
+ } else if (iy > piy && (y_splits)&(1<<iy)) {
|
|
5028
|
+ float ny = mbl.get_y(iy);
|
|
5029
|
+ float normalized_dist = (ny - current_position[Y_AXIS])/(y - current_position[Y_AXIS]);
|
|
5030
|
+ float nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
|
|
5031
|
+ float ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
|
|
5032
|
+ y_splits ^= 1 << iy;
|
|
5033
|
+ mesh_plan_buffer_line(nx, ny, z, ne, feed_rate, extruder, x_splits, y_splits);
|
|
5034
|
+ mesh_plan_buffer_line(x, y, z, e, feed_rate, extruder, x_splits, y_splits);
|
|
5035
|
+ return;
|
|
5036
|
+ } else if (iy < piy && (y_splits)&(1<<piy)) {
|
|
5037
|
+ float ny = mbl.get_y(piy);
|
|
5038
|
+ float normalized_dist = (ny - current_position[Y_AXIS])/(y - current_position[Y_AXIS]);
|
|
5039
|
+ float nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
|
|
5040
|
+ float ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
|
|
5041
|
+ y_splits ^= 1 << piy;
|
|
5042
|
+ mesh_plan_buffer_line(nx, ny, z, ne, feed_rate, extruder, x_splits, y_splits);
|
|
5043
|
+ mesh_plan_buffer_line(x, y, z, e, feed_rate, extruder, x_splits, y_splits);
|
|
5044
|
+ return;
|
|
5045
|
+ }
|
|
5046
|
+ plan_buffer_line(x, y, z, e, feedrate, extruder);
|
|
5047
|
+ for(int8_t i=0; i < NUM_AXIS; i++) {
|
|
5048
|
+ current_position[i] = destination[i];
|
|
5049
|
+ }
|
|
5050
|
+}
|
|
5051
|
+#endif // MESH_BED_LEVELING
|
|
5052
|
+
|
4990
|
5053
|
void prepare_move()
|
4991
|
5054
|
{
|
4992
|
5055
|
clamp_to_software_endstops(destination);
|
|
@@ -5102,10 +5165,14 @@ for (int s = 1; s <= steps; s++) {
|
5102
|
5165
|
#if ! (defined DELTA || defined SCARA)
|
5103
|
5166
|
// Do not use feedmultiply for E or Z only moves
|
5104
|
5167
|
if( (current_position[X_AXIS] == destination [X_AXIS]) && (current_position[Y_AXIS] == destination [Y_AXIS])) {
|
5105
|
|
- plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
5106
|
|
- }
|
5107
|
|
- else {
|
|
5168
|
+ plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
|
5169
|
+ } else {
|
|
5170
|
+#if defined(MESH_BED_LEVELING)
|
|
5171
|
+ mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
|
|
5172
|
+ return;
|
|
5173
|
+#else
|
5108
|
5174
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
|
|
5175
|
+#endif // MESH_BED_LEVELING
|
5109
|
5176
|
}
|
5110
|
5177
|
#endif // !(DELTA || SCARA)
|
5111
|
5178
|
|