Acceleration in meter per second square
Fork of MPU6050 by
Embed:
(wiki syntax)
Show/hide line numbers
MPU6050.h
00001 /* 00002 * Copyright (c) 2015, Baser Kandehir, baser.kandehir@ieee.metu.edu.tr 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy 00005 * of this software and associated documentation files (the "Software"), to deal 00006 * in the Software without restriction, including without limitation the rights 00007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 * copies of the Software, and to permit persons to whom the Software is 00009 * furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included in 00012 * all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00020 * THE SOFTWARE. 00021 * 00022 */ 00023 00024 // Most of the code is adapted from Kris Winer's MPU6050 library 00025 00026 #ifndef MPU6050_H 00027 #define MPU6050_H 00028 00029 #include "mbed.h" 00030 #include "math.h" 00031 #include "MPU6050RegDef.h" 00032 00033 #define PI 3.14159265359 // This value will be used when calculating angles 00034 #define dt 0.005 // 200 Hz sampling period 00035 00036 extern float aRes, gRes; 00037 00038 /* whoAmI func uses this func, variables etc */ 00039 extern Ticker toggler1; 00040 extern Serial pc; 00041 extern DigitalOut led2; 00042 extern void toggle_led1(); 00043 00044 /* Sensor datas to be used in program */ 00045 extern float ax,ay,az; 00046 extern float gx,gy,gz; 00047 extern int16_t accelData[3],gyroData[3],tempData; 00048 extern float accelBias[3], gyroBias[3]; 00049 extern float axx; 00050 00051 /* Function Prototypes */ 00052 class MPU6050 00053 { 00054 protected: 00055 public: 00056 void getAres(); 00057 void getGres(); 00058 void writeByte(uint8_t address, uint8_t subAddress, uint8_t data); 00059 char readByte(uint8_t address, uint8_t subAddress); 00060 void readBytes(uint8_t address, uint8_t subAddress, uint8_t byteNum, uint8_t* dest); 00061 void checkaddress(); 00062 void init(); 00063 void reset(); 00064 void readAccelData(int16_t* dest); 00065 void readGyroData(int16_t* dest); 00066 int16_t readTempData(); 00067 void calibrate(float* dest1, float* dest2); 00068 void complementaryFilter(float* pitch, float* roll); 00069 }; 00070 00071 #endif
Generated on Wed Jul 13 2022 02:06:12 by 1.7.2