Skip to content

Commit f22c453

Browse files
GMagicianthinkyhead
authored andcommitted
Make M600 heat up the nozzle. Reset runout on fail. (MarlinFirmware#19298)
Co-authored-by: Scott Lahteine <[email protected]>
1 parent 228db08 commit f22c453

File tree

4 files changed

+56
-13
lines changed

4 files changed

+56
-13
lines changed

Marlin/src/feature/pause.cpp

+46-12
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
#if ENABLED(ADVANCED_PAUSE_FEATURE)
3131

32+
//#define DEBUG_PAUSE_RESUME
33+
3234
#include "../MarlinCore.h"
3335
#include "../gcode/gcode.h"
3436
#include "../module/motion.h"
@@ -62,6 +64,9 @@
6264
#include "../libs/nozzle.h"
6365
#include "pause.h"
6466

67+
#define DEBUG_OUT ENABLED(DEBUG_PAUSE_RESUME)
68+
#include "../core/debug_out.h"
69+
6570
// private:
6671

6772
static xyze_pos_t resume_position;
@@ -120,25 +125,32 @@ fil_change_settings_t fc_settings[EXTRUDERS];
120125
* Returns 'true' if heating was completed, 'false' for abort
121126
*/
122127
static bool ensure_safe_temperature(const bool wait=true, const PauseMode mode=PAUSE_MODE_SAME) {
128+
DEBUG_SECTION(est, "ensure_safe_temperature", true);
129+
DEBUG_ECHOLNPAIR("... wait:", int(wait), " mode:", int(mode));
123130

124-
#if ENABLED(PREVENT_COLD_EXTRUSION)
125-
if (!DEBUGGING(DRYRUN) && thermalManager.targetTooColdToExtrude(active_extruder)) {
126-
SERIAL_ECHO_MSG(STR_ERR_HOTEND_TOO_COLD);
127-
return false;
128-
}
129-
#endif
131+
if (!DEBUGGING(DRYRUN) && thermalManager.targetTooColdToExtrude(active_extruder))
132+
thermalManager.setTargetHotend(thermalManager.extrude_min_temp, active_extruder);
130133

131134
#if HAS_LCD_MENU
132135
lcd_pause_show_message(PAUSE_MESSAGE_HEATING, mode);
133-
#else
134-
UNUSED(mode);
135136
#endif
137+
UNUSED(mode);
136138

137139
if (wait)
138140
return thermalManager.wait_for_hotend(active_extruder);
139141

140-
while (ABS(thermalManager.degHotend(active_extruder) - thermalManager.degTargetHotend(active_extruder)) > TEMP_WINDOW)
142+
wait_for_heatup = true; // Allow interruption by Emergency Parser M108
143+
while (wait_for_heatup && ABS(thermalManager.degHotend(active_extruder) - thermalManager.degTargetHotend(active_extruder)) > TEMP_WINDOW)
141144
idle();
145+
wait_for_heatup = false;
146+
147+
#if ENABLED(PREVENT_COLD_EXTRUSION)
148+
// A user can cancel wait-for-heating with M108
149+
if (!DEBUGGING(DRYRUN) && thermalManager.targetTooColdToExtrude(active_extruder)) {
150+
SERIAL_ECHO_MSG(STR_ERR_HOTEND_TOO_COLD);
151+
return false;
152+
}
153+
#endif
142154

143155
return true;
144156
}
@@ -160,7 +172,10 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
160172
const PauseMode mode/*=PAUSE_MODE_PAUSE_PRINT*/
161173
DXC_ARGS
162174
) {
163-
TERN(HAS_LCD_MENU,,UNUSED(show_lcd));
175+
DEBUG_SECTION(lf, "load_filament", true);
176+
DEBUG_ECHOLNPAIR("... slowlen:", slow_load_length, " fastlen:", fast_load_length, " purgelen:", purge_length, " maxbeep:", int(max_beep_count), " showlcd:", int(show_lcd), " pauseforuser:", int(pause_for_user), " pausemode:", int(mode) DXC_SAY);
177+
178+
UNUSED(show_lcd);
164179

165180
if (!ensure_safe_temperature(false, mode)) {
166181
#if HAS_LCD_MENU
@@ -292,7 +307,14 @@ bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
292307
, const float &mix_multiplier/*=1.0*/
293308
#endif
294309
) {
295-
TERN(HAS_LCD_MENU,,UNUSED(show_lcd));
310+
DEBUG_SECTION(uf, "unload_filament", true);
311+
DEBUG_ECHOLNPAIR("... unloadlen:", unload_length, " showlcd:", int(show_lcd), " mode:", int(mode)
312+
#if BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER)
313+
, " mixmult:", mix_multiplier
314+
#endif
315+
);
316+
317+
UNUSED(show_lcd);
296318

297319
#if !BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER)
298320
constexpr float mix_multiplier = 1.0;
@@ -358,7 +380,10 @@ bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
358380
uint8_t did_pause_print = 0;
359381

360382
bool pause_print(const float &retract, const xyz_pos_t &park_point, const float &unload_length/*=0*/, const bool show_lcd/*=false*/ DXC_ARGS) {
361-
TERN(HAS_LCD_MENU,,UNUSED(show_lcd));
383+
DEBUG_SECTION(pp, "pause_print", true);
384+
DEBUG_ECHOLNPAIR("... retract:", retract, " park.x:", park_point.x, " y:", park_point.y, " z:", park_point.z, " unloadlen:", unload_length, " showlcd:", int(show_lcd) DXC_SAY);
385+
386+
UNUSED(show_lcd);
362387

363388
if (did_pause_print) return false; // already paused
364389

@@ -449,12 +474,18 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float
449474
*/
450475

451476
void show_continue_prompt(const bool is_reload) {
477+
DEBUG_SECTION(scp, "pause_print", true);
478+
DEBUG_ECHOLNPAIR("... is_reload:", int(is_reload));
479+
452480
TERN_(HAS_LCD_MENU, lcd_pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING));
453481
SERIAL_ECHO_START();
454482
serialprintPGM(is_reload ? PSTR(_PMSG(STR_FILAMENT_CHANGE_INSERT) "\n") : PSTR(_PMSG(STR_FILAMENT_CHANGE_WAIT) "\n"));
455483
}
456484

457485
void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep_count/*=0*/ DXC_ARGS) {
486+
DEBUG_SECTION(wfc, "wait_for_confirmation", true);
487+
DEBUG_ECHOLNPAIR("... is_reload:", is_reload, " maxbeep:", int(max_beep_count) DXC_SAY);
488+
458489
bool nozzle_timed_out = false;
459490

460491
show_continue_prompt(is_reload);
@@ -551,6 +582,9 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
551582
* - Resume the current SD print job, if any
552583
*/
553584
void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_length/*=0*/, const float &purge_length/*=ADVANCED_PAUSE_PURGE_LENGTH*/, const int8_t max_beep_count/*=0*/, int16_t targetTemp/*=0*/ DXC_ARGS) {
585+
DEBUG_SECTION(rp, "resume_print", true);
586+
DEBUG_ECHOLNPAIR("... slowlen:", slow_load_length, " fastlen:", fast_load_length, " purgelen:", purge_length, " maxbeep:", int(max_beep_count), " targetTemp:", targetTemp DXC_SAY);
587+
554588
/*
555589
SERIAL_ECHOLNPAIR(
556590
"start of resume_print()\ndual_x_carriage_mode:", dual_x_carriage_mode,

Marlin/src/feature/pause.h

+2
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ extern uint8_t did_pause_print;
7777
#define DXC_PARAMS , const int8_t DXC_ext=-1
7878
#define DXC_ARGS , const int8_t DXC_ext
7979
#define DXC_PASS , DXC_ext
80+
#define DXC_SAY , " dxc:", int(DXC_ext)
8081
#else
8182
#define DXC_PARAMS
8283
#define DXC_ARGS
8384
#define DXC_PASS
85+
#define DXC_SAY
8486
#endif
8587

8688
bool pause_print(const float &retract, const xyz_pos_t &park_point, const float &unload_length=0, const bool show_lcd=false DXC_PARAMS);

Marlin/src/gcode/feature/pause/M600.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
#include "../../../feature/mixing.h"
4646
#endif
4747

48+
#if HAS_FILAMENT_SENSOR
49+
#include "../../../feature/runout.h"
50+
#endif
51+
4852
/**
4953
* M600: Pause for filament change
5054
*
@@ -158,6 +162,9 @@ void GcodeSuite::M600() {
158162
beep_count, (parser.seenval('R') ? parser.value_celsius() : 0) DXC_PASS);
159163
#endif
160164
}
165+
else {
166+
TERN_(HAS_FILAMENT_SENSOR, runout.reset());
167+
}
161168

162169
#if EXTRUDERS > 1
163170
// Restore toolhead if it was changed

Marlin/src/module/temperature.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ class Temperature {
330330
#if ENABLED(PREVENT_COLD_EXTRUSION)
331331
static bool allow_cold_extrude;
332332
static int16_t extrude_min_temp;
333-
FORCE_INLINE static bool tooCold(const int16_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp; }
333+
FORCE_INLINE static bool tooCold(const int16_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); }
334334
FORCE_INLINE static bool tooColdToExtrude(const uint8_t E_NAME) {
335335
return tooCold(degHotend(HOTEND_INDEX));
336336
}

0 commit comments

Comments
 (0)