My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

temperature.h 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  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. * temperature.h - temperature controller
  24. */
  25. #ifndef TEMPERATURE_H
  26. #define TEMPERATURE_H
  27. #include "thermistor/thermistors.h"
  28. #include "../inc/MarlinConfig.h"
  29. #if ENABLED(BABYSTEPPING)
  30. extern bool axis_known_position[XYZ];
  31. #endif
  32. #if ENABLED(AUTO_POWER_CONTROL)
  33. #include "../feature/power.h"
  34. #endif
  35. #ifndef SOFT_PWM_SCALE
  36. #define SOFT_PWM_SCALE 0
  37. #endif
  38. #if HOTENDS == 1
  39. #define HOTEND_INDEX 0
  40. #else
  41. #define HOTEND_INDEX e
  42. #endif
  43. /**
  44. * States for ADC reading in the ISR
  45. */
  46. enum ADCSensorState : char {
  47. #if HAS_TEMP_ADC_0
  48. PrepareTemp_0,
  49. MeasureTemp_0,
  50. #endif
  51. #if HAS_TEMP_ADC_1
  52. PrepareTemp_1,
  53. MeasureTemp_1,
  54. #endif
  55. #if HAS_TEMP_ADC_2
  56. PrepareTemp_2,
  57. MeasureTemp_2,
  58. #endif
  59. #if HAS_TEMP_ADC_3
  60. PrepareTemp_3,
  61. MeasureTemp_3,
  62. #endif
  63. #if HAS_TEMP_ADC_4
  64. PrepareTemp_4,
  65. MeasureTemp_4,
  66. #endif
  67. #if HAS_HEATED_BED
  68. PrepareTemp_BED,
  69. MeasureTemp_BED,
  70. #endif
  71. #if HAS_TEMP_CHAMBER
  72. PrepareTemp_CHAMBER,
  73. MeasureTemp_CHAMBER,
  74. #endif
  75. #if ENABLED(FILAMENT_WIDTH_SENSOR)
  76. Prepare_FILWIDTH,
  77. Measure_FILWIDTH,
  78. #endif
  79. #if ENABLED(ADC_KEYPAD)
  80. Prepare_ADC_KEY,
  81. Measure_ADC_KEY,
  82. #endif
  83. SensorsReady, // Temperatures ready. Delay the next round of readings to let ADC pins settle.
  84. StartupDelay // Startup, delay initial temp reading a tiny bit so the hardware can settle
  85. };
  86. // Minimum number of Temperature::ISR loops between sensor readings.
  87. // Multiplied by 16 (OVERSAMPLENR) to obtain the total time to
  88. // get all oversampled sensor readings
  89. #define MIN_ADC_ISR_LOOPS 10
  90. #define ACTUAL_ADC_SAMPLES MAX(int(MIN_ADC_ISR_LOOPS), int(SensorsReady))
  91. #if HAS_PID_HEATING
  92. #define PID_K2 (1.0-PID_K1)
  93. #define PID_dT ((OVERSAMPLENR * float(ACTUAL_ADC_SAMPLES)) / TEMP_TIMER_FREQUENCY)
  94. // Apply the scale factors to the PID values
  95. #define scalePID_i(i) ( (i) * PID_dT )
  96. #define unscalePID_i(i) ( (i) / PID_dT )
  97. #define scalePID_d(d) ( (d) / PID_dT )
  98. #define unscalePID_d(d) ( (d) * PID_dT )
  99. #endif
  100. class Temperature {
  101. public:
  102. static volatile bool in_temp_isr;
  103. static float current_temperature[HOTENDS];
  104. static int16_t current_temperature_raw[HOTENDS],
  105. target_temperature[HOTENDS];
  106. static uint8_t soft_pwm_amount[HOTENDS];
  107. #if ENABLED(AUTO_POWER_E_FANS)
  108. static int16_t autofan_speed[HOTENDS];
  109. #endif
  110. #if ENABLED(FAN_SOFT_PWM)
  111. static uint8_t soft_pwm_amount_fan[FAN_COUNT],
  112. soft_pwm_count_fan[FAN_COUNT];
  113. #endif
  114. #if ENABLED(PIDTEMP)
  115. #if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
  116. static float Kp[HOTENDS], Ki[HOTENDS], Kd[HOTENDS];
  117. #if ENABLED(PID_EXTRUSION_SCALING)
  118. static float Kc[HOTENDS];
  119. #endif
  120. #define PID_PARAM(param, h) Temperature::param[h]
  121. #else
  122. static float Kp, Ki, Kd;
  123. #if ENABLED(PID_EXTRUSION_SCALING)
  124. static float Kc;
  125. #endif
  126. #define PID_PARAM(param, h) Temperature::param
  127. #endif // PID_PARAMS_PER_HOTEND
  128. #endif
  129. #if HAS_HEATED_BED
  130. static float current_temperature_bed;
  131. static int16_t current_temperature_bed_raw, target_temperature_bed;
  132. static uint8_t soft_pwm_amount_bed;
  133. #if ENABLED(PIDTEMPBED)
  134. static float bedKp, bedKi, bedKd;
  135. #endif
  136. #endif
  137. #if ENABLED(BABYSTEPPING)
  138. static volatile int babystepsTodo[3];
  139. #endif
  140. #if ENABLED(PREVENT_COLD_EXTRUSION)
  141. static bool allow_cold_extrude;
  142. static int16_t extrude_min_temp;
  143. FORCE_INLINE static bool tooCold(const int16_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp; }
  144. FORCE_INLINE static bool tooColdToExtrude(const uint8_t e) {
  145. #if HOTENDS == 1
  146. UNUSED(e);
  147. #endif
  148. return tooCold(degHotend(HOTEND_INDEX));
  149. }
  150. FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t e) {
  151. #if HOTENDS == 1
  152. UNUSED(e);
  153. #endif
  154. return tooCold(degTargetHotend(HOTEND_INDEX));
  155. }
  156. #else
  157. FORCE_INLINE static bool tooColdToExtrude(const uint8_t e) { UNUSED(e); return false; }
  158. FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t e) { UNUSED(e); return false; }
  159. #endif
  160. FORCE_INLINE static bool hotEnoughToExtrude(const uint8_t e) { return !tooColdToExtrude(e); }
  161. FORCE_INLINE static bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); }
  162. private:
  163. #if EARLY_WATCHDOG
  164. static bool inited; // If temperature controller is running
  165. #endif
  166. static volatile bool temp_meas_ready;
  167. static uint16_t raw_temp_value[MAX_EXTRUDERS];
  168. #if WATCH_HOTENDS
  169. static uint16_t watch_target_temp[HOTENDS];
  170. static millis_t watch_heater_next_ms[HOTENDS];
  171. #endif
  172. #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
  173. static uint16_t redundant_temperature_raw;
  174. static float redundant_temperature;
  175. #endif
  176. #if ENABLED(PIDTEMP)
  177. static float temp_iState[HOTENDS],
  178. temp_dState[HOTENDS],
  179. pTerm[HOTENDS],
  180. iTerm[HOTENDS],
  181. dTerm[HOTENDS];
  182. #if ENABLED(PID_EXTRUSION_SCALING)
  183. static float cTerm[HOTENDS];
  184. static long last_e_position;
  185. static long lpq[LPQ_MAX_LEN];
  186. static int lpq_ptr;
  187. #endif
  188. static float pid_error[HOTENDS];
  189. static bool pid_reset[HOTENDS];
  190. #endif
  191. // Init min and max temp with extreme values to prevent false errors during startup
  192. static int16_t minttemp_raw[HOTENDS],
  193. maxttemp_raw[HOTENDS],
  194. minttemp[HOTENDS],
  195. maxttemp[HOTENDS];
  196. #if HAS_HEATED_BED
  197. static uint16_t raw_temp_bed_value;
  198. #if WATCH_THE_BED
  199. static uint16_t watch_target_bed_temp;
  200. static millis_t watch_bed_next_ms;
  201. #endif
  202. #if ENABLED(PIDTEMPBED)
  203. static float temp_iState_bed,
  204. temp_dState_bed,
  205. pTerm_bed,
  206. iTerm_bed,
  207. dTerm_bed,
  208. pid_error_bed;
  209. #else
  210. static millis_t next_bed_check_ms;
  211. #endif
  212. #if HEATER_IDLE_HANDLER
  213. static millis_t bed_idle_timeout_ms;
  214. static bool bed_idle_timeout_exceeded;
  215. #endif
  216. #ifdef BED_MINTEMP
  217. static int16_t bed_minttemp_raw;
  218. #endif
  219. #ifdef BED_MAXTEMP
  220. static int16_t bed_maxttemp_raw;
  221. #endif
  222. #endif
  223. #if HAS_TEMP_CHAMBER
  224. static uint16_t raw_temp_chamber_value;
  225. static float current_temperature_chamber;
  226. static int16_t current_temperature_chamber_raw;
  227. #endif
  228. #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
  229. static uint8_t consecutive_low_temperature_error[HOTENDS];
  230. #endif
  231. #ifdef MILLISECONDS_PREHEAT_TIME
  232. static millis_t preheat_end_time[HOTENDS];
  233. #endif
  234. #if ENABLED(FILAMENT_WIDTH_SENSOR)
  235. static int8_t meas_shift_index; // Index of a delayed sample in buffer
  236. #endif
  237. #if HAS_AUTO_FAN
  238. static millis_t next_auto_fan_check_ms;
  239. #endif
  240. #if ENABLED(FILAMENT_WIDTH_SENSOR)
  241. static uint16_t current_raw_filwidth; // Measured filament diameter - one extruder only
  242. #endif
  243. #if ENABLED(PROBING_HEATERS_OFF)
  244. static bool paused;
  245. #endif
  246. #if HEATER_IDLE_HANDLER
  247. static millis_t heater_idle_timeout_ms[HOTENDS];
  248. static bool heater_idle_timeout_exceeded[HOTENDS];
  249. #endif
  250. public:
  251. #if ENABLED(ADC_KEYPAD)
  252. static uint32_t current_ADCKey_raw;
  253. static uint8_t ADCKey_count;
  254. #endif
  255. #if ENABLED(PID_EXTRUSION_SCALING)
  256. static int16_t lpq_len;
  257. #endif
  258. /**
  259. * Instance Methods
  260. */
  261. Temperature();
  262. void init();
  263. /**
  264. * Static (class) methods
  265. */
  266. static float analog2temp(const int raw, const uint8_t e);
  267. #if HAS_HEATED_BED
  268. static float analog2tempBed(const int raw);
  269. #endif
  270. #if HAS_TEMP_CHAMBER
  271. static float analog2tempChamber(const int raw);
  272. #endif
  273. /**
  274. * Called from the Temperature ISR
  275. */
  276. static void isr();
  277. /**
  278. * Call periodically to manage heaters
  279. */
  280. static void manage_heater() _O2; // Added _O2 to work around a compiler error
  281. /**
  282. * Preheating hotends
  283. */
  284. #ifdef MILLISECONDS_PREHEAT_TIME
  285. static bool is_preheating(const uint8_t e) {
  286. #if HOTENDS == 1
  287. UNUSED(e);
  288. #endif
  289. return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]);
  290. }
  291. static void start_preheat_time(const uint8_t e) {
  292. #if HOTENDS == 1
  293. UNUSED(e);
  294. #endif
  295. preheat_end_time[HOTEND_INDEX] = millis() + MILLISECONDS_PREHEAT_TIME;
  296. }
  297. static void reset_preheat_time(const uint8_t e) {
  298. #if HOTENDS == 1
  299. UNUSED(e);
  300. #endif
  301. preheat_end_time[HOTEND_INDEX] = 0;
  302. }
  303. #else
  304. #define is_preheating(n) (false)
  305. #endif
  306. #if ENABLED(FILAMENT_WIDTH_SENSOR)
  307. static float analog2widthFil(); // Convert raw Filament Width to millimeters
  308. static int8_t widthFil_to_size_ratio(); // Convert Filament Width (mm) to an extrusion ratio
  309. #endif
  310. //high level conversion routines, for use outside of temperature.cpp
  311. //inline so that there is no performance decrease.
  312. //deg=degreeCelsius
  313. FORCE_INLINE static float degHotend(const uint8_t e) {
  314. #if HOTENDS == 1
  315. UNUSED(e);
  316. #endif
  317. return current_temperature[HOTEND_INDEX];
  318. }
  319. #if ENABLED(SHOW_TEMP_ADC_VALUES)
  320. FORCE_INLINE static int16_t rawHotendTemp(const uint8_t e) {
  321. #if HOTENDS == 1
  322. UNUSED(e);
  323. #endif
  324. return current_temperature_raw[HOTEND_INDEX];
  325. }
  326. #endif
  327. FORCE_INLINE static int16_t degTargetHotend(const uint8_t e) {
  328. #if HOTENDS == 1
  329. UNUSED(e);
  330. #endif
  331. return target_temperature[HOTEND_INDEX];
  332. }
  333. #if WATCH_HOTENDS
  334. static void start_watching_heater(const uint8_t e = 0);
  335. #endif
  336. static void setTargetHotend(const int16_t celsius, const uint8_t e) {
  337. #if HOTENDS == 1
  338. UNUSED(e);
  339. #endif
  340. #ifdef MILLISECONDS_PREHEAT_TIME
  341. if (celsius == 0)
  342. reset_preheat_time(HOTEND_INDEX);
  343. else if (target_temperature[HOTEND_INDEX] == 0)
  344. start_preheat_time(HOTEND_INDEX);
  345. #endif
  346. #if ENABLED(AUTO_POWER_CONTROL)
  347. powerManager.power_on();
  348. #endif
  349. target_temperature[HOTEND_INDEX] = celsius;
  350. #if WATCH_HOTENDS
  351. start_watching_heater(HOTEND_INDEX);
  352. #endif
  353. }
  354. FORCE_INLINE static bool isHeatingHotend(const uint8_t e) {
  355. #if HOTENDS == 1
  356. UNUSED(e);
  357. #endif
  358. return target_temperature[HOTEND_INDEX] > current_temperature[HOTEND_INDEX];
  359. }
  360. FORCE_INLINE static bool isCoolingHotend(const uint8_t e) {
  361. #if HOTENDS == 1
  362. UNUSED(e);
  363. #endif
  364. return target_temperature[HOTEND_INDEX] < current_temperature[HOTEND_INDEX];
  365. }
  366. #if HAS_HEATED_BED
  367. #if ENABLED(SHOW_TEMP_ADC_VALUES)
  368. FORCE_INLINE static int16_t rawBedTemp() { return current_temperature_bed_raw; }
  369. #endif
  370. FORCE_INLINE static float degBed() { return current_temperature_bed; }
  371. FORCE_INLINE static int16_t degTargetBed() { return target_temperature_bed; }
  372. FORCE_INLINE static bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
  373. FORCE_INLINE static bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
  374. static void setTargetBed(const int16_t celsius) {
  375. #if ENABLED(AUTO_POWER_CONTROL)
  376. powerManager.power_on();
  377. #endif
  378. target_temperature_bed =
  379. #ifdef BED_MAXTEMP
  380. MIN(celsius, BED_MAXTEMP)
  381. #else
  382. celsius
  383. #endif
  384. ;
  385. #if WATCH_THE_BED
  386. start_watching_bed();
  387. #endif
  388. }
  389. #if WATCH_THE_BED
  390. static void start_watching_bed();
  391. #endif
  392. #endif
  393. #if HAS_TEMP_CHAMBER
  394. #if ENABLED(SHOW_TEMP_ADC_VALUES)
  395. FORCE_INLINE static int16_t rawChamberTemp() { return current_temperature_chamber_raw; }
  396. #endif
  397. FORCE_INLINE static float degChamber() { return current_temperature_chamber; }
  398. #endif
  399. FORCE_INLINE static bool wait_for_heating(const uint8_t e) {
  400. return degTargetHotend(e) > TEMP_HYSTERESIS && ABS(degHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS;
  401. }
  402. /**
  403. * The software PWM power for a heater
  404. */
  405. static int getHeaterPower(const int heater);
  406. /**
  407. * Switch off all heaters, set all target temperatures to 0
  408. */
  409. static void disable_all_heaters();
  410. /**
  411. * Perform auto-tuning for hotend or bed in response to M303
  412. */
  413. #if HAS_PID_HEATING
  414. static void PID_autotune(const float &target, const int8_t hotend, const int8_t ncycles, const bool set_result=false);
  415. /**
  416. * Update the temp manager when PID values change
  417. */
  418. #if ENABLED(PIDTEMP)
  419. FORCE_INLINE static void updatePID() {
  420. #if ENABLED(PID_EXTRUSION_SCALING)
  421. last_e_position = 0;
  422. #endif
  423. }
  424. #endif
  425. #endif
  426. #if ENABLED(BABYSTEPPING)
  427. static void babystep_axis(const AxisEnum axis, const int16_t distance) {
  428. if (axis_known_position[axis]) {
  429. #if IS_CORE
  430. #if ENABLED(BABYSTEP_XY)
  431. switch (axis) {
  432. case CORE_AXIS_1: // X on CoreXY and CoreXZ, Y on CoreYZ
  433. babystepsTodo[CORE_AXIS_1] += distance * 2;
  434. babystepsTodo[CORE_AXIS_2] += distance * 2;
  435. break;
  436. case CORE_AXIS_2: // Y on CoreXY, Z on CoreXZ and CoreYZ
  437. babystepsTodo[CORE_AXIS_1] += CORESIGN(distance * 2);
  438. babystepsTodo[CORE_AXIS_2] -= CORESIGN(distance * 2);
  439. break;
  440. case NORMAL_AXIS: // Z on CoreXY, Y on CoreXZ, X on CoreYZ
  441. babystepsTodo[NORMAL_AXIS] += distance;
  442. break;
  443. }
  444. #elif CORE_IS_XZ || CORE_IS_YZ
  445. // Only Z stepping needs to be handled here
  446. babystepsTodo[CORE_AXIS_1] += CORESIGN(distance * 2);
  447. babystepsTodo[CORE_AXIS_2] -= CORESIGN(distance * 2);
  448. #else
  449. babystepsTodo[Z_AXIS] += distance;
  450. #endif
  451. #else
  452. babystepsTodo[axis] += distance;
  453. #endif
  454. }
  455. }
  456. #endif // BABYSTEPPING
  457. #if ENABLED(PROBING_HEATERS_OFF)
  458. static void pause(const bool p);
  459. FORCE_INLINE static bool is_paused() { return paused; }
  460. #endif
  461. #if HEATER_IDLE_HANDLER
  462. static void start_heater_idle_timer(const uint8_t e, const millis_t timeout_ms) {
  463. #if HOTENDS == 1
  464. UNUSED(e);
  465. #endif
  466. heater_idle_timeout_ms[HOTEND_INDEX] = millis() + timeout_ms;
  467. heater_idle_timeout_exceeded[HOTEND_INDEX] = false;
  468. }
  469. static void reset_heater_idle_timer(const uint8_t e) {
  470. #if HOTENDS == 1
  471. UNUSED(e);
  472. #endif
  473. heater_idle_timeout_ms[HOTEND_INDEX] = 0;
  474. heater_idle_timeout_exceeded[HOTEND_INDEX] = false;
  475. #if WATCH_HOTENDS
  476. start_watching_heater(HOTEND_INDEX);
  477. #endif
  478. }
  479. FORCE_INLINE static bool is_heater_idle(const uint8_t e) {
  480. #if HOTENDS == 1
  481. UNUSED(e);
  482. #endif
  483. return heater_idle_timeout_exceeded[HOTEND_INDEX];
  484. }
  485. #if HAS_HEATED_BED
  486. static void start_bed_idle_timer(const millis_t timeout_ms) {
  487. bed_idle_timeout_ms = millis() + timeout_ms;
  488. bed_idle_timeout_exceeded = false;
  489. }
  490. static void reset_bed_idle_timer() {
  491. bed_idle_timeout_ms = 0;
  492. bed_idle_timeout_exceeded = false;
  493. #if WATCH_THE_BED
  494. start_watching_bed();
  495. #endif
  496. }
  497. FORCE_INLINE static bool is_bed_idle() { return bed_idle_timeout_exceeded; }
  498. #endif
  499. #endif // HEATER_IDLE_HANDLER
  500. #if HAS_TEMP_SENSOR
  501. static void print_heaterstates(
  502. #if NUM_SERIAL > 1
  503. const int8_t port = -1
  504. #endif
  505. );
  506. #if ENABLED(AUTO_REPORT_TEMPERATURES)
  507. static uint8_t auto_report_temp_interval;
  508. static millis_t next_temp_report_ms;
  509. static void auto_report_temperatures(void);
  510. FORCE_INLINE void set_auto_report_interval(uint8_t v) {
  511. NOMORE(v, 60);
  512. auto_report_temp_interval = v;
  513. next_temp_report_ms = millis() + 1000UL * v;
  514. }
  515. #endif
  516. #endif
  517. private:
  518. #if ENABLED(FAST_PWM_FAN)
  519. static void setPwmFrequency(const pin_t pin, int val);
  520. #endif
  521. static void set_current_temp_raw();
  522. static void updateTemperaturesFromRawValues();
  523. #if ENABLED(HEATER_0_USES_MAX6675)
  524. static int read_max6675();
  525. #endif
  526. static void checkExtruderAutoFans();
  527. static float get_pid_output(const int8_t e);
  528. #if ENABLED(PIDTEMPBED)
  529. static float get_pid_output_bed();
  530. #endif
  531. static void _temp_error(const int8_t e, const char * const serial_msg, const char * const lcd_msg);
  532. static void min_temp_error(const int8_t e);
  533. static void max_temp_error(const int8_t e);
  534. #if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED
  535. enum TRState : char { TRInactive, TRFirstHeating, TRStable, TRRunaway };
  536. 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);
  537. #if ENABLED(THERMAL_PROTECTION_HOTENDS)
  538. static TRState thermal_runaway_state_machine[HOTENDS];
  539. static millis_t thermal_runaway_timer[HOTENDS];
  540. #endif
  541. #if HAS_THERMALLY_PROTECTED_BED
  542. static TRState thermal_runaway_bed_state_machine;
  543. static millis_t thermal_runaway_bed_timer;
  544. #endif
  545. #endif // THERMAL_PROTECTION
  546. };
  547. extern Temperature thermalManager;
  548. #endif // TEMPERATURE_H