First off, thank you for an awesome library. Running low on space in the atmega328 so streamlining code and came across the following nuances
Taken right from the example that comes with the libraries, MPU6050_DMP6.INO i was wondering why?
1. During setup, this line occurs:
mpu.initialize();
followed by this line:
devStatus = mpu.dmpInitialize();
Which resets the device and changes any configs set by the the first initialize(). The first initialize line can be commented out completely and functions the same.
Is it req'd at all?
2. In the motion_apps.h this line occurs many times and i was wondering why?
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
The code is exactly the same, in fact deleting the whole section of dmpupdates, resets, enables etc seems to have no effect on operation.
Was curious as to why the above statement is repeated exactly with the same data many times.
Thanks in advance. I'm just looking to save some compiled code space.
uint8_t dmpUpdate[16], j;
uint16_t pos = 0;
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
/*
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
*/
resetFIFO();
uint16_t fifoCount = getFIFOCount();
uint8_t fifoBuffer[128];
getFIFOBytes(fifoBuffer, fifoCount);
setFIFOEnabled(true);
setDMPEnabled(true);
resetDMP();
/*
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
while ((fifoCount = getFIFOCount()) < 3); getFIFOBytes(fifoBuffer, fifoCount);
uint8_t mpuIntStatus = getIntStatus();
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
readMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
while ((fifoCount = getFIFOCount()) < 3); getFIFOBytes(fifoBuffer, fifoCount);
//mpuIntStatus = getIntStatus();
for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) dmpUpdate[j] = pgm_read_byte(&dmpUpdates[pos]);
writeMemoryBlock(dmpUpdate + 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]);
*/
//setDMPEnabled(false);
//$$$$ set to 18 for quaternion only
dmpPacketSize = 18;
//resetFIFO();
//getIntStatus();