implementação do sgam_mdw baseado na placa NUCLEO FZ429ZI para ser testada
Dependencies: MPU6050 Grove_temperature
sensor/gyroscope/Gyroscope.cpp@3:f67352c85fd7, 2019-06-20 (annotated)
- Committer:
- AndersonIctus
- Date:
- Thu Jun 20 12:29:07 2019 -0300
- Revision:
- 3:f67352c85fd7
- Child:
- 5:fa36c3288be8
- Inclusao dos sensores de gyroscopio
- Atualizacao dos sensores de temperatura
- Inclusao dos sensores como teste de retorno no ControlImpl
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AndersonIctus | 3:f67352c85fd7 | 1 | #include "sgam_mdw.h" |
AndersonIctus | 3:f67352c85fd7 | 2 | #include "mbed.h" |
AndersonIctus | 3:f67352c85fd7 | 3 | #include "MPU6050.h" |
AndersonIctus | 3:f67352c85fd7 | 4 | #include "Gyroscope.h" |
AndersonIctus | 3:f67352c85fd7 | 5 | |
AndersonIctus | 3:f67352c85fd7 | 6 | Gyroscope::Gyroscope(I2C &i2c): mpu(i2c, MPU6050_ADDRESS_AD0_LOW) { |
AndersonIctus | 3:f67352c85fd7 | 7 | mpu.initialize(); |
AndersonIctus | 3:f67352c85fd7 | 8 | |
AndersonIctus | 3:f67352c85fd7 | 9 | if( mpu.testConnection() ) { |
AndersonIctus | 3:f67352c85fd7 | 10 | LOG("Giroscope Initialized !!\r\n"); |
AndersonIctus | 3:f67352c85fd7 | 11 | } else { |
AndersonIctus | 3:f67352c85fd7 | 12 | LOG("There's an error trying initialize the Gyroscope !!\r\n"); |
AndersonIctus | 3:f67352c85fd7 | 13 | } |
AndersonIctus | 3:f67352c85fd7 | 14 | |
AndersonIctus | 3:f67352c85fd7 | 15 | value = new GyroscopeData(); |
AndersonIctus | 3:f67352c85fd7 | 16 | } |
AndersonIctus | 3:f67352c85fd7 | 17 | |
AndersonIctus | 3:f67352c85fd7 | 18 | Gyroscope::~Gyroscope() { |
AndersonIctus | 3:f67352c85fd7 | 19 | value->~GyroscopeData(); |
AndersonIctus | 3:f67352c85fd7 | 20 | } |
AndersonIctus | 3:f67352c85fd7 | 21 | |
AndersonIctus | 3:f67352c85fd7 | 22 | void Gyroscope::getMotion(GyroscopeData* data) { |
AndersonIctus | 3:f67352c85fd7 | 23 | mpu.getMotion6( |
AndersonIctus | 3:f67352c85fd7 | 24 | &data->ax, &data->ay, &data->az, |
AndersonIctus | 3:f67352c85fd7 | 25 | &data->gx, &data->gy, &data->gz |
AndersonIctus | 3:f67352c85fd7 | 26 | ); |
AndersonIctus | 3:f67352c85fd7 | 27 | } |
AndersonIctus | 3:f67352c85fd7 | 28 | |
AndersonIctus | 3:f67352c85fd7 | 29 | GyroscopeData* Gyroscope::getValue() { |
AndersonIctus | 3:f67352c85fd7 | 30 | getMotion(value); |
AndersonIctus | 3:f67352c85fd7 | 31 | return value; |
AndersonIctus | 3:f67352c85fd7 | 32 | } |
AndersonIctus | 3:f67352c85fd7 | 33 | |
AndersonIctus | 3:f67352c85fd7 | 34 | char* Gyroscope::getName() { |
AndersonIctus | 3:f67352c85fd7 | 35 | return (char*)"Gyroscope"; |
AndersonIctus | 3:f67352c85fd7 | 36 | } |