mpu-9250

yzheka-m/mpu-9250/mpu-9250

No description
mpu-9250
@/mpu-9250
CAGpulse
calibrate accelerometer and gyroscope
CMpulse
calibrate magnetometer
UPDATEpulse
update pusle
mpu-9250
CAG
CM
UPDATE
PITCH
YAW
ROLL
CON
CONboolean
is connected
ROLLnumber
YAWnumber
PITCHnumber
To use the node in your project you should have the yzheka-m/mpu-9250 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 require "https://github.com/hideakitai/MPU9250"

{{#global}}
#include "MPU9250.h"
{{/global}}

struct State {
    MPU9250 mpu;
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    auto state=getState(ctx);
    if(isSettingUp()){
        Serial.begin(115200);
        Wire.begin();
        delay(2000);
        state->mpu.setup();
    }
    if(isInputDirty<input_CAG>(ctx))state->mpu.calibrateAccelGyro();
    if(isInputDirty<input_CM>(ctx))state->mpu.calibrateMag();
    if(isInputDirty<input_UPDATE>(ctx)){
        state->mpu.update();
        emitValue<output_PITCH>(ctx,state->mpu.getPitch());
        emitValue<output_YAW>(ctx,state->mpu.getYaw());
        emitValue<output_ROLL>(ctx,state->mpu.getRoll());
    }
    emitValue<output_CON>(ctx,state->mpu.isConnectedMPU9250()||state->mpu.isConnectedAK8963());
}