Official interfaces for ST components.
Dependents: X_NUCLEO_IKS01A1 mDot_X_NUCLEO_IKS01A1 53L0A1 X_NUCLEO_IKS01A1 ... more
Fork of ST_INTERFACES by
This library contains all abstract classes which together constitute the common API to which all existing and future ST components will adhere to.
Diff: Sensors/TempSensor.h
- Revision:
- 3:b1bb477e115e
- Parent:
- 1:a7810e7acf8d
--- a/Sensors/TempSensor.h Tue Nov 29 17:43:48 2016 +0000 +++ b/Sensors/TempSensor.h Fri Mar 10 10:50:53 2017 +0100 @@ -36,41 +36,56 @@ ****************************************************************************** */ + /* Define to prevent from recursive inclusion --------------------------------*/ + #ifndef __TEMP_SENSOR_CLASS_H #define __TEMP_SENSOR_CLASS_H + /* Includes ------------------------------------------------------------------*/ -#include <ComponentObject.h> + +#include <Component.h> + /* Classes ------------------------------------------------------------------*/ -/** An abstract class for Temperature sensors + +/** + * An abstract class for Temperature sensors */ -class TempSensor : public ComponentObject -{ - public: +class TempSensor : public Component { +public: + /** * @brief Get current temperature in degrees Celsius [°C] - * @param[out] pfData Pointer to where to store temperature to + * @param[out] pf_data Pointer to where to store temperature to * @return 0 in case of success, an error code otherwise */ - virtual int GetTemperature(float *pfData) = 0; + virtual int get_temperature(float *pf_data) = 0; /** * @brief Get current temperature in degrees Fahrenheit [°F] - * @param[out] pfData Pointer to where to store temperature to + * @param[out] pf_data Pointer to where to store temperature to * @return 0 in case of success, an error code otherwise */ - virtual int GetFahrenheit(float *pfData) { + virtual int get_fahrenheit(float *pf_data) { float celsius; int ret; - ret = GetTemperature(&celsius); - if(ret) return ret; + ret = get_temperature(&celsius); + if (ret) { + return ret; + } - *pfData = ((celsius * 1.8f) + 32.0f); + *pf_data = ((celsius * 1.8f) + 32.0f); + return 0; } + + /** + * @brief Destructor. + */ + virtual ~TempSensor() {}; }; #endif /* __TEMP_SENSOR_CLASS_H */