Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of X_NUCLEO_IKS01A1 by
Components/Interfaces/TempSensor.h@88:662bba2414a8, 2016-09-15 (annotated)
- Committer:
- hitzqt
- Date:
- Thu Sep 15 10:35:37 2016 +0000
- Revision:
- 88:662bba2414a8
- Parent:
- 46:badcff0675e8
temperature, humidity and burglar alarm, safe mode
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Wolfgang Betz |
43:2544d064d528 | 1 | /** |
Wolfgang Betz |
43:2544d064d528 | 2 | ****************************************************************************** |
Wolfgang Betz |
43:2544d064d528 | 3 | * @file TempSensor.h |
Wolfgang Betz |
43:2544d064d528 | 4 | * @author AST / EST |
Wolfgang Betz |
43:2544d064d528 | 5 | * @version V0.0.1 |
Wolfgang Betz |
43:2544d064d528 | 6 | * @date 13-April-2015 |
Wolfgang Betz |
43:2544d064d528 | 7 | * @brief This file contains the abstract class describing in general |
Wolfgang Betz |
43:2544d064d528 | 8 | * the interfaces of a temperature sensor |
Wolfgang Betz |
43:2544d064d528 | 9 | ****************************************************************************** |
Wolfgang Betz |
43:2544d064d528 | 10 | * @attention |
Wolfgang Betz |
43:2544d064d528 | 11 | * |
Wolfgang Betz |
43:2544d064d528 | 12 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
Wolfgang Betz |
43:2544d064d528 | 13 | * |
Wolfgang Betz |
43:2544d064d528 | 14 | * Redistribution and use in source and binary forms, with or without modification, |
Wolfgang Betz |
43:2544d064d528 | 15 | * are permitted provided that the following conditions are met: |
Wolfgang Betz |
43:2544d064d528 | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
Wolfgang Betz |
43:2544d064d528 | 17 | * this list of conditions and the following disclaimer. |
Wolfgang Betz |
43:2544d064d528 | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
Wolfgang Betz |
43:2544d064d528 | 19 | * this list of conditions and the following disclaimer in the documentation |
Wolfgang Betz |
43:2544d064d528 | 20 | * and/or other materials provided with the distribution. |
Wolfgang Betz |
43:2544d064d528 | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
Wolfgang Betz |
43:2544d064d528 | 22 | * may be used to endorse or promote products derived from this software |
Wolfgang Betz |
43:2544d064d528 | 23 | * without specific prior written permission. |
Wolfgang Betz |
43:2544d064d528 | 24 | * |
Wolfgang Betz |
43:2544d064d528 | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
Wolfgang Betz |
43:2544d064d528 | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
Wolfgang Betz |
43:2544d064d528 | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Wolfgang Betz |
43:2544d064d528 | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
Wolfgang Betz |
43:2544d064d528 | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
Wolfgang Betz |
43:2544d064d528 | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
Wolfgang Betz |
43:2544d064d528 | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
Wolfgang Betz |
43:2544d064d528 | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
Wolfgang Betz |
43:2544d064d528 | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
Wolfgang Betz |
43:2544d064d528 | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Wolfgang Betz |
43:2544d064d528 | 35 | * |
Wolfgang Betz |
43:2544d064d528 | 36 | ****************************************************************************** |
Wolfgang Betz |
43:2544d064d528 | 37 | */ |
Wolfgang Betz |
43:2544d064d528 | 38 | |
Wolfgang Betz |
43:2544d064d528 | 39 | /* Define to prevent from recursive inclusion --------------------------------*/ |
Wolfgang Betz |
43:2544d064d528 | 40 | #ifndef __TEMP_SENSOR_CLASS_H |
Wolfgang Betz |
43:2544d064d528 | 41 | #define __TEMP_SENSOR_CLASS_H |
Wolfgang Betz |
43:2544d064d528 | 42 | |
Wolfgang Betz |
43:2544d064d528 | 43 | /* Includes ------------------------------------------------------------------*/ |
Wolfgang Betz |
46:badcff0675e8 | 44 | #include <GenericSensor.h> |
Wolfgang Betz |
43:2544d064d528 | 45 | |
Wolfgang Betz |
43:2544d064d528 | 46 | /* Classes ------------------------------------------------------------------*/ |
Wolfgang Betz |
43:2544d064d528 | 47 | /** An abstract class for Temperature sensors |
Wolfgang Betz |
43:2544d064d528 | 48 | */ |
Wolfgang Betz |
46:badcff0675e8 | 49 | class TempSensor : public GenericSensor |
Wolfgang Betz |
43:2544d064d528 | 50 | { |
Wolfgang Betz |
43:2544d064d528 | 51 | public: |
Wolfgang Betz |
43:2544d064d528 | 52 | /** |
Wolfgang Betz |
43:2544d064d528 | 53 | * @brief Get current temperature in degrees Celsius [°C] |
Wolfgang Betz |
43:2544d064d528 | 54 | * @param[out] pfData Pointer to where to store temperature to |
Wolfgang Betz |
43:2544d064d528 | 55 | * @return 0 in case of success, an error code otherwise |
Wolfgang Betz |
43:2544d064d528 | 56 | */ |
Wolfgang Betz |
43:2544d064d528 | 57 | virtual int GetTemperature(float *pfData) = 0; |
Wolfgang Betz |
43:2544d064d528 | 58 | |
Wolfgang Betz |
43:2544d064d528 | 59 | /** |
Wolfgang Betz |
43:2544d064d528 | 60 | * @brief Get current temperature in degrees Fahrenheit [°F] |
Wolfgang Betz |
43:2544d064d528 | 61 | * @param[out] pfData Pointer to where to store temperature to |
Wolfgang Betz |
43:2544d064d528 | 62 | * @return 0 in case of success, an error code otherwise |
Wolfgang Betz |
43:2544d064d528 | 63 | */ |
Wolfgang Betz |
43:2544d064d528 | 64 | virtual int GetFahrenheit(float *pfData) { |
Wolfgang Betz |
43:2544d064d528 | 65 | float celsius; |
Wolfgang Betz |
43:2544d064d528 | 66 | int ret; |
Wolfgang Betz |
43:2544d064d528 | 67 | |
Wolfgang Betz |
43:2544d064d528 | 68 | ret = GetTemperature(&celsius); |
Wolfgang Betz |
43:2544d064d528 | 69 | if(ret) return ret; |
Wolfgang Betz |
43:2544d064d528 | 70 | |
Wolfgang Betz |
43:2544d064d528 | 71 | *pfData = ((celsius * 1.8f) + 32.0f); |
Wolfgang Betz |
43:2544d064d528 | 72 | return 0; |
Wolfgang Betz |
43:2544d064d528 | 73 | } |
Wolfgang Betz |
43:2544d064d528 | 74 | }; |
Wolfgang Betz |
43:2544d064d528 | 75 | |
Wolfgang Betz |
43:2544d064d528 | 76 | #endif /* __TEMP_SENSOR_CLASS_H */ |