Javascript wrappers for LPS22HB Sensor library
Dependencies: LPS22HB
LPS22HB_JS.cpp@6:a480866ede7e, 2018-01-17 (annotated)
- Committer:
- akhtar.syedzeeshan@gmail.com
- Date:
- Wed Jan 17 10:55:45 2018 +0100
- Revision:
- 6:a480866ede7e
- Parent:
- 5:e92dbbec30d7
Code fixes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 1 | /** |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 2 | ****************************************************************************** |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 3 | * @file LPS22HB_JS.cpp |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 4 | * @author ST |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 5 | * @version V1.0.0 |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 6 | * @date 9 October 2017 |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 7 | * @brief Implementation of an LPS22HB Pressure and Temperature sensor for use |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 8 | * with Javascript. |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 9 | ****************************************************************************** |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 10 | * @attention |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 11 | * |
akhtar.syedzeeshan@gmail.com | 6:a480866ede7e | 12 | * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 13 | * |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 14 | * Redistribution and use in source and binary forms, with or without modification, |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 15 | * are permitted provided that the following conditions are met: |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 17 | * this list of conditions and the following disclaimer. |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 19 | * this list of conditions and the following disclaimer in the documentation |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 20 | * and/or other materials provided with the distribution. |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 22 | * may be used to endorse or promote products derived from this software |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 23 | * without specific prior written permission. |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 24 | * |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 35 | * |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 36 | ****************************************************************************** |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 37 | */ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 38 | |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 39 | |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 40 | /* Includes ------------------------------------------------------------------*/ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 41 | |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 42 | #include "LPS22HB_JS.h" |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 43 | |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 44 | #include <stdlib.h> /* atoi */ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 45 | #include "mbed.h" |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 46 | |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 47 | /* Helper function for printing floats & doubles */ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 48 | static char *print_double(char* str, double v, int decimalDigits=2) |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 49 | { |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 50 | int i = 1; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 51 | int intPart, fractPart; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 52 | int len; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 53 | char *ptr; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 54 | |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 55 | /* prepare decimal digits multiplicator */ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 56 | for (;decimalDigits!=0; i*=10, decimalDigits--); |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 57 | |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 58 | /* calculate integer & fractinal parts */ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 59 | intPart = (int)v; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 60 | fractPart = (int)((v-(double)(int)v)*i); |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 61 | |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 62 | /* fill in integer part */ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 63 | sprintf(str, "%i.", intPart); |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 64 | |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 65 | /* prepare fill in of fractional part */ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 66 | len = strlen(str); |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 67 | ptr = &str[len]; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 68 | |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 69 | /* fill in leading fractional zeros */ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 70 | for (i/=10;i>1; i/=10, ptr++) { |
akhtar.syedzeeshan@gmail.com | 3:3e19d8808491 | 71 | if (fractPart >= i) { |
akhtar.syedzeeshan@gmail.com | 3:3e19d8808491 | 72 | break; |
akhtar.syedzeeshan@gmail.com | 3:3e19d8808491 | 73 | } |
akhtar.syedzeeshan@gmail.com | 3:3e19d8808491 | 74 | *ptr = '0'; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 75 | } |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 76 | |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 77 | /* fill in (rest of) fractional part */ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 78 | sprintf(ptr, "%i", fractPart); |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 79 | |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 80 | return str; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 81 | } |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 82 | |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 83 | /* Class Implementation ------------------------------------------------------*/ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 84 | |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 85 | |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 86 | /** Constructor |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 87 | * @brief Initializing the component. |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 88 | * @param DevI2c object of helper class which handles the DevI2C peripheral |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 89 | */ |
akhtar.syedzeeshan@gmail.com | 4:c2cf5deba40f | 90 | LPS22HB_JS::LPS22HB_JS(DevI2C &devI2c){ |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 91 | init(devI2c); |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 92 | } |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 93 | |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 94 | /** init |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 95 | * @brief Initializing the component. |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 96 | * @param DevI2c object of helper class which handles the DevI2C peripheral |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 97 | */ |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 98 | void LPS22HB_JS::init(DevI2C &devI2c){ |
akhtar.syedzeeshan@gmail.com | 4:c2cf5deba40f | 99 | press_temp = new LPS22HBSensor(&devI2c); |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 100 | press_temp->init(NULL); |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 101 | press_temp->enable(); |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 102 | } |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 103 | |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 104 | /** Constructor |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 105 | * @brief Initializing the component. |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 106 | * @param DevI2c object of helper class which handles the DevI2C peripheral |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 107 | * @param Address |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 108 | * @param INT pin |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 109 | */ |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 110 | LPS22HB_JS::LPS22HB_JS(DevI2C &devI2c, uint8_t address, PinName int_pin){ |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 111 | init(devI2c, address, int_pin); |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 112 | } |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 113 | |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 114 | /** init |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 115 | * @brief Initializing the component. |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 116 | * @param DevI2c object of helper class which handles the DevI2C peripheral |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 117 | * @param Address |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 118 | * @param INT pin |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 119 | */ |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 120 | void LPS22HB_JS::init(DevI2C &devI2c, uint8_t address, PinName int_pin){ |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 121 | press_temp = new LPS22HBSensor(&devI2c, address, int_pin); |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 122 | press_temp->init(NULL); |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 123 | press_temp->enable(); |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 124 | } |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 125 | |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 126 | /** Constructor |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 127 | * @brief Initializing the component. |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 128 | * @param SPI object of helper class which handles the SPI peripheral |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 129 | * @param CS pin |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 130 | */ |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 131 | LPS22HB_JS::LPS22HB_JS(SPI &spi, PinName cs_pin){ |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 132 | init(spi, cs_pin); |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 133 | } |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 134 | |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 135 | /** init |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 136 | * @brief Initializing the component. |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 137 | * @param SPI object of helper class which handles the SPI peripheral |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 138 | * @param CS pin |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 139 | */ |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 140 | void LPS22HB_JS::init(SPI &spi, PinName cs_pin){ |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 141 | press_temp = new LPS22HBSensor(&spi, cs_pin); |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 142 | press_temp->init(NULL); |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 143 | press_temp->enable(); |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 144 | } |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 145 | |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 146 | /** Constructor |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 147 | * @brief Initializing the component. |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 148 | * @param SPI object of helper class which handles the SPI peripheral |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 149 | * @param CS pin |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 150 | * @param INT pin |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 151 | * @param SPI type |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 152 | */ |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 153 | LPS22HB_JS::LPS22HB_JS(SPI &spi, PinName cs_pin, PinName int_pin, int spi_type){ |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 154 | init(spi, cs_pin, int_pin, spi_type); |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 155 | } |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 156 | |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 157 | /** init |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 158 | * @brief Initializing the component. |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 159 | * @param SPI object of helper class which handles the SPI peripheral |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 160 | * @param CS pin |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 161 | * @param INT pin |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 162 | * @param SPI type |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 163 | */ |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 164 | void LPS22HB_JS::init(SPI &spi, PinName cs_pin, PinName int_pin, int spi_type){ |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 165 | press_temp = new LPS22HBSensor(&spi, cs_pin, int_pin, spi_type == 3? LPS22HBSensor::SPI3W: LPS22HBSensor::SPI4W); |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 166 | press_temp->init(NULL); |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 167 | press_temp->enable(); |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 168 | } |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 169 | |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 170 | /** Destructor |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 171 | * @brief Recycling the component. Deletes the Sensor Object |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 172 | */ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 173 | LPS22HB_JS::~LPS22HB_JS(){ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 174 | if(press_temp != NULL){ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 175 | delete press_temp; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 176 | } |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 177 | } |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 178 | |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 179 | /** readID |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 180 | * @brief Read ID address of LPS22HB |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 181 | * @retval The ID of the Sensor |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 182 | */ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 183 | uint8_t LPS22HB_JS::readID(){ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 184 | uint8_t result; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 185 | press_temp->read_id(&result); |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 186 | return result; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 187 | } |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 188 | |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 189 | /** get_temperature |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 190 | * @brief Gets the temperature reading from LPS22HB |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 191 | * @retval Temperature value |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 192 | */ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 193 | float LPS22HB_JS::get_temperature(){ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 194 | float value; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 195 | press_temp->get_temperature(&value); |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 196 | return value; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 197 | } |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 198 | |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 199 | /** get_temperature_string |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 200 | * @brief Gets the temperature reading from LPS22HB |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 201 | * @retval Temperature value in string form |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 202 | */ |
akhtar.syedzeeshan@gmail.com | 1:6b7b798e36ae | 203 | char *LPS22HB_JS::get_temperature_string(char *buffer){ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 204 | float value; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 205 | press_temp->get_temperature(&value); |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 206 | print_double(buffer, value); |
akhtar.syedzeeshan@gmail.com | 1:6b7b798e36ae | 207 | return buffer; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 208 | } |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 209 | |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 210 | /** get_pressure |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 211 | * @brief Gets the pressure reading from LPS22HB |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 212 | * @retval Pressure value |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 213 | */ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 214 | float LPS22HB_JS::get_pressure(){ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 215 | float value; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 216 | press_temp->get_pressure(&value); |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 217 | return value; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 218 | } |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 219 | |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 220 | /** get_pressure_string |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 221 | * @brief Gets the pressure reading from LPS22HB |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 222 | * @retval pressure value in string form |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 223 | */ |
akhtar.syedzeeshan@gmail.com | 1:6b7b798e36ae | 224 | char *LPS22HB_JS::get_pressure_string(char *buffer){ |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 225 | float value; |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 226 | press_temp->get_pressure(&value); |
akhtar.syedzeeshan@gmail.com | 0:c256bbccd0d4 | 227 | print_double(buffer, value); |
akhtar.syedzeeshan@gmail.com | 1:6b7b798e36ae | 228 | return buffer; |
akhtar.syedzeeshan@gmail.com | 5:e92dbbec30d7 | 229 | } |