|
@@ -4242,12 +4242,11 @@ inline void gcode_M105() {
|
4242
|
4242
|
* Rxxx Wait for extruder(s) to reach temperature. Waits when heating and cooling.
|
4243
|
4243
|
*/
|
4244
|
4244
|
inline void gcode_M109() {
|
4245
|
|
- bool no_wait_for_cooling = true;
|
4246
|
4245
|
|
4247
|
4246
|
if (setTargetedHotend(109)) return;
|
4248
|
4247
|
if (DEBUGGING(DRYRUN)) return;
|
4249
|
4248
|
|
4250
|
|
- no_wait_for_cooling = code_seen('S');
|
|
4249
|
+ bool no_wait_for_cooling = code_seen('S');
|
4251
|
4250
|
if (no_wait_for_cooling || code_seen('R')) {
|
4252
|
4251
|
float temp = code_value();
|
4253
|
4252
|
setTargetHotend(temp, target_extruder);
|
|
@@ -4282,12 +4281,14 @@ inline void gcode_M109() {
|
4282
|
4281
|
if (code_seen('B')) autotemp_max = code_value();
|
4283
|
4282
|
#endif
|
4284
|
4283
|
|
4285
|
|
- // Exit if the temperature is above target and not waiting for cooling
|
4286
|
|
- if (no_wait_for_cooling && !isHeatingHotend(target_extruder)) return;
|
|
4284
|
+ bool wants_to_cool = isCoolingHotend(target_extruder);
|
|
4285
|
+
|
|
4286
|
+ // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
|
|
4287
|
+ if (no_wait_for_cooling && wants_to_cool) return;
|
4287
|
4288
|
|
4288
|
4289
|
// Prevents a wait-forever situation if R is misused i.e. M109 R0
|
4289
|
4290
|
// Try to calculate a ballpark safe margin by halving EXTRUDE_MINTEMP
|
4290
|
|
- if (degTargetHotend(target_extruder) < (EXTRUDE_MINTEMP)/2) return;
|
|
4291
|
+ if (wants_to_cool && degTargetHotend(target_extruder) < (EXTRUDE_MINTEMP)/2) return;
|
4291
|
4292
|
|
4292
|
4293
|
#ifdef TEMP_RESIDENCY_TIME
|
4293
|
4294
|
millis_t residency_start_ms = 0;
|
|
@@ -4295,12 +4296,12 @@ inline void gcode_M109() {
|
4295
|
4296
|
#define TEMP_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_RESIDENCY_TIME) * 1000UL))
|
4296
|
4297
|
#else
|
4297
|
4298
|
// Loop until the temperature is very close target
|
4298
|
|
- #define TEMP_CONDITIONS (isHeatingHotend(target_extruder))
|
|
4299
|
+ #define TEMP_CONDITIONS (wants_to_cool ? isCoolingHotend(target_extruder) : isHeatingHotend(target_extruder))
|
4299
|
4300
|
#endif //TEMP_RESIDENCY_TIME
|
4300
|
4301
|
|
4301
|
4302
|
cancel_heatup = false;
|
4302
|
|
- millis_t now = millis(), next_temp_ms = now + 1000UL;
|
4303
|
|
- while (!cancel_heatup && TEMP_CONDITIONS) {
|
|
4303
|
+ millis_t now, next_temp_ms = 0;
|
|
4304
|
+ do {
|
4304
|
4305
|
now = millis();
|
4305
|
4306
|
if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
|
4306
|
4307
|
next_temp_ms = now + 1000UL;
|
|
@@ -4326,7 +4327,7 @@ inline void gcode_M109() {
|
4326
|
4327
|
|
4327
|
4328
|
#ifdef TEMP_RESIDENCY_TIME
|
4328
|
4329
|
|
4329
|
|
- float temp_diff = labs(degHotend(target_extruder) - degTargetHotend(target_extruder));
|
|
4330
|
+ float temp_diff = fabs(degTargetHotend(target_extruder) - degHotend(target_extruder));
|
4330
|
4331
|
|
4331
|
4332
|
if (!residency_start_ms) {
|
4332
|
4333
|
// Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
|
|
@@ -4339,7 +4340,7 @@ inline void gcode_M109() {
|
4339
|
4340
|
|
4340
|
4341
|
#endif //TEMP_RESIDENCY_TIME
|
4341
|
4342
|
|
4342
|
|
- } // while(!cancel_heatup && TEMP_CONDITIONS)
|
|
4343
|
+ } while (!cancel_heatup && TEMP_CONDITIONS);
|
4343
|
4344
|
|
4344
|
4345
|
LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
|
4345
|
4346
|
}
|
|
@@ -4355,15 +4356,18 @@ inline void gcode_M109() {
|
4355
|
4356
|
|
4356
|
4357
|
LCD_MESSAGEPGM(MSG_BED_HEATING);
|
4357
|
4358
|
bool no_wait_for_cooling = code_seen('S');
|
4358
|
|
- if (no_wait_for_cooling || code_seen('R'))
|
4359
|
|
- setTargetBed(code_value());
|
|
4359
|
+ if (no_wait_for_cooling || code_seen('R')) setTargetBed(code_value());
|
|
4360
|
+
|
|
4361
|
+ bool wants_to_cool = isCoolingBed();
|
4360
|
4362
|
|
4361
|
|
- // Exit if the temperature is above target and not waiting for cooling
|
4362
|
|
- if (no_wait_for_cooling && !isHeatingBed()) return;
|
|
4363
|
+ // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
|
|
4364
|
+ if (no_wait_for_cooling && wants_to_cool) return;
|
4363
|
4365
|
|
4364
|
4366
|
cancel_heatup = false;
|
4365
|
|
- millis_t now = millis(), next_temp_ms = now + 1000UL;
|
4366
|
|
- while (!cancel_heatup && isHeatingBed()) {
|
|
4367
|
+ millis_t next_temp_ms = 0;
|
|
4368
|
+
|
|
4369
|
+ // Wait for temperature to come close enough
|
|
4370
|
+ do {
|
4367
|
4371
|
millis_t now = millis();
|
4368
|
4372
|
if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
|
4369
|
4373
|
next_temp_ms = now + 1000UL;
|
|
@@ -4372,7 +4376,7 @@ inline void gcode_M109() {
|
4372
|
4376
|
}
|
4373
|
4377
|
idle();
|
4374
|
4378
|
refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
|
4375
|
|
- }
|
|
4379
|
+ } while (!cancel_heatup && (wants_to_cool ? isCoolingBed() : isHeatingBed()));
|
4376
|
4380
|
LCD_MESSAGEPGM(MSG_BED_DONE);
|
4377
|
4381
|
}
|
4378
|
4382
|
|