|
Aquarium Cooling Controller
ESP32 firmware for aquarium cooling fan control, monitoring, telemetry, and fault handling.
|
Drives the cooling fan with an ESP32 LEDC PWM output. More...
#include <fan_driver.h>
Public Member Functions | |
| FanDriver (const FanDriverConfig &config=kDefaultFanDriverConfig) | |
| Creates a fan driver using the supplied PWM configuration. | |
| bool | begin () |
| Attaches the PWM channel and initializes the fan output to off. | |
| void | setCommandedPwmPercent (uint8_t pwmPercent, uint32_t nowMs) |
| Sets the desired fan PWM command. | |
| void | update (uint32_t nowMs) |
| Ends the start boost when its configured duration has elapsed. | |
| uint8_t | commandedPwmPercent () const |
| Returns the requested fan PWM command. | |
| uint8_t | appliedPwmPercent () const |
| Returns the PWM value currently applied to the hardware. | |
| bool | isStartBoostActive () const |
| Indicates whether the temporary fan start boost is active. | |
Drives the cooling fan with an ESP32 LEDC PWM output.
Commands are expressed in percent so the rest of the controller does not need to know the PWM resolution. The class also keeps the last commanded value separate from the applied value because start boost can temporarily apply a higher PWM than the steady-state command.
|
explicit |
Creates a fan driver using the supplied PWM configuration.
| config | Fan PWM pin, frequency, resolution, and start-boost settings. |
| uint8_t FanDriver::appliedPwmPercent | ( | ) | const |
Returns the PWM value currently applied to the hardware.
| bool FanDriver::begin | ( | ) |
Attaches the PWM channel and initializes the fan output to off.
| uint8_t FanDriver::commandedPwmPercent | ( | ) | const |
Returns the requested fan PWM command.
| bool FanDriver::isStartBoostActive | ( | ) | const |
Indicates whether the temporary fan start boost is active.
| void FanDriver::setCommandedPwmPercent | ( | uint8_t | pwmPercent, |
| uint32_t | nowMs | ||
| ) |
Sets the desired fan PWM command.
A start boost is applied automatically when a stopped fan is commanded to a low nonzero PWM value. Commands are clamped to the 0 to 100 percent range before they are stored or written to the hardware.
| pwmPercent | Desired fan command from 0 to 100 percent. |
| nowMs | Current monotonic timestamp in milliseconds. |
| void FanDriver::update | ( | uint32_t | nowMs | ) |
Ends the start boost when its configured duration has elapsed.
| nowMs | Current monotonic timestamp in milliseconds. |