upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
bmx055.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 <vector>
30 
31 #include "bma250e.hpp"
32 #include "bmg160.hpp"
33 #include "bmm150.hpp"
34 
35 #define BMX055_DEFAULT_MAG_I2C_ADDR 0x12
36 
37 namespace upm {
38 
79  class BMX055 {
80  public:
107  BMX055(int accelBus=BMA250E_DEFAULT_I2C_BUS,
108  int accelAddr=BMA250E_DEFAULT_ADDR,
109  int accelCS=-1,
110  int gyroBus=BMG160_DEFAULT_I2C_BUS,
111  int gyroAddr=BMG160_DEFAULT_ADDR,
112  int gyroCS=-1,
113  int magBus=BMM150_DEFAULT_I2C_BUS,
114  int magAddr=BMX055_DEFAULT_MAG_I2C_ADDR,
115  int magCS=-1);
116 
120  ~BMX055();
121 
125  void update();
126 
140  void initAccelerometer(
141  BMA250E_POWER_MODE_T pwr=BMA250E_POWER_MODE_NORMAL,
142  BMA250E_RANGE_T range=BMA250E_RANGE_2G,
143  BMA250E_BW_T bw=BMA250E_BW_250);
144 
158  void initGyroscope(BMG160_POWER_MODE_T pwr=BMG160_POWER_MODE_NORMAL,
159  BMG160_RANGE_T range=BMG160_RANGE_250,
160  BMG160_BW_T bw=BMG160_BW_400_47);
161 
172  void initMagnetometer(
173  BMM150_USAGE_PRESETS_T usage=BMM150_USAGE_HIGH_ACCURACY);
174 
186  void getAccelerometer(float *x, float *y, float *z);
187 
196  std::vector<float> getAccelerometer();
197 
209  void getGyroscope(float *x, float *y, float *z);
210 
219  std::vector<float> getGyroscope();
220 
232  void getMagnetometer(float *x, float *y, float *z);
233 
242  std::vector<float> getMagnetometer();
243 
244  protected:
245  BMA250E *m_accel;
246  BMG160 *m_gyro;
247  BMM150 *m_mag;
248 
249  private:
250  /* Disable implicit copy and assignment operators */
251  BMX055(const BMX055&) = delete;
252  BMX055 &operator=(const BMX055&) = delete;
253  };
254 }
void initGyroscope(BMG160_POWER_MODE_T pwr=BMG160_POWER_MODE_NORMAL, BMG160_RANGE_T range=BMG160_RANGE_250, BMG160_BW_T bw=BMG160_BW_400_47)
Definition: bmx055.cxx:75
BMX055(int accelBus=BMA250E_DEFAULT_I2C_BUS, int accelAddr=BMA250E_DEFAULT_ADDR, int accelCS=-1, int gyroBus=BMG160_DEFAULT_I2C_BUS, int gyroAddr=BMG160_DEFAULT_ADDR, int gyroCS=-1, int magBus=BMM150_DEFAULT_I2C_BUS, int magAddr=BMX055_DEFAULT_MAG_I2C_ADDR, int magCS=-1)
Definition: bmx055.cxx:37
std::vector< float > getGyroscope()
Definition: bmx055.cxx:139
void initAccelerometer(BMA250E_POWER_MODE_T pwr=BMA250E_POWER_MODE_NORMAL, BMA250E_RANGE_T range=BMA250E_RANGE_2G, BMA250E_BW_T bw=BMA250E_BW_250)
Definition: bmx055.cxx:67
API for the BMM150 3-Axis Geomagnetic Sensor.
Definition: bmm150.hpp:76
API for the BMG160 16 bit Triaxial Gyroscope.
Definition: bmg160.hpp:74
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
~BMX055()
Definition: bmx055.cxx:55
std::vector< float > getAccelerometer()
Definition: bmx055.cxx:116
API for the BMA250E 10 bit Triaxial Accelerometer.
Definition: bma250e.hpp:76
void update()
Definition: bmx055.cxx:89
std::vector< float > getMagnetometer()
Definition: bmx055.cxx:162
API for the BMX055 9-axis Sensor Module.
Definition: bmx055.hpp:79
void initMagnetometer(BMM150_USAGE_PRESETS_T usage=BMM150_USAGE_HIGH_ACCURACY)
Definition: bmx055.cxx:83