Initial release. Mbed library for VL53L1CB

Committer:
charlesmn
Date:
Fri Nov 06 12:15:24 2020 +0000
Revision:
0:3d72bef69191
Initial release. Mbed library for VL53L1CB

Who changed what in which revision?

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