|
@@ -2119,8 +2119,13 @@ static void clean_up_after_endstop_or_probe_move() {
|
2119
|
2119
|
|
2120
|
2120
|
|
2121
|
2121
|
* Reset calibration results to zero.
|
|
2122
|
+ *
|
|
2123
|
+ * TODO: Proper functions to disable / enable
|
|
2124
|
+ * bed leveling via a flag, correcting the
|
|
2125
|
+ * current position in each case.
|
2122
|
2126
|
*/
|
2123
|
2127
|
void reset_bed_level() {
|
|
2128
|
+ planner.abl_enabled = false;
|
2124
|
2129
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2125
|
2130
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("reset_bed_level");
|
2126
|
2131
|
#endif
|
|
@@ -2128,7 +2133,6 @@ static void clean_up_after_endstop_or_probe_move() {
|
2128
|
2133
|
planner.bed_level_matrix.set_to_identity();
|
2129
|
2134
|
#elif ENABLED(AUTO_BED_LEVELING_NONLINEAR)
|
2130
|
2135
|
memset(bed_level_grid, 0, sizeof(bed_level_grid));
|
2131
|
|
- nonlinear_grid_spacing[X_AXIS] = nonlinear_grid_spacing[Y_AXIS] = 0;
|
2132
|
2136
|
#endif
|
2133
|
2137
|
}
|
2134
|
2138
|
|
|
@@ -3505,16 +3509,15 @@ inline void gcode_G28() {
|
3505
|
3509
|
|
3506
|
3510
|
stepper.synchronize();
|
3507
|
3511
|
|
3508
|
|
- if (!dryrun) {
|
|
3512
|
+
|
|
3513
|
+ bool auto_bed_leveling_was_enabled = planner.abl_enabled,
|
|
3514
|
+ abl_should_reenable = auto_bed_leveling_was_enabled;
|
3509
|
3515
|
|
3510
|
|
-
|
3511
|
|
-
|
3512
|
|
- reset_bed_level();
|
|
3516
|
+ planner.abl_enabled = false;
|
3513
|
3517
|
|
3514
|
|
-
|
|
3518
|
+ if (!dryrun) {
|
3515
|
3519
|
|
3516
|
3520
|
|
3517
|
|
-
|
3518
|
3521
|
get_cartesian_from_steppers();
|
3519
|
3522
|
memcpy(current_position, cartes, sizeof(cartes));
|
3520
|
3523
|
|
|
@@ -3525,7 +3528,10 @@ inline void gcode_G28() {
|
3525
|
3528
|
setup_for_endstop_or_probe_move();
|
3526
|
3529
|
|
3527
|
3530
|
|
3528
|
|
- if (DEPLOY_PROBE()) return;
|
|
3531
|
+ if (DEPLOY_PROBE()) {
|
|
3532
|
+ planner.abl_enabled = abl_should_reenable;
|
|
3533
|
+ return;
|
|
3534
|
+ }
|
3529
|
3535
|
|
3530
|
3536
|
float xProbe = 0, yProbe = 0, measured_z = 0;
|
3531
|
3537
|
|
|
@@ -3537,11 +3543,16 @@ inline void gcode_G28() {
|
3537
|
3543
|
|
3538
|
3544
|
#if ENABLED(AUTO_BED_LEVELING_NONLINEAR)
|
3539
|
3545
|
|
3540
|
|
- nonlinear_grid_spacing[X_AXIS] = xGridSpacing;
|
3541
|
|
- nonlinear_grid_spacing[Y_AXIS] = yGridSpacing;
|
3542
|
3546
|
float zoffset = zprobe_zoffset;
|
3543
|
3547
|
if (code_seen('Z')) zoffset += code_value_axis_units(Z_AXIS);
|
3544
|
3548
|
|
|
3549
|
+ if (xGridSpacing != nonlinear_grid_spacing[X_AXIS] || yGridSpacing != nonlinear_grid_spacing[Y_AXIS]) {
|
|
3550
|
+ nonlinear_grid_spacing[X_AXIS] = xGridSpacing;
|
|
3551
|
+ nonlinear_grid_spacing[Y_AXIS] = yGridSpacing;
|
|
3552
|
+
|
|
3553
|
+ abl_should_reenable = false;
|
|
3554
|
+ }
|
|
3555
|
+
|
3545
|
3556
|
#elif ENABLED(AUTO_BED_LEVELING_LINEAR_GRID)
|
3546
|
3557
|
|
3547
|
3558
|
|
|
@@ -3600,6 +3611,11 @@ inline void gcode_G28() {
|
3600
|
3611
|
|
3601
|
3612
|
measured_z = probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
|
3602
|
3613
|
|
|
3614
|
+ if (measured_z == NAN) {
|
|
3615
|
+ planner.abl_enabled = abl_should_reenable;
|
|
3616
|
+ return;
|
|
3617
|
+ }
|
|
3618
|
+
|
3603
|
3619
|
#if ENABLED(AUTO_BED_LEVELING_LINEAR_GRID)
|
3604
|
3620
|
|
3605
|
3621
|
mean += measured_z;
|
|
@@ -3639,6 +3655,11 @@ inline void gcode_G28() {
|
3639
|
3655
|
measured_z = points[i].z = probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
|
3640
|
3656
|
}
|
3641
|
3657
|
|
|
3658
|
+ if (measured_z == NAN) {
|
|
3659
|
+ planner.abl_enabled = abl_should_reenable;
|
|
3660
|
+ return;
|
|
3661
|
+ }
|
|
3662
|
+
|
3642
|
3663
|
if (!dryrun) {
|
3643
|
3664
|
vector_3 planeNormal = vector_3::cross(points[0] - points[1], points[2] - points[1]).get_normal();
|
3644
|
3665
|
if (planeNormal.z < 0) {
|
|
@@ -3647,12 +3668,23 @@ inline void gcode_G28() {
|
3647
|
3668
|
planeNormal.z *= -1;
|
3648
|
3669
|
}
|
3649
|
3670
|
planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
|
|
3671
|
+
|
|
3672
|
+
|
|
3673
|
+ abl_should_reenable = false;
|
3650
|
3674
|
}
|
3651
|
3675
|
|
3652
|
3676
|
#endif
|
3653
|
3677
|
|
3654
|
3678
|
|
3655
|
|
- if (STOW_PROBE()) return;
|
|
3679
|
+ if (STOW_PROBE()) {
|
|
3680
|
+ planner.abl_enabled = abl_should_reenable;
|
|
3681
|
+ return;
|
|
3682
|
+ }
|
|
3683
|
+
|
|
3684
|
+
|
|
3685
|
+
|
|
3686
|
+
|
|
3687
|
+
|
3656
|
3688
|
|
3657
|
3689
|
|
3658
|
3690
|
clean_up_after_endstop_or_probe_move();
|
|
@@ -3842,6 +3874,9 @@ inline void gcode_G28() {
|
3842
|
3874
|
report_current_position();
|
3843
|
3875
|
|
3844
|
3876
|
KEEPALIVE_STATE(IN_HANDLER);
|
|
3877
|
+
|
|
3878
|
+
|
|
3879
|
+ planner.abl_enabled = dryrun ? abl_should_reenable : true;
|
3845
|
3880
|
}
|
3846
|
3881
|
|
3847
|
3882
|
#endif
|
|
@@ -7738,7 +7773,7 @@ void ok_to_send() {
|
7738
|
7773
|
|
7739
|
7774
|
|
7740
|
7775
|
float nonlinear_z_offset(float cartesian[XYZ]) {
|
7741
|
|
- if (nonlinear_grid_spacing[X_AXIS] == 0 || nonlinear_grid_spacing[Y_AXIS] == 0) return 0;
|
|
7776
|
+ if (planner.abl_enabled) return;
|
7742
|
7777
|
|
7743
|
7778
|
int half_x = (ABL_GRID_POINTS_X - 1) / 2,
|
7744
|
7779
|
half_y = (ABL_GRID_POINTS_Y - 1) / 2;
|