Saya Matsuura
/
drum
明石高専ロボ研 drum
gy521.hpp@0:ca84ed7518f5, 2020-01-02 (annotated)
- Committer:
- TanakaRobo
- Date:
- Thu Jan 02 09:30:06 2020 +0000
- Revision:
- 0:ca84ed7518f5
- Child:
- 3:28c77df7c0b6
buffered serial before test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
TanakaRobo | 0:ca84ed7518f5 | 1 | #ifndef GY521_H |
TanakaRobo | 0:ca84ed7518f5 | 2 | #define GY521_H |
TanakaRobo | 0:ca84ed7518f5 | 3 | #include "mbed.h" |
TanakaRobo | 0:ca84ed7518f5 | 4 | |
TanakaRobo | 0:ca84ed7518f5 | 5 | /*GY521を使う。 |
TanakaRobo | 0:ca84ed7518f5 | 6 | *I2Cオブジェクトを渡す |
TanakaRobo | 0:ca84ed7518f5 | 7 | *GY521(I2C &i2c,int bit = 2,int calibration = 1000,double user_reg = 1.0); |
TanakaRobo | 0:ca84ed7518f5 | 8 | *example |
TanakaRobo | 0:ca84ed7518f5 | 9 | *L432KC : SDA = PB_7 , SCL = PB_6 |
TanakaRobo | 0:ca84ed7518f5 | 10 | *F446RE : SDA = PB_3 , SCL = PB_10 |
TanakaRobo | 0:ca84ed7518f5 | 11 | */ |
TanakaRobo | 0:ca84ed7518f5 | 12 | //I2C i2c(SDA,SCL); |
TanakaRobo | 0:ca84ed7518f5 | 13 | //GY521 gyro(i2c); |
TanakaRobo | 0:ca84ed7518f5 | 14 | |
TanakaRobo | 0:ca84ed7518f5 | 15 | class GY521{ |
TanakaRobo | 0:ca84ed7518f5 | 16 | public: |
TanakaRobo | 0:ca84ed7518f5 | 17 | GY521(I2C &i2c,int bit = 2,int calibration = 1000,double user_reg = 1.0); |
TanakaRobo | 0:ca84ed7518f5 | 18 | double yaw; |
TanakaRobo | 0:ca84ed7518f5 | 19 | //double temp; |
TanakaRobo | 0:ca84ed7518f5 | 20 | void updata(); |
TanakaRobo | 0:ca84ed7518f5 | 21 | void reset(int user); |
TanakaRobo | 0:ca84ed7518f5 | 22 | void start(double start = 0){ |
TanakaRobo | 0:ca84ed7518f5 | 23 | yaw = start; |
TanakaRobo | 0:ca84ed7518f5 | 24 | } |
TanakaRobo | 0:ca84ed7518f5 | 25 | double checkStatus(int mode); |
TanakaRobo | 0:ca84ed7518f5 | 26 | private: |
TanakaRobo | 0:ca84ed7518f5 | 27 | I2C &i2c_; |
TanakaRobo | 0:ca84ed7518f5 | 28 | Timer timer_; |
TanakaRobo | 0:ca84ed7518f5 | 29 | int16_t gyroRead2(enum GY521RegisterMap reg); |
TanakaRobo | 0:ca84ed7518f5 | 30 | double gyro_z_aver_; |
TanakaRobo | 0:ca84ed7518f5 | 31 | double gyro_z_now_; |
TanakaRobo | 0:ca84ed7518f5 | 32 | double gyro_z_prev_; |
TanakaRobo | 0:ca84ed7518f5 | 33 | double gyro_LSB_; |
TanakaRobo | 0:ca84ed7518f5 | 34 | double diff_yaw_; |
TanakaRobo | 0:ca84ed7518f5 | 35 | int bit_; |
TanakaRobo | 0:ca84ed7518f5 | 36 | int calibration_; |
TanakaRobo | 0:ca84ed7518f5 | 37 | bool flag_; |
TanakaRobo | 0:ca84ed7518f5 | 38 | }; |
TanakaRobo | 0:ca84ed7518f5 | 39 | |
TanakaRobo | 0:ca84ed7518f5 | 40 | #endif /* GY521_H */ |