Aquarium Cooling Controller
ESP32 firmware for aquarium cooling fan control, monitoring, telemetry, and fault handling.
Loading...
Searching...
No Matches
Functions
ControlEngine Namespace Reference

Pure cooling-control calculations. More...

Functions

bool isTargetTemperatureValid (float targetTemperatureC, const ControlConfig &config=kDefaultControlConfig)
 Checks whether a target temperature is finite and inside configured limits.
 
bool isControlConfigValid (const ControlConfig &config)
 Checks whether a full staged-control configuration is internally valid.
 
float sanitizeTargetTemperature (float targetTemperatureC, const ControlConfig &config=kDefaultControlConfig)
 Replaces invalid target temperatures with the configured default.
 
ControlSnapshot compute (const ControlInputs &inputs, const ControlConfig &config=kDefaultControlConfig)
 Computes the fan command and control mode for the current inputs.
 
const char * modeLabel (ControlMode mode)
 Converts a control mode to a stable diagnostic label.
 

Detailed Description

Pure cooling-control calculations.

Functions in this namespace avoid direct hardware access. Callers provide sensor validity and temperature values, and the namespace returns the PWM decision plus stable labels for logs and telemetry.

Function Documentation

◆ compute()

ControlSnapshot ControlEngine::compute ( const ControlInputs inputs,
const ControlConfig config = kDefaultControlConfig 
)

Computes the fan command and control mode for the current inputs.

Water temperature is the only closed-loop control variable. The previous control mode is used to hold the current state within the hysteresis band. If the water sensor is invalid, the configured fallback PWM is used.

Parameters
inputsSensor validity, measured temperatures, and requested target.
configControl limits and hysteresis settings.
Returns
Snapshot containing intermediate values and the final PWM command.

◆ isControlConfigValid()

bool ControlEngine::isControlConfigValid ( const ControlConfig config)

Checks whether a full staged-control configuration is internally valid.

Parameters
configCandidate control configuration.
Returns
True when ranges and cross-field relationships are valid.

◆ isTargetTemperatureValid()

bool ControlEngine::isTargetTemperatureValid ( float  targetTemperatureC,
const ControlConfig config = kDefaultControlConfig 
)

Checks whether a target temperature is finite and inside configured limits.

Parameters
targetTemperatureCCandidate target temperature in degrees Celsius.
configControl limits used for validation.
Returns
True when the target can be used.

◆ modeLabel()

const char * ControlEngine::modeLabel ( ControlMode  mode)

Converts a control mode to a stable diagnostic label.

Parameters
modeControl mode to label.
Returns
Null-terminated label string.

◆ sanitizeTargetTemperature()

float ControlEngine::sanitizeTargetTemperature ( float  targetTemperatureC,
const ControlConfig config = kDefaultControlConfig 
)

Replaces invalid target temperatures with the configured default.

Parameters
targetTemperatureCCandidate target temperature in degrees Celsius.
configControl limits and default target.
Returns
A valid target temperature in degrees Celsius.