Skip to content

Commit

Permalink
🚸 Fix UI behavior for G29 with retry (MarlinFirmware#27146)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored Jul 15, 2024
1 parent ee99eed commit 5334a8f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
15 changes: 11 additions & 4 deletions Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,21 @@
#endif
#endif

/**
* @brief Do some things before returning from G29.
* @param retry : true if the G29 can and should be retried. false if the failure is too serious.
* @param did : true if the leveling procedure completed successfully.
*/
static void pre_g29_return(const bool retry, const bool did) {
if (!retry) {
TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE, false));
}
if (did) {
TERN_(DWIN_CREALITY_LCD, dwinLevelingDone());
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
}
#if DISABLED(G29_RETRY_AND_RECOVER)
if (!retry || did) {
TERN_(DWIN_CREALITY_LCD, dwinLevelingDone());
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
}
#endif
}

#define G29_RETURN(retry, did) do{ \
Expand Down
31 changes: 18 additions & 13 deletions Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,22 +289,27 @@ void GcodeSuite::dwell(millis_t time) {

void GcodeSuite::G29_with_retry() {
uint8_t retries = G29_MAX_RETRIES;
while (G29()) { // G29 should return true for failed probes ONLY
if (retries) {
event_probe_recover();
--retries;
}
else {
event_probe_failure();
return;
}
bool fail = false;
for (;;) {
fail = G29(); // G29 should return true for failed probes ONLY
if (!fail || !retries) break;
event_probe_recover();
--retries;
}

TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_end());
if (fail) {
event_probe_failure();
TERN_(G29_HALT_ON_FAILURE, return);
}
else {
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_end());
#ifdef G29_SUCCESS_COMMANDS
process_subcommands_now(F(G29_SUCCESS_COMMANDS));
#endif
}

#ifdef G29_SUCCESS_COMMANDS
process_subcommands_now(F(G29_SUCCESS_COMMANDS));
#endif
TERN_(HAS_DWIN_E3V2_BASIC, dwinLevelingDone());
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
}

#endif // G29_RETRY_AND_RECOVER
Expand Down

0 comments on commit 5334a8f

Please sign in to comment.