HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
Loading...
Searching...
No Matches
BaseTemperature.h
Go to the documentation of this file.
1
19#pragma once
20
21#include "HardwareTypes.h"
22#include <cstdint>
23#include <string_view>
24
30//--------------------------------------
31// HardFOC Temperature Error Codes (Table)
32//--------------------------------------
33
41#define HF_TEMP_ERR_LIST(X) \
42 /* Success codes */ \
43 X(TEMP_SUCCESS, 0, "Success") \
44 /* General errors */ \
45 X(TEMP_ERR_FAILURE, 1, "General failure") \
46 X(TEMP_ERR_NOT_INITIALIZED, 2, "Not initialized") \
47 X(TEMP_ERR_ALREADY_INITIALIZED, 3, "Already initialized") \
48 X(TEMP_ERR_INVALID_PARAMETER, 4, "Invalid parameter") \
49 X(TEMP_ERR_NULL_POINTER, 5, "Null pointer") \
50 X(TEMP_ERR_OUT_OF_MEMORY, 6, "Out of memory") \
51 /* Sensor specific errors */ \
52 X(TEMP_ERR_SENSOR_NOT_AVAILABLE, 7, "Temperature sensor not available") \
53 X(TEMP_ERR_SENSOR_BUSY, 8, "Sensor already in use") \
54 X(TEMP_ERR_SENSOR_DISABLED, 9, "Sensor is disabled") \
55 X(TEMP_ERR_SENSOR_NOT_READY, 10, "Sensor not ready") \
56 /* Reading errors */ \
57 X(TEMP_ERR_READ_FAILED, 11, "Failed to read temperature") \
58 X(TEMP_ERR_INVALID_READING, 12, "Invalid temperature reading") \
59 X(TEMP_ERR_OUT_OF_RANGE, 13, "Temperature out of sensor range") \
60 X(TEMP_ERR_TIMEOUT, 14, "Operation timeout") \
61 /* Configuration errors */ \
62 X(TEMP_ERR_INVALID_RANGE, 15, "Invalid temperature range") \
63 X(TEMP_ERR_RANGE_TOO_NARROW, 16, "Temperature range too narrow") \
64 X(TEMP_ERR_RANGE_TOO_WIDE, 17, "Temperature range too wide") \
65 X(TEMP_ERR_UNSUPPORTED_RANGE, 18, "Unsupported temperature range") \
66 /* Calibration errors */ \
67 X(TEMP_ERR_CALIBRATION_FAILED, 19, "Calibration failed") \
68 X(TEMP_ERR_NOT_CALIBRATED, 20, "Sensor not calibrated") \
69 X(TEMP_ERR_INVALID_CALIBRATION, 21, "Invalid calibration data") \
70 /* Communication errors */ \
71 X(TEMP_ERR_COMMUNICATION_FAILED, 22, "Communication with sensor failed") \
72 X(TEMP_ERR_CHECKSUM_FAILED, 23, "Data checksum verification failed") \
73 /* Power management errors */ \
74 X(TEMP_ERR_POWER_DOWN_FAILED, 24, "Failed to power down sensor") \
75 X(TEMP_ERR_POWER_UP_FAILED, 25, "Failed to power up sensor") \
76 /* Hardware errors */ \
77 X(TEMP_ERR_HARDWARE_FAULT, 26, "Hardware fault detected") \
78 X(TEMP_ERR_OVERCURRENT, 27, "Overcurrent condition") \
79 X(TEMP_ERR_OVERVOLTAGE, 28, "Overvoltage condition") \
80 X(TEMP_ERR_UNDERVOLTAGE, 29, "Undervoltage condition") \
81 X(TEMP_ERR_OVERHEATING, 30, "Sensor overheating") \
82 /* Resource errors */ \
83 X(TEMP_ERR_RESOURCE_BUSY, 31, "Required resource is busy") \
84 X(TEMP_ERR_RESOURCE_UNAVAILABLE, 32, "Required resource unavailable") \
85 X(TEMP_ERR_INSUFFICIENT_RESOURCES, 33, "Insufficient system resources") \
86 /* Operation errors */ \
87 X(TEMP_ERR_OPERATION_ABORTED, 34, "Operation was aborted") \
88 X(TEMP_ERR_OPERATION_PENDING, 35, "Operation is pending") \
89 X(TEMP_ERR_INVALID_STATE, 36, "Invalid sensor state") \
90 X(TEMP_ERR_STATE_TRANSITION_FAILED, 37, "State transition failed") \
91 /* Data processing errors */ \
92 X(TEMP_ERR_DATA_CORRUPTION, 38, "Data corruption detected") \
93 X(TEMP_ERR_CONVERSION_FAILED, 39, "Temperature conversion failed") \
94 X(TEMP_ERR_FILTERING_FAILED, 40, "Temperature filtering failed") \
95 /* Threshold and monitoring errors */ \
96 X(TEMP_ERR_THRESHOLD_EXCEEDED, 41, "Temperature threshold exceeded") \
97 X(TEMP_ERR_INVALID_THRESHOLD, 42, "Invalid threshold value") \
98 X(TEMP_ERR_MONITORING_FAILED, 43, "Temperature monitoring failed") \
99 /* Advanced feature errors */ \
100 X(TEMP_ERR_UNSUPPORTED_OPERATION, 44, "Operation not supported") \
101 X(TEMP_ERR_DRIVER_ERROR, 45, "Driver error") \
102 X(TEMP_ERR_UNKNOWN, 46, "Unknown error") \
103 /* Maximum error code marker */ \
104 X(TEMP_ERR_MAX, 47, "Maximum error code")
105
106//--------------------------------------
107// HardFOC Temperature Error Enum
108//--------------------------------------
109
113typedef enum {
114#define TEMP_ERROR_ENUM(name, code, desc) name = code,
116#undef TEMP_ERROR_ENUM
118
119//--------------------------------------
120// Error String Utility Implementation
121//--------------------------------------
122
128constexpr std::string_view HfTempErrToString(hf_temp_err_t err) noexcept {
129 switch (err) {
130#define X(NAME, VALUE, DESC) \
131 case NAME: \
132 return DESC;
134#undef X
135 default:
137 }
138}
139
140//--------------------------------------
141// HardFOC Temperature Types
142//--------------------------------------
143
158
173
184
199
200//--------------------------------------
201// HardFOC Temperature Configuration
202//--------------------------------------
203
221
233
249
267
283
284//--------------------------------------
285// HardFOC Temperature Callback Types
286//--------------------------------------
287
288// Forward declaration
289class BaseTemperature;
290
299 void(*)(BaseTemperature* temp_sensor, float temperature_celsius,
300 hf_u32_t threshold_type, void* user_data);
301
308using hf_temp_reading_callback_t = void(*)(BaseTemperature* temp_sensor, const hf_temp_reading_t* reading, void* user_data);
309
318 void(*)(BaseTemperature* temp_sensor, hf_temp_err_t error,
319 const char* error_description, void* user_data);
320
321//--------------------------------------
322// Utility Functions and Macros
323//--------------------------------------
324
330#define HF_TEMP_CELSIUS_TO_FAHRENHEIT(celsius) ((celsius) * 9.0f / 5.0f + 32.0f)
331
337#define HF_TEMP_FAHRENHEIT_TO_CELSIUS(fahrenheit) (((fahrenheit) - 32.0f) * 5.0f / 9.0f)
338
344#define HF_TEMP_CELSIUS_TO_KELVIN(celsius) ((celsius) + 273.15f)
345
351#define HF_TEMP_KELVIN_TO_CELSIUS(kelvin) ((kelvin) - 273.15f)
352
356#define HF_TEMP_CONFIG_DEFAULT() \
357 {.range_min_celsius = -40.0f, \
358 .range_max_celsius = 125.0f, \
359 .resolution = 0.1f, \
360 .sample_rate_hz = 0, \
361 .enable_threshold_monitoring = false, \
362 .high_threshold_celsius = 100.0f, \
363 .low_threshold_celsius = -20.0f, \
364 .enable_power_management = false, \
365 .enable_calibration = false, \
366 .timeout_ms = 1000, \
367 .sensor_type = HF_TEMP_SENSOR_TYPE_UNKNOWN, \
368 .capabilities = HF_TEMP_CAP_NONE}
369
377inline bool IsTempInRange(float temperature, float min_temp, float max_temp) noexcept {
378 return (temperature >= min_temp) && (temperature <= max_temp);
379}
380//--------------------------------------
381// BaseTemperature Abstract Class
382//--------------------------------------
383
408public:
409 //==============================================================//
410 // CONSTRUCTORS AND DESTRUCTOR
411 //==============================================================//
412
417
422
426 virtual ~BaseTemperature() noexcept = default;
427
428 //==============================================================//
429 // INITIALIZATION AND STATUS
430 //==============================================================//
431
436 [[nodiscard]] bool IsInitialized() const noexcept;
437
442 bool EnsureInitialized() noexcept;
443
448 bool EnsureDeinitialized() noexcept;
449
454 [[nodiscard]] hf_temp_state_t GetState() const noexcept;
455
456protected:
457 //==============================================================//
458 // [PROTECTED] PURE VIRTUAL IMPLEMENTATIONS - PLATFORM SPECIFIC
459 //==============================================================//
460
465 virtual bool Initialize() noexcept = 0;
466
471 virtual bool Deinitialize() noexcept = 0;
472
478 virtual hf_temp_err_t ReadTemperatureCelsiusImpl(float* temperature_celsius) noexcept = 0;
479
480public:
481 //==============================================================//
482 // CORE TEMPERATURE INTERFACE
483 //==============================================================//
484
490 hf_temp_err_t ReadTemperatureCelsius(float* temperature_celsius) noexcept;
491
498
499 //==============================================================//
500 // TEMPERATURE CONVERSION UTILITIES
501 //==============================================================//
502
508 hf_temp_err_t ReadTemperatureFahrenheit(float* temperature_fahrenheit) noexcept;
509
515 hf_temp_err_t ReadTemperatureKelvin(float* temperature_kelvin) noexcept;
516
523 hf_temp_err_t ReadTemperatureUnit(float* temperature, hf_temp_unit_t unit) noexcept;
524
525 //==============================================================//
526 // INFORMATION INTERFACE
527 //==============================================================//
528
534 virtual hf_temp_err_t GetSensorInfo(hf_temp_sensor_info_t* info) const noexcept = 0;
535
540 [[nodiscard]] virtual hf_u32_t GetCapabilities() const noexcept = 0;
541
547 [[nodiscard]] bool HasCapability(hf_temp_capabilities_t capability) const noexcept;
548
549 //==============================================================//
550 // ADVANCED FEATURES (OPTIONAL - MAY RETURN UNSUPPORTED)
551 //==============================================================//
552
559 virtual hf_temp_err_t SetRange(float min_celsius, float max_celsius) noexcept {
561 }
562
569 virtual hf_temp_err_t GetRange(float* min_celsius, float* max_celsius) const noexcept {
571 }
572
578 virtual hf_temp_err_t SetResolution(float resolution_celsius) noexcept {
580 }
581
587 virtual hf_temp_err_t GetResolution(float* resolution_celsius) const noexcept {
589 }
590
597 virtual hf_temp_err_t SetThresholds(float low_threshold_celsius,
598 float high_threshold_celsius) noexcept {
600 }
601
608 virtual hf_temp_err_t GetThresholds(float* low_threshold_celsius,
609 float* high_threshold_celsius) const noexcept {
611 }
612
623
631
641 void* user_data) noexcept {
643 }
644
652
657 [[nodiscard]] virtual bool IsMonitoringActive() const noexcept {
658 return false; // Default: not supported
659 }
660
666 virtual hf_temp_err_t Calibrate(float reference_temperature_celsius) noexcept {
668 }
669
675 virtual hf_temp_err_t SetCalibrationOffset(float offset_celsius) noexcept {
677 }
678
684 virtual hf_temp_err_t GetCalibrationOffset(float* offset_celsius) const noexcept {
686 }
687
695
703
711
716 [[nodiscard]] virtual bool IsSleeping() const noexcept {
717 return false; // Default: not supported
718 }
719
727
735
741 virtual hf_temp_err_t GetStatistics(hf_temp_statistics_t& statistics) noexcept {
742 statistics = hf_temp_statistics_t{}; // Reset to defaults
744 }
745
751 virtual hf_temp_err_t GetDiagnostics(hf_temp_diagnostics_t& diagnostics) noexcept {
752 diagnostics = hf_temp_diagnostics_t{}; // Reset to defaults
754 }
755
763
771
772protected:
773 //==============================================================//
774 // [PROTECTED] CONSTRUCTOR AND MEMBER VARIABLES
775 //==============================================================//
776
781
786 hf_temp_err_t ValidateBasicOperation() const noexcept;
787
788 //==============================================================//
789 // [PROTECTED] MEMBER VARIABLES
790 //==============================================================//
791
794};
795
796//--------------------------------------
797// Inline Implementations
798//--------------------------------------
799
800inline bool BaseTemperature::IsInitialized() const noexcept {
801 return initialized_;
802}
803
805 if (!initialized_) {
807 if (initialized_) {
809 }
810 }
811 return initialized_;
812}
813
815 if (initialized_) {
817 if (!initialized_) {
819 }
820 }
821 return !initialized_;
822}
823
825 return current_state_;
826}
827
828inline bool BaseTemperature::HasCapability(hf_temp_capabilities_t capability) const noexcept {
829 return (GetCapabilities() & capability) != 0;
830}
831
838
839inline hf_temp_err_t BaseTemperature::ReadTemperatureCelsius(float* temperature_celsius) noexcept {
840 if (temperature_celsius == nullptr) {
842 }
843
845 if (validation != hf_temp_err_t::TEMP_SUCCESS) {
846 return validation;
847 }
848
850 hf_temp_err_t result = ReadTemperatureCelsiusImpl(temperature_celsius);
853
854 return result;
855}
856
858 if (reading == nullptr) {
860 }
861
862 // Initialize reading structure
863 reading->error = hf_temp_err_t::TEMP_SUCCESS;
864 reading->is_valid = false;
865 reading->timestamp_us = 0; // Implementation should fill this
866 reading->accuracy_celsius = 0.0f;
867 reading->temperature_raw = 0.0f;
868
869 float temperature;
870 hf_temp_err_t error = ReadTemperatureCelsius(&temperature);
871
872 reading->temperature_celsius = temperature;
873 reading->error = error;
874 reading->is_valid = (error == hf_temp_err_t::TEMP_SUCCESS);
875
876 return error;
877}
878
880 float* temperature_fahrenheit) noexcept {
881 if (temperature_fahrenheit == nullptr) {
883 }
884
885 float celsius;
886 hf_temp_err_t error = ReadTemperatureCelsius(&celsius);
887 if (error == hf_temp_err_t::TEMP_SUCCESS) {
888 *temperature_fahrenheit = HF_TEMP_CELSIUS_TO_FAHRENHEIT(celsius);
889 }
890 return error;
891}
892
893inline hf_temp_err_t BaseTemperature::ReadTemperatureKelvin(float* temperature_kelvin) noexcept {
894 if (temperature_kelvin == nullptr) {
896 }
897
898 float celsius;
899 hf_temp_err_t error = ReadTemperatureCelsius(&celsius);
900 if (error == hf_temp_err_t::TEMP_SUCCESS) {
901 *temperature_kelvin = HF_TEMP_CELSIUS_TO_KELVIN(celsius);
902 }
903 return error;
904}
905
907 hf_temp_unit_t unit) noexcept {
908 if (temperature == nullptr) {
910 }
911
912 float celsius;
913 hf_temp_err_t error = ReadTemperatureCelsius(&celsius);
914 if (error == hf_temp_err_t::TEMP_SUCCESS) {
915 switch (unit) {
917 *temperature = celsius;
918 break;
920 *temperature = HF_TEMP_CELSIUS_TO_FAHRENHEIT(celsius);
921 break;
923 *temperature = HF_TEMP_CELSIUS_TO_KELVIN(celsius);
924 break;
926 *temperature = HF_TEMP_CELSIUS_TO_KELVIN(celsius) * 9.0f / 5.0f;
927 break;
928 default:
930 break;
931 }
932 }
933 return error;
934}
bool IsTempInRange(float temperature, float min_temp, float max_temp) noexcept
Check if temperature is within range.
Definition BaseTemperature.h:377
hf_temp_unit_t
Temperature measurement units.
Definition BaseTemperature.h:177
@ HF_TEMP_UNIT_KELVIN
Kelvin (K)
Definition BaseTemperature.h:180
@ HF_TEMP_UNIT_RANKINE
Rankine (°R)
Definition BaseTemperature.h:181
@ HF_TEMP_UNIT_CELSIUS
Celsius (°C)
Definition BaseTemperature.h:178
@ HF_TEMP_UNIT_MAX
Maximum unit marker.
Definition BaseTemperature.h:182
@ HF_TEMP_UNIT_FAHRENHEIT
Fahrenheit (°F)
Definition BaseTemperature.h:179
hf_temp_capabilities_t
Temperature sensor capabilities flags.
Definition BaseTemperature.h:188
@ HF_TEMP_CAP_CONTINUOUS_READING
Supports continuous reading.
Definition BaseTemperature.h:191
@ HF_TEMP_CAP_SELF_TEST
Supports self-test.
Definition BaseTemperature.h:194
@ HF_TEMP_CAP_ALARM_OUTPUT
Has alarm output capability.
Definition BaseTemperature.h:195
@ HF_TEMP_CAP_HIGH_PRECISION
High precision measurements.
Definition BaseTemperature.h:196
@ HF_TEMP_CAP_THRESHOLD_MONITORING
Supports threshold monitoring.
Definition BaseTemperature.h:190
@ HF_TEMP_CAP_NONE
No special capabilities.
Definition BaseTemperature.h:189
@ HF_TEMP_CAP_CALIBRATION
Supports calibration.
Definition BaseTemperature.h:192
@ HF_TEMP_CAP_FAST_RESPONSE
Fast response time.
Definition BaseTemperature.h:197
@ HF_TEMP_CAP_POWER_MANAGEMENT
Supports power management.
Definition BaseTemperature.h:193
constexpr std::string_view HfTempErrToString(hf_temp_err_t err) noexcept
Convert temperature error code to string view.
Definition BaseTemperature.h:128
hf_temp_sensor_type_t
Temperature sensor types.
Definition BaseTemperature.h:147
@ HF_TEMP_SENSOR_TYPE_MAX
Maximum sensor type marker.
Definition BaseTemperature.h:156
@ HF_TEMP_SENSOR_TYPE_INFRARED
Infrared temperature sensor.
Definition BaseTemperature.h:155
@ HF_TEMP_SENSOR_TYPE_EXTERNAL_DIGITAL
External digital temperature sensor.
Definition BaseTemperature.h:150
@ HF_TEMP_SENSOR_TYPE_THERMISTOR
Thermistor temperature sensor.
Definition BaseTemperature.h:154
@ HF_TEMP_SENSOR_TYPE_INTERNAL
Internal chip temperature sensor.
Definition BaseTemperature.h:149
@ HF_TEMP_SENSOR_TYPE_UNKNOWN
Unknown or unspecified sensor type.
Definition BaseTemperature.h:148
@ HF_TEMP_SENSOR_TYPE_THERMOCOUPLE
Thermocouple temperature sensor.
Definition BaseTemperature.h:152
@ HF_TEMP_SENSOR_TYPE_EXTERNAL_ANALOG
External analog temperature sensor.
Definition BaseTemperature.h:151
@ HF_TEMP_SENSOR_TYPE_RTD
Resistance Temperature Detector.
Definition BaseTemperature.h:153
#define HF_TEMP_CELSIUS_TO_FAHRENHEIT(celsius)
Convert Celsius to Fahrenheit.
Definition BaseTemperature.h:330
hf_temp_err_t
Temperature sensor error codes enumeration.
Definition BaseTemperature.h:113
@ TEMP_ERR_INVALID_PARAMETER
Definition BaseTemperature.h:115
@ TEMP_ERR_NULL_POINTER
Definition BaseTemperature.h:115
@ TEMP_ERR_NOT_INITIALIZED
Definition BaseTemperature.h:115
@ TEMP_SUCCESS
Definition BaseTemperature.h:115
@ TEMP_ERR_UNSUPPORTED_OPERATION
Definition BaseTemperature.h:115
@ TEMP_ERR_UNKNOWN
Definition BaseTemperature.h:115
#define X(NAME, VALUE, DESC)
void(*)(BaseTemperature *temp_sensor, hf_temp_err_t error, const char *error_description, void *user_data) hf_temp_error_callback_t
Temperature error callback function type.
Definition BaseTemperature.h:317
#define HF_TEMP_CELSIUS_TO_KELVIN(celsius)
Convert Celsius to Kelvin.
Definition BaseTemperature.h:344
void(*)(BaseTemperature *temp_sensor, const hf_temp_reading_t *reading, void *user_data) hf_temp_reading_callback_t
Temperature reading callback function type (for continuous monitoring)
Definition BaseTemperature.h:308
#define TEMP_ERROR_ENUM(name, code, desc)
Definition BaseTemperature.h:114
hf_temp_state_t
Temperature sensor states.
Definition BaseTemperature.h:162
@ HF_TEMP_STATE_READING
Sensor is performing a reading.
Definition BaseTemperature.h:166
@ HF_TEMP_STATE_MAX
Maximum state marker.
Definition BaseTemperature.h:171
@ HF_TEMP_STATE_CALIBRATING
Sensor is being calibrated.
Definition BaseTemperature.h:169
@ HF_TEMP_STATE_DISABLED
Sensor is disabled.
Definition BaseTemperature.h:168
@ HF_TEMP_STATE_ERROR
Sensor is in error state.
Definition BaseTemperature.h:167
@ HF_TEMP_STATE_ENABLED
Sensor is enabled and ready.
Definition BaseTemperature.h:165
@ HF_TEMP_STATE_UNINITIALIZED
Sensor is not initialized.
Definition BaseTemperature.h:163
@ HF_TEMP_STATE_INITIALIZED
Sensor is initialized but not enabled.
Definition BaseTemperature.h:164
@ HF_TEMP_STATE_SLEEPING
Sensor is in low power mode.
Definition BaseTemperature.h:170
void(*)(BaseTemperature *temp_sensor, float temperature_celsius, hf_u32_t threshold_type, void *user_data) hf_temp_threshold_callback_t
Temperature threshold callback function type.
Definition BaseTemperature.h:298
Platform-agnostic hardware type definitions for the HardFOC system.
uint32_t hf_u32_t
Platform-agnostic 32-bit unsigned integer type.
Definition HardwareTypes.h:52
uint64_t hf_u64_t
Platform-agnostic 64-bit unsigned integer type.
Definition HardwareTypes.h:58
Abstract base class for all temperature sensor implementations.
Definition BaseTemperature.h:407
hf_temp_state_t GetState() const noexcept
Get current sensor state.
Definition BaseTemperature.h:824
bool EnsureDeinitialized() noexcept
Ensures the sensor is deinitialized (lazy deinitialization).
Definition BaseTemperature.h:814
virtual hf_temp_err_t SelfTest() noexcept
Perform sensor self-test (advanced feature)
Definition BaseTemperature.h:724
BaseTemperature(const BaseTemperature &)=delete
Copy constructor is deleted to avoid copying instances.
virtual hf_temp_err_t ResetStatistics() noexcept
Reset operation statistics (advanced feature)
Definition BaseTemperature.h:760
virtual hf_temp_err_t SetRange(float min_celsius, float max_celsius) noexcept
Set temperature measurement range (advanced feature)
Definition BaseTemperature.h:559
virtual hf_temp_err_t CheckHealth() noexcept
Check sensor health status (advanced feature)
Definition BaseTemperature.h:732
virtual hf_temp_err_t EnableThresholdMonitoring(hf_temp_threshold_callback_t callback, void *user_data) noexcept
Enable threshold monitoring (advanced feature)
Definition BaseTemperature.h:619
virtual hf_temp_err_t ResetDiagnostics() noexcept
Reset diagnostic information (advanced feature)
Definition BaseTemperature.h:768
virtual ~BaseTemperature() noexcept=default
Virtual destructor for proper cleanup of derived classes.
virtual hf_temp_err_t GetRange(float *min_celsius, float *max_celsius) const noexcept
Get temperature measurement range (advanced feature)
Definition BaseTemperature.h:569
bool IsInitialized() const noexcept
Check if the temperature sensor is initialized.
Definition BaseTemperature.h:800
virtual hf_temp_err_t GetDiagnostics(hf_temp_diagnostics_t &diagnostics) noexcept
Get diagnostic information (advanced feature)
Definition BaseTemperature.h:751
virtual hf_temp_err_t ResetCalibration() noexcept
Reset calibration to default (advanced feature)
Definition BaseTemperature.h:692
virtual hf_temp_err_t StopContinuousMonitoring() noexcept
Stop continuous temperature monitoring (advanced feature)
Definition BaseTemperature.h:649
hf_temp_err_t ReadTemperatureFahrenheit(float *temperature_fahrenheit) noexcept
Read temperature in Fahrenheit.
Definition BaseTemperature.h:879
virtual hf_temp_err_t SetThresholds(float low_threshold_celsius, float high_threshold_celsius) noexcept
Set temperature thresholds (advanced feature)
Definition BaseTemperature.h:597
hf_temp_err_t ReadTemperature(hf_temp_reading_t *reading) noexcept
Read temperature with full information (blocking)
Definition BaseTemperature.h:857
virtual hf_temp_err_t Calibrate(float reference_temperature_celsius) noexcept
Perform sensor calibration (advanced feature)
Definition BaseTemperature.h:666
virtual hf_temp_err_t ExitSleepMode() noexcept
Exit low power mode (advanced feature)
Definition BaseTemperature.h:708
virtual hf_temp_err_t GetResolution(float *resolution_celsius) const noexcept
Get measurement resolution (advanced feature)
Definition BaseTemperature.h:587
virtual hf_temp_err_t GetCalibrationOffset(float *offset_celsius) const noexcept
Get calibration offset (advanced feature)
Definition BaseTemperature.h:684
hf_temp_err_t ReadTemperatureUnit(float *temperature, hf_temp_unit_t unit) noexcept
Read temperature in specified unit.
Definition BaseTemperature.h:906
hf_temp_state_t current_state_
Current sensor state.
Definition BaseTemperature.h:793
virtual bool IsSleeping() const noexcept
Check if sensor is in sleep mode (advanced feature)
Definition BaseTemperature.h:716
bool initialized_
Initialization status.
Definition BaseTemperature.h:792
virtual hf_temp_err_t GetStatistics(hf_temp_statistics_t &statistics) noexcept
Get operation statistics (advanced feature)
Definition BaseTemperature.h:741
virtual hf_temp_err_t GetThresholds(float *low_threshold_celsius, float *high_threshold_celsius) const noexcept
Get temperature thresholds (advanced feature)
Definition BaseTemperature.h:608
BaseTemperature() noexcept
Protected default constructor.
Definition BaseTemperature.h:780
virtual hf_u32_t GetCapabilities() const noexcept=0
Get sensor capabilities.
virtual hf_temp_err_t GetSensorInfo(hf_temp_sensor_info_t *info) const noexcept=0
Get sensor information.
hf_temp_err_t ReadTemperatureCelsius(float *temperature_celsius) noexcept
Read temperature in Celsius (blocking)
Definition BaseTemperature.h:839
virtual hf_temp_err_t SetResolution(float resolution_celsius) noexcept
Set measurement resolution (advanced feature)
Definition BaseTemperature.h:578
virtual hf_temp_err_t SetCalibrationOffset(float offset_celsius) noexcept
Set calibration offset (advanced feature)
Definition BaseTemperature.h:675
BaseTemperature & operator=(const BaseTemperature &)=delete
Assignment operator is deleted to avoid copying instances.
virtual bool IsMonitoringActive() const noexcept
Check if continuous monitoring is active (advanced feature)
Definition BaseTemperature.h:657
virtual hf_temp_err_t EnterSleepMode() noexcept
Enter low power mode (advanced feature)
Definition BaseTemperature.h:700
virtual bool Deinitialize() noexcept=0
Platform-specific implementation for deinitialization.
bool EnsureInitialized() noexcept
Ensures the sensor is initialized (lazy initialization).
Definition BaseTemperature.h:804
virtual hf_temp_err_t DisableThresholdMonitoring() noexcept
Disable threshold monitoring (advanced feature)
Definition BaseTemperature.h:628
virtual bool Initialize() noexcept=0
Platform-specific implementation for initialization.
bool HasCapability(hf_temp_capabilities_t capability) const noexcept
Check if a specific capability is supported.
Definition BaseTemperature.h:828
hf_temp_err_t ValidateBasicOperation() const noexcept
Protected helper to validate basic operation preconditions.
Definition BaseTemperature.h:832
hf_temp_err_t ReadTemperatureKelvin(float *temperature_kelvin) noexcept
Read temperature in Kelvin.
Definition BaseTemperature.h:893
virtual hf_temp_err_t ReadTemperatureCelsiusImpl(float *temperature_celsius) noexcept=0
Platform-specific implementation for reading temperature in Celsius.
virtual hf_temp_err_t StartContinuousMonitoring(hf_u32_t sample_rate_hz, hf_temp_reading_callback_t callback, void *user_data) noexcept
Start continuous temperature monitoring (advanced feature)
Definition BaseTemperature.h:639
#define HF_TEMP_ERR_LIST(X)
HardFOC Temperature sensor error codes.
Definition BaseTemperature.h:41
Temperature sensor configuration structure.
Definition BaseTemperature.h:207
bool enable_calibration
Enable calibration if supported.
Definition BaseTemperature.h:216
bool enable_threshold_monitoring
Enable threshold monitoring.
Definition BaseTemperature.h:212
float low_threshold_celsius
Low temperature threshold in Celsius.
Definition BaseTemperature.h:214
bool enable_power_management
Enable power management features.
Definition BaseTemperature.h:215
hf_u32_t capabilities
Required capabilities (hf_temp_capabilities_t flags)
Definition BaseTemperature.h:219
hf_temp_sensor_type_t sensor_type
Sensor type (hint for implementation)
Definition BaseTemperature.h:218
float range_min_celsius
Minimum temperature range in Celsius.
Definition BaseTemperature.h:208
float high_threshold_celsius
High temperature threshold in Celsius.
Definition BaseTemperature.h:213
float resolution
Temperature resolution in Celsius.
Definition BaseTemperature.h:210
float range_max_celsius
Maximum temperature range in Celsius.
Definition BaseTemperature.h:209
hf_u32_t timeout_ms
Operation timeout in milliseconds.
Definition BaseTemperature.h:217
hf_u32_t sample_rate_hz
Sampling rate in Hz (0 = on-demand)
Definition BaseTemperature.h:211
Temperature sensor diagnostics.
Definition BaseTemperature.h:271
bool sensor_healthy
Overall sensor health status.
Definition BaseTemperature.h:272
hf_temp_err_t last_error_code
Last error code.
Definition BaseTemperature.h:273
bool threshold_monitoring_enabled
Threshold monitoring enabled status.
Definition BaseTemperature.h:278
bool sensor_available
Sensor availability status.
Definition BaseTemperature.h:276
bool continuous_monitoring_active
Continuous monitoring status.
Definition BaseTemperature.h:279
hf_u32_t current_temperature_raw
Current raw temperature reading.
Definition BaseTemperature.h:280
hf_u32_t consecutive_errors
Consecutive error count.
Definition BaseTemperature.h:275
hf_u32_t last_error_timestamp
Last error timestamp.
Definition BaseTemperature.h:274
bool calibration_valid
Calibration validity status.
Definition BaseTemperature.h:281
bool threshold_monitoring_supported
Threshold monitoring support.
Definition BaseTemperature.h:277
Temperature reading structure.
Definition BaseTemperature.h:225
float accuracy_celsius
Estimated accuracy in Celsius.
Definition BaseTemperature.h:231
hf_u64_t timestamp_us
Timestamp of reading in microseconds.
Definition BaseTemperature.h:228
hf_temp_err_t error
Error code for this reading.
Definition BaseTemperature.h:229
float temperature_celsius
Temperature in Celsius.
Definition BaseTemperature.h:226
float temperature_raw
Raw sensor value (implementation specific)
Definition BaseTemperature.h:227
bool is_valid
Whether this reading is valid.
Definition BaseTemperature.h:230
Temperature sensor information structure.
Definition BaseTemperature.h:237
const char * model
Sensor model.
Definition BaseTemperature.h:246
float accuracy_celsius
Typical accuracy.
Definition BaseTemperature.h:242
const char * version
Driver/firmware version.
Definition BaseTemperature.h:247
float min_temp_celsius
Minimum measurable temperature.
Definition BaseTemperature.h:239
hf_temp_sensor_type_t sensor_type
Type of temperature sensor.
Definition BaseTemperature.h:238
const char * manufacturer
Sensor manufacturer.
Definition BaseTemperature.h:245
hf_u32_t capabilities
Sensor capabilities (hf_temp_capabilities_t flags)
Definition BaseTemperature.h:244
float max_temp_celsius
Maximum measurable temperature.
Definition BaseTemperature.h:240
float resolution_celsius
Temperature resolution.
Definition BaseTemperature.h:241
hf_u32_t response_time_ms
Typical response time.
Definition BaseTemperature.h:243
Temperature sensor statistics.
Definition BaseTemperature.h:253
hf_u32_t failed_operations
Failed operations.
Definition BaseTemperature.h:256
hf_u32_t total_operations
Total operations performed.
Definition BaseTemperature.h:254
hf_u32_t min_operation_time_us
Minimum operation time.
Definition BaseTemperature.h:262
hf_u32_t threshold_violations
Number of threshold violations.
Definition BaseTemperature.h:259
float min_temperature_celsius
Minimum temperature recorded.
Definition BaseTemperature.h:263
hf_u32_t temperature_readings
Number of temperature readings.
Definition BaseTemperature.h:257
float avg_temperature_celsius
Average temperature.
Definition BaseTemperature.h:265
float max_temperature_celsius
Maximum temperature recorded.
Definition BaseTemperature.h:264
hf_u32_t calibration_count
Number of calibrations performed.
Definition BaseTemperature.h:258
hf_u32_t average_operation_time_us
Average operation time (microseconds)
Definition BaseTemperature.h:260
hf_u32_t successful_operations
Successful operations.
Definition BaseTemperature.h:255
hf_u32_t max_operation_time_us
Maximum operation time.
Definition BaseTemperature.h:261