-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmpu6050.h
45 lines (31 loc) · 833 Bytes
/
mpu6050.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef MPU6050_H
#define MPU6050_H
#include <i2c_t3.h>
#include <elapsedMillis.h>
#define Q_RADDEG 57.29577
#define Q_DEGRAD 0.01745329
class MPU6050 {
public:
MPU6050(uint16_t x):samplerate(x){}
void setup();
void update();
float PITCH, ROLL;
private:
void writeToMPU(byte address, byte val);
void readFromMPU();
int32_t gyro_x_cal, gyro_y_cal, gyro_z_cal;
int32_t gyro_x, gyro_y, gyro_z;
int32_t acc_x, acc_y, acc_z;
int32_t acc_total_vector;
int32_t still_length_acc;
float angle_pitch, angle_roll;
float angle_pitch_output, angle_roll_output;
float angle_roll_acc, angle_pitch_acc;
float angle_roll_acc_prev, angle_pitch_acc_prev;
int16_t temperature;
bool gyro_angles_set;
uint16_t samplerate;
uint32_t wait_target;
elapsedMillis wait_elapsed;
};
#endif