mpu9250

dinosalvioni/mpu9250/mpu9250

No description
mpu9250
@/mpu9250
CAGpulse
Calibra Gyroscopio
CMpulse
Calibra Magnetometro. Dopo l'impulso muovere l'hardware a figura di 8
UPDATEpulse
Update pulse per nuova lettura
mpu9250
CAG
CM
UPDATE
PITCH
YAW
ROLL
CON
DONE
DONEpulse
Lettura avvenuta
CONboolean
True se connesso
ROLLnumber
Asse Z
YAWnumber
Asse Y
PITCHnumber
Asse X
To use the node in your project you should have the dinosalvioni/mpu9250 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 <Arduino.h>
#include <Wire.h>

#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();

        if (!state->mpu.setup(0x68)) {  // change to your own address
            emitValue<output_CON>(ctx,false);
        } else {
           emitValue<output_CON>(ctx,true);
        }
    }

    if(isInputDirty<input_CAG>(ctx)){
        state->mpu.calibrateAccelGyro();
    }
    if(isInputDirty<input_CM>(ctx)){
        state->mpu.calibrateMag();
    }

    if(isInputDirty<input_UPDATE>(ctx)){
        state->mpu.update();
        static uint32_t prev_ms = millis();
        if (millis() > prev_ms + 5000) {
        
        
        
        
        
        int Pitch = state->mpu.getPitch();
        int Yaw = state->mpu.getYaw();
        int Roll = state->mpu.getRoll();
        emitValue<output_PITCH>(ctx,Pitch);
        emitValue<output_YAW>(ctx,Yaw);
        emitValue<output_ROLL>(ctx,Roll);
        emitValue<output_DONE>(ctx,true);
        }
        
        
        }

}