🚸 More ExtUI events for ABL / UBL

This commit is contained in:
Scott Lahteine 2022-04-22 01:12:43 -05:00 committed by Scott Lahteine
parent 7444933d5d
commit 4bdec5e993
2 changed files with 30 additions and 25 deletions

View file

@ -726,6 +726,7 @@ void unified_bed_leveling::shift_mesh_height() {
probe.deploy(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW
TERN_(HAS_MARLINUI_MENU, ui.capture());
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart());
save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained
uint8_t count = GRID_MAX_POINTS;
@ -747,6 +748,7 @@ void unified_bed_leveling::shift_mesh_height() {
ui.quick_feedback();
ui.release();
probe.stow(); // Release UI before stow to allow for PAUSE_BEFORE_DEPLOY_STOW
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
return restore_ubl_active_state_and_leave();
}
#endif
@ -786,6 +788,8 @@ void unified_bed_leveling::shift_mesh_height() {
constrain(nearby.x - probe.offset_xy.x, MESH_MIN_X, MESH_MAX_X),
constrain(nearby.y - probe.offset_xy.y, MESH_MIN_Y, MESH_MAX_Y)
);
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
}
#endif // HAS_BED_PROBE
@ -885,6 +889,7 @@ void set_message_with_feedback(FSTR_P const fstr) {
*/
void unified_bed_leveling::manually_probe_remaining_mesh(const xy_pos_t &pos, const_float_t z_clearance, const_float_t thick, const bool do_ubl_mesh_map) {
ui.capture();
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart());
save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained
do_blocking_move_to_xy_z(current_position, z_clearance);
@ -948,6 +953,8 @@ void set_message_with_feedback(FSTR_P const fstr) {
restore_ubl_active_state_and_leave();
do_blocking_move_to_xy_z(pos, Z_CLEARANCE_DEPLOY_PROBE);
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
}
/**

View file

@ -74,10 +74,14 @@
#endif
#endif
#define G29_RETURN(retry) do{ \
#define G29_RETURN(retry, did) do{ \
if (TERN(G29_RETRY_AND_RECOVER, !retry, true)) { \
TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE, false)); \
} \
if (did) { \
TERN_(HAS_DWIN_E3V2_BASIC, DWIN_LevelingDone()); \
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); \
} \
return TERN_(G29_RETRY_AND_RECOVER, retry); \
}while(0)
@ -233,7 +237,7 @@ G29_TYPE GcodeSuite::G29() {
// G29 Q is also available if debugging
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (seenQ || DEBUGGING(LEVELING)) log_machine_info();
if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false);
if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false, false);
#endif
// A = Abort manual probing
@ -245,7 +249,7 @@ G29_TYPE GcodeSuite::G29() {
// O = Don't level if leveling is already active
if (!no_action && planner.leveling_active && parser.boolval('O')) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Auto-level not needed, skip");
G29_RETURN(false);
G29_RETURN(false, false);
}
// Send 'N' to force homing before G29 (internal only)
@ -253,7 +257,7 @@ G29_TYPE GcodeSuite::G29() {
process_subcommands_now(TERN(CAN_SET_LEVELING_AFTER_G28, F("G28L0"), FPSTR(G28_STR)));
// Don't allow auto-leveling without homing first
if (homing_needed_error()) G29_RETURN(false);
if (homing_needed_error()) G29_RETURN(false, false);
// 3-point leveling gets points from the probe class
#if ENABLED(AUTO_BED_LEVELING_3POINT)
@ -291,13 +295,13 @@ G29_TYPE GcodeSuite::G29() {
if (seen_w) {
if (!leveling_is_valid()) {
SERIAL_ERROR_MSG("No bilinear grid");
G29_RETURN(false);
G29_RETURN(false, false);
}
const float rz = parser.seenval('Z') ? RAW_Z_POSITION(parser.value_linear_units()) : current_position.z;
if (!WITHIN(rz, -10, 10)) {
SERIAL_ERROR_MSG("Bad Z value");
G29_RETURN(false);
G29_RETURN(false, false);
}
const float rx = RAW_X_POSITION(parser.linearval('X', NAN)),
@ -325,7 +329,7 @@ G29_TYPE GcodeSuite::G29() {
set_bed_leveling_enabled(abl.reenable);
if (abl.reenable) report_current_position();
}
G29_RETURN(false);
G29_RETURN(false, false);
} // parser.seen_test('W')
#else
@ -337,13 +341,13 @@ G29_TYPE GcodeSuite::G29() {
// Jettison bed leveling data
if (!seen_w && parser.seen_test('J')) {
reset_bed_level();
G29_RETURN(false);
G29_RETURN(false, false);
}
abl.verbose_level = parser.intval('V');
if (!WITHIN(abl.verbose_level, 0, 4)) {
SERIAL_ECHOLNPGM("?(V)erbose level implausible (0-4).");
G29_RETURN(false);
G29_RETURN(false, false);
}
abl.dryrun = parser.boolval('D') || TERN0(PROBE_MANUALLY, no_action);
@ -364,11 +368,11 @@ G29_TYPE GcodeSuite::G29() {
if (!WITHIN(abl.grid_points.x, 2, GRID_MAX_POINTS_X)) {
SERIAL_ECHOLNPGM("?Probe points (X) implausible (2-" STRINGIFY(GRID_MAX_POINTS_X) ").");
G29_RETURN(false);
G29_RETURN(false, false);
}
if (!WITHIN(abl.grid_points.y, 2, GRID_MAX_POINTS_Y)) {
SERIAL_ECHOLNPGM("?Probe points (Y) implausible (2-" STRINGIFY(GRID_MAX_POINTS_Y) ").");
G29_RETURN(false);
G29_RETURN(false, false);
}
abl.abl_points = abl.grid_points.x * abl.grid_points.y;
@ -403,7 +407,7 @@ G29_TYPE GcodeSuite::G29() {
" F", abl.probe_position_lf.y, " B", abl.probe_position_rb.y);
}
SERIAL_ECHOLNPGM("? (L,R,F,B) out of bounds.");
G29_RETURN(false);
G29_RETURN(false, false);
}
// Probe at the points of a lattice grid
@ -420,8 +424,6 @@ G29_TYPE GcodeSuite::G29() {
planner.synchronize();
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart());
#if ENABLED(AUTO_BED_LEVELING_3POINT)
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> 3-point Leveling");
points[0].z = points[1].z = points[2].z = 0; // Probe at 3 arbitrary points
@ -429,6 +431,8 @@ G29_TYPE GcodeSuite::G29() {
TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_LevelingStart());
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart());
if (!faux) {
remember_feedrate_scaling_off();
@ -453,7 +457,7 @@ G29_TYPE GcodeSuite::G29() {
#elif HAS_BED_PROBE
if (probe.deploy()) { // (returns true on deploy failure)
set_bed_leveling_enabled(abl.reenable);
G29_RETURN(false);
G29_RETURN(false, true);
}
#endif
@ -503,7 +507,7 @@ G29_TYPE GcodeSuite::G29() {
}
// For 'A' or 'Q' exit with success state
if (no_action) G29_RETURN(false);
if (no_action) G29_RETURN(false, true);
if (abl.abl_probe_index == 0) {
// For the initial G29 S2 save software endstop state
@ -578,14 +582,13 @@ G29_TYPE GcodeSuite::G29() {
// Disable software endstops to allow manual adjustment
// If G29 is not completed, they will not be re-enabled
SET_SOFT_ENDSTOP_LOOSE(true);
G29_RETURN(false);
G29_RETURN(false, true);
}
else {
// Leveling done! Fall through to G29 finishing code below
SERIAL_ECHOLNPGM("Grid probing done.");
// Re-enable software endstops, if needed
SET_SOFT_ENDSTOP_LOOSE(false);
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
}
#elif ENABLED(AUTO_BED_LEVELING_3POINT)
@ -597,7 +600,7 @@ G29_TYPE GcodeSuite::G29() {
// Disable software endstops to allow manual adjustment
// If G29 is not completed, they will not be re-enabled
SET_SOFT_ENDSTOP_LOOSE(true);
G29_RETURN(false);
G29_RETURN(false, true);
}
else {
@ -615,8 +618,6 @@ G29_TYPE GcodeSuite::G29() {
abl.reenable = false;
}
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
}
#endif // AUTO_BED_LEVELING_3POINT
@ -912,14 +913,11 @@ G29_TYPE GcodeSuite::G29() {
process_subcommands_now(F(Z_PROBE_END_SCRIPT));
#endif
TERN_(HAS_DWIN_E3V2_BASIC, DWIN_LevelingDone());
TERN_(HAS_MULTI_HOTEND, if (abl.tool_index != 0) tool_change(abl.tool_index));
report_current_position();
G29_RETURN(isnan(abl.measured_z));
G29_RETURN(isnan(abl.measured_z), true);
}
#endif // HAS_ABL_NOT_UBL