これは MMA7361 3軸アナログ加速度センサ の Nucleo F401RE 用のライブラリです。詳しい説明はLibrary中のReadMe.hに記載しています。文字化けや開けない場合はダウンロードしてみてください。Google Chrome では見れるはずです。
Dependents: Nucleo_L3GD20_MMA7361_Kalman
mma7361.h@4:c3d863eb7f91, 2016-09-28 (annotated)
- Committer:
- hirokimineshita
- Date:
- Wed Sep 28 11:12:01 2016 +0000
- Revision:
- 4:c3d863eb7f91
- Parent:
- 3:0359af763b6c
- Child:
- 5:83a3021f51f8
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hirokimineshita | 0:ad6f3a862ed5 | 1 | #ifndef _MMA7361_H_20150129_1716_ |
hirokimineshita | 0:ad6f3a862ed5 | 2 | #define _MMA7361_H_20150129_1716_ |
hirokimineshita | 0:ad6f3a862ed5 | 3 | |
hirokimineshita | 0:ad6f3a862ed5 | 4 | #define def -1 |
hirokimineshita | 0:ad6f3a862ed5 | 5 | #define x_axis 0 |
hirokimineshita | 0:ad6f3a862ed5 | 6 | #define y_axis 1 |
hirokimineshita | 0:ad6f3a862ed5 | 7 | #define z_axis 2 |
hirokimineshita | 0:ad6f3a862ed5 | 8 | #define A00 31356 |
hirokimineshita | 0:ad6f3a862ed5 | 9 | #define A10 34040 |
hirokimineshita | 0:ad6f3a862ed5 | 10 | #define A20 28639 |
hirokimineshita | 0:ad6f3a862ed5 | 11 | #define A01 32717 |
hirokimineshita | 0:ad6f3a862ed5 | 12 | #define A11 33388 |
hirokimineshita | 0:ad6f3a862ed5 | 13 | #define A21 31475 |
hirokimineshita | 0:ad6f3a862ed5 | 14 | #define G00 15633 |
hirokimineshita | 0:ad6f3a862ed5 | 15 | #define G10 15797 |
hirokimineshita | 0:ad6f3a862ed5 | 16 | #define G20 15187 |
hirokimineshita | 0:ad6f3a862ed5 | 17 | #define G01 5416 |
hirokimineshita | 0:ad6f3a862ed5 | 18 | #define G11 3220 |
hirokimineshita | 0:ad6f3a862ed5 | 19 | #define G21 7131 |
hirokimineshita | 0:ad6f3a862ed5 | 20 | #define PI 3.1415926535 |
hirokimineshita | 4:c3d863eb7f91 | 21 | #define THHO 0.0000000001 |
hirokimineshita | 0:ad6f3a862ed5 | 22 | |
hirokimineshita | 0:ad6f3a862ed5 | 23 | class mma7361{ |
hirokimineshita | 0:ad6f3a862ed5 | 24 | private: |
hirokimineshita | 0:ad6f3a862ed5 | 25 | AnalogIn dx; |
hirokimineshita | 0:ad6f3a862ed5 | 26 | AnalogIn dy; |
hirokimineshita | 0:ad6f3a862ed5 | 27 | AnalogIn dz; |
hirokimineshita | 0:ad6f3a862ed5 | 28 | DigitalOut ST; |
hirokimineshita | 0:ad6f3a862ed5 | 29 | DigitalOut GS; |
hirokimineshita | 0:ad6f3a862ed5 | 30 | Serial pcdev; |
hirokimineshita | 0:ad6f3a862ed5 | 31 | int range; //0 : 1.5G 1 : 6.0G |
hirokimineshita | 0:ad6f3a862ed5 | 32 | int mat[4][3]; |
hirokimineshita | 0:ad6f3a862ed5 | 33 | public: |
hirokimineshita | 0:ad6f3a862ed5 | 34 | mma7361(); |
hirokimineshita | 0:ad6f3a862ed5 | 35 | mma7361(PinName accelx,PinName accely,PinName accelz); |
hirokimineshita | 0:ad6f3a862ed5 | 36 | mma7361(PinName accelx,PinName accely,PinName accelz,PinName set); |
hirokimineshita | 0:ad6f3a862ed5 | 37 | mma7361(PinName accelx,PinName accely,PinName accelz,PinName set,PinName set_range); |
hirokimineshita | 0:ad6f3a862ed5 | 38 | void calibration(); |
hirokimineshita | 0:ad6f3a862ed5 | 39 | void set_each_num(int ax_0_0,int ay_0_0,int az_0_0,int ax_1_0,int ay_1_0,int az_1_0,int gx_0_0,int gy_0_0,int gz_0_0,int gx_1_0,int gy_1_0,int gz_1_0,int new_range); |
hirokimineshita | 3:0359af763b6c | 40 | void set_num(int (*new_mat)[3],int new_range); |
hirokimineshita | 0:ad6f3a862ed5 | 41 | void set_range(int new_range); |
hirokimineshita | 0:ad6f3a862ed5 | 42 | void clear_mat(); |
hirokimineshita | 0:ad6f3a862ed5 | 43 | int read_bit(int axis); |
hirokimineshita | 0:ad6f3a862ed5 | 44 | int read_bit_0(int axis); |
hirokimineshita | 0:ad6f3a862ed5 | 45 | float read_by_g(int axis); |
hirokimineshita | 0:ad6f3a862ed5 | 46 | void low_pass_filter(int *int_bit,int axis); |
hirokimineshita | 0:ad6f3a862ed5 | 47 | void show_mat(); |
hirokimineshita | 0:ad6f3a862ed5 | 48 | float bit_to_g(int bit,int axis); |
hirokimineshita | 0:ad6f3a862ed5 | 49 | void set_1st_bit(int *variable,int axis,float direction_G); |
hirokimineshita | 0:ad6f3a862ed5 | 50 | |
hirokimineshita | 0:ad6f3a862ed5 | 51 | float rotate(int *a_value,int a_axis,int *b_value,int b_axis); |
hirokimineshita | 0:ad6f3a862ed5 | 52 | float rad_to_deg(float rad); |
hirokimineshita | 0:ad6f3a862ed5 | 53 | }; |
hirokimineshita | 0:ad6f3a862ed5 | 54 | |
hirokimineshita | 0:ad6f3a862ed5 | 55 | #endif |