Skip to content

Commit ffe47a0

Browse files
committed
🚸 Improve PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED (MarlinFirmware#25681)
1 parent 6a12937 commit ffe47a0

File tree

9 files changed

+46
-37
lines changed

9 files changed

+46
-37
lines changed

Marlin/src/feature/leds/pca9632.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void PCA9632_set_led_color(const LEDColor &color) {
148148

149149
#if ENABLED(PCA9632_BUZZER)
150150

151-
void PCA9632_buzz(const long, const uint16_t) {
151+
void PCA9632_buzz(const long, const uint16_t=0) {
152152
uint8_t data[] = PCA9632_BUZZER_DATA;
153153
Wire.beginTransmission(I2C_ADDRESS(PCA9632_ADDRESS));
154154
Wire.write(data, sizeof(data));

Marlin/src/feature/leds/pca9632.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ void PCA9632_set_led_color(const LEDColor &color);
3333

3434
#if ENABLED(PCA9632_BUZZER)
3535
#include <stdint.h>
36-
void PCA9632_buzz(const long, const uint16_t);
36+
void PCA9632_buzz(const long, const uint16_t=0);
3737
#endif

Marlin/src/lcd/HD44780/marlinui_HD44780.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static void createChar_P(const char c, const byte * const ptr) {
125125

126126
#if ENABLED(LCD_USE_I2C_BUZZER)
127127

128-
void MarlinUI::buzz(const long duration, const uint16_t freq) {
128+
void MarlinUI::buzz(const long duration, const uint16_t freq/*=0*/) {
129129
if (sound_on) lcd.buzz(duration, freq);
130130
}
131131

Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ uint8_t MarlinUI::read_slow_buttons() {
299299
}
300300

301301
// Duration in ms, freq in Hz
302-
void MarlinUI::buzz(const long duration, const uint16_t freq) {
302+
void MarlinUI::buzz(const long duration, const uint16_t freq/*=0*/) {
303303
if (!PanelDetected) return;
304304
if (!sound_on) return;
305305
#if ENABLED(TFTGLCD_PANEL_SPI)

Marlin/src/lcd/marlinui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
127127
#endif
128128

129129
#if ENABLED(PCA9632_BUZZER)
130-
void MarlinUI::buzz(const long duration, const uint16_t freq) {
130+
void MarlinUI::buzz(const long duration, const uint16_t freq/*=0*/) {
131131
if (sound_on) PCA9632_buzz(duration, freq);
132132
}
133133
#endif

Marlin/src/lcd/marlinui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class MarlinUI {
228228
#endif
229229

230230
#if USE_MARLINUI_BUZZER
231-
static void buzz(const long duration, const uint16_t freq);
231+
static void buzz(const long duration, const uint16_t freq=0);
232232
#endif
233233

234234
static void chirp() {

Marlin/src/libs/buzzer.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,20 @@
115115
extern Buzzer buzzer;
116116

117117
// Buzz directly via the BEEPER pin tone queue
118-
#define BUZZ(d,f) buzzer.tone(d, f)
118+
#define BUZZ(V...) buzzer.tone(V)
119119

120120
#elif USE_MARLINUI_BUZZER
121121

122122
// Use MarlinUI for a buzzer on the LCD
123-
#include "../lcd/marlinui.h"
124-
#define BUZZ(d,f) ui.buzz(d,f)
123+
#define BUZZ(V...) ui.buzz(V)
125124

126125
#else
127126

128127
// No buzz capability
129-
#define BUZZ(d,f) NOOP
128+
#define BUZZ(...) NOOP
130129

131130
#endif
132131

133-
#define ERR_BUZZ() BUZZ(400, 40);
134-
#define OKAY_BUZZ() do{ BUZZ(100, 659); BUZZ(10, 0); BUZZ(100, 698); }while(0)
135-
#define DONE_BUZZ(OK) do{ if (OK) OKAY_BUZZ(); else ERR_BUZZ(); }while(0)
132+
#define ERR_BUZZ() BUZZ(400, 40)
133+
#define OKAY_BUZZ() do{ BUZZ(100, 659); BUZZ(10); BUZZ(100, 698); }while(0)
134+
#define DONE_BUZZ(ok) do{ if (ok) OKAY_BUZZ(); else ERR_BUZZ(); }while(0)

Marlin/src/module/probe.cpp

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -361,25 +361,35 @@ void Probe::do_z_raise(const float z_raise) {
361361

362362
FORCE_INLINE void probe_specific_action(const bool deploy) {
363363
#if ENABLED(PAUSE_BEFORE_DEPLOY_STOW)
364-
do {
365-
#if ENABLED(PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED)
366-
if (deploy != PROBE_TRIGGERED()) break;
367-
#endif
368364

369-
OKAY_BUZZ();
365+
// Start preheating before waiting for user confirmation that the probe is ready.
366+
TERN_(PREHEAT_BEFORE_PROBING, if (deploy) probe.preheat_for_probing(0, PROBING_BED_TEMP, true));
367+
368+
FSTR_P const ds_str = deploy ? GET_TEXT_F(MSG_MANUAL_DEPLOY) : GET_TEXT_F(MSG_MANUAL_STOW);
369+
ui.return_to_status(); // To display the new status message
370+
ui.set_status(ds_str, 99);
371+
SERIAL_ECHOLNF(deploy ? GET_EN_TEXT_F(MSG_MANUAL_DEPLOY) : GET_EN_TEXT_F(MSG_MANUAL_STOW));
372+
373+
OKAY_BUZZ();
374+
375+
#if ENABLED(PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED)
376+
// Wait for the probe to be attached or detached before asking for explicit user confirmation
377+
// Allow the user to interrupt
378+
{
379+
KEEPALIVE_STATE(PAUSED_FOR_USER);
380+
TERN_(HAS_RESUME_CONTINUE, wait_for_user = true);
381+
while (deploy == PROBE_TRIGGERED() && TERN1(HAS_RESUME_CONTINUE, wait_for_user)) idle_no_sleep();
382+
TERN_(HAS_RESUME_CONTINUE, wait_for_user = false);
383+
OKAY_BUZZ();
384+
}
385+
#endif
370386

371-
FSTR_P const ds_str = deploy ? GET_TEXT_F(MSG_MANUAL_DEPLOY) : GET_TEXT_F(MSG_MANUAL_STOW);
372-
ui.return_to_status(); // To display the new status message
373-
ui.set_status(ds_str, 99);
374-
SERIAL_ECHOLNF(deploy ? GET_EN_TEXT_F(MSG_MANUAL_DEPLOY) : GET_EN_TEXT_F(MSG_MANUAL_STOW));
387+
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(ds_str));
388+
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(ds_str));
389+
TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, ds_str, FPSTR(CONTINUE_STR)));
390+
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
375391

376-
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(ds_str));
377-
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(ds_str));
378-
TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, ds_str, FPSTR(CONTINUE_STR)));
379-
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
380-
ui.reset_status();
381-
382-
} while (ENABLED(PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED));
392+
ui.reset_status();
383393

384394
#endif // PAUSE_BEFORE_DEPLOY_STOW
385395

@@ -436,15 +446,15 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
436446
* - If a preheat input is higher than the current target, raise the target temperature.
437447
* - If a preheat input is higher than the current temperature, wait for stabilization.
438448
*/
439-
void Probe::preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp) {
449+
void Probe::preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp, const bool early/*=false*/) {
440450
#if HAS_HOTEND && (PROBING_NOZZLE_TEMP || LEVELING_NOZZLE_TEMP)
441451
#define WAIT_FOR_NOZZLE_HEAT
442452
#endif
443453
#if HAS_HEATED_BED && (PROBING_BED_TEMP || LEVELING_BED_TEMP)
444454
#define WAIT_FOR_BED_HEAT
445455
#endif
446456

447-
LCD_MESSAGE(MSG_PREHEATING);
457+
if (!early) LCD_MESSAGE(MSG_PREHEATING);
448458

449459
DEBUG_ECHOPGM("Preheating ");
450460

@@ -454,23 +464,23 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
454464
DEBUG_ECHOPGM("hotend (", hotendPreheat, ")");
455465
thermalManager.setTargetHotend(hotendPreheat, 0);
456466
}
457-
#elif ENABLED(WAIT_FOR_BED_HEAT)
458-
constexpr celsius_t hotendPreheat = 0;
459467
#endif
460468

461469
#if ENABLED(WAIT_FOR_BED_HEAT)
462470
const celsius_t bedPreheat = bed_temp > thermalManager.degTargetBed() ? bed_temp : 0;
463471
if (bedPreheat) {
464-
if (hotendPreheat) DEBUG_ECHOPGM(" and ");
472+
if (TERN0(WAIT_FOR_NOZZLE_HEAT, hotendPreheat)) DEBUG_ECHOPGM(" and ");
465473
DEBUG_ECHOPGM("bed (", bedPreheat, ")");
466474
thermalManager.setTargetBed(bedPreheat);
467475
}
468476
#endif
469477

470478
DEBUG_EOL();
471479

472-
TERN_(WAIT_FOR_NOZZLE_HEAT, if (hotend_temp > thermalManager.wholeDegHotend(0) + (TEMP_WINDOW)) thermalManager.wait_for_hotend(0));
473-
TERN_(WAIT_FOR_BED_HEAT, if (bed_temp > thermalManager.wholeDegBed() + (TEMP_BED_WINDOW)) thermalManager.wait_for_bed_heating());
480+
if (!early) {
481+
TERN_(WAIT_FOR_NOZZLE_HEAT, if (hotend_temp > thermalManager.wholeDegHotend(0) + (TEMP_WINDOW)) thermalManager.wait_for_hotend(0));
482+
TERN_(WAIT_FOR_BED_HEAT, if (bed_temp > thermalManager.wholeDegBed() + (TEMP_BED_WINDOW)) thermalManager.wait_for_bed_heating());
483+
}
474484
}
475485

476486
#endif

Marlin/src/module/probe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Probe {
8787
static xyz_pos_t offset;
8888

8989
#if EITHER(PREHEAT_BEFORE_PROBING, PREHEAT_BEFORE_LEVELING)
90-
static void preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp);
90+
static void preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp, const bool early=false);
9191
#endif
9292

9393
static void probe_error_stop();

0 commit comments

Comments
 (0)