* Manage heating activities for extruder hot-ends and a heated bed * - Acquire updated temperature readings * - Also resets the watchdog timer * - Invoke thermal runaway protection * - Manage extruder auto-fan * - Apply filament width to the extrusion rate (may move) * - Update the heated bed PID output value */
| 2352 | * - Update the heated bed PID output value |
| 2353 | */ |
| 2354 | void Temperature::task() { |
| 2355 | if (marlin_state == MarlinState::MF_INITIALIZING) return hal.watchdog_refresh(); // If Marlin isn't started, at least reset the watchdog! |
| 2356 | |
| 2357 | static bool no_reentry = false; // Prevent recursion |
| 2358 | if (no_reentry) return; |
| 2359 | REMEMBER(mh, no_reentry, true); |
| 2360 | |
| 2361 | #if ENABLED(EMERGENCY_PARSER) |
| 2362 | if (emergency_parser.killed_by_M112) kill(FPSTR(M112_KILL_STR), nullptr, true); |
| 2363 | |
| 2364 | if (emergency_parser.quickstop_by_M410) { |
| 2365 | emergency_parser.quickstop_by_M410 = false; // quickstop_stepper may call idle so clear this now! |
| 2366 | quickstop_stepper(); |
| 2367 | } |
| 2368 | |
| 2369 | #if HAS_MEDIA |
| 2370 | if (emergency_parser.sd_abort_by_M524) { // abort SD print immediately |
| 2371 | emergency_parser.sd_abort_by_M524 = false; |
| 2372 | card.flag.abort_sd_printing = true; |
| 2373 | gcode.process_subcommands_now(F("M524")); |
| 2374 | } |
| 2375 | #endif |
| 2376 | #endif |
| 2377 | |
| 2378 | if (!updateTemperaturesIfReady()) return; // Will also reset the watchdog if temperatures are ready |
| 2379 | |
| 2380 | #if DISABLED(IGNORE_THERMOCOUPLE_ERRORS) |
| 2381 | #if TEMP_SENSOR_IS_MAX_TC(0) |
| 2382 | { |
| 2383 | const auto deg = degHotend(0); |
| 2384 | if (deg > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.00f)) MAXTEMP_ERROR(H_E0, deg); |
| 2385 | if (deg < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + 0.01f)) MINTEMP_ERROR(H_E0, deg); |
| 2386 | } |
| 2387 | #endif |
| 2388 | #if TEMP_SENSOR_IS_MAX_TC(1) |
| 2389 | { |
| 2390 | const auto deg = degHotend(1); |
| 2391 | if (deg > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.00f)) MAXTEMP_ERROR(H_E1, deg); |
| 2392 | if (deg < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + 0.01f)) MINTEMP_ERROR(H_E1, deg); |
| 2393 | } |
| 2394 | #endif |
| 2395 | #if TEMP_SENSOR_IS_MAX_TC(2) |
| 2396 | { |
| 2397 | const auto deg = degHotend(2); |
| 2398 | if (deg > _MIN(HEATER_2_MAXTEMP, TEMP_SENSOR_2_MAX_TC_TMAX - 1.00f)) MAXTEMP_ERROR(H_E2, deg); |
| 2399 | if (deg < _MAX(HEATER_2_MINTEMP, TEMP_SENSOR_2_MAX_TC_TMIN + 0.01f)) MINTEMP_ERROR(H_E2, deg); |
| 2400 | } |
| 2401 | #endif |
| 2402 | #if TEMP_SENSOR_IS_MAX_TC(REDUNDANT) |
| 2403 | { |
| 2404 | const auto deg = degRedundant(); |
| 2405 | if (deg > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.00f) MAXTEMP_ERROR(H_REDUNDANT, deg); |
| 2406 | if (deg < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + 0.01f) MINTEMP_ERROR(H_REDUNDANT, deg); |
| 2407 | } |
| 2408 | #endif |
| 2409 | #if TEMP_SENSOR_IS_MAX_TC(BED) |
| 2410 | { |
| 2411 | const auto deg = degBed(); |
no test coverage detected