Subversion Repositories Tronxy-X3A-Marlin

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ron 1
/**
2
 * Marlin 3D Printer Firmware
3
 * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
 *
5
 * Based on Sprinter and grbl.
6
 * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 */
22
 
23
/**
24
 * temperature.h - temperature controller
25
 */
26
 
27
#ifndef TEMPERATURE_H
28
#define TEMPERATURE_H
29
 
30
#include "thermistortables.h"
31
 
32
#include "MarlinConfig.h"
33
 
34
#if ENABLED(AUTO_POWER_CONTROL)
35
  #include "power.h"
36
#endif
37
 
38
#if ENABLED(PID_EXTRUSION_SCALING)
39
  #include "stepper.h"
40
#endif
41
 
42
#ifndef SOFT_PWM_SCALE
43
  #define SOFT_PWM_SCALE 0
44
#endif
45
 
46
#define ENABLE_TEMPERATURE_INTERRUPT()  SBI(TIMSK0, OCIE0B)
47
#define DISABLE_TEMPERATURE_INTERRUPT() CBI(TIMSK0, OCIE0B)
48
#define TEMPERATURE_ISR_ENABLED()      TEST(TIMSK0, OCIE0B)
49
 
50
#define HOTEND_LOOP() for (int8_t e = 0; e < HOTENDS; e++)
51
 
52
#if HOTENDS == 1
53
  #define HOTEND_INDEX  0
54
#else
55
  #define HOTEND_INDEX  e
56
#endif
57
 
58
/**
59
 * States for ADC reading in the ISR
60
 */
61
enum ADCSensorState : char {
62
  StartSampling,
63
  #if HAS_TEMP_ADC_0
64
    PrepareTemp_0,
65
    MeasureTemp_0,
66
  #endif
67
  #if HAS_TEMP_ADC_1
68
    PrepareTemp_1,
69
    MeasureTemp_1,
70
  #endif
71
  #if HAS_TEMP_ADC_2
72
    PrepareTemp_2,
73
    MeasureTemp_2,
74
  #endif
75
  #if HAS_TEMP_ADC_3
76
    PrepareTemp_3,
77
    MeasureTemp_3,
78
  #endif
79
  #if HAS_TEMP_ADC_4
80
    PrepareTemp_4,
81
    MeasureTemp_4,
82
  #endif
83
  #if HAS_HEATED_BED
84
    PrepareTemp_BED,
85
    MeasureTemp_BED,
86
  #endif
87
  #if HAS_TEMP_CHAMBER
88
    PrepareTemp_CHAMBER,
89
    MeasureTemp_CHAMBER,
90
  #endif
91
  #if ENABLED(FILAMENT_WIDTH_SENSOR)
92
    Prepare_FILWIDTH,
93
    Measure_FILWIDTH,
94
  #endif
95
  #if ENABLED(ADC_KEYPAD)
96
    Prepare_ADC_KEY,
97
    Measure_ADC_KEY,
98
  #endif
99
  SensorsReady, // Temperatures ready. Delay the next round of readings to let ADC pins settle.
100
  StartupDelay  // Startup, delay initial temp reading a tiny bit so the hardware can settle
101
};
102
 
103
// Minimum number of Temperature::ISR loops between sensor readings.
104
// Multiplied by 16 (OVERSAMPLENR) to obtain the total time to
105
// get all oversampled sensor readings
106
#define MIN_ADC_ISR_LOOPS 10
107
 
108
#define ACTUAL_ADC_SAMPLES MAX(int(MIN_ADC_ISR_LOOPS), int(SensorsReady))
109
 
110
#if HAS_PID_HEATING
111
  #define PID_K2 (1.0f-PID_K1)
112
  #define PID_dT ((OVERSAMPLENR * float(ACTUAL_ADC_SAMPLES)) / (F_CPU / 64.0f / 256.0f))
113
 
114
  // Apply the scale factors to the PID values
115
  #define scalePID_i(i)   ( (i) * float(PID_dT) )
116
  #define unscalePID_i(i) ( (i) / float(PID_dT) )
117
  #define scalePID_d(d)   ( (d) / float(PID_dT) )
118
  #define unscalePID_d(d) ( (d) * float(PID_dT) )
119
#endif
120
 
121
class Temperature {
122
 
123
  public:
124
 
125
    static float current_temperature[HOTENDS];
126
    static int16_t current_temperature_raw[HOTENDS],
127
                   target_temperature[HOTENDS];
128
    static uint8_t soft_pwm_amount[HOTENDS];
129
 
130
    #if ENABLED(AUTO_POWER_E_FANS)
131
      static int16_t autofan_speed[HOTENDS];
132
    #endif
133
 
134
    #if ENABLED(FAN_SOFT_PWM)
135
      static uint8_t soft_pwm_amount_fan[FAN_COUNT],
136
                     soft_pwm_count_fan[FAN_COUNT];
137
    #endif
138
 
139
    #if ENABLED(PIDTEMP)
140
 
141
      #if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
142
 
143
        static float Kp[HOTENDS], Ki[HOTENDS], Kd[HOTENDS];
144
        #if ENABLED(PID_EXTRUSION_SCALING)
145
          static float Kc[HOTENDS];
146
        #endif
147
        #define PID_PARAM(param, h) Temperature::param[h]
148
 
149
      #else
150
 
151
        static float Kp, Ki, Kd;
152
        #if ENABLED(PID_EXTRUSION_SCALING)
153
          static float Kc;
154
        #endif
155
        #define PID_PARAM(param, h) Temperature::param
156
 
157
      #endif // PID_PARAMS_PER_HOTEND
158
 
159
    #endif
160
 
161
    #if HAS_HEATED_BED
162
      static float current_temperature_bed;
163
      static int16_t current_temperature_bed_raw, target_temperature_bed;
164
      static uint8_t soft_pwm_amount_bed;
165
      #if ENABLED(PIDTEMPBED)
166
        static float bedKp, bedKi, bedKd;
167
      #endif
168
    #endif
169
 
170
    #if ENABLED(BABYSTEPPING)
171
      static volatile int babystepsTodo[3];
172
    #endif
173
 
174
    #if ENABLED(PREVENT_COLD_EXTRUSION)
175
      static bool allow_cold_extrude;
176
      static int16_t extrude_min_temp;
177
      FORCE_INLINE static bool tooCold(const int16_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp; }
178
      FORCE_INLINE static bool tooColdToExtrude(const uint8_t e) {
179
        #if HOTENDS == 1
180
          UNUSED(e);
181
        #endif
182
        return tooCold(degHotend(HOTEND_INDEX));
183
      }
184
      FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t e) {
185
        #if HOTENDS == 1
186
          UNUSED(e);
187
        #endif
188
        return tooCold(degTargetHotend(HOTEND_INDEX));
189
      }
190
    #else
191
      FORCE_INLINE static bool tooColdToExtrude(const uint8_t e) { UNUSED(e); return false; }
192
      FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t e) { UNUSED(e); return false; }
193
    #endif
194
 
195
    FORCE_INLINE static bool hotEnoughToExtrude(const uint8_t e) { return !tooColdToExtrude(e); }
196
    FORCE_INLINE static bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); }
197
 
198
  private:
199
 
200
    static volatile bool temp_meas_ready;
201
    static uint16_t raw_temp_value[MAX_EXTRUDERS];
202
 
203
    #if WATCH_HOTENDS
204
      static uint16_t watch_target_temp[HOTENDS];
205
      static millis_t watch_heater_next_ms[HOTENDS];
206
    #endif
207
 
208
    #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
209
      static uint16_t redundant_temperature_raw;
210
      static float redundant_temperature;
211
    #endif
212
 
213
    #if ENABLED(PIDTEMP)
214
      static float temp_iState[HOTENDS],
215
                   temp_dState[HOTENDS],
216
                   pTerm[HOTENDS],
217
                   iTerm[HOTENDS],
218
                   dTerm[HOTENDS];
219
 
220
      #if ENABLED(PID_EXTRUSION_SCALING)
221
        static float cTerm[HOTENDS];
222
        static long last_e_position;
223
        static long lpq[LPQ_MAX_LEN];
224
        static int lpq_ptr;
225
      #endif
226
 
227
      static float pid_error[HOTENDS];
228
      static bool pid_reset[HOTENDS];
229
    #endif
230
 
231
    // Init min and max temp with extreme values to prevent false errors during startup
232
    static int16_t minttemp_raw[HOTENDS],
233
                   maxttemp_raw[HOTENDS],
234
                   minttemp[HOTENDS],
235
                   maxttemp[HOTENDS];
236
 
237
    #if HAS_HEATED_BED
238
      static uint16_t raw_temp_bed_value;
239
      #if WATCH_THE_BED
240
        static uint16_t watch_target_bed_temp;
241
        static millis_t watch_bed_next_ms;
242
      #endif
243
      #if ENABLED(PIDTEMPBED)
244
        static float temp_iState_bed,
245
                     temp_dState_bed,
246
                     pTerm_bed,
247
                     iTerm_bed,
248
                     dTerm_bed,
249
                     pid_error_bed;
250
      #else
251
        static millis_t next_bed_check_ms;
252
      #endif
253
      #if HEATER_IDLE_HANDLER
254
        static millis_t bed_idle_timeout_ms;
255
        static bool bed_idle_timeout_exceeded;
256
      #endif
257
      #ifdef BED_MINTEMP
258
        static int16_t bed_minttemp_raw;
259
      #endif
260
      #ifdef BED_MAXTEMP
261
        static int16_t bed_maxttemp_raw;
262
      #endif
263
    #endif
264
 
265
    #if HAS_TEMP_CHAMBER
266
      static uint16_t raw_temp_chamber_value;
267
      static float current_temperature_chamber;
268
      static int16_t current_temperature_chamber_raw;
269
    #endif
270
 
271
    #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
272
      static uint8_t consecutive_low_temperature_error[HOTENDS];
273
    #endif
274
 
275
    #ifdef MILLISECONDS_PREHEAT_TIME
276
      static millis_t preheat_end_time[HOTENDS];
277
    #endif
278
 
279
    #if ENABLED(FILAMENT_WIDTH_SENSOR)
280
      static int8_t meas_shift_index;  // Index of a delayed sample in buffer
281
    #endif
282
 
283
    #if HAS_AUTO_FAN
284
      static millis_t next_auto_fan_check_ms;
285
    #endif
286
 
287
    #if ENABLED(FILAMENT_WIDTH_SENSOR)
288
      static uint16_t current_raw_filwidth; // Measured filament diameter - one extruder only
289
    #endif
290
 
291
    #if ENABLED(PROBING_HEATERS_OFF)
292
      static bool paused;
293
    #endif
294
 
295
    #if HEATER_IDLE_HANDLER
296
      static millis_t heater_idle_timeout_ms[HOTENDS];
297
      static bool heater_idle_timeout_exceeded[HOTENDS];
298
    #endif
299
 
300
  public:
301
    #if ENABLED(ADC_KEYPAD)
302
      static uint32_t current_ADCKey_raw;
303
      static uint8_t ADCKey_count;
304
    #endif
305
 
306
    #if ENABLED(PID_EXTRUSION_SCALING)
307
      static int16_t lpq_len;
308
    #endif
309
 
310
    /**
311
     * Instance Methods
312
     */
313
 
314
    Temperature();
315
 
316
    void init();
317
 
318
    /**
319
     * Static (class) methods
320
     */
321
    static float analog_to_celsius_hotend(const int raw, const uint8_t e);
322
 
323
    #if HAS_HEATED_BED
324
      static float analog_to_celsius_bed(const int raw);
325
    #endif
326
    #if HAS_TEMP_CHAMBER
327
      static float analog_to_celsius_chamber(const int raw);
328
    #endif
329
 
330
    /**
331
     * Called from the Temperature ISR
332
     */
333
    static void readings_ready();
334
    static void isr();
335
 
336
    /**
337
     * Call periodically to manage heaters
338
     */
339
    static void manage_heater() _O2; // Added _O2 to work around a compiler error
340
 
341
    /**
342
     * Preheating hotends
343
     */
344
    #ifdef MILLISECONDS_PREHEAT_TIME
345
      static bool is_preheating(const uint8_t e) {
346
        #if HOTENDS == 1
347
          UNUSED(e);
348
        #endif
349
        return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]);
350
      }
351
      static void start_preheat_time(const uint8_t e) {
352
        #if HOTENDS == 1
353
          UNUSED(e);
354
        #endif
355
        preheat_end_time[HOTEND_INDEX] = millis() + MILLISECONDS_PREHEAT_TIME;
356
      }
357
      static void reset_preheat_time(const uint8_t e) {
358
        #if HOTENDS == 1
359
          UNUSED(e);
360
        #endif
361
        preheat_end_time[HOTEND_INDEX] = 0;
362
      }
363
    #else
364
      #define is_preheating(n) (false)
365
    #endif
366
 
367
    #if ENABLED(FILAMENT_WIDTH_SENSOR)
368
      static float analog_to_mm_fil_width();         // Convert raw Filament Width to millimeters
369
      static int8_t widthFil_to_size_ratio(); // Convert Filament Width (mm) to an extrusion ratio
370
    #endif
371
 
372
 
373
    //high level conversion routines, for use outside of temperature.cpp
374
    //inline so that there is no performance decrease.
375
    //deg=degreeCelsius
376
 
377
    FORCE_INLINE static float degHotend(const uint8_t e) {
378
      #if HOTENDS == 1
379
        UNUSED(e);
380
      #endif
381
      return current_temperature[HOTEND_INDEX];
382
    }
383
 
384
    #if ENABLED(SHOW_TEMP_ADC_VALUES)
385
      FORCE_INLINE static int16_t rawHotendTemp(const uint8_t e) {
386
        #if HOTENDS == 1
387
          UNUSED(e);
388
        #endif
389
        return current_temperature_raw[HOTEND_INDEX];
390
      }
391
    #endif
392
 
393
    FORCE_INLINE static int16_t degTargetHotend(const uint8_t e) {
394
      #if HOTENDS == 1
395
        UNUSED(e);
396
      #endif
397
      return target_temperature[HOTEND_INDEX];
398
    }
399
 
400
    #if WATCH_HOTENDS
401
      static void start_watching_heater(const uint8_t e = 0);
402
    #endif
403
 
404
    static void setTargetHotend(const int16_t celsius, const uint8_t e) {
405
      #if HOTENDS == 1
406
        UNUSED(e);
407
      #endif
408
      #ifdef MILLISECONDS_PREHEAT_TIME
409
        if (celsius == 0)
410
          reset_preheat_time(HOTEND_INDEX);
411
        else if (target_temperature[HOTEND_INDEX] == 0)
412
          start_preheat_time(HOTEND_INDEX);
413
      #endif
414
      #if ENABLED(AUTO_POWER_CONTROL)
415
        powerManager.power_on();
416
      #endif
417
      target_temperature[HOTEND_INDEX] = MIN(celsius, maxttemp[HOTEND_INDEX] - 15);
418
      #if WATCH_HOTENDS
419
        start_watching_heater(HOTEND_INDEX);
420
      #endif
421
    }
422
 
423
    FORCE_INLINE static bool isHeatingHotend(const uint8_t e) {
424
      #if HOTENDS == 1
425
        UNUSED(e);
426
      #endif
427
      return target_temperature[HOTEND_INDEX] > current_temperature[HOTEND_INDEX];
428
    }
429
 
430
    FORCE_INLINE static bool isCoolingHotend(const uint8_t e) {
431
      #if HOTENDS == 1
432
        UNUSED(e);
433
      #endif
434
      return target_temperature[HOTEND_INDEX] < current_temperature[HOTEND_INDEX];
435
    }
436
 
437
    #if HAS_HEATED_BED
438
      #if ENABLED(SHOW_TEMP_ADC_VALUES)
439
        FORCE_INLINE static int16_t rawBedTemp()  { return current_temperature_bed_raw; }
440
      #endif
441
      FORCE_INLINE static float degBed()          { return current_temperature_bed; }
442
      FORCE_INLINE static int16_t degTargetBed()  { return target_temperature_bed; }
443
      FORCE_INLINE static bool isHeatingBed()     { return target_temperature_bed > current_temperature_bed; }
444
      FORCE_INLINE static bool isCoolingBed()     { return target_temperature_bed < current_temperature_bed; }
445
 
446
      static void setTargetBed(const int16_t celsius) {
447
        #if ENABLED(AUTO_POWER_CONTROL)
448
          powerManager.power_on();
449
        #endif
450
        target_temperature_bed =
451
          #ifdef BED_MAXTEMP
452
            MIN(celsius, BED_MAXTEMP - 15)
453
          #else
454
            celsius
455
          #endif
456
        ;
457
        #if WATCH_THE_BED
458
          start_watching_bed();
459
        #endif
460
      }
461
 
462
      #if WATCH_THE_BED
463
        static void start_watching_bed();
464
      #endif
465
    #endif
466
 
467
    #if HAS_TEMP_CHAMBER
468
      #if ENABLED(SHOW_TEMP_ADC_VALUES)
469
        FORCE_INLINE static int16_t rawChamberTemp() { return current_temperature_chamber_raw; }
470
      #endif
471
      FORCE_INLINE static float degChamber() { return current_temperature_chamber; }
472
    #endif
473
 
474
    FORCE_INLINE static bool wait_for_heating(const uint8_t e) {
475
      return degTargetHotend(e) > TEMP_HYSTERESIS && ABS(degHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS;
476
    }
477
 
478
    /**
479
     * The software PWM power for a heater
480
     */
481
    static int getHeaterPower(const int heater);
482
 
483
    /**
484
     * Switch off all heaters, set all target temperatures to 0
485
     */
486
    static void disable_all_heaters();
487
 
488
    /**
489
     * Perform auto-tuning for hotend or bed in response to M303
490
     */
491
    #if HAS_PID_HEATING
492
      static void pid_autotune(const float &target, const int8_t hotend, const int8_t ncycles, const bool set_result=false);
493
 
494
      /**
495
       * Update the temp manager when PID values change
496
       */
497
      #if ENABLED(PIDTEMP)
498
        FORCE_INLINE static void update_pid() {
499
          #if ENABLED(PID_EXTRUSION_SCALING)
500
            last_e_position = 0;
501
          #endif
502
        }
503
      #endif
504
 
505
    #endif
506
 
507
    #if ENABLED(BABYSTEPPING)
508
 
509
      static void babystep_axis(const AxisEnum axis, const int16_t distance) {
510
        if (TEST(axis_known_position, axis)) {
511
          #if IS_CORE
512
            #if ENABLED(BABYSTEP_XY)
513
              switch (axis) {
514
                case CORE_AXIS_1: // X on CoreXY and CoreXZ, Y on CoreYZ
515
                  babystepsTodo[CORE_AXIS_1] += distance * 2;
516
                  babystepsTodo[CORE_AXIS_2] += distance * 2;
517
                  break;
518
                case CORE_AXIS_2: // Y on CoreXY, Z on CoreXZ and CoreYZ
519
                  babystepsTodo[CORE_AXIS_1] += CORESIGN(distance * 2);
520
                  babystepsTodo[CORE_AXIS_2] -= CORESIGN(distance * 2);
521
                  break;
522
                case NORMAL_AXIS: // Z on CoreXY, Y on CoreXZ, X on CoreYZ
523
                  babystepsTodo[NORMAL_AXIS] += distance;
524
                  break;
525
              }
526
            #elif CORE_IS_XZ || CORE_IS_YZ
527
              // Only Z stepping needs to be handled here
528
              babystepsTodo[CORE_AXIS_1] += CORESIGN(distance * 2);
529
              babystepsTodo[CORE_AXIS_2] -= CORESIGN(distance * 2);
530
            #else
531
              babystepsTodo[Z_AXIS] += distance;
532
            #endif
533
          #else
534
            babystepsTodo[axis] += distance;
535
          #endif
536
        }
537
      }
538
 
539
    #endif // BABYSTEPPING
540
 
541
    #if ENABLED(PROBING_HEATERS_OFF)
542
      static void pause(const bool p);
543
      FORCE_INLINE static bool is_paused() { return paused; }
544
    #endif
545
 
546
    #if HEATER_IDLE_HANDLER
547
 
548
      static void start_heater_idle_timer(const uint8_t e, const millis_t timeout_ms) {
549
        #if HOTENDS == 1
550
          UNUSED(e);
551
        #endif
552
        heater_idle_timeout_ms[HOTEND_INDEX] = millis() + timeout_ms;
553
        heater_idle_timeout_exceeded[HOTEND_INDEX] = false;
554
      }
555
 
556
      static void reset_heater_idle_timer(const uint8_t e) {
557
        #if HOTENDS == 1
558
          UNUSED(e);
559
        #endif
560
        heater_idle_timeout_ms[HOTEND_INDEX] = 0;
561
        heater_idle_timeout_exceeded[HOTEND_INDEX] = false;
562
        #if WATCH_HOTENDS
563
          start_watching_heater(HOTEND_INDEX);
564
        #endif
565
      }
566
 
567
      FORCE_INLINE static bool is_heater_idle(const uint8_t e) {
568
        #if HOTENDS == 1
569
          UNUSED(e);
570
        #endif
571
        return heater_idle_timeout_exceeded[HOTEND_INDEX];
572
      }
573
 
574
      #if HAS_HEATED_BED
575
        static void start_bed_idle_timer(const millis_t timeout_ms) {
576
          bed_idle_timeout_ms = millis() + timeout_ms;
577
          bed_idle_timeout_exceeded = false;
578
        }
579
 
580
        static void reset_bed_idle_timer() {
581
          bed_idle_timeout_ms = 0;
582
          bed_idle_timeout_exceeded = false;
583
          #if WATCH_THE_BED
584
            start_watching_bed();
585
          #endif
586
        }
587
 
588
        FORCE_INLINE static bool is_bed_idle() { return bed_idle_timeout_exceeded; }
589
      #endif
590
 
591
    #endif // HEATER_IDLE_HANDLER
592
 
593
    #if HAS_TEMP_SENSOR
594
      static void print_heaterstates();
595
      #if ENABLED(AUTO_REPORT_TEMPERATURES)
596
        static uint8_t auto_report_temp_interval;
597
        static millis_t next_temp_report_ms;
598
        static void auto_report_temperatures(void);
599
        FORCE_INLINE void set_auto_report_interval(uint8_t v) {
600
          NOMORE(v, 60);
601
          auto_report_temp_interval = v;
602
          next_temp_report_ms = millis() + 1000UL * v;
603
        }
604
      #endif
605
    #endif
606
 
607
  private:
608
 
609
    #if ENABLED(FAST_PWM_FAN)
610
      static void setPwmFrequency(const pin_t pin, int val);
611
    #endif
612
 
613
    static void set_current_temp_raw();
614
 
615
    static void calculate_celsius_temperatures();
616
 
617
    #if ENABLED(HEATER_0_USES_MAX6675)
618
      static int read_max6675();
619
    #endif
620
 
621
    static void check_extruder_auto_fans();
622
 
623
    static float get_pid_output(const int8_t e);
624
 
625
    #if ENABLED(PIDTEMPBED)
626
      static float get_pid_output_bed();
627
    #endif
628
 
629
    static void _temp_error(const int8_t e, const char * const serial_msg, const char * const lcd_msg);
630
    static void min_temp_error(const int8_t e);
631
    static void max_temp_error(const int8_t e);
632
 
633
    #if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED
634
 
635
      enum TRState : char { TRInactive, TRFirstHeating, TRStable, TRRunaway };
636
 
637
      static void thermal_runaway_protection(TRState * const state, millis_t * const timer, const float &current, const float &target, const int8_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc);
638
 
639
      #if ENABLED(THERMAL_PROTECTION_HOTENDS)
640
        static TRState thermal_runaway_state_machine[HOTENDS];
641
        static millis_t thermal_runaway_timer[HOTENDS];
642
      #endif
643
 
644
      #if HAS_THERMALLY_PROTECTED_BED
645
        static TRState thermal_runaway_bed_state_machine;
646
        static millis_t thermal_runaway_bed_timer;
647
      #endif
648
 
649
    #endif // THERMAL_PROTECTION
650
 
651
};
652
 
653
extern Temperature thermalManager;
654
 
655
#endif // TEMPERATURE_H