upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
bmc150.hpp
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016-2017 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #pragma once
25 
26 #include <string>
27 #include <vector>
28 
29 #include "bma250e.hpp"
30 #include "bmm150.hpp"
31 
32 #define BMC150_DEFAULT_BUS 0
33 #define BMC150_DEFAULT_ACC_ADDR 0x10
34 #define BMC150_DEFAULT_MAG_ADDR 0x12
35 
36 namespace upm {
37 
73  class BMC150 {
74  public:
96  BMC150(int accelBus=BMC150_DEFAULT_BUS,
97  int accelAddr=BMC150_DEFAULT_ACC_ADDR,
98  int accelCS=-1,
99  int magBus=BMC150_DEFAULT_BUS,
100  int magAddr=BMC150_DEFAULT_MAG_ADDR,
101  int magCS=-1);
102 
106  ~BMC150();
107 
111  void update();
112 
126  void initAccelerometer(
127  BMA250E_POWER_MODE_T pwr=BMA250E_POWER_MODE_NORMAL,
128  BMA250E_RANGE_T range=BMA250E_RANGE_2G,
129  BMA250E_BW_T bw=BMA250E_BW_250);
130 
141  void initMagnetometer(
142  BMM150_USAGE_PRESETS_T usage=BMM150_USAGE_HIGH_ACCURACY);
143 
155  void getAccelerometer(float *x, float *y, float *z);
156 
165  std::vector<float> getAccelerometer();
166 
178  void getMagnetometer(float *x, float *y, float *z);
179 
188  std::vector<float> getMagnetometer();
189 
190 
191  protected:
192  BMA250E *m_accel;
193  BMM150 *m_mag;
194 
195  private:
196  /* Disable implicit copy and assignment operators */
197  BMC150(const BMC150&) = delete;
198  BMC150 &operator=(const BMC150&) = delete;
199  };
200 }
std::vector< float > getMagnetometer()
Definition: bmc150.cxx:110
void initMagnetometer(BMM150_USAGE_PRESETS_T usage=BMM150_USAGE_HIGH_ACCURACY)
Definition: bmc150.cxx:75
API for the BMM150 3-Axis Geomagnetic Sensor.
Definition: bmm150.hpp:76
~BMC150()
Definition: bmc150.cxx:58
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
void update()
Definition: bmc150.cxx:81
BMC150(int accelBus=BMC150_DEFAULT_BUS, int accelAddr=BMC150_DEFAULT_ACC_ADDR, int accelCS=-1, int magBus=BMC150_DEFAULT_BUS, int magAddr=BMC150_DEFAULT_MAG_ADDR, int magCS=-1)
Definition: bmc150.cxx:37
API for the BMC150 6-axis eCompass.
Definition: bmc150.hpp:73
std::vector< float > getAccelerometer()
Definition: bmc150.cxx:96
API for the BMA250E 10 bit Triaxial Accelerometer.
Definition: bma250e.hpp:76
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: bmc150.cxx:67