Browse Source

Standard methods to wait for heating (#11949)

Scott Lahteine 6 years ago
parent
commit
e4389f7d23
No account linked to committer's email address

+ 1
- 6
Marlin/src/feature/pause.cpp View File

@@ -109,12 +109,7 @@ static bool ensure_safe_temperature(const AdvancedPauseMode mode=ADVANCED_PAUSE_
109 109
     UNUSED(mode);
110 110
   #endif
111 111
 
112
-  wait_for_heatup = true; // M108 will clear this
113
-  while (wait_for_heatup && thermalManager.wait_for_heating(active_extruder)) idle();
114
-  const bool status = wait_for_heatup;
115
-  wait_for_heatup = false;
116
-
117
-  return status;
112
+  return thermalManager.wait_for_hotend(active_extruder);
118 113
 }
119 114
 
120 115
 static void do_pause_e_move(const float &length, const float &fr) {

+ 3
- 0
Marlin/src/gcode/control/M108_M112_M410.cpp View File

@@ -31,6 +31,9 @@
31 31
  * M108: Stop the waiting for heaters in M109, M190, M303. Does not affect the target temperature.
32 32
  */
33 33
 void GcodeSuite::M108() {
34
+  #if HAS_RESUME_CONTINUE
35
+    wait_for_user = false;
36
+  #endif
34 37
   wait_for_heatup = false;
35 38
 }
36 39
 

+ 1
- 1
Marlin/src/gcode/feature/pause/M701_M702.cpp View File

@@ -81,7 +81,7 @@ void GcodeSuite::M701() {
81 81
   const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
82 82
                                                        : filament_change_load_length[active_extruder]);
83 83
   load_filament(slow_load_length, fast_load_length, ADVANCED_PAUSE_PURGE_LENGTH, FILAMENT_CHANGE_ALERT_BEEPS,
84
-                true, thermalManager.wait_for_heating(target_extruder), ADVANCED_PAUSE_MODE_LOAD_FILAMENT
84
+                true, thermalManager.still_heating(target_extruder), ADVANCED_PAUSE_MODE_LOAD_FILAMENT
85 85
                 #if ENABLED(DUAL_X_CARRIAGE)
86 86
                   , target_extruder
87 87
                 #endif

+ 1
- 114
Marlin/src/gcode/temperature/M104_M109.cpp View File

@@ -80,14 +80,6 @@ void GcodeSuite::M104() {
80 80
  * M109: Sxxx Wait for extruder(s) to reach temperature. Waits only when heating.
81 81
  *       Rxxx Wait for extruder(s) to reach temperature. Waits when heating and cooling.
82 82
  */
83
-
84
-#ifndef MIN_COOLING_SLOPE_DEG
85
-  #define MIN_COOLING_SLOPE_DEG 1.50
86
-#endif
87
-#ifndef MIN_COOLING_SLOPE_TIME
88
-  #define MIN_COOLING_SLOPE_TIME 60
89
-#endif
90
-
91 83
 void GcodeSuite::M109() {
92 84
 
93 85
   if (get_target_extruder_from_command()) return;
@@ -137,110 +129,5 @@ void GcodeSuite::M109() {
137 129
     planner.autotemp_M104_M109();
138 130
   #endif
139 131
 
140
-  #if TEMP_RESIDENCY_TIME > 0
141
-    millis_t residency_start_ms = 0;
142
-    // Loop until the temperature has stabilized
143
-    #define TEMP_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_RESIDENCY_TIME) * 1000UL))
144
-  #else
145
-    // Loop until the temperature is very close target
146
-    #define TEMP_CONDITIONS (wants_to_cool ? thermalManager.isCoolingHotend(target_extruder) : thermalManager.isHeatingHotend(target_extruder))
147
-  #endif
148
-
149
-  float target_temp = -1.0, old_temp = 9999.0;
150
-  bool wants_to_cool = false;
151
-  wait_for_heatup = true;
152
-  millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
153
-
154
-  #if DISABLED(BUSY_WHILE_HEATING)
155
-    KEEPALIVE_STATE(NOT_BUSY);
156
-  #endif
157
-
158
-  #if ENABLED(PRINTER_EVENT_LEDS)
159
-    const float start_temp = thermalManager.degHotend(target_extruder);
160
-    uint8_t old_blue = 0;
161
-  #endif
162
-
163
-  do {
164
-    // Target temperature might be changed during the loop
165
-    if (target_temp != thermalManager.degTargetHotend(target_extruder)) {
166
-      wants_to_cool = thermalManager.isCoolingHotend(target_extruder);
167
-      target_temp = thermalManager.degTargetHotend(target_extruder);
168
-
169
-      // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
170
-      if (no_wait_for_cooling && wants_to_cool) break;
171
-    }
172
-
173
-    now = millis();
174
-    if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
175
-      next_temp_ms = now + 1000UL;
176
-      thermalManager.print_heaterstates();
177
-      #if TEMP_RESIDENCY_TIME > 0
178
-        SERIAL_PROTOCOLPGM(" W:");
179
-        if (residency_start_ms)
180
-          SERIAL_PROTOCOL(long((((TEMP_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL));
181
-        else
182
-          SERIAL_PROTOCOLCHAR('?');
183
-      #endif
184
-      SERIAL_EOL();
185
-    }
186
-
187
-    idle();
188
-    reset_stepper_timeout(); // Keep steppers powered
189
-
190
-    const float temp = thermalManager.degHotend(target_extruder);
191
-
192
-    #if ENABLED(PRINTER_EVENT_LEDS)
193
-      // Gradually change LED strip from violet to red as nozzle heats up
194
-      if (!wants_to_cool) {
195
-        const uint8_t blue = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 255, 0);
196
-        if (blue != old_blue) {
197
-          old_blue = blue;
198
-          leds.set_color(
199
-            MakeLEDColor(255, 0, blue, 0, pixels.getBrightness())
200
-            #if ENABLED(NEOPIXEL_IS_SEQUENTIAL)
201
-              , true
202
-            #endif
203
-          );
204
-        }
205
-      }
206
-    #endif
207
-
208
-    #if TEMP_RESIDENCY_TIME > 0
209
-
210
-      const float temp_diff = ABS(target_temp - temp);
211
-
212
-      if (!residency_start_ms) {
213
-        // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
214
-        if (temp_diff < TEMP_WINDOW) residency_start_ms = now;
215
-      }
216
-      else if (temp_diff > TEMP_HYSTERESIS) {
217
-        // Restart the timer whenever the temperature falls outside the hysteresis.
218
-        residency_start_ms = now;
219
-      }
220
-
221
-    #endif
222
-
223
-    // Prevent a wait-forever situation if R is misused i.e. M109 R0
224
-    if (wants_to_cool) {
225
-      // break after MIN_COOLING_SLOPE_TIME seconds
226
-      // if the temperature did not drop at least MIN_COOLING_SLOPE_DEG
227
-      if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
228
-        if (old_temp - temp < float(MIN_COOLING_SLOPE_DEG)) break;
229
-        next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME;
230
-        old_temp = temp;
231
-      }
232
-    }
233
-
234
-  } while (wait_for_heatup && TEMP_CONDITIONS);
235
-
236
-  if (wait_for_heatup) {
237
-    lcd_reset_status();
238
-    #if ENABLED(PRINTER_EVENT_LEDS)
239
-      leds.set_white();
240
-    #endif
241
-  }
242
-
243
-  #if DISABLED(BUSY_WHILE_HEATING)
244
-    KEEPALIVE_STATE(IN_HANDLER);
245
-  #endif
132
+  (void)thermalManager.wait_for_hotend(target_extruder, no_wait_for_cooling);
246 133
 }

+ 1
- 109
Marlin/src/gcode/temperature/M140_M190.cpp View File

@@ -47,13 +47,6 @@ void GcodeSuite::M140() {
47 47
   if (parser.seenval('S')) thermalManager.setTargetBed(parser.value_celsius());
48 48
 }
49 49
 
50
-#ifndef MIN_COOLING_SLOPE_DEG_BED
51
-  #define MIN_COOLING_SLOPE_DEG_BED 1.50
52
-#endif
53
-#ifndef MIN_COOLING_SLOPE_TIME_BED
54
-  #define MIN_COOLING_SLOPE_TIME_BED 60
55
-#endif
56
-
57 50
 /**
58 51
  * M190: Sxxx Wait for bed current temp to reach target temp. Waits only when heating
59 52
  *       Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
@@ -73,108 +66,7 @@ void GcodeSuite::M190() {
73 66
 
74 67
   lcd_setstatusPGM(thermalManager.isHeatingBed() ? PSTR(MSG_BED_HEATING) : PSTR(MSG_BED_COOLING));
75 68
 
76
-  #if TEMP_BED_RESIDENCY_TIME > 0
77
-    millis_t residency_start_ms = 0;
78
-    // Loop until the temperature has stabilized
79
-    #define TEMP_BED_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_BED_RESIDENCY_TIME) * 1000UL))
80
-  #else
81
-    // Loop until the temperature is very close target
82
-    #define TEMP_BED_CONDITIONS (wants_to_cool ? thermalManager.isCoolingBed() : thermalManager.isHeatingBed())
83
-  #endif
84
-
85
-  float target_temp = -1, old_temp = 9999;
86
-  bool wants_to_cool = false;
87
-  wait_for_heatup = true;
88
-  millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
89
-
90
-  #if DISABLED(BUSY_WHILE_HEATING)
91
-    KEEPALIVE_STATE(NOT_BUSY);
92
-  #endif
93
-
94
-  target_extruder = active_extruder; // for print_heaterstates
95
-
96
-  #if ENABLED(PRINTER_EVENT_LEDS)
97
-    const float start_temp = thermalManager.degBed();
98
-    uint8_t old_red = 127;
99
-  #endif
100
-
101
-  do {
102
-    // Target temperature might be changed during the loop
103
-    if (target_temp != thermalManager.degTargetBed()) {
104
-      wants_to_cool = thermalManager.isCoolingBed();
105
-      target_temp = thermalManager.degTargetBed();
106
-
107
-      // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
108
-      if (no_wait_for_cooling && wants_to_cool) break;
109
-    }
110
-
111
-    now = millis();
112
-    if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
113
-      next_temp_ms = now + 1000UL;
114
-      thermalManager.print_heaterstates();
115
-      #if TEMP_BED_RESIDENCY_TIME > 0
116
-        SERIAL_PROTOCOLPGM(" W:");
117
-        if (residency_start_ms)
118
-          SERIAL_PROTOCOL(long((((TEMP_BED_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL));
119
-        else
120
-          SERIAL_PROTOCOLCHAR('?');
121
-      #endif
122
-      SERIAL_EOL();
123
-    }
124
-
125
-    idle();
126
-    reset_stepper_timeout(); // Keep steppers powered
127
-
128
-    const float temp = thermalManager.degBed();
129
-
130
-    #if ENABLED(PRINTER_EVENT_LEDS)
131
-      // Gradually change LED strip from blue to violet as bed heats up
132
-      if (!wants_to_cool) {
133
-        const uint8_t red = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 0, 255);
134
-        if (red != old_red) {
135
-          old_red = red;
136
-          leds.set_color(
137
-            MakeLEDColor(red, 0, 255, 0, pixels.getBrightness())
138
-            #if ENABLED(NEOPIXEL_IS_SEQUENTIAL)
139
-              , true
140
-            #endif
141
-          );
142
-        }
143
-      }
144
-    #endif
145
-
146
-    #if TEMP_BED_RESIDENCY_TIME > 0
147
-
148
-      const float temp_diff = ABS(target_temp - temp);
149
-
150
-      if (!residency_start_ms) {
151
-        // Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
152
-        if (temp_diff < TEMP_BED_WINDOW) residency_start_ms = now;
153
-      }
154
-      else if (temp_diff > TEMP_BED_HYSTERESIS) {
155
-        // Restart the timer whenever the temperature falls outside the hysteresis.
156
-        residency_start_ms = now;
157
-      }
158
-
159
-    #endif // TEMP_BED_RESIDENCY_TIME > 0
160
-
161
-    // Prevent a wait-forever situation if R is misused i.e. M190 R0
162
-    if (wants_to_cool) {
163
-      // Break after MIN_COOLING_SLOPE_TIME_BED seconds
164
-      // if the temperature did not drop at least MIN_COOLING_SLOPE_DEG_BED
165
-      if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
166
-        if (old_temp - temp < float(MIN_COOLING_SLOPE_DEG_BED)) break;
167
-        next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME_BED;
168
-        old_temp = temp;
169
-      }
170
-    }
171
-
172
-  } while (wait_for_heatup && TEMP_BED_CONDITIONS);
173
-
174
-  if (wait_for_heatup) lcd_reset_status();
175
-  #if DISABLED(BUSY_WHILE_HEATING)
176
-    KEEPALIVE_STATE(IN_HANDLER);
177
-  #endif
69
+  thermalManager.wait_for_bed(no_wait_for_cooling);
178 70
 }
179 71
 
180 72
 #endif // HAS_HEATED_BED

+ 248
- 0
Marlin/src/module/temperature.cpp View File

@@ -51,6 +51,10 @@
51 51
   #include "../feature/emergency_parser.h"
52 52
 #endif
53 53
 
54
+#if ENABLED(PRINTER_EVENT_LEDS)
55
+  #include "../feature/leds/leds.h"
56
+#endif
57
+
54 58
 #if HOTEND_USES_THERMISTOR
55 59
   #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
56 60
     static void* heater_ttbl_map[2] = { (void*)HEATER_0_TEMPTABLE, (void*)HEATER_1_TEMPTABLE };
@@ -2412,4 +2416,248 @@ void Temperature::isr() {
2412 2416
 
2413 2417
   #endif // AUTO_REPORT_TEMPERATURES
2414 2418
 
2419
+  #if HAS_TEMP_HOTEND
2420
+
2421
+    #ifndef MIN_COOLING_SLOPE_DEG
2422
+      #define MIN_COOLING_SLOPE_DEG 1.50
2423
+    #endif
2424
+    #ifndef MIN_COOLING_SLOPE_TIME
2425
+      #define MIN_COOLING_SLOPE_TIME 60
2426
+    #endif
2427
+
2428
+    bool Temperature::wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling/*=true*/) {
2429
+      #if TEMP_RESIDENCY_TIME > 0
2430
+        millis_t residency_start_ms = 0;
2431
+        // Loop until the temperature has stabilized
2432
+        #define TEMP_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_RESIDENCY_TIME) * 1000UL))
2433
+      #else
2434
+        // Loop until the temperature is very close target
2435
+        #define TEMP_CONDITIONS (wants_to_cool ? isCoolingHotend(target_extruder) : isHeatingHotend(target_extruder))
2436
+      #endif
2437
+
2438
+      #if DISABLED(BUSY_WHILE_HEATING)
2439
+        #if ENABLED(HOST_KEEPALIVE_FEATURE)
2440
+          const MarlinBusyState old_busy_state = gcode.busy_state;
2441
+        #endif
2442
+        KEEPALIVE_STATE(NOT_BUSY);
2443
+      #endif
2444
+
2445
+      #if ENABLED(PRINTER_EVENT_LEDS)
2446
+        const float start_temp = degHotend(target_extruder);
2447
+        uint8_t old_blue = 0;
2448
+      #endif
2449
+
2450
+      float target_temp = -1.0, old_temp = 9999.0;
2451
+      bool wants_to_cool = false;
2452
+      wait_for_heatup = true;
2453
+      millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
2454
+      do {
2455
+        // Target temperature might be changed during the loop
2456
+        if (target_temp != degTargetHotend(target_extruder)) {
2457
+          wants_to_cool = isCoolingHotend(target_extruder);
2458
+          target_temp = degTargetHotend(target_extruder);
2459
+
2460
+          // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
2461
+          if (no_wait_for_cooling && wants_to_cool) break;
2462
+        }
2463
+
2464
+        now = millis();
2465
+        if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
2466
+          next_temp_ms = now + 1000UL;
2467
+          print_heaterstates();
2468
+          #if TEMP_RESIDENCY_TIME > 0
2469
+            SERIAL_PROTOCOLPGM(" W:");
2470
+            if (residency_start_ms)
2471
+              SERIAL_PROTOCOL(long((((TEMP_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL));
2472
+            else
2473
+              SERIAL_PROTOCOLCHAR('?');
2474
+          #endif
2475
+          SERIAL_EOL();
2476
+        }
2477
+
2478
+        idle();
2479
+        gcode.reset_stepper_timeout(); // Keep steppers powered
2480
+
2481
+        const float temp = degHotend(target_extruder);
2482
+
2483
+        #if ENABLED(PRINTER_EVENT_LEDS)
2484
+          // Gradually change LED strip from violet to red as nozzle heats up
2485
+          if (!wants_to_cool) {
2486
+            const uint8_t blue = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 255, 0);
2487
+            if (blue != old_blue) {
2488
+              old_blue = blue;
2489
+              leds.set_color(
2490
+                MakeLEDColor(255, 0, blue, 0, pixels.getBrightness())
2491
+                #if ENABLED(NEOPIXEL_IS_SEQUENTIAL)
2492
+                  , true
2493
+                #endif
2494
+              );
2495
+            }
2496
+          }
2497
+        #endif
2498
+
2499
+        #if TEMP_RESIDENCY_TIME > 0
2500
+
2501
+          const float temp_diff = ABS(target_temp - temp);
2502
+
2503
+          if (!residency_start_ms) {
2504
+            // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
2505
+            if (temp_diff < TEMP_WINDOW) residency_start_ms = now;
2506
+          }
2507
+          else if (temp_diff > TEMP_HYSTERESIS) {
2508
+            // Restart the timer whenever the temperature falls outside the hysteresis.
2509
+            residency_start_ms = now;
2510
+          }
2511
+
2512
+        #endif
2513
+
2514
+        // Prevent a wait-forever situation if R is misused i.e. M109 R0
2515
+        if (wants_to_cool) {
2516
+          // break after MIN_COOLING_SLOPE_TIME seconds
2517
+          // if the temperature did not drop at least MIN_COOLING_SLOPE_DEG
2518
+          if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
2519
+            if (old_temp - temp < float(MIN_COOLING_SLOPE_DEG)) break;
2520
+            next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME;
2521
+            old_temp = temp;
2522
+          }
2523
+        }
2524
+
2525
+      } while (wait_for_heatup && TEMP_CONDITIONS);
2526
+
2527
+      if (wait_for_heatup) {
2528
+        lcd_reset_status();
2529
+        #if ENABLED(PRINTER_EVENT_LEDS)
2530
+          leds.set_white();
2531
+        #endif
2532
+      }
2533
+
2534
+      #if DISABLED(BUSY_WHILE_HEATING) && ENABLED(HOST_KEEPALIVE_FEATURE)
2535
+        gcode.busy_state = old_busy_state;
2536
+      #endif
2537
+
2538
+      return wait_for_heatup;
2539
+    }
2540
+
2541
+  #endif // HAS_TEMP_HOTEND
2542
+
2543
+  #if HAS_HEATED_BED
2544
+
2545
+    #ifndef MIN_COOLING_SLOPE_DEG_BED
2546
+      #define MIN_COOLING_SLOPE_DEG_BED 1.50
2547
+    #endif
2548
+    #ifndef MIN_COOLING_SLOPE_TIME_BED
2549
+      #define MIN_COOLING_SLOPE_TIME_BED 60
2550
+    #endif
2551
+
2552
+    void Temperature::wait_for_bed(const bool no_wait_for_cooling) {
2553
+      #if TEMP_BED_RESIDENCY_TIME > 0
2554
+        millis_t residency_start_ms = 0;
2555
+        // Loop until the temperature has stabilized
2556
+        #define TEMP_BED_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_BED_RESIDENCY_TIME) * 1000UL))
2557
+      #else
2558
+        // Loop until the temperature is very close target
2559
+        #define TEMP_BED_CONDITIONS (wants_to_cool ? isCoolingBed() : isHeatingBed())
2560
+      #endif
2561
+
2562
+      float target_temp = -1, old_temp = 9999;
2563
+      bool wants_to_cool = false;
2564
+      wait_for_heatup = true;
2565
+      millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
2566
+
2567
+      #if DISABLED(BUSY_WHILE_HEATING)
2568
+        #if ENABLED(HOST_KEEPALIVE_FEATURE)
2569
+          const MarlinBusyState old_busy_state = gcode.busy_state;
2570
+        #endif
2571
+        KEEPALIVE_STATE(NOT_BUSY);
2572
+      #endif
2573
+
2574
+      gcode.target_extruder = active_extruder; // for print_heaterstates
2575
+
2576
+      #if ENABLED(PRINTER_EVENT_LEDS)
2577
+        const float start_temp = degBed();
2578
+        uint8_t old_red = 127;
2579
+      #endif
2580
+
2581
+      do {
2582
+        // Target temperature might be changed during the loop
2583
+        if (target_temp != degTargetBed()) {
2584
+          wants_to_cool = isCoolingBed();
2585
+          target_temp = degTargetBed();
2586
+
2587
+          // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
2588
+          if (no_wait_for_cooling && wants_to_cool) break;
2589
+        }
2590
+
2591
+        now = millis();
2592
+        if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
2593
+          next_temp_ms = now + 1000UL;
2594
+          print_heaterstates();
2595
+          #if TEMP_BED_RESIDENCY_TIME > 0
2596
+            SERIAL_PROTOCOLPGM(" W:");
2597
+            if (residency_start_ms)
2598
+              SERIAL_PROTOCOL(long((((TEMP_BED_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL));
2599
+            else
2600
+              SERIAL_PROTOCOLCHAR('?');
2601
+          #endif
2602
+          SERIAL_EOL();
2603
+        }
2604
+
2605
+        idle();
2606
+        gcode.reset_stepper_timeout(); // Keep steppers powered
2607
+
2608
+        const float temp = degBed();
2609
+
2610
+        #if ENABLED(PRINTER_EVENT_LEDS)
2611
+          // Gradually change LED strip from blue to violet as bed heats up
2612
+          if (!wants_to_cool) {
2613
+            const uint8_t red = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 0, 255);
2614
+            if (red != old_red) {
2615
+              old_red = red;
2616
+              leds.set_color(
2617
+                MakeLEDColor(red, 0, 255, 0, pixels.getBrightness())
2618
+                #if ENABLED(NEOPIXEL_IS_SEQUENTIAL)
2619
+                  , true
2620
+                #endif
2621
+              );
2622
+            }
2623
+          }
2624
+        #endif
2625
+
2626
+        #if TEMP_BED_RESIDENCY_TIME > 0
2627
+
2628
+          const float temp_diff = ABS(target_temp - temp);
2629
+
2630
+          if (!residency_start_ms) {
2631
+            // Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
2632
+            if (temp_diff < TEMP_BED_WINDOW) residency_start_ms = now;
2633
+          }
2634
+          else if (temp_diff > TEMP_BED_HYSTERESIS) {
2635
+            // Restart the timer whenever the temperature falls outside the hysteresis.
2636
+            residency_start_ms = now;
2637
+          }
2638
+
2639
+        #endif // TEMP_BED_RESIDENCY_TIME > 0
2640
+
2641
+        // Prevent a wait-forever situation if R is misused i.e. M190 R0
2642
+        if (wants_to_cool) {
2643
+          // Break after MIN_COOLING_SLOPE_TIME_BED seconds
2644
+          // if the temperature did not drop at least MIN_COOLING_SLOPE_DEG_BED
2645
+          if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
2646
+            if (old_temp - temp < float(MIN_COOLING_SLOPE_DEG_BED)) break;
2647
+            next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME_BED;
2648
+            old_temp = temp;
2649
+          }
2650
+        }
2651
+
2652
+      } while (wait_for_heatup && TEMP_BED_CONDITIONS);
2653
+
2654
+      if (wait_for_heatup) lcd_reset_status();
2655
+
2656
+      #if DISABLED(BUSY_WHILE_HEATING) && ENABLED(HOST_KEEPALIVE_FEATURE)
2657
+        gcode.busy_state = old_busy_state;
2658
+      #endif
2659
+    }
2660
+
2661
+  #endif // HAS_HEATED_BED
2662
+
2415 2663
 #endif // HAS_TEMP_SENSOR

+ 10
- 2
Marlin/src/module/temperature.h View File

@@ -433,7 +433,12 @@ class Temperature {
433 433
       return target_temperature[HOTEND_INDEX] < current_temperature[HOTEND_INDEX];
434 434
     }
435 435
 
436
+    #if HAS_TEMP_HOTEND
437
+      static bool wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling=true);
438
+    #endif
439
+
436 440
     #if HAS_HEATED_BED
441
+
437 442
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
438 443
         FORCE_INLINE static int16_t rawBedTemp()  { return current_temperature_bed_raw; }
439 444
       #endif
@@ -461,7 +466,10 @@ class Temperature {
461 466
       #if WATCH_THE_BED
462 467
         static void start_watching_bed();
463 468
       #endif
464
-    #endif
469
+
470
+      static void wait_for_bed(const bool no_wait_for_cooling);
471
+
472
+    #endif // HAS_HEATED_BED
465 473
 
466 474
     #if HAS_TEMP_CHAMBER
467 475
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
@@ -470,7 +478,7 @@ class Temperature {
470 478
       FORCE_INLINE static float degChamber() { return current_temperature_chamber; }
471 479
     #endif
472 480
 
473
-    FORCE_INLINE static bool wait_for_heating(const uint8_t e) {
481
+    FORCE_INLINE static bool still_heating(const uint8_t e) {
474 482
       return degTargetHotend(e) > TEMP_HYSTERESIS && ABS(degHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS;
475 483
     }
476 484
 

Loading…
Cancel
Save