これは MMA7361 3軸アナログ加速度センサ の Nucleo F401RE 用のライブラリです。詳しい説明はLibrary中のReadMe.hに記載しています。文字化けや開けない場合はダウンロードしてみてください。Google Chrome では見れるはずです。
Dependents: Nucleo_L3GD20_MMA7361_Kalman
mma7361.h
- Committer:
- hirokimineshita
- Date:
- 2016-09-30
- Revision:
- 5:83a3021f51f8
- Parent:
- 4:c3d863eb7f91
- Child:
- 6:ca882e5e2686
File content as of revision 5:83a3021f51f8:
#ifndef _MMA7361_H_20150129_1716_ #define _MMA7361_H_20150129_1716_ #define def -1 #define x_axis 0 #define y_axis 1 #define z_axis 2 #define A00 31356 #define A10 34040 #define A20 28639 #define A01 32717 #define A11 33388 #define A21 31475 #define G00 15633 #define G10 15797 #define G20 15187 #define G01 5416 #define G11 3220 #define G21 7131 #define PI 3.1415926535 #define THHO 0.0000000001 /** This progrum is to be easy to control MMA7361 analog sensor\n * site http://akizukidenshi.com/catalog/g/gM-06725/ */ class mma7361{ private: AnalogIn dx; AnalogIn dy; AnalogIn dz; DigitalOut ST; DigitalOut GS; Serial pcdev; int range; //0 : 1.5G 1 : 6.0G /** matrix * * the matrix which use to calcurate the gravity */ int mat[4][3]; public: /** constracta * * set all pin number * @param accelx analog pin which conect to x-axis (default = PA_0) * @param accely analog pin which conect to y-axis (default = PA_1) * @param accelz analog pin which conect to z-axis (default = PA_4) * @param set digital pin which conect to ST (default = PH_0) * @param set_range digital pin which conect to GS (default = PH_1) */ mma7361(PinName accelx = PA_0,PinName accely = PA_1,PinName accelz = PA_4,PinName set = PH_0,PinName set_range = PH_1); /** function * * do the calibration, you need to conect terminal (ex.TeraTerm) by USB\n * the serial port is set in this class, but it's private\n * please follow the sentence on the terminal\n * this function set the matrix\n * if you don't want to do this or know the data, you can use set_each_num() or set_num() to set matrix */ void calibration(); /** function * * */ 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); void set_num(int (*new_mat)[3],int new_range); void set_range(int new_range); void clear_mat(); int read_bit(int axis); int read_bit_0(int axis); float read_by_g(int axis); void low_pass_filter(int *int_bit,int axis); void show_mat(); float bit_to_g(int bit,int axis); void set_1st_bit(int *variable,int axis,float direction_G); float rotate(int *a_value,int a_axis,int *b_value,int b_axis); float rad_to_deg(float rad); }; #endif