HardFOC Flux V1 HAL
Unified HAL API for the HardFOC Flux valve-control platform (ESP32-S3)
Loading...
Searching...
No Matches
Classes | Enumerations | Functions
TemperatureManager.h File Reference

Temperature sensor management for the HardFOC Flux V1 platform. More...

#include <array>
#include <atomic>
#include <cstdint>
#include <optional>
#include <string_view>
#include "core/hf-core-drivers/internal/hf-internal-interface-wrap/inc/base/BaseTemperature.h"
#include "handlers/mcp9700/Mcp9700TemperatureHandler.h"
#include "handlers/ntc/NtcTemperatureHandler.h"
#include "handlers/logger/Logger.h"
#include "RtosMutex.h"
#include "flux_hal/flux_hal_types.hpp"
Include dependency graph for TemperatureManager.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  TempEntry
 A single temperature sensor entry in the fixed-size registry. More...
 
struct  TempSystemDiagnostics
 Temperature subsystem diagnostics snapshot (cross-HAL compatible format). More...
 
class  TemperatureManager
 Singleton manager for all temperature sensors on Flux V1. More...
 

Enumerations

enum class  TemperatureError : uint8_t {
  SUCCESS = 0 , NOT_INITIALIZED , INITIALIZATION_FAILED , SENSOR_NOT_FOUND ,
  SENSOR_NOT_AVAILABLE , READ_FAILED , INVALID_PARAMETER , NO_SENSORS_AVAILABLE ,
  ALLOCATION_FAILED , DEPENDENCY_NOT_READY , MUTEX_LOCK_FAILED
}
 Temperature manager error codes for consistent error reporting. More...
 
enum class  FluxTempSensorType : uint8_t { ESP32_INTERNAL = 0 , NTC_THERMISTOR = 1 , MCP9700_THERMISTOR = 2 , SENSOR_COUNT }
 Identifies the physical temperature sensor type on the Flux board. More...
 

Functions

constexpr const char * TemperatureErrorToString (TemperatureError error) noexcept
 Convert TemperatureError to string for debugging.
 
constexpr const char * FluxTempSensorTypeToString (FluxTempSensorType type) noexcept
 Convert FluxTempSensorType to a human-readable string.
 
TemperatureManager & GetTemperatureManager () noexcept
 Convenience accessor — equivalent to TemperatureManager::GetInstance().
 

Detailed Description

Temperature sensor management for the HardFOC Flux V1 platform.

The Flux board temperature sources include:

  1. ESP32 internal temperature sensor (on-chip)
  2. NTC thermistor on the internal ADC
  3. MCP9700 on ADS7952 channel 8 (when the external ADC is present)

No TMC9660 temperature sensor (Flux has no motor controller).

Stack-friendly design: fixed-size array of TempEntry structs, no heap vectors or unordered_maps. Sensor driver instances are individually heap-allocated via unique_ptr (singleton lifetime).

Author
HardFOC Team
Date
2026
Version
1.0

Enumeration Type Documentation

◆ FluxTempSensorType

enum class FluxTempSensorType : uint8_t
strong

Identifies the physical temperature sensor type on the Flux board.

Enumerator
ESP32_INTERNAL 

ESP32 on-chip temperature sensor.

NTC_THERMISTOR 

External NTC thermistor via ADC.

MCP9700_THERMISTOR 

MCP9700 on ADS7952 multiplexed channel.

SENSOR_COUNT 

Number of sensor types (not a valid sensor)

◆ TemperatureError

enum class TemperatureError : uint8_t
strong

Temperature manager error codes for consistent error reporting.

Manager-layer errors that are sensor-family agnostic. Driver-level errors (hf_temp_err_t) are translated into this common manager error domain.

Enumerator
SUCCESS 

Operation completed successfully.

NOT_INITIALIZED 

Manager not yet initialised.

INITIALIZATION_FAILED 

Sensor initialisation failed.

SENSOR_NOT_FOUND 

Named sensor does not exist in registry.

SENSOR_NOT_AVAILABLE 

Sensor exists but is unavailable.

READ_FAILED 

Driver-level read returned an error.

INVALID_PARAMETER 

Null pointer or out-of-range argument.

NO_SENSORS_AVAILABLE 

No sensors were registered at init.

ALLOCATION_FAILED 

Heap allocation for a sensor driver failed.

DEPENDENCY_NOT_READY 

Required dependency not initialised.

MUTEX_LOCK_FAILED 

RTOS mutex acquire timed out.

Function Documentation

◆ FluxTempSensorTypeToString()

constexpr const char * FluxTempSensorTypeToString ( FluxTempSensorType  type)
constexprnoexcept

Convert FluxTempSensorType to a human-readable string.

Parameters
typeSensor type to convert.
Returns
Null-terminated string representation.
Here is the caller graph for this function:

◆ GetTemperatureManager()

TemperatureManager & GetTemperatureManager ( )
inlinenoexcept

Convenience accessor — equivalent to TemperatureManager::GetInstance().

Returns
Reference to the singleton TemperatureManager.
Here is the call graph for this function:

◆ TemperatureErrorToString()

constexpr const char * TemperatureErrorToString ( TemperatureError  error)
constexprnoexcept

Convert TemperatureError to string for debugging.

Parameters
errorError code to convert.
Returns
Null-terminated string representation.