Header file and functions

Committer:
moklumbys
Date:
Thu Feb 19 00:15:52 2015 +0000
Revision:
9:898effccce30
Parent:
8:b1570b99df9e
Child:
10:bd9665d14241
additional fnctions - done.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sissors 0:6757f7363a9f 1 /**
Sissors 0:6757f7363a9f 2 * Includes
Sissors 0:6757f7363a9f 3 */
Sissors 0:6757f7363a9f 4 #include "MPU6050.h"
Sissors 0:6757f7363a9f 5
Sissors 0:6757f7363a9f 6 MPU6050::MPU6050(PinName sda, PinName scl) : connection(sda, scl) {
Sissors 0:6757f7363a9f 7 this->setSleepMode(false);
Sissors 0:6757f7363a9f 8
Sissors 0:6757f7363a9f 9 //Initializations:
Sissors 0:6757f7363a9f 10 currentGyroRange = 0;
Sissors 0:6757f7363a9f 11 currentAcceleroRange=0;
moklumbys 9:898effccce30 12 alpha = 0.97;
Sissors 0:6757f7363a9f 13 }
Sissors 0:6757f7363a9f 14
Sissors 0:6757f7363a9f 15 //--------------------------------------------------
Sissors 0:6757f7363a9f 16 //-------------------General------------------------
Sissors 0:6757f7363a9f 17 //--------------------------------------------------
Sissors 0:6757f7363a9f 18
Sissors 0:6757f7363a9f 19 void MPU6050::write(char address, char data) {
Sissors 0:6757f7363a9f 20 char temp[2];
Sissors 0:6757f7363a9f 21 temp[0]=address;
Sissors 0:6757f7363a9f 22 temp[1]=data;
Sissors 0:6757f7363a9f 23
Sissors 0:6757f7363a9f 24 connection.write(MPU6050_ADDRESS * 2,temp,2);
Sissors 0:6757f7363a9f 25 }
Sissors 0:6757f7363a9f 26
Sissors 0:6757f7363a9f 27 char MPU6050::read(char address) {
Sissors 0:6757f7363a9f 28 char retval;
Sissors 0:6757f7363a9f 29 connection.write(MPU6050_ADDRESS * 2, &address, 1, true);
Sissors 0:6757f7363a9f 30 connection.read(MPU6050_ADDRESS * 2, &retval, 1);
Sissors 0:6757f7363a9f 31 return retval;
Sissors 0:6757f7363a9f 32 }
Sissors 0:6757f7363a9f 33
Sissors 0:6757f7363a9f 34 void MPU6050::read(char address, char *data, int length) {
Sissors 0:6757f7363a9f 35 connection.write(MPU6050_ADDRESS * 2, &address, 1, true);
Sissors 0:6757f7363a9f 36 connection.read(MPU6050_ADDRESS * 2, data, length);
Sissors 0:6757f7363a9f 37 }
Sissors 0:6757f7363a9f 38
Sissors 0:6757f7363a9f 39 void MPU6050::setSleepMode(bool state) {
Sissors 0:6757f7363a9f 40 char temp;
Sissors 0:6757f7363a9f 41 temp = this->read(MPU6050_PWR_MGMT_1_REG);
Sissors 0:6757f7363a9f 42 if (state == true)
Sissors 0:6757f7363a9f 43 temp |= 1<<MPU6050_SLP_BIT;
Sissors 0:6757f7363a9f 44 if (state == false)
Sissors 0:6757f7363a9f 45 temp &= ~(1<<MPU6050_SLP_BIT);
Sissors 0:6757f7363a9f 46 this->write(MPU6050_PWR_MGMT_1_REG, temp);
Sissors 0:6757f7363a9f 47 }
Sissors 0:6757f7363a9f 48
Sissors 0:6757f7363a9f 49 bool MPU6050::testConnection( void ) {
Sissors 0:6757f7363a9f 50 char temp;
Sissors 0:6757f7363a9f 51 temp = this->read(MPU6050_WHO_AM_I_REG);
Sissors 0:6757f7363a9f 52 return (temp == (MPU6050_ADDRESS & 0xFE));
Sissors 0:6757f7363a9f 53 }
Sissors 0:6757f7363a9f 54
Sissors 0:6757f7363a9f 55 void MPU6050::setBW(char BW) {
Sissors 0:6757f7363a9f 56 char temp;
Sissors 0:6757f7363a9f 57 BW=BW & 0x07;
Sissors 0:6757f7363a9f 58 temp = this->read(MPU6050_CONFIG_REG);
Sissors 0:6757f7363a9f 59 temp &= 0xF8;
Sissors 0:6757f7363a9f 60 temp = temp + BW;
Sissors 0:6757f7363a9f 61 this->write(MPU6050_CONFIG_REG, temp);
Sissors 0:6757f7363a9f 62 }
Sissors 0:6757f7363a9f 63
Sissors 0:6757f7363a9f 64 void MPU6050::setI2CBypass(bool state) {
Sissors 0:6757f7363a9f 65 char temp;
Sissors 0:6757f7363a9f 66 temp = this->read(MPU6050_INT_PIN_CFG);
Sissors 0:6757f7363a9f 67 if (state == true)
Sissors 0:6757f7363a9f 68 temp |= 1<<MPU6050_BYPASS_BIT;
Sissors 0:6757f7363a9f 69 if (state == false)
Sissors 0:6757f7363a9f 70 temp &= ~(1<<MPU6050_BYPASS_BIT);
Sissors 0:6757f7363a9f 71 this->write(MPU6050_INT_PIN_CFG, temp);
Sissors 0:6757f7363a9f 72 }
Sissors 0:6757f7363a9f 73
Sissors 0:6757f7363a9f 74 //--------------------------------------------------
Sissors 0:6757f7363a9f 75 //----------------Accelerometer---------------------
Sissors 0:6757f7363a9f 76 //--------------------------------------------------
Sissors 0:6757f7363a9f 77
Sissors 0:6757f7363a9f 78 void MPU6050::setAcceleroRange( char range ) {
Sissors 0:6757f7363a9f 79 char temp;
Sissors 0:6757f7363a9f 80 range = range & 0x03;
Sissors 0:6757f7363a9f 81 currentAcceleroRange = range;
Sissors 0:6757f7363a9f 82
Sissors 0:6757f7363a9f 83 temp = this->read(MPU6050_ACCELERO_CONFIG_REG);
Sissors 0:6757f7363a9f 84 temp &= ~(3<<3);
Sissors 0:6757f7363a9f 85 temp = temp + (range<<3);
Sissors 0:6757f7363a9f 86 this->write(MPU6050_ACCELERO_CONFIG_REG, temp);
Sissors 0:6757f7363a9f 87 }
Sissors 0:6757f7363a9f 88
Sissors 0:6757f7363a9f 89 int MPU6050::getAcceleroRawX( void ) {
Sissors 0:6757f7363a9f 90 short retval;
Sissors 0:6757f7363a9f 91 char data[2];
Sissors 0:6757f7363a9f 92 this->read(MPU6050_ACCEL_XOUT_H_REG, data, 2);
Sissors 0:6757f7363a9f 93 retval = (data[0]<<8) + data[1];
Sissors 0:6757f7363a9f 94 return (int)retval;
Sissors 0:6757f7363a9f 95 }
Sissors 0:6757f7363a9f 96
Sissors 0:6757f7363a9f 97 int MPU6050::getAcceleroRawY( void ) {
Sissors 0:6757f7363a9f 98 short retval;
Sissors 0:6757f7363a9f 99 char data[2];
Sissors 0:6757f7363a9f 100 this->read(MPU6050_ACCEL_YOUT_H_REG, data, 2);
Sissors 0:6757f7363a9f 101 retval = (data[0]<<8) + data[1];
Sissors 0:6757f7363a9f 102 return (int)retval;
Sissors 0:6757f7363a9f 103 }
Sissors 0:6757f7363a9f 104
Sissors 0:6757f7363a9f 105 int MPU6050::getAcceleroRawZ( void ) {
Sissors 0:6757f7363a9f 106 short retval;
Sissors 0:6757f7363a9f 107 char data[2];
Sissors 0:6757f7363a9f 108 this->read(MPU6050_ACCEL_ZOUT_H_REG, data, 2);
Sissors 0:6757f7363a9f 109 retval = (data[0]<<8) + data[1];
Sissors 0:6757f7363a9f 110 return (int)retval;
Sissors 0:6757f7363a9f 111 }
Sissors 0:6757f7363a9f 112
Sissors 0:6757f7363a9f 113 void MPU6050::getAcceleroRaw( int *data ) {
Sissors 0:6757f7363a9f 114 char temp[6];
Sissors 0:6757f7363a9f 115 this->read(MPU6050_ACCEL_XOUT_H_REG, temp, 6);
Sissors 0:6757f7363a9f 116 data[0] = (int)(short)((temp[0]<<8) + temp[1]);
Sissors 0:6757f7363a9f 117 data[1] = (int)(short)((temp[2]<<8) + temp[3]);
Sissors 0:6757f7363a9f 118 data[2] = (int)(short)((temp[4]<<8) + temp[5]);
Sissors 0:6757f7363a9f 119 }
Sissors 0:6757f7363a9f 120
Sissors 0:6757f7363a9f 121 void MPU6050::getAccelero( float *data ) {
Sissors 0:6757f7363a9f 122 int temp[3];
Sissors 0:6757f7363a9f 123 this->getAcceleroRaw(temp);
Sissors 0:6757f7363a9f 124 if (currentAcceleroRange == MPU6050_ACCELERO_RANGE_2G) {
Sissors 0:6757f7363a9f 125 data[0]=(float)temp[0] / 16384.0 * 9.81;
Sissors 0:6757f7363a9f 126 data[1]=(float)temp[1] / 16384.0 * 9.81;
Sissors 0:6757f7363a9f 127 data[2]=(float)temp[2] / 16384.0 * 9.81;
Sissors 0:6757f7363a9f 128 }
Sissors 0:6757f7363a9f 129 if (currentAcceleroRange == MPU6050_ACCELERO_RANGE_4G){
Sissors 0:6757f7363a9f 130 data[0]=(float)temp[0] / 8192.0 * 9.81;
Sissors 0:6757f7363a9f 131 data[1]=(float)temp[1] / 8192.0 * 9.81;
Sissors 0:6757f7363a9f 132 data[2]=(float)temp[2] / 8192.0 * 9.81;
Sissors 0:6757f7363a9f 133 }
Sissors 0:6757f7363a9f 134 if (currentAcceleroRange == MPU6050_ACCELERO_RANGE_8G){
Sissors 0:6757f7363a9f 135 data[0]=(float)temp[0] / 4096.0 * 9.81;
Sissors 0:6757f7363a9f 136 data[1]=(float)temp[1] / 4096.0 * 9.81;
Sissors 0:6757f7363a9f 137 data[2]=(float)temp[2] / 4096.0 * 9.81;
Sissors 0:6757f7363a9f 138 }
Sissors 0:6757f7363a9f 139 if (currentAcceleroRange == MPU6050_ACCELERO_RANGE_16G){
Sissors 0:6757f7363a9f 140 data[0]=(float)temp[0] / 2048.0 * 9.81;
Sissors 0:6757f7363a9f 141 data[1]=(float)temp[1] / 2048.0 * 9.81;
Sissors 0:6757f7363a9f 142 data[2]=(float)temp[2] / 2048.0 * 9.81;
Sissors 0:6757f7363a9f 143 }
Sissors 0:6757f7363a9f 144
Sissors 0:6757f7363a9f 145 #ifdef DOUBLE_ACCELERO
Sissors 0:6757f7363a9f 146 data[0]*=2;
Sissors 0:6757f7363a9f 147 data[1]*=2;
Sissors 0:6757f7363a9f 148 data[2]*=2;
Sissors 0:6757f7363a9f 149 #endif
Sissors 0:6757f7363a9f 150 }
Sissors 0:6757f7363a9f 151
moklumbys 4:268d3fcb92ba 152 //function for getting angles from accelerometer
moklumbys 4:268d3fcb92ba 153 void MPU6050::getAcceleroAngle( float *data ) {
moklumbys 6:502448484f91 154 float temp[3];
moklumbys 4:268d3fcb92ba 155 this->getAccelero(temp);
moklumbys 4:268d3fcb92ba 156
moklumbys 9:898effccce30 157 data[X_AXIS] = atan (temp[Y_AXIS]/sqrt(pow(temp[X_AXIS], 2) + pow(temp[Z_AXIS], 2))) * RADIANS_TO_DEGREES; //calculate angle x(pitch/roll?) from accellerometer reading
moklumbys 9:898effccce30 158 data[Y_AXIS] = atan (-1*temp[X_AXIS]/sqrt(pow(temp[Y_AXIS], 2) + pow(temp[Z_AXIS], 2))) * RADIANS_TO_DEGREES; //calculate angle x(pitch/roll?) from accellerometer reading
moklumbys 9:898effccce30 159 data[Z_AXIS] = atan (sqrt(pow(temp[X_AXIS], 2) + pow(temp[Y_AXIS], 2))/temp[Z_AXIS]) * RADIANS_TO_DEGREES; //This one is not used anywhere later on
moklumbys 4:268d3fcb92ba 160
moklumbys 9:898effccce30 161 // data[Y_AXIS] = atan2 (temp[Y_AXIS],temp[Z_AXIS]) * RADIANS_TO_DEGREES; //This spits out values between -180 to 180 (360 degrees)
moklumbys 9:898effccce30 162 // data[X_AXIS] = atan2 (-1*temp[X_AXIS], temp[Z_AXIS]) * RADIANS_TO_DEGREES; //but it takes longer and system gets unstable when angles ~90 degrees
moklumbys 4:268d3fcb92ba 163 }
moklumbys 5:5873df1e58be 164 void MPU6050::getOffset(float *accOffset, float *gyroOffset, int sampleSize){
moklumbys 5:5873df1e58be 165 float gyro[3];
moklumbys 5:5873df1e58be 166 float accAngle[3];
moklumbys 5:5873df1e58be 167
moklumbys 5:5873df1e58be 168 for (int i = 0; i < 3; i++) //initialise to 0.0 offsets
moklumbys 5:5873df1e58be 169 {
moklumbys 5:5873df1e58be 170 accOffset[i] = 0.0;
moklumbys 5:5873df1e58be 171 gyroOffset[i] = 0.0;
moklumbys 5:5873df1e58be 172 }
moklumbys 5:5873df1e58be 173
moklumbys 5:5873df1e58be 174 for (int i = 0; i < sampleSize; i++)
moklumbys 5:5873df1e58be 175 {
moklumbys 6:502448484f91 176 this->getGyro(gyro); //take real life measurements
moklumbys 6:502448484f91 177 this->getAcceleroAngle (accAngle);
moklumbys 5:5873df1e58be 178
moklumbys 5:5873df1e58be 179 for (int j = 0; j < 3; j++)
moklumbys 5:5873df1e58be 180 {
moklumbys 5:5873df1e58be 181 *(accOffset+j) += accAngle[j]/sampleSize; //average measurements
moklumbys 5:5873df1e58be 182 *(gyroOffset+j) += gyro[j]/sampleSize;
moklumbys 5:5873df1e58be 183 }
moklumbys 5:5873df1e58be 184 wait (0.01); //wait between each reading for accuracy (maybe will not need later on) ****))#$(#@)$@#)(#@(%)@#(%@)(#%#@$--------------
moklumbys 5:5873df1e58be 185 }
moklumbys 5:5873df1e58be 186 }
moklumbys 7:56e591a74939 187
moklumbys 7:56e591a74939 188 void MPU6050::computeAngle (float *angle, float *accOffset, float *gyroOffset, float *currTime, float *prevTime)
moklumbys 7:56e591a74939 189 {
moklumbys 7:56e591a74939 190 float gyro[3];
moklumbys 7:56e591a74939 191 float accAngle[3];
moklumbys 7:56e591a74939 192
moklumbys 7:56e591a74939 193 this->getGyro(gyro);
moklumbys 7:56e591a74939 194 this->getAcceleroAngle(accAngle);
moklumbys 7:56e591a74939 195
moklumbys 7:56e591a74939 196 for (int i = 0; i < 3; i++)
moklumbys 7:56e591a74939 197 {
moklumbys 7:56e591a74939 198 gyro[i] -= gyroOffset[i];
moklumbys 7:56e591a74939 199 accAngle[i] -= accOffset[i];
moklumbys 7:56e591a74939 200 }
moklumbys 7:56e591a74939 201
moklumbys 9:898effccce30 202 angle[X_AXIS] = alpha * (angle[X_AXIS] + GYRO_SCALE*gyro[X_AXIS]*(*currTime-*prevTime)) + (1-alpha)*accAngle[X_AXIS]; //apply filter on both reading to get all angles
moklumbys 9:898effccce30 203 angle[Y_AXIS] = alpha * (angle[Y_AXIS] + GYRO_SCALE*gyro[Y_AXIS]*(*currTime-*prevTime)) + (1-alpha)*accAngle[Y_AXIS];
moklumbys 9:898effccce30 204 //angle[Z_AXIS] = alpha * (angle[Z_AXIS] + GYRO_SCALE*gyro[Z_AXIS]*(*currTime-*prevTime)) + (1-alpha)*accAngle[Z_AXIS];
moklumbys 9:898effccce30 205 angle[Z_AXIS] = angle[Z_AXIS] + GYRO_SCALE*gyro[Z_AXIS]*(*currTime-*prevTime); //this is Yaw
moklumbys 9:898effccce30 206 }
moklumbys 9:898effccce30 207
moklumbys 9:898effccce30 208 void MPU6050::setAlpha(float val)
moklumbys 9:898effccce30 209 {
moklumbys 9:898effccce30 210 alpha = val;
moklumbys 7:56e591a74939 211 }
moklumbys 8:b1570b99df9e 212
moklumbys 8:b1570b99df9e 213 void MPU6050::enableInt( void )
moklumbys 8:b1570b99df9e 214 {
moklumbys 8:b1570b99df9e 215 char temp;
moklumbys 8:b1570b99df9e 216 temp = this->read(MPU6050_RA_INT_ENABLE);
moklumbys 8:b1570b99df9e 217 temp |= 0x01;
moklumbys 8:b1570b99df9e 218 this->write(MPU6050_RA_INT_ENABLE, temp);
moklumbys 8:b1570b99df9e 219 }
moklumbys 8:b1570b99df9e 220 void MPU6050::disableInt ( void )
moklumbys 8:b1570b99df9e 221 {
moklumbys 8:b1570b99df9e 222 char temp;
moklumbys 8:b1570b99df9e 223 temp = this->read(MPU6050_RA_INT_ENABLE);
moklumbys 8:b1570b99df9e 224 temp &= 0xFE;
moklumbys 8:b1570b99df9e 225 this->write(MPU6050_RA_INT_ENABLE, temp);
moklumbys 8:b1570b99df9e 226 }
Sissors 0:6757f7363a9f 227 //--------------------------------------------------
Sissors 0:6757f7363a9f 228 //------------------Gyroscope-----------------------
Sissors 0:6757f7363a9f 229 //--------------------------------------------------
Sissors 0:6757f7363a9f 230 void MPU6050::setGyroRange( char range ) {
Sissors 0:6757f7363a9f 231 char temp;
Sissors 0:6757f7363a9f 232 currentGyroRange = range;
Sissors 0:6757f7363a9f 233 range = range & 0x03;
Sissors 0:6757f7363a9f 234 temp = this->read(MPU6050_GYRO_CONFIG_REG);
Sissors 0:6757f7363a9f 235 temp &= ~(3<<3);
Sissors 0:6757f7363a9f 236 temp = temp + range<<3;
Sissors 0:6757f7363a9f 237 this->write(MPU6050_GYRO_CONFIG_REG, temp);
Sissors 0:6757f7363a9f 238 }
Sissors 0:6757f7363a9f 239
Sissors 0:6757f7363a9f 240 int MPU6050::getGyroRawX( void ) {
Sissors 0:6757f7363a9f 241 short retval;
Sissors 0:6757f7363a9f 242 char data[2];
Sissors 0:6757f7363a9f 243 this->read(MPU6050_GYRO_XOUT_H_REG, data, 2);
Sissors 0:6757f7363a9f 244 retval = (data[0]<<8) + data[1];
Sissors 0:6757f7363a9f 245 return (int)retval;
Sissors 0:6757f7363a9f 246 }
Sissors 0:6757f7363a9f 247
Sissors 0:6757f7363a9f 248 int MPU6050::getGyroRawY( void ) {
Sissors 0:6757f7363a9f 249 short retval;
Sissors 0:6757f7363a9f 250 char data[2];
Sissors 0:6757f7363a9f 251 this->read(MPU6050_GYRO_YOUT_H_REG, data, 2);
Sissors 0:6757f7363a9f 252 retval = (data[0]<<8) + data[1];
Sissors 0:6757f7363a9f 253 return (int)retval;
Sissors 0:6757f7363a9f 254 }
Sissors 0:6757f7363a9f 255
Sissors 0:6757f7363a9f 256 int MPU6050::getGyroRawZ( void ) {
Sissors 0:6757f7363a9f 257 short retval;
Sissors 0:6757f7363a9f 258 char data[2];
Sissors 0:6757f7363a9f 259 this->read(MPU6050_GYRO_ZOUT_H_REG, data, 2);
Sissors 0:6757f7363a9f 260 retval = (data[0]<<8) + data[1];
Sissors 0:6757f7363a9f 261 return (int)retval;
Sissors 0:6757f7363a9f 262 }
Sissors 0:6757f7363a9f 263
Sissors 0:6757f7363a9f 264 void MPU6050::getGyroRaw( int *data ) {
Sissors 0:6757f7363a9f 265 char temp[6];
Sissors 0:6757f7363a9f 266 this->read(MPU6050_GYRO_XOUT_H_REG, temp, 6);
Sissors 0:6757f7363a9f 267 data[0] = (int)(short)((temp[0]<<8) + temp[1]);
Sissors 0:6757f7363a9f 268 data[1] = (int)(short)((temp[2]<<8) + temp[3]);
Sissors 0:6757f7363a9f 269 data[2] = (int)(short)((temp[4]<<8) + temp[5]);
Sissors 0:6757f7363a9f 270 }
Sissors 0:6757f7363a9f 271
Sissors 0:6757f7363a9f 272 void MPU6050::getGyro( float *data ) {
Sissors 0:6757f7363a9f 273 int temp[3];
Sissors 0:6757f7363a9f 274 this->getGyroRaw(temp);
Sissors 1:a3366f09e95c 275 if (currentGyroRange == MPU6050_GYRO_RANGE_250) {
moklumbys 3:187152513f8d 276 data[0]=(float)temp[0] / 301.0;
moklumbys 3:187152513f8d 277 data[1]=(float)temp[1] / 301.0;
moklumbys 3:187152513f8d 278 data[2]=(float)temp[2] / 301.0;
moklumbys 3:187152513f8d 279 } //7505.5
Sissors 1:a3366f09e95c 280 if (currentGyroRange == MPU6050_GYRO_RANGE_500){
Sissors 0:6757f7363a9f 281 data[0]=(float)temp[0] / 3752.9;
Sissors 0:6757f7363a9f 282 data[1]=(float)temp[1] / 3752.9;
Sissors 0:6757f7363a9f 283 data[2]=(float)temp[2] / 3752.9;
Sissors 0:6757f7363a9f 284 }
Sissors 1:a3366f09e95c 285 if (currentGyroRange == MPU6050_GYRO_RANGE_1000){
Sissors 0:6757f7363a9f 286 data[0]=(float)temp[0] / 1879.3;;
Sissors 0:6757f7363a9f 287 data[1]=(float)temp[1] / 1879.3;
Sissors 0:6757f7363a9f 288 data[2]=(float)temp[2] / 1879.3;
Sissors 0:6757f7363a9f 289 }
Sissors 1:a3366f09e95c 290 if (currentGyroRange == MPU6050_GYRO_RANGE_2000){
Sissors 0:6757f7363a9f 291 data[0]=(float)temp[0] / 939.7;
Sissors 0:6757f7363a9f 292 data[1]=(float)temp[1] / 939.7;
Sissors 0:6757f7363a9f 293 data[2]=(float)temp[2] / 939.7;
Sissors 0:6757f7363a9f 294 }
Sissors 0:6757f7363a9f 295 }
Sissors 0:6757f7363a9f 296 //--------------------------------------------------
Sissors 0:6757f7363a9f 297 //-------------------Temperature--------------------
Sissors 0:6757f7363a9f 298 //--------------------------------------------------
Sissors 0:6757f7363a9f 299 int MPU6050::getTempRaw( void ) {
Sissors 0:6757f7363a9f 300 short retval;
Sissors 0:6757f7363a9f 301 char data[2];
Sissors 0:6757f7363a9f 302 this->read(MPU6050_TEMP_H_REG, data, 2);
Sissors 0:6757f7363a9f 303 retval = (data[0]<<8) + data[1];
Sissors 0:6757f7363a9f 304 return (int)retval;
Sissors 0:6757f7363a9f 305 }
Sissors 0:6757f7363a9f 306
Sissors 0:6757f7363a9f 307 float MPU6050::getTemp( void ) {
Sissors 0:6757f7363a9f 308 float retval;
Sissors 0:6757f7363a9f 309 retval=(float)this->getTempRaw();
Sissors 0:6757f7363a9f 310 retval=(retval+521.0)/340.0+35.0;
Sissors 0:6757f7363a9f 311 return retval;
Sissors 0:6757f7363a9f 312 }
Sissors 0:6757f7363a9f 313