Im not that great at OOP so i needed some help. I wanted to take the logic that happens in this example and condense it to my own OOP where this logic occurs in methods such as setupMPU() and setRollPitchYaw()
So i thought of inheriting the MPU6050 class and adding all those variables to it and then adding these methods that call other methods which were in the original external library.
Basically Ill have mpu.h and mpu.cpp and in the header can I do this
#ifndef MPU_H
#define MPU_H
#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
#include "Wire.h"
#include <Arduino.h>
class MPU : public MPU6050 {
private:
// MPU control/status vars
bool dmpReady = false; // set true if DMP init was successful
uint8_t devStatus; // return status after each device operation (0 = success, !0 = error)
uint16_t packetSize; // expected DMP packet size (default is 42 bytes)
uint16_t fifoCount; // count of all bytes currently in FIFO
uint8_t fifoBuffer[64]; // FIFO storage buffer
// orientation/motion vars
Quaternion q; // [w, x, y, z] quaternion container
VectorFloat gravity; // [x, y, z] gravity vector
float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector
public:
void setupMPU(); // Wakes up MPU and gets it ready for reading data.
void setData();
};
#endif
And what will my sketch have, should i include only the mpu.h or should I also include the external library?
And are there other ways to go about this and or will this work