Browse Source

🚸 More ExtUI events for ABL / UBL

FB4S_WIFI
Scott Lahteine 3 years ago
committed by Scott Lahteine
parent
commit
4bdec5e993
  1. 7
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  2. 48
      Marlin/src/gcode/bedlevel/abl/G29.cpp

7
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp

@ -726,6 +726,7 @@ void unified_bed_leveling::shift_mesh_height() {
probe.deploy(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW probe.deploy(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW
TERN_(HAS_MARLINUI_MENU, ui.capture()); 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 save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained
uint8_t count = GRID_MAX_POINTS; uint8_t count = GRID_MAX_POINTS;
@ -747,6 +748,7 @@ void unified_bed_leveling::shift_mesh_height() {
ui.quick_feedback(); ui.quick_feedback();
ui.release(); ui.release();
probe.stow(); // Release UI before stow to allow for PAUSE_BEFORE_DEPLOY_STOW 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(); return restore_ubl_active_state_and_leave();
} }
#endif #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.x - probe.offset_xy.x, MESH_MIN_X, MESH_MAX_X),
constrain(nearby.y - probe.offset_xy.y, MESH_MIN_Y, MESH_MAX_Y) constrain(nearby.y - probe.offset_xy.y, MESH_MIN_Y, MESH_MAX_Y)
); );
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
} }
#endif // HAS_BED_PROBE #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) { 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(); ui.capture();
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart());
save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained 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); 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(); restore_ubl_active_state_and_leave();
do_blocking_move_to_xy_z(pos, Z_CLEARANCE_DEPLOY_PROBE); do_blocking_move_to_xy_z(pos, Z_CLEARANCE_DEPLOY_PROBE);
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
} }
/** /**

48
Marlin/src/gcode/bedlevel/abl/G29.cpp

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

Loading…
Cancel
Save