|
@@ -400,7 +400,6 @@ static uint8_t target_extruder;
|
400
|
400
|
|
401
|
401
|
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
|
402
|
402
|
float xy_probe_feedrate_mm_s = MMM_TO_MMS(XY_PROBE_SPEED);
|
403
|
|
- bool bed_leveling_in_progress = false;
|
404
|
403
|
#define XY_PROBE_FEEDRATE_MM_S xy_probe_feedrate_mm_s
|
405
|
404
|
#elif defined(XY_PROBE_SPEED)
|
406
|
405
|
#define XY_PROBE_FEEDRATE_MM_S MMM_TO_MMS(XY_PROBE_SPEED)
|
|
@@ -3434,8 +3433,6 @@ inline void gcode_G28() {
|
3434
|
3433
|
// Deploy the probe. Probe will raise if needed.
|
3435
|
3434
|
if (DEPLOY_PROBE()) return;
|
3436
|
3435
|
|
3437
|
|
- bed_leveling_in_progress = true;
|
3438
|
|
-
|
3439
|
3436
|
float xProbe, yProbe, measured_z = 0;
|
3440
|
3437
|
|
3441
|
3438
|
#if ENABLED(AUTO_BED_LEVELING_GRID)
|
|
@@ -3576,6 +3573,8 @@ inline void gcode_G28() {
|
3576
|
3573
|
|
3577
|
3574
|
#elif ENABLED(AUTO_BED_LEVELING_LINEAR)
|
3578
|
3575
|
|
|
3576
|
+ // For LINEAR leveling calculate matrix, print reports, correct the position
|
|
3577
|
+
|
3579
|
3578
|
// solve lsq problem
|
3580
|
3579
|
double plane_equation_coefficients[3];
|
3581
|
3580
|
qr_solve(plane_equation_coefficients, abl2, 3, eqnAMatrix, eqnBVector);
|
|
@@ -3669,6 +3668,8 @@ inline void gcode_G28() {
|
3669
|
3668
|
}
|
3670
|
3669
|
} //do_topography_map
|
3671
|
3670
|
|
|
3671
|
+ // For LINEAR and 3POINT leveling correct the current position
|
|
3672
|
+
|
3672
|
3673
|
if (verbose_level > 0)
|
3673
|
3674
|
planner.bed_level_matrix.debug("\n\nBed Level Correction Matrix:");
|
3674
|
3675
|
|
|
@@ -3738,8 +3739,6 @@ inline void gcode_G28() {
|
3738
|
3739
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G29");
|
3739
|
3740
|
#endif
|
3740
|
3741
|
|
3741
|
|
- bed_leveling_in_progress = false;
|
3742
|
|
-
|
3743
|
3742
|
report_current_position();
|
3744
|
3743
|
|
3745
|
3744
|
KEEPALIVE_STATE(IN_HANDLER);
|
|
@@ -7638,6 +7637,48 @@ void ok_to_send() {
|
7638
|
7637
|
|
7639
|
7638
|
#endif
|
7640
|
7639
|
|
|
7640
|
+#if ENABLED(AUTO_BED_LEVELING_NONLINEAR)
|
|
7641
|
+
|
|
7642
|
+ // Get the Z adjustment for non-linear bed leveling
|
|
7643
|
+ float nonlinear_z_offset(float cartesian[XYZ]) {
|
|
7644
|
+ if (nonlinear_grid_spacing[X_AXIS] == 0 || nonlinear_grid_spacing[Y_AXIS] == 0) return 0; // G29 not done!
|
|
7645
|
+
|
|
7646
|
+ int half_x = (ABL_GRID_POINTS_X - 1) / 2,
|
|
7647
|
+ half_y = (ABL_GRID_POINTS_Y - 1) / 2;
|
|
7648
|
+ float hx2 = half_x - 0.001, hx1 = -hx2,
|
|
7649
|
+ hy2 = half_y - 0.001, hy1 = -hy2,
|
|
7650
|
+ grid_x = max(hx1, min(hx2, RAW_X_POSITION(cartesian[X_AXIS]) / nonlinear_grid_spacing[X_AXIS])),
|
|
7651
|
+ grid_y = max(hy1, min(hy2, RAW_Y_POSITION(cartesian[Y_AXIS]) / nonlinear_grid_spacing[Y_AXIS]));
|
|
7652
|
+ int floor_x = floor(grid_x), floor_y = floor(grid_y);
|
|
7653
|
+ float ratio_x = grid_x - floor_x, ratio_y = grid_y - floor_y,
|
|
7654
|
+ z1 = bed_level_grid[floor_x + half_x][floor_y + half_y],
|
|
7655
|
+ z2 = bed_level_grid[floor_x + half_x][floor_y + half_y + 1],
|
|
7656
|
+ z3 = bed_level_grid[floor_x + half_x + 1][floor_y + half_y],
|
|
7657
|
+ z4 = bed_level_grid[floor_x + half_x + 1][floor_y + half_y + 1],
|
|
7658
|
+ left = (1 - ratio_y) * z1 + ratio_y * z2,
|
|
7659
|
+ right = (1 - ratio_y) * z3 + ratio_y * z4;
|
|
7660
|
+
|
|
7661
|
+ /*
|
|
7662
|
+ SERIAL_ECHOPAIR("grid_x=", grid_x);
|
|
7663
|
+ SERIAL_ECHOPAIR(" grid_y=", grid_y);
|
|
7664
|
+ SERIAL_ECHOPAIR(" floor_x=", floor_x);
|
|
7665
|
+ SERIAL_ECHOPAIR(" floor_y=", floor_y);
|
|
7666
|
+ SERIAL_ECHOPAIR(" ratio_x=", ratio_x);
|
|
7667
|
+ SERIAL_ECHOPAIR(" ratio_y=", ratio_y);
|
|
7668
|
+ SERIAL_ECHOPAIR(" z1=", z1);
|
|
7669
|
+ SERIAL_ECHOPAIR(" z2=", z2);
|
|
7670
|
+ SERIAL_ECHOPAIR(" z3=", z3);
|
|
7671
|
+ SERIAL_ECHOPAIR(" z4=", z4);
|
|
7672
|
+ SERIAL_ECHOPAIR(" left=", left);
|
|
7673
|
+ SERIAL_ECHOPAIR(" right=", right);
|
|
7674
|
+ SERIAL_ECHOPAIR(" offset=", (1 - ratio_x) * left + ratio_x * right);
|
|
7675
|
+ //*/
|
|
7676
|
+
|
|
7677
|
+ return (1 - ratio_x) * left + ratio_x * right;
|
|
7678
|
+ }
|
|
7679
|
+
|
|
7680
|
+#endif // AUTO_BED_LEVELING_NONLINEAR
|
|
7681
|
+
|
7641
|
7682
|
#if ENABLED(DELTA)
|
7642
|
7683
|
|
7643
|
7684
|
/**
|
|
@@ -7828,50 +7869,6 @@ void ok_to_send() {
|
7828
|
7869
|
forward_kinematics_DELTA(point[A_AXIS], point[B_AXIS], point[C_AXIS]);
|
7829
|
7870
|
}
|
7830
|
7871
|
|
7831
|
|
- #if ENABLED(AUTO_BED_LEVELING_NONLINEAR)
|
7832
|
|
-
|
7833
|
|
- // Adjust print surface height by linear interpolation over the bed_level array.
|
7834
|
|
- void adjust_delta(float cartesian[XYZ]) {
|
7835
|
|
- if (nonlinear_grid_spacing[X_AXIS] == 0 || nonlinear_grid_spacing[Y_AXIS] == 0) return; // G29 not done!
|
7836
|
|
-
|
7837
|
|
- int half_x = (ABL_GRID_POINTS_X - 1) / 2,
|
7838
|
|
- half_y = (ABL_GRID_POINTS_Y - 1) / 2;
|
7839
|
|
- float hx2 = half_x - 0.001, hx1 = -hx2,
|
7840
|
|
- hy2 = half_y - 0.001, hy1 = -hy2,
|
7841
|
|
- grid_x = max(hx1, min(hx2, RAW_X_POSITION(cartesian[X_AXIS]) / nonlinear_grid_spacing[X_AXIS])),
|
7842
|
|
- grid_y = max(hy1, min(hy2, RAW_Y_POSITION(cartesian[Y_AXIS]) / nonlinear_grid_spacing[Y_AXIS]));
|
7843
|
|
- int floor_x = floor(grid_x), floor_y = floor(grid_y);
|
7844
|
|
- float ratio_x = grid_x - floor_x, ratio_y = grid_y - floor_y,
|
7845
|
|
- z1 = bed_level_grid[floor_x + half_x][floor_y + half_y],
|
7846
|
|
- z2 = bed_level_grid[floor_x + half_x][floor_y + half_y + 1],
|
7847
|
|
- z3 = bed_level_grid[floor_x + half_x + 1][floor_y + half_y],
|
7848
|
|
- z4 = bed_level_grid[floor_x + half_x + 1][floor_y + half_y + 1],
|
7849
|
|
- left = (1 - ratio_y) * z1 + ratio_y * z2,
|
7850
|
|
- right = (1 - ratio_y) * z3 + ratio_y * z4,
|
7851
|
|
- offset = (1 - ratio_x) * left + ratio_x * right;
|
7852
|
|
-
|
7853
|
|
- delta[X_AXIS] += offset;
|
7854
|
|
- delta[Y_AXIS] += offset;
|
7855
|
|
- delta[Z_AXIS] += offset;
|
7856
|
|
-
|
7857
|
|
- /**
|
7858
|
|
- SERIAL_ECHOPAIR("grid_x=", grid_x);
|
7859
|
|
- SERIAL_ECHOPAIR(" grid_y=", grid_y);
|
7860
|
|
- SERIAL_ECHOPAIR(" floor_x=", floor_x);
|
7861
|
|
- SERIAL_ECHOPAIR(" floor_y=", floor_y);
|
7862
|
|
- SERIAL_ECHOPAIR(" ratio_x=", ratio_x);
|
7863
|
|
- SERIAL_ECHOPAIR(" ratio_y=", ratio_y);
|
7864
|
|
- SERIAL_ECHOPAIR(" z1=", z1);
|
7865
|
|
- SERIAL_ECHOPAIR(" z2=", z2);
|
7866
|
|
- SERIAL_ECHOPAIR(" z3=", z3);
|
7867
|
|
- SERIAL_ECHOPAIR(" z4=", z4);
|
7868
|
|
- SERIAL_ECHOPAIR(" left=", left);
|
7869
|
|
- SERIAL_ECHOPAIR(" right=", right);
|
7870
|
|
- SERIAL_ECHOLNPAIR(" offset=", offset);
|
7871
|
|
- */
|
7872
|
|
- }
|
7873
|
|
- #endif // AUTO_BED_LEVELING_NONLINEAR
|
7874
|
|
-
|
7875
|
7872
|
#endif // DELTA
|
7876
|
7873
|
|
7877
|
7874
|
/**
|
|
@@ -8018,10 +8015,6 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
|
8018
|
8015
|
|
8019
|
8016
|
inverse_kinematics(logical);
|
8020
|
8017
|
|
8021
|
|
- #if ENABLED(DELTA) && ENABLED(AUTO_BED_LEVELING_NONLINEAR)
|
8022
|
|
- if (!bed_leveling_in_progress) adjust_delta(logical);
|
8023
|
|
- #endif
|
8024
|
|
-
|
8025
|
8018
|
//DEBUG_POS("prepare_kinematic_move_to", logical);
|
8026
|
8019
|
//DEBUG_POS("prepare_kinematic_move_to", delta);
|
8027
|
8020
|
|
|
@@ -8272,9 +8265,6 @@ void prepare_move_to_destination() {
|
8272
|
8265
|
|
8273
|
8266
|
#if IS_KINEMATIC
|
8274
|
8267
|
inverse_kinematics(arc_target);
|
8275
|
|
- #if ENABLED(DELTA) && ENABLED(AUTO_BED_LEVELING_NONLINEAR)
|
8276
|
|
- adjust_delta(arc_target);
|
8277
|
|
- #endif
|
8278
|
8268
|
planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], arc_target[E_AXIS], fr_mm_s, active_extruder);
|
8279
|
8269
|
#else
|
8280
|
8270
|
planner.buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], arc_target[E_AXIS], fr_mm_s, active_extruder);
|
|
@@ -8284,9 +8274,6 @@ void prepare_move_to_destination() {
|
8284
|
8274
|
// Ensure last segment arrives at target location.
|
8285
|
8275
|
#if IS_KINEMATIC
|
8286
|
8276
|
inverse_kinematics(logical);
|
8287
|
|
- #if ENABLED(DELTA) && ENABLED(AUTO_BED_LEVELING_NONLINEAR)
|
8288
|
|
- adjust_delta(logical);
|
8289
|
|
- #endif
|
8290
|
8277
|
planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], logical[E_AXIS], fr_mm_s, active_extruder);
|
8291
|
8278
|
#else
|
8292
|
8279
|
planner.buffer_line(logical[X_AXIS], logical[Y_AXIS], logical[Z_AXIS], logical[E_AXIS], fr_mm_s, active_extruder);
|