⚡️ Misc. optimizations
This commit is contained in:
@@ -2890,7 +2890,7 @@ void Temperature::init() {
|
||||
*
|
||||
* TODO: Embed the last 3 parameters during init, if not less optimal
|
||||
*/
|
||||
void Temperature::tr_state_machine_t::run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc) {
|
||||
void Temperature::tr_state_machine_t::run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_float_t hysteresis_degc) {
|
||||
|
||||
#if HEATER_IDLE_HANDLER
|
||||
// Convert the given heater_id_t to an idle array index
|
||||
@@ -2959,21 +2959,26 @@ void Temperature::init() {
|
||||
// While the temperature is stable watch for a bad temperature
|
||||
case TRStable: {
|
||||
|
||||
const celsius_float_t rdiff = running_temp - current;
|
||||
|
||||
#if ENABLED(ADAPTIVE_FAN_SLOWING)
|
||||
if (adaptive_fan_slowing && heater_id >= 0) {
|
||||
const int fan_index = _MIN(heater_id, FAN_COUNT - 1);
|
||||
if (fan_speed[fan_index] == 0 || current >= running_temp - (hysteresis_degc * 0.25f))
|
||||
fan_speed_scaler[fan_index] = 128;
|
||||
else if (current >= running_temp - (hysteresis_degc * 0.3335f))
|
||||
fan_speed_scaler[fan_index] = 96;
|
||||
else if (current >= running_temp - (hysteresis_degc * 0.5f))
|
||||
fan_speed_scaler[fan_index] = 64;
|
||||
else if (current >= running_temp - (hysteresis_degc * 0.8f))
|
||||
fan_speed_scaler[fan_index] = 32;
|
||||
const int_fast8_t fan_index = _MIN(heater_id, FAN_COUNT - 1);
|
||||
uint8_t scale;
|
||||
if (fan_speed[fan_index] == 0 || rdiff <= hysteresis_degc * 0.25f)
|
||||
scale = 128;
|
||||
else if (rdiff <= hysteresis_degc * 0.3335f)
|
||||
scale = 96;
|
||||
else if (rdiff <= hysteresis_degc * 0.5f)
|
||||
scale = 64;
|
||||
else if (rdiff <= hysteresis_degc * 0.8f)
|
||||
scale = 32;
|
||||
else
|
||||
fan_speed_scaler[fan_index] = 0;
|
||||
scale = 0;
|
||||
|
||||
fan_speed_scaler[fan_index] = scale;
|
||||
}
|
||||
#endif
|
||||
#endif // ADAPTIVE_FAN_SLOWING
|
||||
|
||||
const millis_t now = millis();
|
||||
|
||||
@@ -2993,7 +2998,7 @@ void Temperature::init() {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (current >= running_temp - hysteresis_degc) {
|
||||
if (rdiff <= hysteresis_degc) {
|
||||
timer = now + SEC_TO_MS(period_seconds);
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user