nucleo-l432kcのテンプレートです。
Dependencies: mbed ros_lib_kinetic
Diff: library/GY521.hpp
- Revision:
- 1:17051435cfc5
- Parent:
- 0:a8a56075e947
diff -r a8a56075e947 -r 17051435cfc5 library/GY521.hpp --- a/library/GY521.hpp Sat May 18 12:09:43 2019 +0000 +++ b/library/GY521.hpp Tue Jul 09 07:56:07 2019 +0000 @@ -1,27 +1,21 @@ -#pragma once +#ifndef GY521_H +#define GY521_H #include "mbed.h" -const double GY521_LSB_MAP[4] = {131, 65.5, 32.8, 16.4}; -enum GY521RegisterMap { - WHO_AM_I = 0x75, - PWR_MGMT_1 = 0x6B, - LPF = 0x1A, - FS_SEL = 0x1B, - AFS_SEL = 0x1C, - ACCEL_XOUT_H = 0x3B, - ACCEL_YOUT_H = 0x3D, - ACCEL_ZOUT_H = 0x3F, - //TEMPERATURE = 0x41, - //GYRO_XOUT_H = 0x43, - //GYRO_YOUT_H = 0x45, - GYRO_ZOUT_H = 0x47 -}; +/*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 diffyaw; //double temp; void updata(); void reset(int user); @@ -30,15 +24,17 @@ } double checkStatus(int mode); private: - I2C &i2c; - Timer time; - unsigned int dev_id; + 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 gyro_z_aver_; + double gyro_z_now_; + double gyro_z_prev_; + double gyro_LSB_; + double diff_yaw_; int bit_; - int calibration; - bool flag; -}; \ No newline at end of file + int calibration_; + bool flag_; +}; + +#endif /* GY521_H */ \ No newline at end of file