Hello, dear pro MPU users! :-)
I have no problem to compile the example for Arduino. This is good :-)
But I can't move all the initializations and all the serial output into new class, I called Sensor.
I'v created Sensor.h, Sensor.cpp
In the sensor.h:
#ifndef SENSOR_H
#define SENSOR_H
#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
//#include "MPU6050.h" // not necessary if using MotionApps include file
// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#include "Wire.h"
#endif
class Sensor{
public:
static Sensor & getInstance(){
static Sensor instance;
return instance;
}
bool init();
bool getYpr(float & y, float & p, float r);
protected:
MPU6050 _mpu;
..................................
......................
...........
In the main project:
#include "Wire.h"
#include "sensor.h"
void setup() {
Sensor::getInstance().init();
}
void loop() {
float y,p,r;
Sensor::getInstance().getYpr(y,p,r);
}
And I have a lot of errors like this:
I'v found some information, that this may be caused by including "MPU6050.h", but I don't do it!
I can't attach archives here. So, here is a link to a dropbox with my test project:
https://dl.dropboxusercontent.com/u/51786067/testMPU.rar
Hope, my question is not very stupid :-) Thanks!