upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
mma7361.hpp
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 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 <string>
27 #include <iostream>
28 
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <string.h>
32 
33 #include "mma7361.h"
34 
35 namespace upm {
60  class MMA7361 {
61  public:
62 
77  MMA7361(int x_pin, int y_pin, int z_pin,
78  int selftest_pin, int sleep_pin,
79  int freefall_pin, int range_pin,
80  float a_ref=5.0);
81 
85  ~MMA7361();
86 
93  void setRange(bool range);
94 
100  void setSleep(bool sleep);
101 
107  bool isInFreefall();
108 
114  void enableSelftest(bool enable);
115 
121  void update();
122 
131  void setOffset(float x, float y, float z);
132 
141  void setScale(float x, float y, float z);
142 
151  void getAcceleration(float *x, float *y, float *z);
152 
160  float *getAcceleration();
161 
170  void getVolts(float *x, float *y, float *z);
171 
179  float *getVolts();
180 
189  void getNormalized(float *x, float *y, float *z);
190 
198  float *getNormalized();
199 
200  protected:
201  // mma7361 device context
202  mma7361_context m_mma7361;
203 
204  private:
205  /* Disable implicit copy and assignment operators */
206  MMA7361(const MMA7361&) = delete;
207  MMA7361 &operator=(const MMA7361&) = delete;
208  };
209 }
210 
211 
void setOffset(float x, float y, float z)
Definition: mma7361.cxx:100
C API for the MMA7361 Analog Accelerometer.
float * getAcceleration()
Definition: mma7361.cxx:115
void update()
Definition: mma7361.cxx:88
void setScale(float x, float y, float z)
Definition: mma7361.cxx:105
void enableSelftest(bool enable)
Definition: mma7361.cxx:76
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
~MMA7361()
Definition: mma7361.cxx:46
float * getVolts()
Definition: mma7361.cxx:129
float * getNormalized()
Definition: mma7361.cxx:143
Definition: mma7361.h:47
bool isInFreefall()
Definition: mma7361.cxx:61
MMA7361(int x_pin, int y_pin, int z_pin, int selftest_pin, int sleep_pin, int freefall_pin, int range_pin, float a_ref=5.0)
Definition: mma7361.cxx:34
void setSleep(bool sleep)
Definition: mma7361.cxx:56
void setRange(bool range)
Definition: mma7361.cxx:51
API for the DFRobot MMA7361 Analog Accelerometer.
Definition: mma7361.hpp:60