Some temperature code cleanup
This commit is contained in:
parent
949191215b
commit
9de9e37539
@ -6737,7 +6737,7 @@ inline void gcode_M17() {
|
|||||||
HOTEND_LOOP()
|
HOTEND_LOOP()
|
||||||
thermalManager.start_heater_idle_timer(e, nozzle_timeout);
|
thermalManager.start_heater_idle_timer(e, nozzle_timeout);
|
||||||
|
|
||||||
wait_for_user = true; /* Wait for user to load filament */
|
wait_for_user = true; // Wait for user to load filament
|
||||||
nozzle_timed_out = false;
|
nozzle_timed_out = false;
|
||||||
|
|
||||||
#if HAS_BUZZER
|
#if HAS_BUZZER
|
||||||
|
@ -830,10 +830,8 @@ void Temperature::manage_heater() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HEATER_IDLE_HANDLER
|
#if HEATER_IDLE_HANDLER
|
||||||
if (bed_idle_timeout_exceeded)
|
if (bed_idle_timeout_exceeded) {
|
||||||
{
|
|
||||||
soft_pwm_amount_bed = 0;
|
soft_pwm_amount_bed = 0;
|
||||||
|
|
||||||
#if DISABLED(PIDTEMPBED)
|
#if DISABLED(PIDTEMPBED)
|
||||||
WRITE_HEATER_BED(LOW);
|
WRITE_HEATER_BED(LOW);
|
||||||
#endif
|
#endif
|
||||||
@ -843,23 +841,17 @@ void Temperature::manage_heater() {
|
|||||||
{
|
{
|
||||||
#if ENABLED(PIDTEMPBED)
|
#if ENABLED(PIDTEMPBED)
|
||||||
soft_pwm_amount_bed = WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0;
|
soft_pwm_amount_bed = WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0;
|
||||||
|
#else
|
||||||
#elif ENABLED(BED_LIMIT_SWITCHING)
|
|
||||||
// Check if temperature is within the correct band
|
// Check if temperature is within the correct band
|
||||||
if (WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP)) {
|
if (WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP)) {
|
||||||
|
#if ENABLED(BED_LIMIT_SWITCHING)
|
||||||
if (current_temperature_bed >= target_temperature_bed + BED_HYSTERESIS)
|
if (current_temperature_bed >= target_temperature_bed + BED_HYSTERESIS)
|
||||||
soft_pwm_amount_bed = 0;
|
soft_pwm_amount_bed = 0;
|
||||||
else if (current_temperature_bed <= target_temperature_bed - (BED_HYSTERESIS))
|
else if (current_temperature_bed <= target_temperature_bed - (BED_HYSTERESIS))
|
||||||
soft_pwm_amount_bed = MAX_BED_POWER >> 1;
|
soft_pwm_amount_bed = MAX_BED_POWER >> 1;
|
||||||
}
|
|
||||||
else {
|
|
||||||
soft_pwm_amount_bed = 0;
|
|
||||||
WRITE_HEATER_BED(LOW);
|
|
||||||
}
|
|
||||||
#else // !PIDTEMPBED && !BED_LIMIT_SWITCHING
|
#else // !PIDTEMPBED && !BED_LIMIT_SWITCHING
|
||||||
// Check if temperature is within the correct range
|
|
||||||
if (WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP)) {
|
|
||||||
soft_pwm_amount_bed = current_temperature_bed < target_temperature_bed ? MAX_BED_POWER >> 1 : 0;
|
soft_pwm_amount_bed = current_temperature_bed < target_temperature_bed ? MAX_BED_POWER >> 1 : 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
soft_pwm_amount_bed = 0;
|
soft_pwm_amount_bed = 0;
|
||||||
@ -1257,7 +1249,7 @@ void Temperature::init() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif // BED_MAXTEMP
|
#endif // BED_MAXTEMP
|
||||||
#endif //HAS_TEMP_BED
|
#endif // HAS_TEMP_BED
|
||||||
|
|
||||||
#if ENABLED(PROBING_HEATERS_OFF)
|
#if ENABLED(PROBING_HEATERS_OFF)
|
||||||
paused = false;
|
paused = false;
|
||||||
@ -1311,7 +1303,7 @@ void Temperature::init() {
|
|||||||
millis_t Temperature::thermal_runaway_bed_timer;
|
millis_t Temperature::thermal_runaway_bed_timer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Temperature::thermal_runaway_protection(Temperature::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) {
|
void Temperature::thermal_runaway_protection(Temperature::TRState * const state, millis_t * const timer, const float ¤t, const float &target, const int8_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc) {
|
||||||
|
|
||||||
static float tr_target_temperature[HOTENDS + 1] = { 0.0 };
|
static float tr_target_temperature[HOTENDS + 1] = { 0.0 };
|
||||||
|
|
||||||
@ -1334,23 +1326,23 @@ void Temperature::init() {
|
|||||||
|
|
||||||
#if HEATER_IDLE_HANDLER
|
#if HEATER_IDLE_HANDLER
|
||||||
// If the heater idle timeout expires, restart
|
// If the heater idle timeout expires, restart
|
||||||
if (heater_id >= 0 && heater_idle_timeout_exceeded[heater_id]) {
|
if ((heater_id >= 0 && heater_idle_timeout_exceeded[heater_id])
|
||||||
*state = TRInactive;
|
|
||||||
tr_target_temperature[heater_index] = 0;
|
|
||||||
}
|
|
||||||
#if HAS_TEMP_BED
|
#if HAS_TEMP_BED
|
||||||
else if (heater_id < 0 && bed_idle_timeout_exceeded) {
|
|| (heater_id < 0 && bed_idle_timeout_exceeded)
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
*state = TRInactive;
|
*state = TRInactive;
|
||||||
tr_target_temperature[heater_index] = 0;
|
tr_target_temperature[heater_index] = 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
// If the target temperature changes, restart
|
// If the target temperature changes, restart
|
||||||
if (tr_target_temperature[heater_index] != target) {
|
if (tr_target_temperature[heater_index] != target) {
|
||||||
tr_target_temperature[heater_index] = target;
|
tr_target_temperature[heater_index] = target;
|
||||||
*state = target > 0 ? TRFirstHeating : TRInactive;
|
*state = target > 0 ? TRFirstHeating : TRInactive;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (*state) {
|
switch (*state) {
|
||||||
// Inactive state waits for a target temperature to be set
|
// Inactive state waits for a target temperature to be set
|
||||||
|
@ -508,7 +508,8 @@ class Temperature {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HEATER_IDLE_HANDLER
|
#if HEATER_IDLE_HANDLER
|
||||||
static void start_heater_idle_timer(uint8_t e, millis_t timeout_ms) {
|
|
||||||
|
static void start_heater_idle_timer(const uint8_t e, const millis_t timeout_ms) {
|
||||||
#if HOTENDS == 1
|
#if HOTENDS == 1
|
||||||
UNUSED(e);
|
UNUSED(e);
|
||||||
#endif
|
#endif
|
||||||
@ -535,7 +536,7 @@ class Temperature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if HAS_TEMP_BED
|
#if HAS_TEMP_BED
|
||||||
static void start_bed_idle_timer(millis_t timeout_ms) {
|
static void start_bed_idle_timer(const millis_t timeout_ms) {
|
||||||
bed_idle_timeout_ms = millis() + timeout_ms;
|
bed_idle_timeout_ms = millis() + timeout_ms;
|
||||||
bed_idle_timeout_exceeded = false;
|
bed_idle_timeout_exceeded = false;
|
||||||
}
|
}
|
||||||
@ -550,7 +551,8 @@ class Temperature {
|
|||||||
|
|
||||||
FORCE_INLINE static bool is_bed_idle() { return bed_idle_timeout_exceeded; }
|
FORCE_INLINE static bool is_bed_idle() { return bed_idle_timeout_exceeded; }
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
#endif // HEATER_IDLE_HANDLER
|
||||||
|
|
||||||
#if HAS_TEMP_HOTEND || HAS_TEMP_BED
|
#if HAS_TEMP_HOTEND || HAS_TEMP_BED
|
||||||
static void print_heaterstates();
|
static void print_heaterstates();
|
||||||
@ -592,7 +594,7 @@ class Temperature {
|
|||||||
|
|
||||||
typedef enum TRState { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate;
|
typedef enum TRState { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate;
|
||||||
|
|
||||||
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);
|
static void thermal_runaway_protection(TRState * const state, millis_t * const timer, const float ¤t, const float &target, const int8_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc);
|
||||||
|
|
||||||
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
|
||||||
static TRState thermal_runaway_state_machine[HOTENDS];
|
static TRState thermal_runaway_state_machine[HOTENDS];
|
||||||
|
Loading…
Reference in New Issue
Block a user