protesis_03/mpu6050.hpp

57 lines
1.4 KiB
C++

/*
* mpu6050.h
*
* Created on: 08.01.2021
* Author: frank
*/
#ifndef MPU6050_HPP_
#define MPU6050_HPP_
#include <Arduino.h>
#include <Wire.h>
//#define GYRO_CONST_250HZ_131 0.000030534 // = 1 / (250Hz x 131)
//#define GYRO_CONST_500HZ_65_5 0.000030534
#define GYRO_CONST_250_DPS 0.0076336
#define GYRO_CONST_500_DPS 0.015267
#define GYRO_CONST GYRO_CONST_250_DPS
#define ACCELEROMETER_CONST_2G 0.000061035
#define ACCELEROMETER_CONST_4G 0.00012207
#define ACCELEROMETER_CONST_8G 0.00024414
#define ACCELEROMETER_CONST ACCELEROMETER_CONST_8G
struct vector{
long x;
long y;
long z;
};
struct vector_double_precision {
double x;
double y;
double z;
};
struct measurement {
int temperature;
vector acceleration;
vector gyroscope;
};
struct measurement_double_precission {
double temperature;
vector_double_precision acceleration;
vector_double_precision gyroscope;
};
void calculate_mpu_offsets_as_average();
measurement get_mpu_offset();
void read_mpu_6050_data(measurement &measurement);
void read_mpu_6050_data_with_offset_substraction(measurement &measurement);
void setup_mpu_6050_registers();
void substract_gyroscope_offset(measurement &measurement);
void substract_accelerometer_offset(measurement &measurement);
void mpu_measurement_with_precission(measurement_double_precission &measurement_dp, const measurement measurement);
#endif /* MPU6050_HPP_ */