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.
Dependents: measure_1_BBB measure_1_CCC measure_1_DDD
Revision 2:8622f361c1a4, committed 2021-05-14
- Comitter:
- sato_shi
- Date:
- Fri May 14 00:48:09 2021 +0000
- Parent:
- 1:c9dc906f8b9f
- Commit message:
- CCC
Changed in this revision
| MPU6050.cpp | Show annotated file Show diff for this revision Revisions of this file |
| MPU6050.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MPU6050.cpp Thu May 13 05:11:28 2021 +0000
+++ b/MPU6050.cpp Fri May 14 00:48:09 2021 +0000
@@ -72,6 +72,17 @@
}
return false;
}
+bool MPU6050::readraw2(int16_t *ax, int16_t *ay, int16_t *az)
+{
+ char data2[6];
+ if (read_data(ADDRESS, MPU6050_ACCEL_XOUT_H, data2, 6)) {
+ *ax = short(data2[0] << 8 | data2[1]);
+ *ay = short(data2[2] << 8 | data2[3]);
+ *az = short(data2[4] << 8 | data2[5]);
+ return true;
+ }
+ return false;
+}
bool MPU6050::write_reg(int addr_i2c,int addr_reg, char v)
{
char data[2] = {addr_reg, v};
--- a/MPU6050.h Thu May 13 05:11:28 2021 +0000
+++ b/MPU6050.h Fri May 14 00:48:09 2021 +0000
@@ -184,14 +184,16 @@
*/
bool readraw(int *gx, int *gy, int *gz,int *ax, int *ay, int *az);
bool readraw2(int *ax, int *ay, int *az);
-
+ bool readraw2(int16_t *ax, int16_t *ay, int16_t *az);
+ bool read_data(char sad, char sub, char *buf, int length);
+ int ADDRESS;
private:
I2C _MPU6050;
float gx, gy, gz,ax,ay,az;
- int ADDRESS;
+ //int ADDRESS;
bool write_reg(int addr_i2c,int addr_reg, char v);
bool read_reg(int addr_i2c,int addr_reg, char *v);
- bool read_data(char sad, char sub, char *buf, int length);
+ //bool read_data(char sad, char sub, char *buf, int length);
};
#endif