
df
Fork of APP1 by
Diff: Accelerometer.hpp
- Revision:
- 5:f59b51ac4b40
- Parent:
- 4:303fb83498fd
- Child:
- 6:3facf0329142
--- a/Accelerometer.hpp Sat Jan 14 23:32:29 2017 +0000 +++ b/Accelerometer.hpp Sun Jan 15 01:34:25 2017 +0000 @@ -16,6 +16,8 @@ const int I2C_ACCELEROMETER_ADDRESS = 0x1D; +const double PI = 3.14159265; + enum Axis { AXIS_X, @@ -28,6 +30,11 @@ void test_raw_axis_data_to_int(); char get_axis_register(Axis axis); bool is_almost_equal(double a, double b, double tolerance); +//Return angle between 0 and 360 degree +double wrap_angle(double angle); +double g_force_from_int_axis_data(const int axis_data); +double degree_from_radian(const double angle_radian); +double angle_from_int_axis_data(const int axis_data); class Accelerometer { @@ -51,6 +58,8 @@ //Read data from the 8 most significant bits (MSB) of a given axis int read_axis_data_8_bits(Axis axis); + + double get_angle_from_horizontal(); private: I2C device;