|
@@ -74,14 +74,18 @@
|
74
|
74
|
#endif
|
75
|
75
|
#endif
|
76
|
76
|
|
|
77
|
+static void pre_g29_return(const bool retry, const bool did) {
|
|
78
|
+ if (!retry) {
|
|
79
|
+ TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE, false));
|
|
80
|
+ }
|
|
81
|
+ if (did) {
|
|
82
|
+ TERN_(HAS_DWIN_E3V2_BASIC, DWIN_LevelingDone());
|
|
83
|
+ TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
|
|
84
|
+ }
|
|
85
|
+}
|
|
86
|
+
|
77
|
87
|
#define G29_RETURN(retry, did) do{ \
|
78
|
|
- if (TERN(G29_RETRY_AND_RECOVER, !retry, true)) { \
|
79
|
|
- TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE, false)); \
|
80
|
|
- } \
|
81
|
|
- if (did) { \
|
82
|
|
- TERN_(HAS_DWIN_E3V2_BASIC, DWIN_LevelingDone()); \
|
83
|
|
- TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); \
|
84
|
|
- } \
|
|
88
|
+ pre_g29_return(TERN0(G29_RETRY_AND_RECOVER, retry), did); \
|
85
|
89
|
return TERN_(G29_RETRY_AND_RECOVER, retry); \
|
86
|
90
|
}while(0)
|
87
|
91
|
|
|
@@ -326,8 +330,10 @@ G29_TYPE GcodeSuite::G29() {
|
326
|
330
|
bedlevel.z_values[i][j] = rz;
|
327
|
331
|
bedlevel.refresh_bed_level();
|
328
|
332
|
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(i, j, rz));
|
329
|
|
- set_bed_leveling_enabled(abl.reenable);
|
330
|
|
- if (abl.reenable) report_current_position();
|
|
333
|
+ if (abl.reenable) {
|
|
334
|
+ set_bed_leveling_enabled(true);
|
|
335
|
+ report_current_position();
|
|
336
|
+ }
|
331
|
337
|
}
|
332
|
338
|
G29_RETURN(false, false);
|
333
|
339
|
} // parser.seen_test('W')
|
|
@@ -729,7 +735,7 @@ G29_TYPE GcodeSuite::G29() {
|
729
|
735
|
|
730
|
736
|
#endif
|
731
|
737
|
|
732
|
|
- abl.reenable = false;
|
|
738
|
+ abl.reenable = false; // Don't re-enable after modifying the mesh
|
733
|
739
|
idle_no_sleep();
|
734
|
740
|
|
735
|
741
|
} // inner
|
|
@@ -914,33 +920,28 @@ G29_TYPE GcodeSuite::G29() {
|
914
|
920
|
current_position = converted;
|
915
|
921
|
|
916
|
922
|
if (DEBUGGING(LEVELING)) DEBUG_POS("G29 corrected XYZ", current_position);
|
917
|
|
- }
|
918
|
923
|
|
919
|
|
- #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
|
924
|
+ abl.reenable = true;
|
|
925
|
+ }
|
920
|
926
|
|
921
|
|
- if (!abl.dryrun) {
|
922
|
|
- if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("G29 uncorrected Z:", current_position.z);
|
|
927
|
+ // Auto Bed Leveling is complete! Enable if possible.
|
|
928
|
+ if (abl.reenable) {
|
|
929
|
+ planner.leveling_active = true;
|
|
930
|
+ sync_plan_position();
|
|
931
|
+ }
|
923
|
932
|
|
924
|
|
- // Unapply the offset because it is going to be immediately applied
|
925
|
|
- // and cause compensation movement in Z
|
926
|
|
- current_position.z -= bedlevel.get_z_correction(current_position)
|
927
|
|
- TERN_(ENABLE_LEVELING_FADE_HEIGHT, * planner.fade_scaling_factor_for_z(current_position.z));
|
|
933
|
+ #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
928
|
934
|
|
929
|
|
- if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM(" corrected Z:", current_position.z);
|
930
|
|
- }
|
|
935
|
+ // Auto Bed Leveling is complete! Enable if possible.
|
|
936
|
+ if (!abl.dryrun || abl.reenable) set_bed_leveling_enabled(true);
|
931
|
937
|
|
932
|
|
- #endif // ABL_PLANAR
|
|
938
|
+ #endif
|
933
|
939
|
|
934
|
|
- // Auto Bed Leveling is complete! Enable if possible.
|
935
|
|
- planner.leveling_active = !abl.dryrun || abl.reenable;
|
936
|
940
|
} // !isnan(abl.measured_z)
|
937
|
941
|
|
938
|
942
|
// Restore state after probing
|
939
|
943
|
if (!faux) restore_feedrate_and_scaling();
|
940
|
944
|
|
941
|
|
- // Sync the planner from the current_position
|
942
|
|
- if (planner.leveling_active) sync_plan_position();
|
943
|
|
-
|
944
|
945
|
TERN_(HAS_BED_PROBE, probe.move_z_after_probing());
|
945
|
946
|
|
946
|
947
|
#ifdef Z_PROBE_END_SCRIPT
|