TM: Fan measuring state reset unification

Add resetFanCheck() to reset the fan measuring state as it's needed in
several places and save some flash space.
This commit is contained in:
Yuri D'Elia 2023-01-15 17:36:17 +01:00 committed by DRracer
parent 7529652dca
commit 4f177f0b38
3 changed files with 12 additions and 4 deletions

View File

@ -280,11 +280,18 @@ void checkFans()
#endif //DEBUG_DISABLE_FANCHECK
}
void resetFanCheck() {
fan_measuring = false;
extruder_autofan_last_check = _millis();
}
void hotendFanSetFullSpeed()
{
#ifdef EXTRUDER_ALTFAN_DETECT
altfanStatus.altfanOverride = 1; //full speed
#endif //EXTRUDER_ALTFAN_DETECT
resetFanCheck();
setExtruderAutoFanState(3);
SET_OUTPUT(FAN_PIN);
#ifdef FAN_SOFT_PWM
@ -301,6 +308,7 @@ void hotendDefaultAutoFanState()
#ifdef EXTRUDER_ALTFAN_DETECT
altfanStatus.altfanOverride = eeprom_read_byte((uint8_t*)EEPROM_ALTFAN_OVERRIDE);
#endif
resetFanCheck();
setExtruderAutoFanState(1);
#endif
}

View File

@ -32,5 +32,7 @@ void checkExtruderAutoFans();
#endif
void checkFans();
void resetFanCheck(); // resets the fan measuring state
void hotendFanSetFullSpeed();
void hotendDefaultAutoFanState();

View File

@ -2632,11 +2632,9 @@ namespace temp_model_cal {
// set current fan speed for both front/backend
static __attribute__((noinline)) void set_fan_speed(uint8_t fan_speed)
{
#if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1)
// reset the fan measuring state due to missing hysteresis handling on the checking side
fan_measuring = false;
extruder_autofan_last_check = _millis();
#endif
resetFanCheck();
fanSpeed = fan_speed;
#ifdef FAN_SOFT_PWM
fanSpeedSoftPwm = fan_speed;