Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: JY901.h
- Revision:
- 4:cd62e2d69f62
- Parent:
- 3:b0aecd9a3cc9
- Child:
- 5:a492cfb18242
--- a/JY901.h Sat Apr 28 03:58:17 2018 +0000 +++ b/JY901.h Thu Aug 23 05:33:30 2018 +0000 @@ -7,15 +7,16 @@ #include "mbed.h" #include "JY901.h" -JY901 i2c(dp5, dp27); +I2C myi2c(p28, p27); +JY901 jy901(&myi2c); int main() { float angle = 0; - i2c.calibrateAll(5000); + jy901.calibrateAll(5000); while(1) { - angle = i2c.getZaxisAngle(); + angle = jy901.getZaxisAngle(); printf("%f\r\n", angle); } } @@ -91,10 +92,10 @@ #define Q2 0x53 // Quaternion Q2 #define Q3 0x54 // Quaternion Q3 -class JY901 : public I2C +class JY901 { public: - JY901(PinName sda, PinName scl); + JY901(I2C *i2c); void calibrateGyroAccel(); void calibrateMagnetic(); @@ -138,6 +139,8 @@ private: char *getdata(char registar); + + I2C *_i2c; }; #endif \ No newline at end of file