Singleton manager for all temperature sensors on Vortex V1.
More...
#include <TemperatureManager.h>
Singleton manager for all temperature sensors on Vortex V1.
Manages three temperature sources: ESP32 internal sensor, NTC thermistor via TMC9660 AIN3, and TMC9660 internal chip temperature. Sensors are registered in a fixed-size array; readings are returned in Celsius or Fahrenheit.
- Note
- Call EnsureInitialized() once before any reads. All public methods are thread-safe (guarded by an internal RTOS mutex).
◆ TemperatureManager() [1/3]
◆ TemperatureManager() [2/3]
◆ TemperatureManager() [3/3]
| TemperatureManager::TemperatureManager |
( |
| ) |
|
|
privatedefaultnoexcept |
◆ ~TemperatureManager()
| TemperatureManager::~TemperatureManager |
( |
| ) |
|
|
privatedefault |
◆ Deinitialize()
| bool TemperatureManager::Deinitialize |
( |
| ) |
|
|
noexcept |
Release all temperature sensor resources and reset to uninitialised state.
- Returns
- true on success.
◆ DumpStatistics()
| void TemperatureManager::DumpStatistics |
( |
| ) |
const |
|
noexcept |
Log temperature sensor statistics and health info to the console.
◆ EnsureInitialized()
| bool TemperatureManager::EnsureInitialized |
( |
| ) |
|
|
noexcept |
Initialise the temperature subsystem if not already initialised.
- Returns
- true on success or if already initialised.
◆ FindByName()
| size_t TemperatureManager::FindByName |
( |
std::string_view |
name | ) |
const |
|
privatenoexcept |
◆ GetInstance()
◆ GetLastError()
| hf_temp_err_t TemperatureManager::GetLastError |
( |
| ) |
const |
|
inlinenoexcept |
Get the most recent error code from any temperature operation.
- Returns
- Last hf_temp_err_t set by any API call
◆ GetSensorCount()
| size_t TemperatureManager::GetSensorCount |
( |
| ) |
const |
|
inlinenoexcept |
Get the number of registered temperature sensors.
◆ GetSensorEntry()
| const TempEntry * TemperatureManager::GetSensorEntry |
( |
std::string_view |
name | ) |
const |
|
noexcept |
Look up a sensor entry by name.
- Parameters
-
- Returns
- Pointer to the TempEntry, or nullptr if not found.
◆ GetSystemDiagnostics()
Populate a TempSystemDiagnostics snapshot.
- Parameters
-
| [out] | diagnostics | Diagnostics structure to fill. |
- Returns
- TEMP_SUCCESS on success.
◆ GetSystemTemperatureStats()
| hf_temp_err_t TemperatureManager::GetSystemTemperatureStats |
( |
float & |
min_c, |
|
|
float & |
max_c, |
|
|
float & |
avg_c |
|
) |
| |
|
noexcept |
Read all sensors and compute min, max, and average temperatures.
- Parameters
-
| [out] | min_c | Minimum temperature across all sensors (°C). |
| [out] | max_c | Maximum temperature across all sensors (°C). |
| [out] | avg_c | Average temperature across all sensors (°C). |
- Returns
- TEMP_SUCCESS on success.
◆ Initialize()
| bool TemperatureManager::Initialize |
( |
| ) |
|
|
privatenoexcept |
◆ InitializeEsp32Internal()
| bool TemperatureManager::InitializeEsp32Internal |
( |
| ) |
|
|
privatenoexcept |
◆ InitializeNtcThermistor()
| bool TemperatureManager::InitializeNtcThermistor |
( |
| ) |
|
|
privatenoexcept |
◆ InitializeTmc9660Chip()
| bool TemperatureManager::InitializeTmc9660Chip |
( |
| ) |
|
|
privatenoexcept |
◆ IsInitialized()
| bool TemperatureManager::IsInitialized |
( |
| ) |
const |
|
inlinenoexcept |
Check whether the temperature subsystem has been initialised.
- Returns
- true if initialised and ready for reads.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ ReadInternalTemperature()
| hf_temp_err_t TemperatureManager::ReadInternalTemperature |
( |
float & |
temperature_c | ) |
|
|
noexcept |
Convenience: read the ESP32 internal temperature sensor.
- Parameters
-
| temperature_c | Output temperature in °C. |
- Returns
- TEMP_SUCCESS on success.
◆ ReadMotorTemperature()
| hf_temp_err_t TemperatureManager::ReadMotorTemperature |
( |
float & |
temperature_c | ) |
|
|
noexcept |
Convenience: read the TMC9660 motor controller temperature.
- Parameters
-
| temperature_c | Output temperature in °C. |
- Returns
- TEMP_SUCCESS on success.
◆ ReadNtcTemperature()
| hf_temp_err_t TemperatureManager::ReadNtcTemperature |
( |
float & |
temperature_c | ) |
|
|
noexcept |
Convenience: read the NTC thermistor temperature.
- Parameters
-
| temperature_c | Output temperature in °C. |
- Returns
- TEMP_SUCCESS on success.
◆ ReadTemperatureCelsius()
| hf_temp_err_t TemperatureManager::ReadTemperatureCelsius |
( |
std::string_view |
name, |
|
|
float & |
temperature_celsius |
|
) |
| |
|
noexcept |
Read temperature in Celsius from a named sensor.
- Parameters
-
| name | "ESP32_INTERNAL", "NTC_THERMISTOR", or "MOTOR_TEMP" |
| temperature_celsius | Reference to store temperature value |
- Returns
- TEMP_SUCCESS on success, error code otherwise
◆ ReadTemperatureFahrenheit()
| hf_temp_err_t TemperatureManager::ReadTemperatureFahrenheit |
( |
std::string_view |
name, |
|
|
float & |
temperature_fahrenheit |
|
) |
| |
|
noexcept |
Read temperature in Fahrenheit from a named sensor.
- Parameters
-
| name | Sensor name ("ESP32_INTERNAL", "NTC_THERMISTOR", or "MOTOR_TEMP"). |
| temperature_fahrenheit | Output temperature in °F. |
- Returns
- TEMP_SUCCESS on success.
◆ ReleaseLocked()
| void TemperatureManager::ReleaseLocked |
( |
| ) |
|
|
privatenoexcept |
Destroy every sensor object and clear the table. Caller holds mutex_.
◆ entries_
◆ esp32_temp_
| BaseTemperature* TemperatureManager::esp32_temp_ {nullptr} |
|
private |
MCU die sensor, owned by the board binding.
◆ init_time_ms_
| uint64_t TemperatureManager::init_time_ms_ {0} |
|
private |
◆ initialized_
| std::atomic<bool> TemperatureManager::initialized_ {false} |
|
private |
◆ kInvalidIndex
| constexpr size_t TemperatureManager::kInvalidIndex = SIZE_MAX |
|
staticconstexprprivate |
◆ kMaxSensors
◆ last_error_
| std::atomic<hf_temp_err_t> TemperatureManager::last_error_ {hf_temp_err_t::TEMP_SUCCESS} |
|
private |
◆ mutex_
| RtosMutex TemperatureManager::mutex_ |
|
mutableprivate |
◆ ntc_handler_
| std::optional<NtcTemperatureHandler> TemperatureManager::ntc_handler_ |
|
private |
In place; emplaced at init.
◆ registered_count_
| size_t TemperatureManager::registered_count_ {0} |
|
private |
◆ tmc9660_temp_
In place; emplaced at init.
The documentation for this class was generated from the following files: