![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
明石高専ロボ研 mbedライブラリ
Dependencies: mbed
gy521.hpp@3:28c77df7c0b6, 2020-01-06 (annotated)
- Committer:
- TanakaRobo
- Date:
- Mon Jan 06 11:06:26 2020 +0000
- Revision:
- 3:28c77df7c0b6
- Parent:
- 0:ca84ed7518f5
- Child:
- 4:39ef4d91dc34
send not available
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 | 3:28c77df7c0b6 | 11 | *ループ内で毎回 |
TanakaRobo | 3:28c77df7c0b6 | 12 | *<obj>.update() |
TanakaRobo | 3:28c77df7c0b6 | 13 | *を呼び出してください。 |
TanakaRobo | 0:ca84ed7518f5 | 14 | */ |
TanakaRobo | 0:ca84ed7518f5 | 15 | //I2C i2c(SDA,SCL); |
TanakaRobo | 0:ca84ed7518f5 | 16 | //GY521 gyro(i2c); |
TanakaRobo | 0:ca84ed7518f5 | 17 | |
TanakaRobo | 0:ca84ed7518f5 | 18 | class GY521{ |
TanakaRobo | 0:ca84ed7518f5 | 19 | public: |
TanakaRobo | 0:ca84ed7518f5 | 20 | GY521(I2C &i2c,int bit = 2,int calibration = 1000,double user_reg = 1.0); |
TanakaRobo | 0:ca84ed7518f5 | 21 | double yaw; |
TanakaRobo | 0:ca84ed7518f5 | 22 | //double temp; |
TanakaRobo | 3:28c77df7c0b6 | 23 | void update(); |
TanakaRobo | 0:ca84ed7518f5 | 24 | void reset(int user); |
TanakaRobo | 0:ca84ed7518f5 | 25 | void start(double start = 0){ |
TanakaRobo | 0:ca84ed7518f5 | 26 | yaw = start; |
TanakaRobo | 0:ca84ed7518f5 | 27 | } |
TanakaRobo | 0:ca84ed7518f5 | 28 | double checkStatus(int mode); |
TanakaRobo | 0:ca84ed7518f5 | 29 | private: |
TanakaRobo | 0:ca84ed7518f5 | 30 | I2C &i2c_; |
TanakaRobo | 0:ca84ed7518f5 | 31 | Timer timer_; |
TanakaRobo | 0:ca84ed7518f5 | 32 | int16_t gyroRead2(enum GY521RegisterMap reg); |
TanakaRobo | 0:ca84ed7518f5 | 33 | double gyro_z_aver_; |
TanakaRobo | 0:ca84ed7518f5 | 34 | double gyro_z_now_; |
TanakaRobo | 0:ca84ed7518f5 | 35 | double gyro_z_prev_; |
TanakaRobo | 0:ca84ed7518f5 | 36 | double gyro_LSB_; |
TanakaRobo | 0:ca84ed7518f5 | 37 | double diff_yaw_; |
TanakaRobo | 0:ca84ed7518f5 | 38 | int bit_; |
TanakaRobo | 0:ca84ed7518f5 | 39 | int calibration_; |
TanakaRobo | 0:ca84ed7518f5 | 40 | bool flag_; |
TanakaRobo | 0:ca84ed7518f5 | 41 | }; |
TanakaRobo | 0:ca84ed7518f5 | 42 | |
TanakaRobo | 0:ca84ed7518f5 | 43 | #endif /* GY521_H */ |