|
@@ -4389,20 +4389,57 @@ inline void gcode_M109() {
|
4389
|
4389
|
// Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
|
4390
|
4390
|
if (no_wait_for_cooling && wants_to_cool) return;
|
4391
|
4391
|
|
|
4392
|
+ #ifdef TEMP_BED_RESIDENCY_TIME
|
|
4393
|
+ millis_t residency_start_ms = 0;
|
|
4394
|
+ // Loop until the temperature has stabilized
|
|
4395
|
+ #define TEMP_BED_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_BED_RESIDENCY_TIME) * 1000UL))
|
|
4396
|
+ #else
|
|
4397
|
+ // Loop until the temperature is very close target
|
|
4398
|
+ #define TEMP_BED_CONDITIONS (wants_to_cool ? isCoolingBed() : isHeatingBed())
|
|
4399
|
+ #endif //TEMP_BED_RESIDENCY_TIME
|
|
4400
|
+
|
4392
|
4401
|
cancel_heatup = false;
|
4393
|
|
- millis_t next_temp_ms = 0;
|
|
4402
|
+ millis_t now, next_temp_ms = 0;
|
4394
|
4403
|
|
4395
|
4404
|
// Wait for temperature to come close enough
|
4396
|
4405
|
do {
|
4397
|
|
- millis_t now = millis();
|
|
4406
|
+ now = millis();
|
4398
|
4407
|
if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
|
4399
|
4408
|
next_temp_ms = now + 1000UL;
|
4400
|
4409
|
print_heaterstates();
|
4401
|
|
- SERIAL_EOL;
|
|
4410
|
+ #ifdef TEMP_BED_RESIDENCY_TIME
|
|
4411
|
+ SERIAL_PROTOCOLPGM(" W:");
|
|
4412
|
+ if (residency_start_ms) {
|
|
4413
|
+ long rem = (((TEMP_BED_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL;
|
|
4414
|
+ SERIAL_PROTOCOLLN(rem);
|
|
4415
|
+ }
|
|
4416
|
+ else {
|
|
4417
|
+ SERIAL_PROTOCOLLNPGM("?");
|
|
4418
|
+ }
|
|
4419
|
+ #else
|
|
4420
|
+ SERIAL_EOL;
|
|
4421
|
+ #endif
|
4402
|
4422
|
}
|
|
4423
|
+
|
4403
|
4424
|
idle();
|
4404
|
4425
|
refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
|
4405
|
|
- } while (!cancel_heatup && (wants_to_cool ? isCoolingBed() : isHeatingBed()));
|
|
4426
|
+
|
|
4427
|
+ #ifdef TEMP_BED_RESIDENCY_TIME
|
|
4428
|
+
|
|
4429
|
+ float temp_diff = fabs(degBed() - degTargetBed());
|
|
4430
|
+
|
|
4431
|
+ if (!residency_start_ms) {
|
|
4432
|
+ // Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
|
|
4433
|
+ if (temp_diff < TEMP_BED_WINDOW) residency_start_ms = millis();
|
|
4434
|
+ }
|
|
4435
|
+ else if (temp_diff > TEMP_BED_HYSTERESIS) {
|
|
4436
|
+ // Restart the timer whenever the temperature falls outside the hysteresis.
|
|
4437
|
+ residency_start_ms = millis();
|
|
4438
|
+ }
|
|
4439
|
+
|
|
4440
|
+ #endif //TEMP_BED_RESIDENCY_TIME
|
|
4441
|
+
|
|
4442
|
+ } while (!cancel_heatup && TEMP_BED_CONDITIONS);
|
4406
|
4443
|
LCD_MESSAGEPGM(MSG_BED_DONE);
|
4407
|
4444
|
}
|
4408
|
4445
|
|