upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
bmp280.hpp
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016-2017 Intel Corporation.
4  *
5  * The MIT License
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  */
26 #pragma once
27 
28 #include <string>
29 #include "bmp280.h"
30 
31 #include "interfaces/iPressureSensor.hpp"
32 #include "interfaces/iTemperatureSensor.hpp"
33 
34 namespace upm {
35 
70  class BMP280 : public ITemperatureSensor, public IPressureSensor {
71  public:
72 
93  BMP280(int bus=BMP280_DEFAULT_I2C_BUS, int addr=BMP280_DEFAULT_ADDR,
94  int cs=-1);
95 
99  virtual ~BMP280();
100 
106  virtual void update();
107 
113  uint8_t getChipID();
114 
118  void reset();
119 
130  float getTemperature(bool fahrenheit=false);
131 
138  float getPressure();
139 
150  void setSeaLevelPreassure(float seaLevelhPA=1013.25);
151 
158  float getAltitude();
159 
169  virtual void setUsageMode(BMP280_USAGE_MODE_T mode);
170 
179  void setOversampleRateTemperature(BMP280_OSRS_T_T rate);
180 
189  void setOversampleRatePressure(BMP280_OSRS_P_T rate);
190 
198  void setTimerStandby(BMP280_T_SB_T tsb);
199 
207  void setFilter(BMP280_FILTER_T filter);
208 
217  void setMeasureMode(BMP280_MODES_T mode);
218 
219 
220  // Interface support
221  const char *getModuleName()
222  {
223  return "BMP280";
224  };
225 
226  int getTemperatureCelsius()
227  {
228  return int(getTemperature(false));
229  };
230 
231  int getPressurePa()
232  {
233  return int(getPressure());
234  };
235 
236  protected:
237  bmp280_context m_bmp280;
238 
244  uint8_t getStatus();
245 
252  uint8_t readReg(uint8_t reg);
253 
261  int readRegs(uint8_t reg, uint8_t *buffer, int len);
262 
270  void writeReg(uint8_t reg, uint8_t val);
271 
272  private:
273  /* Disable implicit copy and assignment operators */
274  BMP280(const BMP280&) = delete;
275  BMP280 &operator=(const BMP280&) = delete;
276  };
277 }
void writeReg(uint8_t reg, uint8_t val)
Definition: bmp280.cxx:85
int readRegs(uint8_t reg, uint8_t *buffer, int len)
Definition: bmp280.cxx:80
float getPressure()
Definition: bmp280.cxx:113
uint8_t getStatus()
Definition: bmp280.cxx:143
uint8_t readReg(uint8_t reg)
Definition: bmp280.cxx:75
C API for the bmp280 and bme280 driver.
BMP280(int bus=BMP280_DEFAULT_I2C_BUS, int addr=BMP280_DEFAULT_ADDR, int cs=-1)
Definition: bmp280.cxx:45
Interface for Temperature Sensors.
Definition: iTemperatureSensor.hpp:34
void reset()
Definition: bmp280.cxx:97
void setTimerStandby(BMP280_T_SB_T tsb)
Definition: bmp280.cxx:123
void setOversampleRatePressure(BMP280_OSRS_P_T rate)
Definition: bmp280.cxx:133
virtual void update()
Definition: bmp280.cxx:58
virtual ~BMP280()
Definition: bmp280.cxx:53
void setOversampleRateTemperature(BMP280_OSRS_T_T rate)
Definition: bmp280.cxx:138
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
void setMeasureMode(BMP280_MODES_T mode)
Definition: bmp280.cxx:128
const char * getModuleName()
Definition: bmp280.hpp:221
void setFilter(BMP280_FILTER_T filter)
Definition: bmp280.cxx:118
virtual void setUsageMode(BMP280_USAGE_MODE_T mode)
Definition: bmp280.cxx:148
float getAltitude()
Definition: bmp280.cxx:70
void setSeaLevelPreassure(float seaLevelhPA=1013.25)
Definition: bmp280.cxx:65
float getTemperature(bool fahrenheit=false)
Definition: bmp280.cxx:103
API for the BMP280 Digital Pressure Sensor.
Definition: bmp280.hpp:70
uint8_t getChipID()
Definition: bmp280.cxx:92
Definition: iPressureSensor.hpp:36
Definition: bmp280.h:54