Dependents:
accelerometer
MMA7361L.h@4:8bdd5a9f289e, 2012-02-17 (annotated)
- Committer:
- JST2011
- Date:
- Fri Feb 17 15:27:31 2012 +0000
- Revision:
- 4:8bdd5a9f289e
- Parent:
-
2:7635426ea08f
Who changed what in which revision?
User | Revision | Line number | New contents of line |
JST2011 |
2:7635426ea08f
|
1
|
#ifndef MMA7361L_H
|
JST2011 |
2:7635426ea08f
|
2
|
#define MMA7361L_H
|
JST2011 |
2:7635426ea08f
|
3
|
|
JST2011 |
0:be166c309588
|
4
|
#include "mbed.h"
|
JST2011 |
1:49b063625495
|
5
|
/**accelerometer*/
|
JST2011 |
0:be166c309588
|
6
|
class MMA7361L {
|
JST2011 |
0:be166c309588
|
7
|
public:
|
JST2011 |
0:be166c309588
|
8
|
/**
|
JST2011 |
0:be166c309588
|
9
|
* Creates an MMA7361L accelerometer interface, connected to the specified pins
|
JST2011 |
0:be166c309588
|
10
|
* @param xoutPin xout pin
|
JST2011 |
0:be166c309588
|
11
|
* @param youtPin yout pin
|
JST2011 |
0:be166c309588
|
12
|
* @param zoutPin zout pin
|
JST2011 |
0:be166c309588
|
13
|
* @param zeroGDetectPin 0G detect pin
|
JST2011 |
0:be166c309588
|
14
|
*/
|
JST2011 |
0:be166c309588
|
15
|
MMA7361L(PinName xoutPin, PinName youtPin,PinName zoutPin,
|
JST2011 |
0:be166c309588
|
16
|
PinName zeroGDetectPin);
|
JST2011 |
0:be166c309588
|
17
|
/**
|
JST2011 |
0:be166c309588
|
18
|
* Gets the current total acceleration
|
JST2011 |
0:be166c309588
|
19
|
* @returns total acceleration in g
|
JST2011 |
0:be166c309588
|
20
|
*/
|
JST2011 |
0:be166c309588
|
21
|
float getAccel();
|
JST2011 |
0:be166c309588
|
22
|
/**
|
JST2011 |
0:be166c309588
|
23
|
* Gets the current acceleration along the X axis
|
JST2011 |
0:be166c309588
|
24
|
* @returns acceleration along the X axis in g
|
JST2011 |
0:be166c309588
|
25
|
*/
|
JST2011 |
0:be166c309588
|
26
|
float getAccelX();
|
JST2011 |
0:be166c309588
|
27
|
/**
|
JST2011 |
0:be166c309588
|
28
|
* Gets the current acceleration along the Y axis
|
JST2011 |
0:be166c309588
|
29
|
* @returns acceleration along the Y axis in g
|
JST2011 |
0:be166c309588
|
30
|
*/
|
JST2011 |
0:be166c309588
|
31
|
float getAccelY();
|
JST2011 |
0:be166c309588
|
32
|
/**
|
JST2011 |
0:be166c309588
|
33
|
* Gets the current acceleration along the Z axis
|
JST2011 |
0:be166c309588
|
34
|
* @returns acceleration along the Z axis in g
|
JST2011 |
0:be166c309588
|
35
|
*/
|
JST2011 |
0:be166c309588
|
36
|
float getAccelZ();
|
JST2011 |
0:be166c309588
|
37
|
/**
|
JST2011 |
0:be166c309588
|
38
|
* Computes the inclination of the X axis
|
JST2011 |
0:be166c309588
|
39
|
* @returns the inclination of the X axis
|
JST2011 |
0:be166c309588
|
40
|
*/
|
JST2011 |
0:be166c309588
|
41
|
float getTiltX();
|
JST2011 |
0:be166c309588
|
42
|
/**
|
JST2011 |
0:be166c309588
|
43
|
* Computes the inclination of the Y axis
|
JST2011 |
0:be166c309588
|
44
|
* @returns the inclination of the Y axis
|
JST2011 |
0:be166c309588
|
45
|
*/
|
JST2011 |
0:be166c309588
|
46
|
float getTiltY();
|
JST2011 |
0:be166c309588
|
47
|
/**
|
JST2011 |
0:be166c309588
|
48
|
* Computes the inclination of the Z axis
|
JST2011 |
0:be166c309588
|
49
|
* @returns the inclination of the Z axis
|
JST2011 |
0:be166c309588
|
50
|
*/
|
JST2011 |
0:be166c309588
|
51
|
float getTiltZ();
|
JST2011 |
0:be166c309588
|
52
|
/**
|
JST2011 |
0:be166c309588
|
53
|
* Tests whether 0G is detected
|
JST2011 |
0:be166c309588
|
54
|
* @returns true if 0G is detected, false otherwise
|
JST2011 |
0:be166c309588
|
55
|
*/
|
JST2011 |
0:be166c309588
|
56
|
bool zeroGDetected();
|
JST2011 |
0:be166c309588
|
57
|
/**
|
JST2011 |
0:be166c309588
|
58
|
* Sets fucntion to be called when 0G is detected
|
JST2011 |
0:be166c309588
|
59
|
* @param func pointer to a function called when 0G is detected, 0 to reset as none
|
JST2011 |
0:be166c309588
|
60
|
*/
|
JST2011 |
0:be166c309588
|
61
|
void setZeroGDetectListener(void (*func)(void));
|
JST2011 |
0:be166c309588
|
62
|
/**
|
JST2011 |
0:be166c309588
|
63
|
* Sets member fucntion to be called when 0G is detected
|
JST2011 |
0:be166c309588
|
64
|
* @param t pointer to the object to call the member function on
|
JST2011 |
0:be166c309588
|
65
|
* @param func pointer to the member function tobe called when 0G is detected, 0 to reset as none
|
JST2011 |
0:be166c309588
|
66
|
*/
|
JST2011 |
0:be166c309588
|
67
|
template<typename T> void setZeroGDetectListener(T* t, void (T::*func)(void));
|
JST2011 |
0:be166c309588
|
68
|
|
JST2011 |
0:be166c309588
|
69
|
private:
|
JST2011 |
0:be166c309588
|
70
|
void prepare();
|
JST2011 |
0:be166c309588
|
71
|
|
JST2011 |
0:be166c309588
|
72
|
AnalogIn xout, yout, zout;
|
JST2011 |
0:be166c309588
|
73
|
InterruptIn zeroGDetect;
|
JST2011 |
0:be166c309588
|
74
|
float accelX;
|
JST2011 |
0:be166c309588
|
75
|
float accelY;
|
JST2011 |
0:be166c309588
|
76
|
float accelZ;
|
JST2011 |
0:be166c309588
|
77
|
float scaleX;
|
JST2011 |
0:be166c309588
|
78
|
float scaleY;
|
JST2011 |
0:be166c309588
|
79
|
float scaleZ;
|
JST2011 |
0:be166c309588
|
80
|
float Xo;
|
JST2011 |
0:be166c309588
|
81
|
float Yo;
|
JST2011 |
0:be166c309588
|
82
|
float Zo;
|
JST2011 |
2:7635426ea08f
|
83
|
};
|
JST2011 |
2:7635426ea08f
|
84
|
|
JST2011 |
2:7635426ea08f
|
85
|
#endif |