Lauri Pirttiaho / X_NUCLEO_IKS01A1-lapi-1

Dependencies:   X_NUCLEO_COMMON

Fork of X_NUCLEO_IKS01A1-f255a2c75ecb by Ant Robinson

Committer:
lapi
Date:
Sun Nov 20 20:33:33 2016 +0000
Revision:
1:c3c675da96c0
Parent:
0:14ddc33717d5
No functional changes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
antseggs 0:14ddc33717d5 1 /**
antseggs 0:14ddc33717d5 2 ******************************************************************************
antseggs 0:14ddc33717d5 3 * @file TempSensor.h
antseggs 0:14ddc33717d5 4 * @author AST / EST
antseggs 0:14ddc33717d5 5 * @version V0.0.1
antseggs 0:14ddc33717d5 6 * @date 13-April-2015
antseggs 0:14ddc33717d5 7 * @brief This file contains the abstract class describing in general
antseggs 0:14ddc33717d5 8 * the interfaces of a temperature sensor
antseggs 0:14ddc33717d5 9 ******************************************************************************
antseggs 0:14ddc33717d5 10 * @attention
antseggs 0:14ddc33717d5 11 *
antseggs 0:14ddc33717d5 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
antseggs 0:14ddc33717d5 13 *
antseggs 0:14ddc33717d5 14 * Redistribution and use in source and binary forms, with or without modification,
antseggs 0:14ddc33717d5 15 * are permitted provided that the following conditions are met:
antseggs 0:14ddc33717d5 16 * 1. Redistributions of source code must retain the above copyright notice,
antseggs 0:14ddc33717d5 17 * this list of conditions and the following disclaimer.
antseggs 0:14ddc33717d5 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
antseggs 0:14ddc33717d5 19 * this list of conditions and the following disclaimer in the documentation
antseggs 0:14ddc33717d5 20 * and/or other materials provided with the distribution.
antseggs 0:14ddc33717d5 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
antseggs 0:14ddc33717d5 22 * may be used to endorse or promote products derived from this software
antseggs 0:14ddc33717d5 23 * without specific prior written permission.
antseggs 0:14ddc33717d5 24 *
antseggs 0:14ddc33717d5 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
antseggs 0:14ddc33717d5 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
antseggs 0:14ddc33717d5 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
antseggs 0:14ddc33717d5 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
antseggs 0:14ddc33717d5 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
antseggs 0:14ddc33717d5 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
antseggs 0:14ddc33717d5 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
antseggs 0:14ddc33717d5 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
antseggs 0:14ddc33717d5 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
antseggs 0:14ddc33717d5 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
antseggs 0:14ddc33717d5 35 *
antseggs 0:14ddc33717d5 36 ******************************************************************************
antseggs 0:14ddc33717d5 37 */
antseggs 0:14ddc33717d5 38
antseggs 0:14ddc33717d5 39 /* Define to prevent from recursive inclusion --------------------------------*/
antseggs 0:14ddc33717d5 40 #ifndef __TEMP_SENSOR_CLASS_H
antseggs 0:14ddc33717d5 41 #define __TEMP_SENSOR_CLASS_H
antseggs 0:14ddc33717d5 42
antseggs 0:14ddc33717d5 43 /* Includes ------------------------------------------------------------------*/
antseggs 0:14ddc33717d5 44 #include <GenericSensor.h>
antseggs 0:14ddc33717d5 45
antseggs 0:14ddc33717d5 46 /* Classes ------------------------------------------------------------------*/
antseggs 0:14ddc33717d5 47 /** An abstract class for Temperature sensors
antseggs 0:14ddc33717d5 48 */
antseggs 0:14ddc33717d5 49 class TempSensor : public GenericSensor
antseggs 0:14ddc33717d5 50 {
antseggs 0:14ddc33717d5 51 public:
antseggs 0:14ddc33717d5 52 /**
antseggs 0:14ddc33717d5 53 * @brief Get current temperature in degrees Celsius [°C]
antseggs 0:14ddc33717d5 54 * @param[out] pfData Pointer to where to store temperature to
antseggs 0:14ddc33717d5 55 * @return 0 in case of success, an error code otherwise
antseggs 0:14ddc33717d5 56 */
antseggs 0:14ddc33717d5 57 virtual int GetTemperature(float *pfData) = 0;
antseggs 0:14ddc33717d5 58
antseggs 0:14ddc33717d5 59 /**
antseggs 0:14ddc33717d5 60 * @brief Get current temperature in degrees Fahrenheit [°F]
antseggs 0:14ddc33717d5 61 * @param[out] pfData Pointer to where to store temperature to
antseggs 0:14ddc33717d5 62 * @return 0 in case of success, an error code otherwise
antseggs 0:14ddc33717d5 63 */
antseggs 0:14ddc33717d5 64 virtual int GetFahrenheit(float *pfData) {
antseggs 0:14ddc33717d5 65 float celsius;
antseggs 0:14ddc33717d5 66 int ret;
antseggs 0:14ddc33717d5 67
antseggs 0:14ddc33717d5 68 ret = GetTemperature(&celsius);
antseggs 0:14ddc33717d5 69 if(ret) return ret;
antseggs 0:14ddc33717d5 70
antseggs 0:14ddc33717d5 71 *pfData = ((celsius * 1.8f) + 32.0f);
antseggs 0:14ddc33717d5 72 return 0;
antseggs 0:14ddc33717d5 73 }
antseggs 0:14ddc33717d5 74 };
antseggs 0:14ddc33717d5 75
antseggs 0:14ddc33717d5 76 #endif /* __TEMP_SENSOR_CLASS_H */