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.
Dependencies: MPU6050 Grove_temperature
Gyroscope.cpp
00001 #include "sgam_mdw.h" 00002 #include "mbed.h" 00003 00004 #include "MPU6050.h" 00005 #include "Gyroscope.h" 00006 00007 Gyroscope::Gyroscope(I2C &i2c): mpu(i2c, MPU6050_ADDRESS_AD0_LOW) { 00008 mpu.initialize(); 00009 00010 if( mpu.testConnection() ) { 00011 D_LOG("Giroscope Initialized !!\r\n"); 00012 } else { 00013 D_LOG("There's an error trying initialize the Gyroscope !!\r\n"); 00014 } 00015 00016 value = new GyroscopeData(); 00017 } 00018 00019 Gyroscope::~Gyroscope() { 00020 value->~GyroscopeData(); 00021 } 00022 00023 int Gyroscope::initialize() { D_LOG("INITIALIZE %s! \r\n", this->getName() ); return 1; } 00024 int Gyroscope::finalize() { D_LOG("FINALIZE %s! \r\n", this->getName() ); return 1; } 00025 00026 void Gyroscope::getMotion(GyroscopeData* data) { 00027 mpu.getMotion6( 00028 &data->ax, &data->ay, &data->az, 00029 &data->gx, &data->gy, &data->gz 00030 ); 00031 } 00032 00033 GyroscopeData* Gyroscope::getValue() { 00034 getMotion(value); 00035 return value; 00036 } 00037 00038 const char* Gyroscope::getName() { 00039 return "Gyroscope"; 00040 }
Generated on Fri Jul 15 2022 01:20:41 by
1.7.2