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