Some temperature code cleanup
This commit is contained in:
parent
949191215b
commit
9de9e37539
@ -6737,7 +6737,7 @@ inline void gcode_M17() {
|
||||
HOTEND_LOOP()
|
||||
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;
|
||||
|
||||
#if HAS_BUZZER
|
||||
|
@ -830,10 +830,8 @@ void Temperature::manage_heater() {
|
||||
#endif
|
||||
|
||||
#if HEATER_IDLE_HANDLER
|
||||
if (bed_idle_timeout_exceeded)
|
||||
{
|
||||
if (bed_idle_timeout_exceeded) {
|
||||
soft_pwm_amount_bed = 0;
|
||||
|
||||
#if DISABLED(PIDTEMPBED)
|
||||
WRITE_HEATER_BED(LOW);
|
||||
#endif
|
||||
@ -843,23 +841,17 @@ void Temperature::manage_heater() {
|
||||
{
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
soft_pwm_amount_bed = WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0;
|
||||
|
||||
#elif ENABLED(BED_LIMIT_SWITCHING)
|
||||
#else
|
||||
// Check if temperature is within the correct band
|
||||
if (WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP)) {
|
||||
if (current_temperature_bed >= target_temperature_bed + BED_HYSTERESIS)
|
||||
soft_pwm_amount_bed = 0;
|
||||
else if (current_temperature_bed <= target_temperature_bed - (BED_HYSTERESIS))
|
||||
soft_pwm_amount_bed = MAX_BED_POWER >> 1;
|
||||
}
|
||||
else {
|
||||
soft_pwm_amount_bed = 0;
|
||||
WRITE_HEATER_BED(LOW);
|
||||
}
|
||||
#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;
|
||||
#if ENABLED(BED_LIMIT_SWITCHING)
|
||||
if (current_temperature_bed >= target_temperature_bed + BED_HYSTERESIS)
|
||||
soft_pwm_amount_bed = 0;
|
||||
else if (current_temperature_bed <= target_temperature_bed - (BED_HYSTERESIS))
|
||||
soft_pwm_amount_bed = MAX_BED_POWER >> 1;
|
||||
#else // !PIDTEMPBED && !BED_LIMIT_SWITCHING
|
||||
soft_pwm_amount_bed = current_temperature_bed < target_temperature_bed ? MAX_BED_POWER >> 1 : 0;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
soft_pwm_amount_bed = 0;
|
||||
@ -1257,7 +1249,7 @@ void Temperature::init() {
|
||||
#endif
|
||||
}
|
||||
#endif // BED_MAXTEMP
|
||||
#endif //HAS_TEMP_BED
|
||||
#endif // HAS_TEMP_BED
|
||||
|
||||
#if ENABLED(PROBING_HEATERS_OFF)
|
||||
paused = false;
|
||||
@ -1311,7 +1303,7 @@ void Temperature::init() {
|
||||
millis_t Temperature::thermal_runaway_bed_timer;
|
||||
#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 };
|
||||
|
||||
@ -1334,22 +1326,22 @@ void Temperature::init() {
|
||||
|
||||
#if HEATER_IDLE_HANDLER
|
||||
// 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])
|
||||
#if HAS_TEMP_BED
|
||||
|| (heater_id < 0 && bed_idle_timeout_exceeded)
|
||||
#endif
|
||||
) {
|
||||
*state = TRInactive;
|
||||
tr_target_temperature[heater_index] = 0;
|
||||
}
|
||||
#if HAS_TEMP_BED
|
||||
else if (heater_id < 0 && bed_idle_timeout_exceeded) {
|
||||
*state = TRInactive;
|
||||
tr_target_temperature[heater_index] = 0;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
#endif
|
||||
// If the target temperature changes, restart
|
||||
if (tr_target_temperature[heater_index] != target) {
|
||||
tr_target_temperature[heater_index] = target;
|
||||
*state = target > 0 ? TRFirstHeating : TRInactive;
|
||||
{
|
||||
// If the target temperature changes, restart
|
||||
if (tr_target_temperature[heater_index] != target) {
|
||||
tr_target_temperature[heater_index] = target;
|
||||
*state = target > 0 ? TRFirstHeating : TRInactive;
|
||||
}
|
||||
}
|
||||
|
||||
switch (*state) {
|
||||
|
@ -508,7 +508,8 @@ class Temperature {
|
||||
#endif
|
||||
|
||||
#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
|
||||
UNUSED(e);
|
||||
#endif
|
||||
@ -535,7 +536,7 @@ class Temperature {
|
||||
}
|
||||
|
||||
#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_exceeded = false;
|
||||
}
|
||||
@ -550,7 +551,8 @@ class Temperature {
|
||||
|
||||
FORCE_INLINE static bool is_bed_idle() { return bed_idle_timeout_exceeded; }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // HEATER_IDLE_HANDLER
|
||||
|
||||
#if HAS_TEMP_HOTEND || HAS_TEMP_BED
|
||||
static void print_heaterstates();
|
||||
@ -592,7 +594,7 @@ class Temperature {
|
||||
|
||||
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)
|
||||
static TRState thermal_runaway_state_machine[HOTENDS];
|
||||
|
Loading…
x
Reference in New Issue
Block a user