|
HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
|
ESP32-C6 internal temperature sensor implementation. More...
#include <EspTemperature.h>
Public Member Functions | |
| EspTemperature () noexcept | |
| Default constructor. | |
| EspTemperature (const esp_temp_config_t &esp_config) noexcept | |
| Constructor with ESP32-specific configuration. | |
| EspTemperature (const EspTemperature &)=delete | |
| Copy constructor is deleted to avoid copying instances. | |
| EspTemperature & | operator= (const EspTemperature &)=delete |
| Assignment operator is deleted to avoid copying instances. | |
| virtual | ~EspTemperature () noexcept |
| Virtual destructor for proper cleanup. | |
| hf_temp_err_t | GetSensorInfo (hf_temp_sensor_info_t *info) const noexcept override |
| Get ESP32-C6 temperature sensor information. | |
| hf_u32_t | GetCapabilities () const noexcept override |
| Get ESP32-C6 temperature sensor capabilities. | |
| hf_temp_err_t | SetRange (float min_celsius, float max_celsius) noexcept override |
| Set temperature measurement range (ESP32-C6 supported) | |
| hf_temp_err_t | GetRange (float *min_celsius, float *max_celsius) const noexcept override |
| Get temperature measurement range (ESP32-C6 supported) | |
| hf_temp_err_t | GetResolution (float *resolution_celsius) const noexcept override |
| Get measurement resolution (ESP32-C6 supported) | |
| hf_temp_err_t | SetThresholds (float low_threshold_celsius, float high_threshold_celsius) noexcept override |
| Set temperature thresholds (ESP32-C6 supported) | |
| hf_temp_err_t | GetThresholds (float *low_threshold_celsius, float *high_threshold_celsius) const noexcept override |
| Get temperature thresholds (ESP32-C6 supported) | |
| hf_temp_err_t | EnableThresholdMonitoring (hf_temp_threshold_callback_t callback, void *user_data) noexcept override |
| Enable threshold monitoring (ESP32-C6 supported) | |
| hf_temp_err_t | DisableThresholdMonitoring () noexcept override |
| Disable threshold monitoring (ESP32-C6 supported) | |
| hf_temp_err_t | StartContinuousMonitoring (hf_u32_t sample_rate_hz, hf_temp_reading_callback_t callback, void *user_data) noexcept override |
| Start continuous temperature monitoring (ESP32-C6 supported) | |
| hf_temp_err_t | StopContinuousMonitoring () noexcept override |
| Stop continuous temperature monitoring (ESP32-C6 supported) | |
| bool | IsMonitoringActive () const noexcept override |
| Check if continuous monitoring is active (ESP32-C6 supported) | |
| hf_temp_err_t | SetCalibrationOffset (float offset_celsius) noexcept override |
| Set calibration offset (ESP32-C6 supported) | |
| hf_temp_err_t | GetCalibrationOffset (float *offset_celsius) const noexcept override |
| Get calibration offset (ESP32-C6 supported) | |
| hf_temp_err_t | ResetCalibration () noexcept override |
| Reset calibration to default (ESP32-C6 supported) | |
| hf_temp_err_t | EnterSleepMode () noexcept override |
| Enter low power mode (ESP32-C6 supported) | |
| hf_temp_err_t | ExitSleepMode () noexcept override |
| Exit low power mode (ESP32-C6 supported) | |
| bool | IsSleeping () const noexcept override |
| Check if sensor is in sleep mode (ESP32-C6 supported) | |
| hf_temp_err_t | SelfTest () noexcept override |
| Perform sensor self-test (ESP32-C6 supported) | |
| hf_temp_err_t | CheckHealth () noexcept override |
| Check sensor health status (ESP32-C6 supported) | |
| hf_temp_err_t | GetStatistics (hf_temp_statistics_t &statistics) noexcept override |
| Get operation statistics (ESP32-C6 supported) | |
| hf_temp_err_t | GetDiagnostics (hf_temp_diagnostics_t &diagnostics) noexcept override |
| Get diagnostic information (ESP32-C6 supported) | |
| hf_temp_err_t | ResetStatistics () noexcept override |
| Reset operation statistics (ESP32-C6 supported) | |
| hf_temp_err_t | ResetDiagnostics () noexcept override |
| Reset diagnostic information (ESP32-C6 supported) | |
| hf_temp_err_t | InitializeEsp32 (const esp_temp_config_t &esp_config) noexcept |
| Initialize with ESP32-specific configuration. | |
| hf_temp_err_t | SetMeasurementRange (esp_temp_range_t range) noexcept |
| Set measurement range using ESP32 enum. | |
| esp_temp_range_t | GetMeasurementRange () const noexcept |
| Get current measurement range. | |
| hf_temp_err_t | GetRangeInfo (esp_temp_range_t range, float *min_celsius, float *max_celsius, float *accuracy_celsius) const noexcept |
| Get range information for a specific range. | |
| esp_temp_range_t | FindOptimalRange (float min_celsius, float max_celsius) const noexcept |
| Find optimal range for given temperature requirements. | |
| hf_temp_err_t | ReadRawTemperature (float *raw_value) noexcept |
| Read raw temperature value (before calibration) | |
| temperature_sensor_handle_t | GetEspHandle () const noexcept |
| Get ESP-IDF temperature sensor handle. | |
| hf_temp_err_t | SetEspThresholdCallback (esp_temp_threshold_callback_t callback) noexcept |
| Set ESP32-specific threshold callback. | |
| hf_temp_err_t | SetEspMonitoringCallback (esp_temp_monitoring_callback_t callback) noexcept |
| Set ESP32-specific monitoring callback. | |
Public Member Functions inherited from BaseTemperature | |
| BaseTemperature (const BaseTemperature &)=delete | |
| Copy constructor is deleted to avoid copying instances. | |
| BaseTemperature & | operator= (const BaseTemperature &)=delete |
| Assignment operator is deleted to avoid copying instances. | |
| virtual | ~BaseTemperature () noexcept=default |
| Virtual destructor for proper cleanup of derived classes. | |
| bool | IsInitialized () const noexcept |
| Check if the temperature sensor is initialized. | |
| bool | EnsureInitialized () noexcept |
| Ensures the sensor is initialized (lazy initialization). | |
| bool | EnsureDeinitialized () noexcept |
| Ensures the sensor is deinitialized (lazy deinitialization). | |
| hf_temp_state_t | GetState () const noexcept |
| Get current sensor state. | |
| hf_temp_err_t | ReadTemperatureCelsius (float *temperature_celsius) noexcept |
| Read temperature in Celsius (blocking) | |
| hf_temp_err_t | ReadTemperature (hf_temp_reading_t *reading) noexcept |
| Read temperature with full information (blocking) | |
| hf_temp_err_t | ReadTemperatureFahrenheit (float *temperature_fahrenheit) noexcept |
| Read temperature in Fahrenheit. | |
| hf_temp_err_t | ReadTemperatureKelvin (float *temperature_kelvin) noexcept |
| Read temperature in Kelvin. | |
| hf_temp_err_t | ReadTemperatureUnit (float *temperature, hf_temp_unit_t unit) noexcept |
| Read temperature in specified unit. | |
| bool | HasCapability (hf_temp_capabilities_t capability) const noexcept |
| Check if a specific capability is supported. | |
| virtual hf_temp_err_t | SetResolution (float resolution_celsius) noexcept |
| Set measurement resolution (advanced feature) | |
| virtual hf_temp_err_t | Calibrate (float reference_temperature_celsius) noexcept |
| Perform sensor calibration (advanced feature) | |
Protected Member Functions | |
| bool | Initialize () noexcept override |
| ESP32-specific implementation for initialization. | |
| bool | Deinitialize () noexcept override |
| ESP32-specific implementation for deinitialization. | |
| hf_temp_err_t | ReadTemperatureCelsiusImpl (float *temperature_celsius) noexcept override |
| ESP32-specific implementation for reading temperature in Celsius. | |
Protected Member Functions inherited from BaseTemperature | |
| BaseTemperature () noexcept | |
| Protected default constructor. | |
| hf_temp_err_t | ValidateBasicOperation () const noexcept |
| Protected helper to validate basic operation preconditions. | |
Private Member Functions | |
| hf_temp_err_t | ConvertEspError (esp_err_t esp_err) const noexcept |
| Convert ESP-IDF error to HardFOC temperature error. | |
| hf_temp_err_t | ConfigureEspSensor () noexcept |
| Configure ESP temperature sensor with current settings. | |
| hf_temp_err_t | SetupRange (esp_temp_range_t range) noexcept |
| Setup measurement range configuration. | |
| void | GetRangeConfig (esp_temp_range_t range, float *min_celsius, float *max_celsius, float *accuracy_celsius) const noexcept |
| Get range configuration values. | |
| void | SetLastError (hf_temp_err_t error) noexcept |
| Set last error code and update diagnostics. | |
| void | UpdateStatistics (bool operation_successful, hf_u32_t operation_time_us) noexcept |
| Update operation statistics. | |
| void | UpdateDiagnostics (hf_temp_err_t error) noexcept |
| Update diagnostic information. | |
| void | CheckThresholds (float temperature) noexcept |
| Check thresholds and trigger callbacks if needed. | |
| hf_temp_err_t | ValidateConfig (const hf_temp_config_t *config) const noexcept |
| Validate base configuration. | |
| hf_temp_err_t | ValidateEspConfig (const esp_temp_config_t *esp_config) const noexcept |
| Validate ESP32-specific configuration. | |
Static Private Member Functions | |
| static void | MonitoringTimerCallback (void *arg) noexcept |
| Timer callback for continuous monitoring. | |
| static hf_u64_t | GetCurrentTimeUs () noexcept |
| Get current timestamp in microseconds. | |
Private Attributes | |
| PlatformMutex | mutex_ |
| Thread safety mutex (RTOS-aware) | |
| esp_temp_state_t | esp_state_ |
| ESP32-specific state. | |
| esp_temp_config_t | esp_config_ |
| ESP32-specific configuration. | |
| hf_temp_config_t | base_config_ |
| Base class configuration. | |
| hf_temp_statistics_t | statistics_ |
| Operation statistics. | |
| hf_temp_diagnostics_t | diagnostics_ |
| Diagnostic information. | |
| hf_temp_err_t | last_error_ |
| Last error code. | |
| hf_temp_threshold_callback_t | threshold_callback_ |
| Base threshold callback. | |
| hf_temp_reading_callback_t | monitoring_callback_ |
| Base monitoring callback. | |
| esp_temp_threshold_callback_t | esp_threshold_callback_ |
| ESP32-specific threshold callback. | |
| esp_temp_monitoring_callback_t | esp_monitoring_callback_ |
| ESP32-specific monitoring callback. | |
| void * | threshold_user_data_ |
| User data for threshold callback. | |
| void * | monitoring_user_data_ |
| User data for monitoring callback. | |
Static Private Attributes | |
| static const char * | TAG = "EspTemperature" |
| ESP-IDF logging tag. | |
| static const esp_temp_range_info_t | RANGE_INFO [] |
| Range information table. | |
| static PlatformMutex | s_shared_mutex_ |
| Protect shared handle/refcount. | |
| static std::atomic< int > | s_refcount_ {0} |
| Number of active instances. | |
| static temperature_sensor_handle_t | s_shared_handle_ = nullptr |
| Shared ESP-IDF handle. | |
Additional Inherited Members | |
Protected Attributes inherited from BaseTemperature | |
| bool | initialized_ |
| Initialization status. | |
| hf_temp_state_t | current_state_ |
| Current sensor state. | |
ESP32-C6 internal temperature sensor implementation.
This class provides a complete implementation of the BaseTemperature interface specifically for the ESP32-C6 internal temperature sensor. It leverages the ESP-IDF temperature sensor driver to provide accurate temperature measurements with advanced features like threshold monitoring and continuous sampling.
Key features:
|
noexcept |
Default constructor.
|
explicitnoexcept |
Constructor with ESP32-specific configuration.
| esp_config | ESP32-specific configuration |
|
delete |
Copy constructor is deleted to avoid copying instances.
|
virtualnoexcept |
Virtual destructor for proper cleanup.
|
overridevirtualnoexcept |
Check sensor health status (ESP32-C6 supported)
Reimplemented from BaseTemperature.
|
privatenoexcept |
Check thresholds and trigger callbacks if needed.
| temperature | Current temperature reading |
|
privatenoexcept |
Configure ESP temperature sensor with current settings.
|
privatenoexcept |
Convert ESP-IDF error to HardFOC temperature error.
| esp_err | ESP-IDF error code |
|
overrideprotectedvirtualnoexcept |
ESP32-specific implementation for deinitialization.
Implements BaseTemperature.
|
overridevirtualnoexcept |
Disable threshold monitoring (ESP32-C6 supported)
Reimplemented from BaseTemperature.
|
overridevirtualnoexcept |
Enable threshold monitoring (ESP32-C6 supported)
| callback | Callback function for threshold events |
| user_data | User data to pass to callback |
Reimplemented from BaseTemperature.
|
overridevirtualnoexcept |
Enter low power mode (ESP32-C6 supported)
Reimplemented from BaseTemperature.
|
overridevirtualnoexcept |
Exit low power mode (ESP32-C6 supported)
Reimplemented from BaseTemperature.
|
noexcept |
Find optimal range for given temperature requirements.
| min_celsius | Minimum required temperature |
| max_celsius | Maximum required temperature |
|
overridevirtualnoexcept |
Get calibration offset (ESP32-C6 supported)
| offset_celsius | Pointer to store calibration offset |
Reimplemented from BaseTemperature.
|
overridevirtualnoexcept |
Get ESP32-C6 temperature sensor capabilities.
Implements BaseTemperature.
|
staticprivatenoexcept |
Get current timestamp in microseconds.
|
overridevirtualnoexcept |
Get diagnostic information (ESP32-C6 supported)
| diagnostics | Reference to diagnostics structure to fill |
Reimplemented from BaseTemperature.
|
noexcept |
Get ESP-IDF temperature sensor handle.
|
noexcept |
Get current measurement range.
|
overridevirtualnoexcept |
Get temperature measurement range (ESP32-C6 supported)
| min_celsius | Pointer to store minimum temperature |
| max_celsius | Pointer to store maximum temperature |
Reimplemented from BaseTemperature.
|
privatenoexcept |
Get range configuration values.
| range | Range to query |
| min_celsius | Pointer to store minimum temperature |
| max_celsius | Pointer to store maximum temperature |
| accuracy_celsius | Pointer to store accuracy |
|
noexcept |
Get range information for a specific range.
| range | Range to query |
| min_celsius | Pointer to store minimum temperature |
| max_celsius | Pointer to store maximum temperature |
| accuracy_celsius | Pointer to store accuracy |
|
overridevirtualnoexcept |
Get measurement resolution (ESP32-C6 supported)
| resolution_celsius | Pointer to store resolution |
Reimplemented from BaseTemperature.
|
overridevirtualnoexcept |
Get ESP32-C6 temperature sensor information.
| info | Pointer to store sensor information |
Implements BaseTemperature.
|
overridevirtualnoexcept |
Get operation statistics (ESP32-C6 supported)
| statistics | Reference to statistics structure to fill |
Reimplemented from BaseTemperature.
|
overridevirtualnoexcept |
Get temperature thresholds (ESP32-C6 supported)
| low_threshold_celsius | Pointer to store low threshold |
| high_threshold_celsius | Pointer to store high threshold |
Reimplemented from BaseTemperature.
|
overrideprotectedvirtualnoexcept |
ESP32-specific implementation for initialization.
Implements BaseTemperature.
|
noexcept |
Initialize with ESP32-specific configuration.
| esp_config | ESP32-specific configuration structure |
|
overridevirtualnoexcept |
Check if continuous monitoring is active (ESP32-C6 supported)
Reimplemented from BaseTemperature.
|
overridevirtualnoexcept |
Check if sensor is in sleep mode (ESP32-C6 supported)
Reimplemented from BaseTemperature.
|
staticprivatenoexcept |
Timer callback for continuous monitoring.
| arg | Pointer to EspTemperature instance |
|
delete |
Assignment operator is deleted to avoid copying instances.
|
noexcept |
Read raw temperature value (before calibration)
| raw_value | Pointer to store raw temperature |
|
overrideprotectedvirtualnoexcept |
ESP32-specific implementation for reading temperature in Celsius.
| temperature_celsius | Pointer to store temperature value |
Implements BaseTemperature.
|
overridevirtualnoexcept |
Reset calibration to default (ESP32-C6 supported)
Reimplemented from BaseTemperature.
|
overridevirtualnoexcept |
Reset diagnostic information (ESP32-C6 supported)
Reimplemented from BaseTemperature.
|
overridevirtualnoexcept |
Reset operation statistics (ESP32-C6 supported)
Reimplemented from BaseTemperature.
|
overridevirtualnoexcept |
Perform sensor self-test (ESP32-C6 supported)
Reimplemented from BaseTemperature.
|
overridevirtualnoexcept |
Set calibration offset (ESP32-C6 supported)
| offset_celsius | Calibration offset in Celsius |
Reimplemented from BaseTemperature.
|
noexcept |
Set ESP32-specific monitoring callback.
| callback | ESP32-specific callback function |
|
noexcept |
Set ESP32-specific threshold callback.
| callback | ESP32-specific callback function |
|
privatenoexcept |
Set last error code and update diagnostics.
| error | Error code to set |
|
noexcept |
Set measurement range using ESP32 enum.
| range | ESP32-specific range identifier |
|
overridevirtualnoexcept |
Set temperature measurement range (ESP32-C6 supported)
| min_celsius | Minimum temperature in Celsius |
| max_celsius | Maximum temperature in Celsius |
Reimplemented from BaseTemperature.
|
overridevirtualnoexcept |
Set temperature thresholds (ESP32-C6 supported)
| low_threshold_celsius | Low temperature threshold |
| high_threshold_celsius | High temperature threshold |
Reimplemented from BaseTemperature.
|
privatenoexcept |
Setup measurement range configuration.
| range | Range to configure |
|
overridevirtualnoexcept |
Start continuous temperature monitoring (ESP32-C6 supported)
| sample_rate_hz | Sampling rate in Hz |
| callback | Callback function for each reading |
| user_data | User data to pass to callback |
Reimplemented from BaseTemperature.
|
overridevirtualnoexcept |
Stop continuous temperature monitoring (ESP32-C6 supported)
Reimplemented from BaseTemperature.
|
privatenoexcept |
Update diagnostic information.
| error | Error code from operation |
|
privatenoexcept |
Update operation statistics.
| operation_successful | Whether the operation was successful |
| operation_time_us | Operation time in microseconds |
|
privatenoexcept |
Validate base configuration.
| config | Configuration to validate |
|
privatenoexcept |
Validate ESP32-specific configuration.
| esp_config | ESP32 configuration to validate |
|
private |
Base class configuration.
|
private |
Diagnostic information.
|
private |
ESP32-specific configuration.
|
private |
ESP32-specific monitoring callback.
|
private |
ESP32-specific state.
|
private |
ESP32-specific threshold callback.
|
private |
Last error code.
|
private |
Base monitoring callback.
|
private |
User data for monitoring callback.
|
mutableprivate |
Thread safety mutex (RTOS-aware)
|
staticprivate |
Range information table.
ESP32-C6 temperature sensor range information table.
Based on ESP32-C6 hardware specifications and ESP-IDF documentation
|
staticprivate |
Number of active instances.
|
staticprivate |
Shared ESP-IDF handle.
|
staticprivate |
Protect shared handle/refcount.
|
private |
Operation statistics.
|
staticprivate |
ESP-IDF logging tag.
|
private |
Base threshold callback.
|
private |
User data for threshold callback.