Skip to content

Commit 0051282

Browse files
committed
Working!?
1 parent cc0846a commit 0051282

File tree

4 files changed

+485
-294
lines changed

4 files changed

+485
-294
lines changed

examples/Arduino/Example5_DMP/Example5_DMP.ino

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,25 +222,41 @@ void loop()
222222
myICM.readDMPdataFromFIFO(&data);
223223
if( myICM.status == ICM_20948_Stat_Ok )
224224
{
225-
SERIAL_PORT.print("Received data! Header: ");
226-
SERIAL_PORT.println( data.header );
227-
if ( data.header == DMP_header_bitmap_Quat9 ) // We have asked for orientation data so we should receive Quat9
225+
SERIAL_PORT.print(F("Received data! Header: 0x"));
226+
if ( data.header < 0x1000) SERIAL_PORT.print( "0" ); // Pad the zeros
227+
if ( data.header < 0x100) SERIAL_PORT.print( "0" );
228+
if ( data.header < 0x10) SERIAL_PORT.print( "0" );
229+
SERIAL_PORT.println( data.header, HEX );
230+
if ( (data.header | DMP_header_bitmap_Quat9) > 0 ) // We have asked for orientation data so we should receive Quat9
228231
{
229-
SERIAL_PORT.print("Quat9 data is: 0x");
232+
SERIAL_PORT.print(F("Quat9 data is: 0x"));
230233
for (int i = 0; i < 14; i++) // Quat9 data is 14 bytes long
231234
{
232-
if ( data.Quat9[i] < 16) SERIAL_PORT.print( "0" ); // Pad the zero
235+
if ( data.Quat9[i] < 0x10) SERIAL_PORT.print( "0" ); // Pad the zero
233236
SERIAL_PORT.print( data.Quat9[i], HEX );
234237
}
235238
SERIAL_PORT.println();
236239
}
237240
}
238241
else if ( myICM.status != ICM_20948_Stat_FIFONoDataAvail )
239242
{
240-
SERIAL_PORT.print("readDMPdataFromFIFO failed! Status is: ");
243+
SERIAL_PORT.print(F("readDMPdataFromFIFO failed! Status is: "));
244+
SERIAL_PORT.print( myICM.status );
245+
SERIAL_PORT.print(" : ");
241246
SERIAL_PORT.println( myICM.statusString() );
242-
SERIAL_PORT.print("Header is: 0x");
247+
SERIAL_PORT.print(F("Header is: 0x"));
248+
if ( data.header < 0x1000) SERIAL_PORT.print( "0" ); // Pad the zeros
249+
if ( data.header < 0x100) SERIAL_PORT.print( "0" );
250+
if ( data.header < 0x10) SERIAL_PORT.print( "0" );
243251
SERIAL_PORT.println( data.header, HEX );
252+
if ( data.header == DMP_header_bitmap_Header2 )
253+
{
254+
SERIAL_PORT.print(F("Header2 is: 0x"));
255+
if ( data.header2 < 0x1000) SERIAL_PORT.print( "0" ); // Pad the zeros
256+
if ( data.header2 < 0x100) SERIAL_PORT.print( "0" );
257+
if ( data.header2 < 0x10) SERIAL_PORT.print( "0" );
258+
SERIAL_PORT.println( data.header2, HEX );
259+
}
244260
}
245261

246262
delay(10);

src/ICM_20948.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,15 @@ void ICM_20948::debugPrintStatus(ICM_20948_Status_e stat)
113113
case ICM_20948_Stat_DMPVerifyFail:
114114
debugPrint(F("DMP Firmware Verification Failed"));
115115
break;
116+
case ICM_20948_Stat_FIFONoDataAvail:
117+
debugPrint(F("No FIFO Data Available"));
118+
break;
119+
case ICM_20948_Stat_UnrecognisedDMPHeader:
120+
debugPrint(F("Unrecognised DMP Header"));
121+
break;
122+
case ICM_20948_Stat_UnrecognisedDMPHeader2:
123+
debugPrint(F("Unrecognised DMP Header2"));
124+
break;
116125
default:
117126
debugPrint(F("Unknown Status"));
118127
break;
@@ -268,6 +277,21 @@ const char *ICM_20948::statusString(ICM_20948_Status_e stat)
268277
case ICM_20948_Stat_SensorNotSupported:
269278
return "Sensor Not Supported";
270279
break;
280+
case ICM_20948_Stat_DMPNotSupported:
281+
return "DMP Firmware Not Supported. Is #define ICM_20948_USE_DMP commented in util/ICM_20948_C.h?";
282+
break;
283+
case ICM_20948_Stat_DMPVerifyFail:
284+
return "DMP Firmware Verification Failed";
285+
break;
286+
case ICM_20948_Stat_FIFONoDataAvail:
287+
return "No FIFO Data Available";
288+
break;
289+
case ICM_20948_Stat_UnrecognisedDMPHeader:
290+
return "Unrecognised DMP Header";
291+
break;
292+
case ICM_20948_Stat_UnrecognisedDMPHeader2:
293+
return "Unrecognised DMP Header2";
294+
break;
271295
default:
272296
return "Unknown Status";
273297
break;

0 commit comments

Comments
 (0)