I2C通信を使用した角速度測定、LCD表示サンプル
Dependencies: mbed mbed_mpu6050_i2c_raw_register AQM0802
Diff: mpu6050.h
- Revision:
- 0:abd3a0fd55a9
- Child:
- 1:6f743fe9a027
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpu6050.h Wed Dec 12 12:42:30 2018 +0000 @@ -0,0 +1,33 @@ +#include "mbed.h" + +enum { + MAX_ACC_2G, + MAX_ACC_4G, + MAX_ACC_8G, + MAX_ACC_16G, +}; + +enum { + MAX_GYRO_250degpersec, + MAX_GYRO_500degpersec, + MAX_GYRO_1000degpersec, + MAX_GYRO_2000degpersec, +}; + +class MPU6050 +{ +public: + MPU6050(PinName i2c_sda, PinName i2c_scl); + ~MPU6050(); + void readAccelemeter(double &acc_x, double &acc_y, double &acc_z); + void readGyroscope(double &gyro_x, double &gyro_y, double &gyro_z); + void setMaxScale(int max_acc, int max_gyro); + void getMaxScale(int &acc, int &gyro); +private: + I2C i2c; + int address; + double rate_accelemeter; + double rate_gyroscope; + char readByte(char reg); + void writeByte(char reg, char data); +};