Initialize for Mbot only!
dmp-initialize-mbot
@/dmp-initialize-mbot
Initialize for Mbot only!
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.
#pragma XOD error_raise enable
#pragma XOD require "https://github.com/GreyGnome/PinChangeInt"
#include <PinChangeInt.h>
volatile bool mpuInterrupt = false;
void dmpDataReady() {
mpuInterrupt = true;
}
node {
int8_t devStatus; // return status after each device operation (0 = success, !0 = error)
void evaluate(Context ctx) {
auto mpu = getValue<input_DEV>(ctx);
if (isSettingUp())
emitValue<output_DEVU0027>(ctx, mpu);
if (!isInputDirty<input_DO>(ctx))
return;
const uint8_t INTERRUPT_PIN = getValue<input_INT>(ctx);
devStatus = mpu->dmpInitialize();
if (devStatus == 0) {
mpu->setDMPEnabled(true);
PCintPort::attachInterrupt(INTERRUPT_PIN, dmpDataReady, RISING);
mpuIntStatus = mpu->getIntStatus();
dmpReady = true;
packetSize = mpu->dmpGetFIFOPacketSize();
} else {
raiseError(ctx);
return;
}
emitValue<output_DONE>(ctx, 1);
}
}