upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
mma7660.hpp
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2015-2016 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 <vector>
27 
28 #include "mma7660.h"
29 
30 namespace upm {
31 
61  class MMA7660 {
62  public:
63 
70  MMA7660(int bus, uint8_t address=MMA7660_DEFAULT_I2C_ADDR);
71 
75  virtual ~MMA7660();
76 
84  bool writeByte(uint8_t reg, uint8_t byte);
85 
92  uint8_t readByte(uint8_t reg);
93 
101  void getRawValues(int *x, int *y, int *z);
102 
110  void getAcceleration(float *ax, float *ay, float *az);
111 
119  int getVerifiedAxis(MMA7660_REG_T axis);
120 
126  uint8_t getVerifiedTilt();
127 
134  void setModeActive();
135 
143  void setModeStandby();
144 
152  uint8_t tiltBackFront();
153 
161  uint8_t tiltLandscapePortrait();
162 
168  bool tiltTap();
169 
175  bool tiltShake();
176 
181  void uninstallISR();
182 
191  bool setInterruptBits(uint8_t ibits);
192 
200  bool setSampleRate(MMA7660_AUTOSLEEP_T sr);
201 
209  std::vector<float> getAcceleration()
210  {
211  std::vector<float> values(3);
212  getAcceleration(&values[0], &values[1], &values[2]);
213  return values;
214  }
215 
223  std::vector<int> getRawValues()
224  {
225  std::vector<int> values(3);
226  getRawValues(&values[0], &values[1], &values[2]);
227  return values;
228  }
229 
239  void installISR(int pin, void (*isr)(void *), void *arg);
240 
241  protected:
242  mma7660_context m_mma7660;
243 
244  private:
245  /* Disable implicit copy and assignment operators */
246  MMA7660(const MMA7660&) = delete;
247  MMA7660 &operator=(const MMA7660&) = delete;
248 
249  };
250 }
bool writeByte(uint8_t reg, uint8_t byte)
Definition: mma7660.cxx:48
void setModeStandby()
Definition: mma7660.cxx:80
void installISR(int pin, void(*isr)(void *), void *arg)
Definition: mma7660.cxx:158
bool tiltTap()
Definition: mma7660.cxx:138
API for the MMA7660 I2C 3-Axis Digital Accelerometer.
Definition: mma7660.hpp:61
bool setSampleRate(MMA7660_AUTOSLEEP_T sr)
Definition: mma7660.cxx:178
bool tiltShake()
Definition: mma7660.cxx:148
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
std::vector< int > getRawValues()
Definition: mma7660.hpp:223
bool setInterruptBits(uint8_t ibits)
Definition: mma7660.cxx:170
void setModeActive()
Definition: mma7660.cxx:73
uint8_t readByte(uint8_t reg)
Definition: mma7660.cxx:56
uint8_t tiltBackFront()
Definition: mma7660.cxx:118
uint8_t tiltLandscapePortrait()
Definition: mma7660.cxx:128
uint8_t getVerifiedTilt()
Definition: mma7660.cxx:108
void uninstallISR()
Definition: mma7660.cxx:165
int getVerifiedAxis(MMA7660_REG_T axis)
Definition: mma7660.cxx:88
std::vector< float > getAcceleration()
Definition: mma7660.hpp:209
virtual ~MMA7660()
Definition: mma7660.cxx:43
C API for the mma7660 driver.
Definition: mma7660.h:50
MMA7660(int bus, uint8_t address=MMA7660_DEFAULT_I2C_ADDR)
Definition: mma7660.cxx:35