Skip to content

Commit 10ed5ab

Browse files
authored
🚸 Improve PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED (MarlinFirmware#25681)
1 parent 1669356 commit 10ed5ab

File tree

9 files changed

+46
-37
lines changed

9 files changed

+46
-37
lines changed

Marlin/src/feature/leds/pca9632.cpp

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+6-7
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,20 @@
117117
extern Buzzer buzzer;
118118

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

122122
#elif USE_MARLINUI_BUZZER
123123

124124
// Use MarlinUI for a buzzer on the LCD
125-
#include "../lcd/marlinui.h"
126-
#define BUZZ(d,f) ui.buzz(d,f)
125+
#define BUZZ(V...) ui.buzz(V)
127126

128127
#else
129128

130129
// No buzz capability
131-
#define BUZZ(d,f) NOOP
130+
#define BUZZ(...) NOOP
132131

133132
#endif
134133

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

Marlin/src/module/probe.cpp

+33-23
Original file line numberDiff line numberDiff line change
@@ -352,25 +352,35 @@ xyz_pos_t Probe::offset; // Initialized by settings.load()
352352
FORCE_INLINE void probe_specific_action(const bool deploy) {
353353
DEBUG_SECTION(log_psa, "Probe::probe_specific_action", DEBUGGING(LEVELING));
354354
#if ENABLED(PAUSE_BEFORE_DEPLOY_STOW)
355-
do {
356-
#if ENABLED(PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED)
357-
if (deploy != PROBE_TRIGGERED()) break;
358-
#endif
359355

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

362-
FSTR_P const ds_str = deploy ? GET_TEXT_F(MSG_MANUAL_DEPLOY) : GET_TEXT_F(MSG_MANUAL_STOW);
363-
ui.return_to_status(); // To display the new status message
364-
ui.set_status(ds_str, 99);
365-
SERIAL_ECHOLNF(deploy ? GET_EN_TEXT_F(MSG_MANUAL_DEPLOY) : GET_EN_TEXT_F(MSG_MANUAL_STOW));
378+
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(ds_str));
379+
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(ds_str));
380+
TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, ds_str, FPSTR(CONTINUE_STR)));
381+
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
366382

367-
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(ds_str));
368-
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(ds_str));
369-
TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, ds_str, FPSTR(CONTINUE_STR)));
370-
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
371-
ui.reset_status();
372-
373-
} while (ENABLED(PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED));
383+
ui.reset_status();
374384

375385
#endif // PAUSE_BEFORE_DEPLOY_STOW
376386

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

446-
LCD_MESSAGE(MSG_PREHEATING);
456+
if (!early) LCD_MESSAGE(MSG_PREHEATING);
447457

448458
DEBUG_ECHOPGM("Preheating ");
449459

@@ -453,23 +463,23 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
453463
DEBUG_ECHOPGM("hotend (", hotendPreheat, ")");
454464
thermalManager.setTargetHotend(hotendPreheat, 0);
455465
}
456-
#elif ENABLED(WAIT_FOR_BED_HEAT)
457-
constexpr celsius_t hotendPreheat = 0;
458466
#endif
459467

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

469477
DEBUG_EOL();
470478

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

475485
#endif

Marlin/src/module/probe.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Probe {
7676
static xyz_pos_t offset;
7777

7878
#if EITHER(PREHEAT_BEFORE_PROBING, PREHEAT_BEFORE_LEVELING)
79-
static void preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp);
79+
static void preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp, const bool early=false);
8080
#endif
8181

8282
static void probe_error_stop();

0 commit comments

Comments
 (0)