ジャイロ
Dependents: 00_yotsuba 103_JY901_practice 200_yotsuba_21 200_yotuba_21_uiChange
Revision 8:a5ce2d3c49ac, committed 2021-03-05
- Comitter:
- piroro4560
- Date:
- Fri Mar 05 05:03:19 2021 +0000
- Parent:
- 7:9fa716a2100a
- Commit message:
- yawcalibrate and 6axis
Changed in this revision
jy901.cpp | Show annotated file Show diff for this revision Revisions of this file |
jy901.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9fa716a2100a -r a5ce2d3c49ac jy901.cpp --- 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] = {};
diff -r 9fa716a2100a -r a5ce2d3c49ac jy901.h --- a/jy901.h Thu Mar 04 11:57:19 2021 +0000 +++ b/jy901.h Fri Mar 05 05:03:19 2021 +0000 @@ -35,9 +35,15 @@ /** end calibration mode */ void endCalibrate(); + + /** calibrate yaw axis + */ + void yawcalibrate(); - void jyroReset(); - + /** change algorithm + */ + void algorithmtrasition(); + /** calibrate Gyroscope, Accelerometer and Magnetic * set height to 0 */