changed mpu6050 code to class for better abstraction

This commit is contained in:
willem oldemans
2020-10-01 22:21:59 +02:00
parent c7fb9ff84b
commit 48b8cefac8
7 changed files with 113 additions and 98 deletions

View File

@@ -1,15 +1,57 @@
#ifndef MPU6050H
#define MPU6050H
//#include "servos.h"
template <typename T>
struct xyzvector
{
T x;
T y;
T z;
};
void writeDebug();
void readMpu6050Data();
void setupMpu6050();
class _mpu
{
xyzvector<int> gyro;
xyzvector<long> acc_raw;
xyzvector<long> acc;
long acc_total_vector;
int temperature;
xyzvector<long> gyro_cal;
float Mpu6050_getangle_pitch( void );
float Mpu6050_getyaw_rate( void );
long loop_timer;
float angle_pitch;
float angle_roll;
bool set_gyro_angles;
float angle_roll_acc;
float angle_pitch_acc;
float yaw_rate;
const int calibrationPasses = 500;
void readRaw( void );
public:
_mpu(){}
void processData( void );
void run( void );
void begin( void );
float getangle_pitch( void )
{
return angle_pitch;
}
float getyaw_rate( void )
{
return yaw_rate;
}
void print( void );
};
#endif //MPU6050H