82 void update(uint32_t nowMs);
111 void applyPwmPercent(uint8_t pwmPercent);
114 uint8_t commandedPwmPercent_;
115 uint8_t appliedPwmPercent_;
116 bool startBoostActive_;
117 uint32_t startBoostUntilMs_;
Drives the cooling fan with an ESP32 LEDC PWM output.
Definition fan_driver.h:49
bool isStartBoostActive() const
Indicates whether the temporary fan start boost is active.
Definition fan_driver.cpp:76
uint8_t appliedPwmPercent() const
Returns the PWM value currently applied to the hardware.
Definition fan_driver.cpp:72
void setCommandedPwmPercent(uint8_t pwmPercent, uint32_t nowMs)
Sets the desired fan PWM command.
Definition fan_driver.cpp:27
uint8_t commandedPwmPercent() const
Returns the requested fan PWM command.
Definition fan_driver.cpp:68
void update(uint32_t nowMs)
Ends the start boost when its configured duration has elapsed.
Definition fan_driver.cpp:56
bool begin()
Attaches the PWM channel and initializes the fan output to off.
Definition fan_driver.cpp:16
constexpr FanDriverConfig kDefaultFanDriverConfig
Default PWM settings for the configured cooling fan.
Definition fan_driver.h:33
PWM output settings for the cooling fan.
Definition fan_driver.h:22
uint32_t pwmFrequencyHz
PWM carrier frequency in hertz.
Definition fan_driver.h:24
uint8_t pwmPin
GPIO used for fan PWM output.
Definition fan_driver.h:23
uint8_t pwmResolutionBits
PWM resolution passed to ledcAttach().
Definition fan_driver.h:25
uint32_t startBoostDurationMs
Duration of the start boost in milliseconds.
Definition fan_driver.h:27
uint8_t startBoostPwmPercent
Temporary PWM applied to start a stopped fan.
Definition fan_driver.h:26