Skip to content

Commit

Permalink
🚸 Improve PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Apr 16, 2023
1 parent efc7258 commit 0144196
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
5 changes: 2 additions & 3 deletions Marlin/src/libs/buzzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
#elif USE_MARLINUI_BUZZER

// Use MarlinUI for a buzzer on the LCD
#include "../lcd/marlinui.h"
#define BUZZ(d,f) ui.buzz(d,f)

#else
Expand All @@ -132,6 +131,6 @@

#endif

#define ERR_BUZZ() BUZZ(400, 40);
#define ERR_BUZZ() BUZZ(400, 40)
#define OKAY_BUZZ() do{ BUZZ(100, 659); BUZZ(10, 0); BUZZ(100, 698); }while(0)
#define DONE_BUZZ(OK) do{ if (OK) OKAY_BUZZ(); else ERR_BUZZ(); }while(0)
#define DONE_BUZZ(ok) do{ if (ok) OKAY_BUZZ(); else ERR_BUZZ(); }while(0)
52 changes: 32 additions & 20 deletions Marlin/src/module/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,25 +352,35 @@ xyz_pos_t Probe::offset; // Initialized by settings.load()
FORCE_INLINE void probe_specific_action(const bool deploy) {
DEBUG_SECTION(log_psa, "Probe::probe_specific_action", DEBUGGING(LEVELING));
#if ENABLED(PAUSE_BEFORE_DEPLOY_STOW)
do {
#if ENABLED(PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED)
if (deploy != PROBE_TRIGGERED()) break;
#endif

OKAY_BUZZ();
// Start preheating before waiting for user confirmation that the probe is ready.
TERN_(PREHEAT_BEFORE_PROBING, if (deploy) probe.preheat_for_probing(0, PROBING_BED_TEMP, true));

FSTR_P const ds_str = deploy ? GET_TEXT_F(MSG_MANUAL_DEPLOY) : GET_TEXT_F(MSG_MANUAL_STOW);
ui.return_to_status(); // To display the new status message
ui.set_status(ds_str, 99);
SERIAL_ECHOLNF(deploy ? GET_EN_TEXT_F(MSG_MANUAL_DEPLOY) : GET_EN_TEXT_F(MSG_MANUAL_STOW));

OKAY_BUZZ();

#if ENABLED(PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED)
// Wait for the probe to be attached or detached before asking for explicit user confirmation
// Allow the user to interrupt
{
KEEPALIVE_STATE(PAUSED_FOR_USER);
TERN_(HAS_RESUME_CONTINUE, wait_for_user = true);
while (deploy == PROBE_TRIGGERED() && TERN1(HAS_RESUME_CONTINUE, wait_for_user)) idle_no_sleep();
TERN_(HAS_RESUME_CONTINUE, wait_for_user = false);
OKAY_BUZZ();
}
#endif

FSTR_P const ds_str = deploy ? GET_TEXT_F(MSG_MANUAL_DEPLOY) : GET_TEXT_F(MSG_MANUAL_STOW);
ui.return_to_status(); // To display the new status message
ui.set_status(ds_str, 99);
SERIAL_ECHOLNF(deploy ? GET_EN_TEXT_F(MSG_MANUAL_DEPLOY) : GET_EN_TEXT_F(MSG_MANUAL_STOW));
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, ds_str, FPSTR(CONTINUE_STR)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(ds_str));
TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, ds_str, FPSTR(CONTINUE_STR)));
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());

TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, ds_str, FPSTR(CONTINUE_STR)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(ds_str));
TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, ds_str, FPSTR(CONTINUE_STR)));
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
ui.reset_status();

} while (ENABLED(PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED));
ui.reset_status();

#endif // PAUSE_BEFORE_DEPLOY_STOW

Expand Down Expand Up @@ -435,15 +445,15 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
* - If a preheat input is higher than the current target, raise the target temperature.
* - If a preheat input is higher than the current temperature, wait for stabilization.
*/
void Probe::preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp) {
void Probe::preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp, const bool early/*=false*/) {
#if HAS_HOTEND && (PROBING_NOZZLE_TEMP || LEVELING_NOZZLE_TEMP)
#define WAIT_FOR_NOZZLE_HEAT
#endif
#if HAS_HEATED_BED && (PROBING_BED_TEMP || LEVELING_BED_TEMP)
#define WAIT_FOR_BED_HEAT
#endif

LCD_MESSAGE(MSG_PREHEATING);
if (!early) LCD_MESSAGE(MSG_PREHEATING);

DEBUG_ECHOPGM("Preheating ");

Expand All @@ -468,8 +478,10 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {

DEBUG_EOL();

TERN_(WAIT_FOR_NOZZLE_HEAT, if (hotend_temp > thermalManager.wholeDegHotend(0) + (TEMP_WINDOW)) thermalManager.wait_for_hotend(0));
TERN_(WAIT_FOR_BED_HEAT, if (bed_temp > thermalManager.wholeDegBed() + (TEMP_BED_WINDOW)) thermalManager.wait_for_bed_heating());
if (!early) {
TERN_(WAIT_FOR_NOZZLE_HEAT, if (hotend_temp > thermalManager.wholeDegHotend(0) + (TEMP_WINDOW)) thermalManager.wait_for_hotend(0));
TERN_(WAIT_FOR_BED_HEAT, if (bed_temp > thermalManager.wholeDegBed() + (TEMP_BED_WINDOW)) thermalManager.wait_for_bed_heating());
}
}

#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/probe.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Probe {
static xyz_pos_t offset;

#if EITHER(PREHEAT_BEFORE_PROBING, PREHEAT_BEFORE_LEVELING)
static void preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp);
static void preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp, const bool early=false);
#endif

static void probe_error_stop();
Expand Down

0 comments on commit 0144196

Please sign in to comment.