Aquarium Cooling Controller
ESP32 firmware for aquarium cooling fan control, monitoring, telemetry, and fault handling.
Loading...
Searching...
No Matches
Classes | Namespaces | Enumerations | Functions | Variables
control_engine.h File Reference

Computes cooling PWM commands from temperature inputs and policy limits. More...

#include <Arduino.h>
Include dependency graph for control_engine.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ControlConfig
 Tunable limits and hysteresis settings for cooling control. More...
 
struct  ControlInputs
 Sensor and target inputs for one control calculation. More...
 
struct  ControlSnapshot
 Complete result of one control calculation. More...
 

Namespaces

namespace  ControlEngine
 Pure cooling-control calculations.
 

Enumerations

enum class  ControlMode : uint8_t { kFanOff , kFanLow , kFanHigh , kWaterSensorFallback }
 Operating mode selected by the control engine. More...
 

Functions

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

Variables

constexpr ControlConfig kDefaultControlConfig
 Default control limits for the aquarium cooling firmware.
 

Detailed Description

Computes cooling PWM commands from temperature inputs and policy limits.

This module is intentionally independent from sensors, networking, and PWM hardware. It turns already-sampled temperatures into a deterministic control decision that can be unit-tested without an ESP32 runtime.

Enumeration Type Documentation

◆ ControlMode

enum class ControlMode : uint8_t
strong

Operating mode selected by the control engine.

The mode explains why the final PWM command was selected. It is used in diagnostics and telemetry so users can distinguish between an idle fan state, the fixed quiet cooling stage, and the water-sensor fallback mode.

Enumerator
kFanOff 

Water-driven hysteresis currently keeps the fan off.

kFanLow 

Water-driven hysteresis currently commands the low fixed PWM.

kFanHigh 

Water-driven hysteresis currently commands the high fixed PWM.

kWaterSensorFallback 

Water sensor is invalid and fallback PWM is used.