Browse Source

Fix auto bed leveling - turn on after successful G29

Scott Lahteine 8 years ago
parent
commit
e0e0166075
1 changed files with 16 additions and 14 deletions
  1. 16
    14
      Marlin/Marlin_main.cpp

+ 16
- 14
Marlin/Marlin_main.cpp View File

@@ -3516,7 +3516,7 @@ inline void gcode_G28() {
3516 3516
     stepper.synchronize();
3517 3517
 
3518 3518
     // Disable auto bed leveling during G29
3519
-    bool abl_should_reenable = planner.abl_enabled;
3519
+    bool abl_should_enable = planner.abl_enabled;
3520 3520
 
3521 3521
     planner.abl_enabled = false;
3522 3522
 
@@ -3534,7 +3534,7 @@ inline void gcode_G28() {
3534 3534
 
3535 3535
     // Deploy the probe. Probe will raise if needed.
3536 3536
     if (DEPLOY_PROBE()) {
3537
-      planner.abl_enabled = abl_should_reenable;
3537
+      planner.abl_enabled = abl_should_enable;
3538 3538
       return;
3539 3539
     }
3540 3540
 
@@ -3555,7 +3555,7 @@ inline void gcode_G28() {
3555 3555
           bilinear_grid_spacing[X_AXIS] = xGridSpacing;
3556 3556
           bilinear_grid_spacing[Y_AXIS] = yGridSpacing;
3557 3557
           // Can't re-enable (on error) until the new grid is written
3558
-          abl_should_reenable = false;
3558
+          abl_should_enable = false;
3559 3559
         }
3560 3560
 
3561 3561
       #elif ENABLED(AUTO_BED_LEVELING_LINEAR)
@@ -3617,7 +3617,7 @@ inline void gcode_G28() {
3617 3617
           measured_z = probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
3618 3618
 
3619 3619
           if (measured_z == NAN) {
3620
-            planner.abl_enabled = abl_should_reenable;
3620
+            planner.abl_enabled = abl_should_enable;
3621 3621
             return;
3622 3622
           }
3623 3623
 
@@ -3661,7 +3661,7 @@ inline void gcode_G28() {
3661 3661
       }
3662 3662
 
3663 3663
       if (measured_z == NAN) {
3664
-        planner.abl_enabled = abl_should_reenable;
3664
+        planner.abl_enabled = abl_should_enable;
3665 3665
         return;
3666 3666
       }
3667 3667
 
@@ -3675,14 +3675,14 @@ inline void gcode_G28() {
3675 3675
         planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
3676 3676
 
3677 3677
         // Can't re-enable (on error) until the new grid is written
3678
-        abl_should_reenable = false;
3678
+        abl_should_enable = false;
3679 3679
       }
3680 3680
 
3681 3681
     #endif // AUTO_BED_LEVELING_3POINT
3682 3682
 
3683 3683
     // Raise to _Z_CLEARANCE_DEPLOY_PROBE. Stow the probe.
3684 3684
     if (STOW_PROBE()) {
3685
-      planner.abl_enabled = abl_should_reenable;
3685
+      planner.abl_enabled = abl_should_enable;
3686 3686
       return;
3687 3687
     }
3688 3688
 
@@ -3855,27 +3855,29 @@ inline void gcode_G28() {
3855 3855
         current_position[Y_AXIS] = LOGICAL_Y_POSITION(y_dist) + Y_TILT_FULCRUM;
3856 3856
         current_position[Z_AXIS] = new_z;
3857 3857
 
3858
-        SYNC_PLAN_POSITION_KINEMATIC();
3859
-
3860 3858
         #if ENABLED(DEBUG_LEVELING_FEATURE)
3861 3859
           if (DEBUGGING(LEVELING)) DEBUG_POS("G29 corrected XYZ", current_position);
3862 3860
         #endif
3861
+
3862
+        SYNC_PLAN_POSITION_KINEMATIC();
3863
+        abl_should_enable = true;
3863 3864
       }
3864 3865
 
3865 3866
     #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
3866 3867
 
3867 3868
       if (!dryrun) {
3868 3869
         #if ENABLED(DEBUG_LEVELING_FEATURE)
3869
-          if (DEBUGGING(LEVELING)) SERIAL_ECHOPAIR("G29 uncorrected Z:", current_position[Z_AXIS]);
3870
+          if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("G29 uncorrected Z:", current_position[Z_AXIS]);
3870 3871
         #endif
3871 3872
 
3872 3873
         current_position[Z_AXIS] -= bilinear_z_offset(current_position);
3873 3874
 
3874
-        SYNC_PLAN_POSITION_KINEMATIC();
3875
-
3876 3875
         #if ENABLED(DEBUG_LEVELING_FEATURE)
3877
-          if (DEBUGGING(LEVELING)) SERIAL_ECHOPAIR("G29 corrected Z:", current_position[Z_AXIS]);
3876
+          if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR(" corrected Z:", current_position[Z_AXIS]);
3878 3877
         #endif
3878
+
3879
+        SYNC_PLAN_POSITION_KINEMATIC();
3880
+        abl_should_enable = true;
3879 3881
       }
3880 3882
 
3881 3883
     #endif // ABL_PLANAR
@@ -3897,7 +3899,7 @@ inline void gcode_G28() {
3897 3899
     KEEPALIVE_STATE(IN_HANDLER);
3898 3900
 
3899 3901
     // Auto Bed Leveling is complete! Enable if possible.
3900
-    planner.abl_enabled = dryrun ? abl_should_reenable : true;
3902
+    planner.abl_enabled = dryrun ? abl_should_enable : true;
3901 3903
   }
3902 3904
 
3903 3905
 #endif // HAS_ABL

Loading…
Cancel
Save