mpu6050-device

gabbapeople/mpu6050/mpu6050-device

No description
mpu6050-device
@/mpu6050-device
I2Cxod/i2c/i2c
ADDRbyte
mpu6050-device
I2C
ADDR
DEV
DEV@/mpu6050-device
To use the node in your project you should have the gabbapeople/mpu6050 library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD error_raise enable

#include <I2Cdev.h>
#include <MPU6050_6Axis_MotionApps20.h>
#include <Wire.h>

uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU
bool dmpReady = false; // set true if DMP init was successful
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 ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector
VectorInt16 aa; // [x, y, z] accel sensor measurements
VectorInt16 aaReal; // [x, y, z] gravity-free accel sensor measurements

node {
    meta {
        using Type = MPU6050*;
    }

    uint8_t mem[sizeof(MPU6050)];

    void evaluate(Context ctx) {
        if (!isSettingUp())
            return;

        uint8_t addr = getValue<input_ADDR>(ctx);

        if (addr > 127) {
            raiseError(ctx);
            return;
        }

        Type mpu = new (mem) MPU6050(addr);
        mpu->initialize();
        emitValue<output_DEV>(ctx, mpu);
    }
}