nucleo-l432kcのテンプレートです。

Dependencies:   mbed ros_lib_kinetic

Revision:
2:a84e3730c6cb
Parent:
1:17051435cfc5
Child:
4:47f17b5ac6e7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/library/gy521.hpp	Tue Jul 09 08:08:55 2019 +0000
@@ -0,0 +1,40 @@
+#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 */
\ No newline at end of file