ジャイロ

Dependents:   00_yotsuba 103_JY901_practice 200_yotsuba_21 200_yotuba_21_uiChange

Revision:
8:a5ce2d3c49ac
Parent:
7:9fa716a2100a
--- a/jy901.cpp	Thu Mar 04 11:57:19 2021 +0000
+++ b/jy901.cpp	Fri Mar 05 05:03:19 2021 +0000
@@ -28,21 +28,32 @@
     write(IICADDR,calibrationRegistar,3,false);
 }
 
-void JY901::calibrateAll(int time)
+void JY901::yawcalibrate()
+{
+    char calibrationRegistar[3]= {CALSW,0x04,0x00};
+    write(IICADDR,calibrationRegistar,3,false);
+}
+
+void JY901::algorithmtrasition()
+{
+    char calibrationRegistar[3]= {0x24,0x01,0x00};
+    write(IICADDR,calibrationRegistar,3,false);
+}
+
+void JY901::calibrateAll(int time_ms)
 {
     calibrateGyroAccel();
-    thread_sleep_for(time);
+    thread_sleep_for(time_ms);
     calibrateMagnetic();
-    thread_sleep_for(time);
+    thread_sleep_for(time_ms);
     calibrateHeight();
-    thread_sleep_for(time);
+    thread_sleep_for(time_ms);
     endCalibrate();
-}
-
-void JY901::jyroReset()
-{
-    char calibrationRegistar[3]= {0x01,0x04,0x00};
-    write(IICADDR,calibrationRegistar,3,false);
+    thread_sleep_for(time_ms);
+    algorithmtrasition();
+    thread_sleep_for(time_ms);
+    yawcalibrate();
+    
 }
 
 float JY901::getXaxisAcceleration()
@@ -117,8 +128,6 @@
     return (float)((*(data+1) << 8) | *data) / 32768 * 180;
 }
 
-
-
 char *JY901::getdata(char registar)
 {
     char data[2] = {};