|
@ -82,10 +82,6 @@ |
|
|
#endif |
|
|
#endif |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifndef THERMAL_PROTECTION_GRACE_PERIOD |
|
|
|
|
|
#define THERMAL_PROTECTION_GRACE_PERIOD 0 // No grace period needed on well-behaved boards
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
Temperature thermalManager; |
|
|
Temperature thermalManager; |
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
@ -1036,18 +1032,9 @@ void Temperature::manage_heater() { |
|
|
millis_t ms = millis(); |
|
|
millis_t ms = millis(); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#if HAS_THERMAL_PROTECTION |
|
|
|
|
|
#if THERMAL_PROTECTION_GRACE_PERIOD > 0 |
|
|
|
|
|
static millis_t grace_period = ms + THERMAL_PROTECTION_GRACE_PERIOD; |
|
|
|
|
|
if (ELAPSED(ms, grace_period)) grace_period = 0UL; |
|
|
|
|
|
#else |
|
|
|
|
|
static constexpr millis_t grace_period = 0UL; |
|
|
|
|
|
#endif |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
HOTEND_LOOP() { |
|
|
HOTEND_LOOP() { |
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) |
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) |
|
|
if (!grace_period && degHotend(e) > temp_range[e].maxtemp) |
|
|
if (degHotend(e) > temp_range[e].maxtemp) |
|
|
_temp_error((heater_ind_t)e, PSTR(MSG_T_THERMAL_RUNAWAY), TEMP_ERR_PSTR(MSG_THERMAL_RUNAWAY, e)); |
|
|
_temp_error((heater_ind_t)e, PSTR(MSG_T_THERMAL_RUNAWAY), TEMP_ERR_PSTR(MSG_THERMAL_RUNAWAY, e)); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -1103,7 +1090,7 @@ void Temperature::manage_heater() { |
|
|
#if HAS_HEATED_BED |
|
|
#if HAS_HEATED_BED |
|
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_BED) |
|
|
#if ENABLED(THERMAL_PROTECTION_BED) |
|
|
if (!grace_period && degBed() > BED_MAXTEMP) |
|
|
if (degBed() > BED_MAXTEMP) |
|
|
_temp_error(H_BED, PSTR(MSG_T_THERMAL_RUNAWAY), TEMP_ERR_PSTR(MSG_THERMAL_RUNAWAY, H_BED)); |
|
|
_temp_error(H_BED, PSTR(MSG_T_THERMAL_RUNAWAY), TEMP_ERR_PSTR(MSG_THERMAL_RUNAWAY, H_BED)); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -1181,7 +1168,7 @@ void Temperature::manage_heater() { |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_CHAMBER) |
|
|
#if ENABLED(THERMAL_PROTECTION_CHAMBER) |
|
|
if (!grace_period && degChamber() > CHAMBER_MAXTEMP) |
|
|
if (degChamber() > CHAMBER_MAXTEMP) |
|
|
_temp_error(H_CHAMBER, PSTR(MSG_T_THERMAL_RUNAWAY), TEMP_ERR_PSTR(MSG_THERMAL_RUNAWAY, H_CHAMBER)); |
|
|
_temp_error(H_CHAMBER, PSTR(MSG_T_THERMAL_RUNAWAY), TEMP_ERR_PSTR(MSG_THERMAL_RUNAWAY, H_CHAMBER)); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -2224,14 +2211,6 @@ void Temperature::set_current_temp_raw() { |
|
|
|
|
|
|
|
|
void Temperature::readings_ready() { |
|
|
void Temperature::readings_ready() { |
|
|
|
|
|
|
|
|
#if THERMAL_PROTECTION_GRACE_PERIOD > 0 |
|
|
|
|
|
const millis_t ms = millis(); |
|
|
|
|
|
static millis_t grace_period = ms + THERMAL_PROTECTION_GRACE_PERIOD; // NOTE: millis() == 0 on reset
|
|
|
|
|
|
if (ELAPSED(ms, grace_period)) grace_period = 0; |
|
|
|
|
|
#else |
|
|
|
|
|
static constexpr millis_t grace_period = 0; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// Update the raw values if they've been read. Else we could be updating them during reading.
|
|
|
// Update the raw values if they've been read. Else we could be updating them during reading.
|
|
|
if (!temp_meas_ready) set_current_temp_raw(); |
|
|
if (!temp_meas_ready) set_current_temp_raw(); |
|
|
|
|
|
|
|
@ -2250,6 +2229,9 @@ void Temperature::readings_ready() { |
|
|
temp_chamber.acc = 0; |
|
|
temp_chamber.acc = 0; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// Give ADC temperature readings time to settle at boot-up before testing
|
|
|
|
|
|
if (grace_period) return; |
|
|
|
|
|
|
|
|
static constexpr int8_t temp_dir[] = { |
|
|
static constexpr int8_t temp_dir[] = { |
|
|
#if ENABLED(HEATER_0_USES_MAX6675) |
|
|
#if ENABLED(HEATER_0_USES_MAX6675) |
|
|
0 |
|
|
0 |
|
@ -2277,9 +2259,6 @@ void Temperature::readings_ready() { |
|
|
#endif // HOTENDS > 1
|
|
|
#endif // HOTENDS > 1
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// Give ADC temperature readings time to settle at boot-up before testing
|
|
|
|
|
|
if (grace_period) return; |
|
|
|
|
|
|
|
|
|
|
|
for (uint8_t e = 0; e < COUNT(temp_dir); e++) { |
|
|
for (uint8_t e = 0; e < COUNT(temp_dir); e++) { |
|
|
const int8_t tdir = temp_dir[e]; |
|
|
const int8_t tdir = temp_dir[e]; |
|
|
if (tdir) { |
|
|
if (tdir) { |
|
|