Framework of classes and program to measure tilt angles using accelerometers
Fork of tilt_angles by
Tiltmeter.h@1:64f1aefe1842, 2016-11-25 (annotated)
- Committer:
- mpetovello
- Date:
- Fri Nov 25 15:18:28 2016 +0000
- Revision:
- 1:64f1aefe1842
- Parent:
- 0:3bffc1862262
Removed MMA7660 library (unnecessary)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mpetovello | 0:3bffc1862262 | 1 | #ifndef TILTMETER_H |
mpetovello | 0:3bffc1862262 | 2 | #define TILTMETER_H |
mpetovello | 0:3bffc1862262 | 3 | |
mpetovello | 0:3bffc1862262 | 4 | class Tiltmeter |
mpetovello | 0:3bffc1862262 | 5 | { |
mpetovello | 0:3bffc1862262 | 6 | public: |
mpetovello | 0:3bffc1862262 | 7 | |
mpetovello | 0:3bffc1862262 | 8 | // Default constructor |
mpetovello | 0:3bffc1862262 | 9 | Tiltmeter(); |
mpetovello | 0:3bffc1862262 | 10 | |
mpetovello | 0:3bffc1862262 | 11 | |
mpetovello | 0:3bffc1862262 | 12 | // Detect the presence of tiltmeter sensor and ensure its status is appropriately set. |
mpetovello | 0:3bffc1862262 | 13 | // |
mpetovello | 0:3bffc1862262 | 14 | // Arguments: |
mpetovello | 0:3bffc1862262 | 15 | // None |
mpetovello | 0:3bffc1862262 | 16 | // |
mpetovello | 0:3bffc1862262 | 17 | // Returns: |
mpetovello | 0:3bffc1862262 | 18 | // The function returns true if the sensor is present and ready to use, and false otherwise. |
mpetovello | 0:3bffc1862262 | 19 | virtual bool TestConnection() = 0; |
mpetovello | 0:3bffc1862262 | 20 | |
mpetovello | 0:3bffc1862262 | 21 | |
mpetovello | 0:3bffc1862262 | 22 | // Compute the tilt angles and store them internally; you can access the computed values by |
mpetovello | 0:3bffc1862262 | 23 | // calling the GetRoll() and GetPitch() functions. |
mpetovello | 0:3bffc1862262 | 24 | // |
mpetovello | 0:3bffc1862262 | 25 | // Arguments: |
mpetovello | 0:3bffc1862262 | 26 | // None |
mpetovello | 0:3bffc1862262 | 27 | // |
mpetovello | 0:3bffc1862262 | 28 | // Returns: |
mpetovello | 0:3bffc1862262 | 29 | // Nothing |
mpetovello | 0:3bffc1862262 | 30 | void ComputeTiltAngles(); |
mpetovello | 0:3bffc1862262 | 31 | |
mpetovello | 0:3bffc1862262 | 32 | |
mpetovello | 0:3bffc1862262 | 33 | // Get the most recent roll angle as computed by calling ComputeTilt() |
mpetovello | 0:3bffc1862262 | 34 | // |
mpetovello | 0:3bffc1862262 | 35 | // Arguments: |
mpetovello | 0:3bffc1862262 | 36 | // None |
mpetovello | 0:3bffc1862262 | 37 | // |
mpetovello | 0:3bffc1862262 | 38 | // Returns: |
mpetovello | 0:3bffc1862262 | 39 | // The function returns the roll angle in units of degrees |
mpetovello | 0:3bffc1862262 | 40 | float GetRoll() const; |
mpetovello | 0:3bffc1862262 | 41 | |
mpetovello | 0:3bffc1862262 | 42 | |
mpetovello | 0:3bffc1862262 | 43 | // Get the most recent roll angle as computed by calling ComputeTilt() |
mpetovello | 0:3bffc1862262 | 44 | // |
mpetovello | 0:3bffc1862262 | 45 | // Arguments: |
mpetovello | 0:3bffc1862262 | 46 | // None |
mpetovello | 0:3bffc1862262 | 47 | // |
mpetovello | 0:3bffc1862262 | 48 | // Returns: |
mpetovello | 0:3bffc1862262 | 49 | // The function returns the roll angle in units of degrees |
mpetovello | 0:3bffc1862262 | 50 | float GetPitch() const; |
mpetovello | 0:3bffc1862262 | 51 | |
mpetovello | 0:3bffc1862262 | 52 | |
mpetovello | 0:3bffc1862262 | 53 | private: |
mpetovello | 0:3bffc1862262 | 54 | |
mpetovello | 0:3bffc1862262 | 55 | // Read the accelerometer data and store the values for later use. You can access the values by |
mpetovello | 0:3bffc1862262 | 56 | // calling the GetAccelX(), GetAccelY() and/or GetAccelZ(); |
mpetovello | 0:3bffc1862262 | 57 | // |
mpetovello | 0:3bffc1862262 | 58 | // Arguments: |
mpetovello | 0:3bffc1862262 | 59 | // None |
mpetovello | 0:3bffc1862262 | 60 | // |
mpetovello | 0:3bffc1862262 | 61 | // Returns: |
mpetovello | 0:3bffc1862262 | 62 | // Nothing |
mpetovello | 0:3bffc1862262 | 63 | // |
mpetovello | 0:3bffc1862262 | 64 | // Remarks: |
mpetovello | 0:3bffc1862262 | 65 | // The data will be stored in the 'MeasuredAccel' member variable in units of m/s/s |
mpetovello | 0:3bffc1862262 | 66 | virtual void ReadAccelerometers() = 0; |
mpetovello | 0:3bffc1862262 | 67 | |
mpetovello | 0:3bffc1862262 | 68 | |
mpetovello | 0:3bffc1862262 | 69 | // Get the most recently measured X-axis acceleration as stored during the last call to |
mpetovello | 0:3bffc1862262 | 70 | // ReadAccelerometer() |
mpetovello | 0:3bffc1862262 | 71 | // |
mpetovello | 0:3bffc1862262 | 72 | // Arguments: |
mpetovello | 0:3bffc1862262 | 73 | // None |
mpetovello | 0:3bffc1862262 | 74 | // |
mpetovello | 0:3bffc1862262 | 75 | // Returns: |
mpetovello | 0:3bffc1862262 | 76 | // The function returns the most recently measured X-axis acceleration in units of m/s/s |
mpetovello | 0:3bffc1862262 | 77 | virtual float GetAccelX() const = 0; |
mpetovello | 0:3bffc1862262 | 78 | |
mpetovello | 0:3bffc1862262 | 79 | |
mpetovello | 0:3bffc1862262 | 80 | // Get the most recently measured Y-axis acceleration as stored during the last call to |
mpetovello | 0:3bffc1862262 | 81 | // ReadAccelerometer() |
mpetovello | 0:3bffc1862262 | 82 | // |
mpetovello | 0:3bffc1862262 | 83 | // Arguments: |
mpetovello | 0:3bffc1862262 | 84 | // None |
mpetovello | 0:3bffc1862262 | 85 | // |
mpetovello | 0:3bffc1862262 | 86 | // Returns: |
mpetovello | 0:3bffc1862262 | 87 | // The function returns the most recently measured Y-axis acceleration in units of m/s/s |
mpetovello | 0:3bffc1862262 | 88 | virtual float GetAccelY() const = 0; |
mpetovello | 0:3bffc1862262 | 89 | |
mpetovello | 0:3bffc1862262 | 90 | |
mpetovello | 0:3bffc1862262 | 91 | // Get the most recently measured Z-axis acceleration as stored during the last call to |
mpetovello | 0:3bffc1862262 | 92 | // ReadAccelerometer() |
mpetovello | 0:3bffc1862262 | 93 | // |
mpetovello | 0:3bffc1862262 | 94 | // Arguments: |
mpetovello | 0:3bffc1862262 | 95 | // None |
mpetovello | 0:3bffc1862262 | 96 | // |
mpetovello | 0:3bffc1862262 | 97 | // Returns: |
mpetovello | 0:3bffc1862262 | 98 | // The function returns the most recently measured Z-axis acceleration in units of m/s/s |
mpetovello | 0:3bffc1862262 | 99 | virtual float GetAccelZ() const = 0; |
mpetovello | 0:3bffc1862262 | 100 | |
mpetovello | 0:3bffc1862262 | 101 | |
mpetovello | 0:3bffc1862262 | 102 | private: |
mpetovello | 0:3bffc1862262 | 103 | |
mpetovello | 0:3bffc1862262 | 104 | // Variables to store the roll and pitch values in units of degrees |
mpetovello | 0:3bffc1862262 | 105 | float RollAngle, PitchAngle; |
mpetovello | 0:3bffc1862262 | 106 | |
mpetovello | 0:3bffc1862262 | 107 | |
mpetovello | 0:3bffc1862262 | 108 | }; |
mpetovello | 0:3bffc1862262 | 109 | |
mpetovello | 0:3bffc1862262 | 110 | #endif |
mpetovello | 0:3bffc1862262 | 111 |