implementação do sgam_mdw baseado na placa NUCLEO FZ429ZI para ser testada
Dependencies: MPU6050 Grove_temperature
Diff: sensor/gyroscope/Gyroscope.cpp
- Revision:
- 3:f67352c85fd7
- Child:
- 5:fa36c3288be8
diff -r 144ca70fa39a -r f67352c85fd7 sensor/gyroscope/Gyroscope.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sensor/gyroscope/Gyroscope.cpp Thu Jun 20 12:29:07 2019 -0300 @@ -0,0 +1,36 @@ +#include "sgam_mdw.h" +#include "mbed.h" +#include "MPU6050.h" +#include "Gyroscope.h" + +Gyroscope::Gyroscope(I2C &i2c): mpu(i2c, MPU6050_ADDRESS_AD0_LOW) { + mpu.initialize(); + + if( mpu.testConnection() ) { + LOG("Giroscope Initialized !!\r\n"); + } else { + LOG("There's an error trying initialize the Gyroscope !!\r\n"); + } + + value = new GyroscopeData(); +} + +Gyroscope::~Gyroscope() { + value->~GyroscopeData(); +} + +void Gyroscope::getMotion(GyroscopeData* data) { + mpu.getMotion6( + &data->ax, &data->ay, &data->az, + &data->gx, &data->gy, &data->gz + ); +} + +GyroscopeData* Gyroscope::getValue() { + getMotion(value); + return value; +} + +char* Gyroscope::getName() { + return (char*)"Gyroscope"; +}