I'm trying to use a Pro Micro and MPU9250 sensor as a hands free mouse. It compiles but with an error and will not upload. Here is the compiling error:
"Missing 'maintainer' from library in /tmp/387977701/custom/Quaternion"
I've tried using other Quaternion libraries, but they won't compile.
Uploading I get "Executing Command: exit status 1" b/c of maintainer
I am using a sketch I found here. The changes I made were to add these libraries: <Quaternion.h> <BMP180.h> <I2Cdev.h> <MPU9250.h> and removed: "MPU6050_9Axis_MotionApps41.h"
Here's the sketch:
#include <Quaternion.h>
#include <BMP180.h>
#include <I2Cdev.h>
#include <MPU9250.h>
#include <Mouse.h>
#include "Wire.h"
MPU9250 mpu;
#define OUTPUT_READABLE_YAWPITCHROLL
#define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6)
bool blinkState = false;
bool dmpReady = false; // set true if DMP init was successful
uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU
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
Quaternion q; // [w, x, y, z] quaternion container
VectorFloat gravity; // [x, y, z] gravity vector
float euler[3]; // [psi, theta, phi] Euler angle container
float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector
float yaw, pitch, roll;
int left_button_pin = 9; // Left button
int right_button_pin = 10; // right button
int leftClickFlag = 0;
const int sensitivity = 30;
float vertZero, horzZero;
float vertValue, horzValue; // Stores current analog output of each axis
volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high
void dmpDataReady() {
mpuInterrupt = true;
}
// ================================================================
// === INITIAL SETUP ===
// ================================================================
void setup()
{
Wire.begin(); // join I2C bus (I2Cdev library doesn't do this automatically)
Serial.begin(115200); // initialize serial communication
while (!Serial); // wait for Leonardo enumeration, others continue immediately
mpu.initialize();
devStatus = mpu.dmpInitialize();
if (devStatus == 0)
{
mpu.setDMPEnabled(true); // turn on the DMP, now that it's ready
attachInterrupt(0, dmpDataReady, RISING); // enable Arduino interrupt detection
mpuIntStatus = mpu.getIntStatus();
dmpReady = true; // set our DMP Ready flag so the main loop() function knows it's okay to use it
packetSize = mpu.dmpGetFIFOPacketSize(); // get expected DMP packet size for later comparison
}
else
{ // ERROR! 1 = initial memory load failed 2 = DMP configuration updates failed (if it's going to break, usually the code will be 1)
Serial.print(F("DMP Initialization failed (code "));
Serial.print(devStatus);
Serial.println(F(")"));
}
pinMode(LED_PIN, OUTPUT); // configure LED for output
pinMode(left_button_pin, INPUT);
pinMode(right_button_pin, INPUT);
yaw = 0.0;
pitch = 0.0;
roll = 0.0;
vertZero = 0;
horzZero = 0;
}
// ================================================================
// === MAIN PROGRAM LOOP ===
// ================================================================
void loop() {
if (!dmpReady) return; // if programming failed, don't try to do anything
mpuInterrupt = true;
fifoCount = mpu.getFIFOCount(); // get current FIFO count
if ((mpuIntStatus & 0x10) || fifoCount == 1024) // check for overflow (this should never happen unless our code is too inefficient)
{
mpu.resetFIFO(); // reset so we can continue cleanly
Serial.println(F("FIFO overflow!"));
}
else if (mpuIntStatus & 0x01) // otherwise, check for DMP data ready interrupt (this should happen frequently)
{
while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount(); // wait for correct available data length, should be a VERY short wait
mpu.getFIFOBytes(fifoBuffer, packetSize); // read a packet from FIFO
fifoCount -= packetSize; // track FIFO count here in case there is > 1 packet available
#ifdef OUTPUT_READABLE_YAWPITCHROLL // display Euler angles in degrees
mpu.dmpGetQuaternion(&q, fifoBuffer);
mpu.dmpGetGravity(&gravity, &q);
mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
yaw = ypr[1] /PI * 180;
pitch = ypr[2] /PI * 180;
roll = ypr[0] /PI * 180;
Serial.print("ypr\t");
Serial.print(yaw);
Serial.print("\t");
Serial.print(pitch);
Serial.print("\t");
Serial.println(roll);
#endif
blinkState = !blinkState; // blink LED to indicate activity
vertValue = yaw - vertZero;
horzValue = roll - horzZero;
vertZero = yaw;
horzZero = roll;
if (vertValue != 0)
Mouse.move(0, vertValue * sensitivity, 0); // move mouse on y axis
if (horzValue != 0)
Mouse.move(horzValue * sensitivity, 0, 0); // move mouse on x axis
if ((digitalRead(left_button_pin))&&(!leftClickFlag))
{
leftClickFlag = 1;
Mouse.press(MOUSE_LEFT);
}
else if ((digitalRead(left_button_pin))&&(leftClickFlag))
{
leftClickFlag = 0;
Mouse.release(MOUSE_LEFT);
}
if (digitalRead(right_button_pin))
{
Mouse.click(MOUSE_RIGHT);
}
}
}
Thanks and keep in mind I'm a noob