![](/media/cache/profiles/P1030212_resized.JPG.50x50_q85.jpg)
明石高専ロボ研 mbedライブラリ
Dependents: MDD_L432KC USB2RS485 pathtracking odometry ... more
gy521.hpp
- Committer:
- TanakaRobo
- Date:
- 2020-01-02
- Revision:
- 0:ca84ed7518f5
- Child:
- 3:28c77df7c0b6
File content as of revision 0:ca84ed7518f5:
#ifndef GY521_H #define GY521_H #include "mbed.h" /*GY521を使う。 *I2Cオブジェクトを渡す *GY521(I2C &i2c,int bit = 2,int calibration = 1000,double user_reg = 1.0); *example *L432KC : SDA = PB_7 , SCL = PB_6 *F446RE : SDA = PB_3 , SCL = PB_10 */ //I2C i2c(SDA,SCL); //GY521 gyro(i2c); class GY521{ public: GY521(I2C &i2c,int bit = 2,int calibration = 1000,double user_reg = 1.0); double yaw; //double temp; void updata(); void reset(int user); void start(double start = 0){ yaw = start; } double checkStatus(int mode); private: I2C &i2c_; Timer timer_; int16_t gyroRead2(enum GY521RegisterMap reg); double gyro_z_aver_; double gyro_z_now_; double gyro_z_prev_; double gyro_LSB_; double diff_yaw_; int bit_; int calibration_; bool flag_; }; #endif /* GY521_H */